pax_global_header00006660000000000000000000000064123014002750014504gustar00rootroot0000000000000052 comment=20ab8ffe20689179a0d30f0b3ccd404f9b74ed03 icecc-monitor-2.9.90~git20140222/000077500000000000000000000000001230140027500160575ustar00rootroot00000000000000icecc-monitor-2.9.90~git20140222/.gitignore000066400000000000000000000017021230140027500200470ustar00rootroot00000000000000# This file is used to ignore files which are generated # ---------------------------------------------------------------------------- *~ *.a *.core *.moc *.o *.obj *.orig *.rej *.so *_pch.h.cpp *_resource.rc *.qm .#* *.*# core !core/ tags .DS_Store *.debug Makefile* *.prl *.app moc_*.cpp ui_*.h qrc_*.cpp Thumbs.db *.pro.user* # xemacs temporary files # --------------------- *.flc # Vim temporary files # --------------------- .*.swp # KDevelop # --------------------- *.kdev4 .kdev4/ # Visual Studio generated files # --------------------- *.ib_pdb_index *.idb *.ilk *.pdb *.sln *.suo *.vcproj *vcproj.*.*.user *.ncb # MinGW generated files # --------------------- *.Debug *.Release # Directories to ignore # --------------------- debug lib/* lib64/* release doc/html/* doc/html-dev/* doc/api/html/* doc/pluginhowto/html/* .rcc .pch # Binaries # -------- *.dll *.exe icemon # From Git merge # -------------- *.BACKUP.* *.BASE.* *.LOCAL.* *.REMOTE.* icecc-monitor-2.9.90~git20140222/CMakeLists.txt000066400000000000000000000031331230140027500206170ustar00rootroot00000000000000project(icemon) cmake_minimum_required(VERSION 2.8.5) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) include(GNUInstallDirs) include(KDE4Macros-Icecream) # version info set(ICEMON_VERSION_MAJOR "2") set(ICEMON_VERSION_MINOR "9") set(ICEMON_VERSION_PATCH "90") set(ICEMON_VERSION "${ICEMON_VERSION_MAJOR}.${ICEMON_VERSION_MINOR}.${ICEMON_VERSION_PATCH}") set(ICEMON_VERSION_STRING "${ICEMON_VERSION}") if(EXISTS "${CMAKE_SOURCE_DIR}/.git") find_package(Git) if(GIT_FOUND) execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE _git_revision ) string(REGEX REPLACE "\n" "" _git_revision "${_git_revision}") set(ICEMON_VERSION_STRING "${ICEMON_VERSION_STRING} (revision: ${_git_revision})") endif() endif() find_package(Qt4 REQUIRED) find_package(Icecream REQUIRED) find_program(DOCBOOK2X NAMES docbook2x-man docbook-to-man docbook2man.pl ) add_definitions( ${QT_DEFINITIONS} ) include_directories( ${LIBICECREAM_INCLUDE_DIR} ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} # config-icemon.h ) set( INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Devel ) set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) set(ICON_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/icons) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-icemon.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-icemon.h ) add_subdirectory(src) add_subdirectory(doc) icecc-monitor-2.9.90~git20140222/COPYING000066400000000000000000000431331230140027500171160ustar00rootroot00000000000000 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. icecc-monitor-2.9.90~git20140222/README.md000066400000000000000000000010531230140027500173350ustar00rootroot00000000000000Icemon ====== Introduction ------------ Icemon is an Icecream GUI monitor. Installation ------------ To compile icemon, install, the icecc development package, e.g. for Debian/Ubuntu: $ apt-get install libicecc-dev Finally, make sure you have g++, Qt and cmake installed $ apt-get install build-essential libqt4-dev cmake Finally, compile and install the application: $ mkdir build $ cd build $ cmake -DCMAKE_INSTALL_PREFIX=/usr .. $ make $ make install Have a lot of fun ;) icecc-monitor-2.9.90~git20140222/cmake/000077500000000000000000000000001230140027500171375ustar00rootroot00000000000000icecc-monitor-2.9.90~git20140222/cmake/modules/000077500000000000000000000000001230140027500206075ustar00rootroot00000000000000icecc-monitor-2.9.90~git20140222/cmake/modules/COPYING-CMAKE-SCRIPTS000066400000000000000000000024571230140027500236150ustar00rootroot00000000000000Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. icecc-monitor-2.9.90~git20140222/cmake/modules/FindIcecream.cmake000066400000000000000000000035651230140027500241330ustar00rootroot00000000000000# - Try to find the icecream library # Once done this defines # # LIBICECREAM_FOUND - system has libicecream # LIBICECREAM_INCLUDE_DIR - the libicecream include directory # LIBICECREAM_LIBRARIES - Link these to use libicecream # LIBICECREAM_VERSION - the libicecream version, if available if (LIBICECREAM_INCLUDE_DIR AND LIBICECREAM_LIBRARIES) # in cache already set(LIBICECREAM_FOUND TRUE) else (LIBICECREAM_INCLUDE_DIR AND LIBICECREAM_LIBRARIES) set( LIBICECREAM_LIB_EXTRA ) if(NOT WIN32) # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls find_package(PkgConfig) pkg_check_modules(PC_ICECC icecc) # The icecream lib may optionally need linking to -lcap-ng, so dig it out # of pkg-config data. # Somewhat hackish, but I can't find a simpler way to do this with CMake. foreach(lib ${PC_ICECC_STATIC_LIBRARIES}) if(NOT ${lib} STREQUAL "icecc") list(APPEND LIBICECREAM_LIB_EXTRA "-l${lib}") endif(NOT ${lib} STREQUAL "icecc") endforeach(lib ${PC_ICECC_STATIC_LIBRARIES}) set(LIBICECREAM_VERSION "${PC_ICECC_VERSION}") endif(NOT WIN32) find_path(LIBICECREAM_INCLUDE_DIR icecc/comm.h HINTS ${PC_ICECC_INCLUDEDIR} ${PC_ICECC_INCLUDE_DIRS} /opt/icecream/include ) find_library(LIBICECREAM_LIBRARY NAMES icecc HINTS ${PC_ICECC_LIBDIR} ${PC_ICECC_LIBRARY_DIRS} /opt/icecream/lib ) set( LIBICECREAM_LIBRARIES ${LIBICECREAM_LIBRARY} ${LIBICECREAM_LIB_EXTRA} CACHE INTERNAL "The libraries for libicecream" ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Icecream REQUIRED_VARS LIBICECREAM_LIBRARIES LIBICECREAM_INCLUDE_DIR VERSION_VAR LIBICECREAM_VERSION ) mark_as_advanced( LIBICECREAM_INCLUDE_DIR LIBICECREAM_LIBRARIES ) endif (LIBICECREAM_INCLUDE_DIR AND LIBICECREAM_LIBRARIES) icecc-monitor-2.9.90~git20140222/cmake/modules/KDE4Macros-Icecream.cmake000066400000000000000000000126651230140027500251650ustar00rootroot00000000000000# for documentation look at FindKDE4Internal.cmake # this file contains the following macros (or functions): # KDE4_UPDATE_ICONCACHE # KDE4_INSTALL_ICONS # Copyright (c) 2006-2009 Alexander Neundorf, # Copyright (c) 2006, 2007, Laurent Montel, # Copyright (c) 2007 Matthias Kretz # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. macro (KDE4_UPDATE_ICONCACHE) # Update mtime of hicolor icon theme dir. # We don't always have touch command (e.g. on Windows), so instead create # and delete a temporary file in the theme dir. install(CODE " set(DESTDIR_VALUE \"\$ENV{DESTDIR}\") if (NOT DESTDIR_VALUE) file(WRITE \"${ICON_INSTALL_DIR}/hicolor/temp.txt\" \"update\") file(REMOVE \"${ICON_INSTALL_DIR}/hicolor/temp.txt\") endif (NOT DESTDIR_VALUE) ") endmacro (KDE4_UPDATE_ICONCACHE) # a "map" of short type names to the directories # unknown names should give empty results # KDE 3 compatibility set(_KDE4_ICON_GROUP_mime "mimetypes") set(_KDE4_ICON_GROUP_filesys "places") set(_KDE4_ICON_GROUP_device "devices") set(_KDE4_ICON_GROUP_app "apps") set(_KDE4_ICON_GROUP_action "actions") # KDE 4 / icon naming specification compatibility set(_KDE4_ICON_GROUP_mimetypes "mimetypes") set(_KDE4_ICON_GROUP_places "places") set(_KDE4_ICON_GROUP_devices "devices") set(_KDE4_ICON_GROUP_apps "apps") set(_KDE4_ICON_GROUP_actions "actions") set(_KDE4_ICON_GROUP_categories "categories") set(_KDE4_ICON_GROUP_status "status") set(_KDE4_ICON_GROUP_emblems "emblems") set(_KDE4_ICON_GROUP_emotes "emotes") set(_KDE4_ICON_GROUP_animations "animations") set(_KDE4_ICON_GROUP_intl "intl") # a "map" of short theme names to the theme directory set(_KDE4_ICON_THEME_ox "oxygen") set(_KDE4_ICON_THEME_cr "crystalsvg") set(_KDE4_ICON_THEME_lo "locolor") set(_KDE4_ICON_THEME_hi "hicolor") # only used internally by KDE4_INSTALL_ICONS macro (_KDE4_ADD_ICON_INSTALL_RULE _install_SCRIPT _install_PATH _group _orig_NAME _install_NAME _l10n_SUBDIR) # if the string doesn't match the pattern, the result is the full string, so all three have the same content if (NOT ${_group} STREQUAL ${_install_NAME} ) set(_icon_GROUP ${_KDE4_ICON_GROUP_${_group}}) if(NOT _icon_GROUP) set(_icon_GROUP "actions") endif(NOT _icon_GROUP) # message(STATUS "icon: ${_current_ICON} size: ${_size} group: ${_group} name: ${_name} l10n: ${_l10n_SUBDIR}") install(FILES ${_orig_NAME} DESTINATION ${_install_PATH}/${_icon_GROUP}/${_l10n_SUBDIR}/ RENAME ${_install_NAME} ) endif (NOT ${_group} STREQUAL ${_install_NAME} ) endmacro (_KDE4_ADD_ICON_INSTALL_RULE) macro (KDE4_INSTALL_ICONS _defaultpath ) # the l10n-subdir if language given as second argument (localized icon) set(_lang ${ARGV1}) if(_lang) set(_l10n_SUBDIR l10n/${_lang}) else(_lang) set(_l10n_SUBDIR ".") endif(_lang) # first the png icons file(GLOB _icons *.png) foreach (_current_ICON ${_icons} ) # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty string(REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" _dummy "${_current_ICON}") set(_type "${CMAKE_MATCH_1}") set(_size "${CMAKE_MATCH_2}") set(_group "${CMAKE_MATCH_3}") set(_name "${CMAKE_MATCH_4}") set(_theme_GROUP ${_KDE4_ICON_THEME_${_type}}) if( _theme_GROUP) _KDE4_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake ${_defaultpath}/${_theme_GROUP}/${_size}x${_size} ${_group} ${_current_ICON} ${_name} ${_l10n_SUBDIR}) endif( _theme_GROUP) endforeach (_current_ICON) # mng icons file(GLOB _icons *.mng) foreach (_current_ICON ${_icons} ) # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty string(REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" _dummy "${_current_ICON}") set(_type "${CMAKE_MATCH_1}") set(_size "${CMAKE_MATCH_2}") set(_group "${CMAKE_MATCH_3}") set(_name "${CMAKE_MATCH_4}") set(_theme_GROUP ${_KDE4_ICON_THEME_${_type}}) if( _theme_GROUP) _KDE4_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake ${_defaultpath}/${_theme_GROUP}/${_size}x${_size} ${_group} ${_current_ICON} ${_name} ${_l10n_SUBDIR}) endif( _theme_GROUP) endforeach (_current_ICON) # and now the svg icons file(GLOB _icons *.svgz) foreach (_current_ICON ${_icons} ) # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty string(REGEX MATCH "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" _dummy "${_current_ICON}") set(_type "${CMAKE_MATCH_1}") set(_group "${CMAKE_MATCH_2}") set(_name "${CMAKE_MATCH_3}") set(_theme_GROUP ${_KDE4_ICON_THEME_${_type}}) if( _theme_GROUP) _KDE4_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake ${_defaultpath}/${_theme_GROUP}/scalable ${_group} ${_current_ICON} ${_name} ${_l10n_SUBDIR}) endif( _theme_GROUP) endforeach (_current_ICON) kde4_update_iconcache() endmacro (KDE4_INSTALL_ICONS) icecc-monitor-2.9.90~git20140222/config-icemon.h.cmake000066400000000000000000000000711230140027500220220ustar00rootroot00000000000000#define ICEMON_VERSION_STRING "@ICEMON_VERSION_STRING@" icecc-monitor-2.9.90~git20140222/doc/000077500000000000000000000000001230140027500166245ustar00rootroot00000000000000icecc-monitor-2.9.90~git20140222/doc/CMakeLists.txt000066400000000000000000000013511230140027500213640ustar00rootroot00000000000000# It's not possible to install the docbook right now (Qt-only project) #add_subdirectory(icemon) macro(install_docbook_man_page name section) set(inputfn "man-${name}.${section}.xml") set(input "${CMAKE_CURRENT_SOURCE_DIR}/${inputfn}") set(outputfn "${name}.${section}") set(output "${CMAKE_CURRENT_BINARY_DIR}/${outputfn}") set(target "manpage-${outputfn}") add_custom_command( OUTPUT ${output} COMMAND ${DOCBOOK2X} ${input} DEPENDS ${input} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_custom_target(${target} ALL DEPENDS "${output}" ) install( FILES ${output} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section} ) endmacro() if(DOCBOOK2X) install_docbook_man_page(icemon 1) endif() icecc-monitor-2.9.90~git20140222/doc/icemon/000077500000000000000000000000001230140027500200765ustar00rootroot00000000000000icecc-monitor-2.9.90~git20140222/doc/icemon/CMakeLists.txt000066400000000000000000000001731230140027500226370ustar00rootroot00000000000000########### install files ############### # kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en) icecc-monitor-2.9.90~git20140222/doc/icemon/index.docbook000066400000000000000000000166541230140027500225630ustar00rootroot00000000000000 ]> The &icemon; Handbook Cornelius Schumacher
cschum@suse.de
2004Cornelius Schumacher &FDLNotice; 2004-08-25 0.1 &icemon; is the monitor for &icecream;, which is a distributed compile system. &icemon; visualizes the distributed compile jobs and shows statistics and overview information. &icecream;
Introduction &icecream; is a distributed compile system. It allows parallel compiling by distributing the compile jobs to several nodes of a compile net running the icecream daemon. The icecream scheduler routes the jobs and provides status and statistics information to the icemon monitor. Each compile node can accept one or more compile jobs depending on the number of processors and the settings of the daemon. Link jobs and other jobs which cannot be distributed are executed locally on the node where the compilation is started. &icemon; provides a view on the compile net, which jobs run where and details about jobs and nodes. Views &icemon; provides a variety of views on the icecream net. Which view is shown can be selected in the "View" menu. If the view can be configured a configuration dialog can be opened by choosing the "Configure" item from the "Settings" menu. By selecting "Stop" from the "View" menu the view can be stopped from updating. By selecting "Start" from the view menu the updating is resumed. To refresh the nodes in the current view select "Check Nodes" from the "View" menu. The following sections describe the available views. Star View The star view shows the compile net as rings of nodes centered around the scheduler. Each node is assigned a color which is used to color the node itself and the compile jobs started from this node. A dashed line between the scheduler and a node indicates that the corresponding node has sent a compile job to the icecream net. A solid line between the scheduler and a node indicates that the node has been assigned a job by the scheduler. The lines have the color of the node issuing the jobs as well as the rings around the compiling node. Each ring represents one compile job. The nodes have a label with the name of the corresponding host. When leaving the mouse pointer over the label for a couple of seconds a tooltip is shown containing some more information about the node like IP address, processor architecture, name of the icecream flavor the color is based on, icecream id and a speed index. When selecting the "Configure" item of the "Settings" menu you get a configuration dialog where you can configure the number of nodes shown in a ring and specify a filter on the shown architectures. The number of nodes per ring affects in how many rings around the scheduler the nodes are shown. The architecture filter is a regular expression which is applied to the architecture names of the nodes. Only the nodes are shown for which the regular expression matches. If the expression is an empty string all nodes are shown. Summary View The summary view shows a list with a summary for each node. The summary contains the number of jobs the node has processed while the view has been shown, an indicator for each possible job the node can accept and a list of files currently processed by the node. The indicator is black if the node is idle and has the color of the node issuing the compile job when the node is active. The filename and the state of the compile job is shown in the right box of the summary. Gantt View The Gantt View shows a history of compile jobs for each node. Each node has a bar for each compile job it can accept. The compile jobs are shown scrolling on the bar from left to right. A grey bar means idle time. Compile jobs are shown in the color of the node issuing the job and have a label providing the name of the file which is compiled. Local jobs are shown on the bar of the node running the job in a lighter version of the node color. With the configuration dialog available under the "Configure" item of the "Settings" menu you can chose if a time scale should be added to the top of the gantt view or not. The time scale uses units of a second. Host View The host view shows the icecream status of the node the monitor is running on. The background of the view is painted in the color of the node and its name is shown in the center. On top it contains two LED displays, the left one shows the state of the jobs issued by the node the monitor is running on. It is dark if the node is idle, red if the node has issued one or more jobs to other nodes and orange if it is running a local job. The right LED shows the compile status of the node. It is dark when the node is idle and green when the node is running an icecream compile job. At the bottom of the view the current number of local, remote and compile jobs on the node is shown. List View The list view shows a list of all compile jobs which were run since activation of the view. The list shows the identifier of the job, the name of the compiled file, which node issued the job and which node compiled it. The state of the job and some statistics about the job. Credits and License &icemon; Program copyright 2004, The &icecream; Developers &icecream; Authors: Michael Matz matz@suse.de Stephan Kulow coolo@suse.de Cornelius Schumacher cschum@suse.de Based on the work of: The distcc developers Frerich Raabe raabe@kde.org Documentation copyright 2004 Author: Cornelius Schumacher cschum@suse.de See the &icecream; homepage for more details. &underFDL; &underGPL; &documentation.index;
icecc-monitor-2.9.90~git20140222/doc/man-icemon.1.xml000066400000000000000000000032111230140027500215250ustar00rootroot00000000000000 icemon"> ]> Icecream User's Manual Pino Toscano June 12th, 2013 Icecream icemon 1 icemon Icecream network monitor icemon -n net-name Description &icemon; is a graphical application to view an Icecream compile network and monitor its traffic. Options , Print help message and exit. , net-name The name of the Icecream network &icemon; should connect to. See Also icecream(7), icecc-scheduler(1), iceccd(1) Author Pino Toscano icecc-monitor-2.9.90~git20140222/icemon.kdev4000066400000000000000000000000571230140027500202720ustar00rootroot00000000000000[Project] Manager=KDevCMakeManager Name=icemon icecc-monitor-2.9.90~git20140222/src/000077500000000000000000000000001230140027500166465ustar00rootroot00000000000000icecc-monitor-2.9.90~git20140222/src/CMakeLists.txt000066400000000000000000000015431230140027500214110ustar00rootroot00000000000000add_subdirectory(images) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) set(icemon_SRCS fakemonitor.cc job.cc mainwindow.cc monitor.cc icecreammonitor.cc hostlistmodel.cc hostinfo.cc statusview.cc detailedhostview.cc flowtableview.cc hostlistview.cc joblistmodel.cc joblistview.cc listview.cc ganttstatusview.cc summaryview.cc starview.cc poolview.cc main.cc ) qt4_add_resources(resources_SRCS icemon.qrc) qt4_automoc(${icemon_SRCS}) add_executable(icemon ${icemon_SRCS} ${resources_SRCS}) target_link_libraries(icemon ${LIBICECREAM_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${CMAKE_DL_LIBS} ) ########### install files ############### install(TARGETS icemon ${INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES icemon.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) icecc-monitor-2.9.90~git20140222/src/IDEAS.poolview000066400000000000000000000005251230140027500212630ustar00rootroot00000000000000- Basically like the star view; scheduler appears as an isle in the middle, nodes appear as differently colored luftmatrazen around the scheduler. - Nodes slowly drift around the scheduler, in a circle - When a node gets a call from the scheduler, that increases it's attraction to the scheduler for a time, away from the scheduler. - icecc-monitor-2.9.90~git20140222/src/Messages.sh000066400000000000000000000001311230140027500207440ustar00rootroot00000000000000#! /usr/bin/env bash $EXTRACTRC *.rc >> rc.cpp $XGETTEXT *.cpp *.cc -o $podir/icemon.pot icecc-monitor-2.9.90~git20140222/src/detailedhostview.cc000066400000000000000000000126641230140027500225320ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2004-2006 Andre Wöbbeking (c) 2014 Allan Sandfeld Jensen 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include "detailedhostview.h" #include "hostinfo.h" #include "hostlistview.h" #include "hostlistmodel.h" #include "joblistview.h" #include "joblistmodel.h" #include static QString myHostName() { struct utsname uname_buf; if ( ::uname( &uname_buf ) == 0 ) return uname_buf.nodename; else return QString(); } DetailedHostView::DetailedHostView( HostInfoManager* manager, QWidget* parent ) : QWidget( parent ), StatusView( manager ) { QBoxLayout* topLayout = new QVBoxLayout( this ); topLayout->setMargin( 10 ); QSplitter* viewSplitter = new QSplitter( Qt::Vertical, this ); topLayout->addWidget( viewSplitter ); QWidget *hosts = new QWidget( viewSplitter ); QVBoxLayout *dummy = new QVBoxLayout( hosts ); dummy->setSpacing( 10 ); dummy->setMargin( 0 ); mHostListModel = new HostListModel(manager, this); mSortedHostListModel = new QSortFilterProxyModel(this); mSortedHostListModel->setDynamicSortFilter(true); mSortedHostListModel->setSourceModel(mHostListModel); dummy->addWidget(new QLabel( tr("Hosts" ), hosts )); mHostListView = new HostListView( manager, hosts ); mHostListView->setModel(mSortedHostListModel); dummy->addWidget(mHostListView); connect(mHostListView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(slotNodeActivated())); QWidget *locals = new QWidget( viewSplitter ); dummy = new QVBoxLayout( locals ); dummy->setSpacing( 10 ); dummy->setMargin( 0 ); mLocalJobsModel = new JobListModel(manager, this); mLocalJobsModel->setExpireDuration(5); mSortedLocalJobsModel = new JobListSortFilterProxyModel(this); mSortedLocalJobsModel->setDynamicSortFilter(true); mSortedLocalJobsModel->setSourceModel(mLocalJobsModel); dummy->addWidget(new QLabel( tr("Outgoing jobs" ), locals )); mLocalJobsView = new JobListView(locals); mLocalJobsView->setModel(mSortedLocalJobsModel); mLocalJobsView->setClientColumnVisible( false ); dummy->addWidget(mLocalJobsView); QWidget* remotes = new QWidget( viewSplitter ); dummy = new QVBoxLayout( remotes ); dummy->setSpacing( 10 ); dummy->setMargin( 0 ); mRemoteJobsModel = new JobListModel(manager, this); mRemoteJobsModel->setExpireDuration(5); mSortedRemoteJobsModel = new JobListSortFilterProxyModel(this); mSortedRemoteJobsModel->setDynamicSortFilter(true); mSortedRemoteJobsModel->setSourceModel(mRemoteJobsModel); dummy->addWidget(new QLabel( tr("Incoming jobs" ), remotes )); mRemoteJobsView = new JobListView(remotes); mRemoteJobsView->setModel(mSortedRemoteJobsModel); mRemoteJobsView->setServerColumnVisible( false ); dummy->addWidget(mRemoteJobsView); createKnownHosts(); } void DetailedHostView::update( const Job &job ) { const unsigned int hostid = mSortedHostListModel->mapToSource(mHostListView->currentIndex()).data(HostListModel::HostIdRole).value(); if ( !hostid ) return; if ( job.client() != hostid && job.server() != hostid ) return; if ( job.client() == hostid ) mLocalJobsModel->update( job ); if ( job.server() == hostid ) mRemoteJobsModel->update( job ); } void DetailedHostView::checkNode( unsigned int hostid ) { if ( !hostid ) return; mHostListModel->checkNode( hostid ); if ( !mHostListView->selectionModel()->hasSelection() ) { HostInfo* info = hostInfoManager()->find( hostid ); if ( info->name() == myHostName() ) mHostListView->setCurrentIndex( mSortedHostListModel->mapFromSource(mHostListModel->indexForHostInfo(*info, 0) )); } } void DetailedHostView::removeNode( unsigned int hostid ) { mHostListModel->removeNodeById( hostid ); } void DetailedHostView::updateSchedulerState( bool online ) { if ( !online ) { mHostListModel->clear(); mLocalJobsModel->clear(); mRemoteJobsModel->clear(); } } void DetailedHostView::slotNodeActivated() { mLocalJobsModel->clear(); mRemoteJobsModel->clear(); } void DetailedHostView::createKnownHosts() { const HostInfoManager::HostMap& hosts(hostInfoManager()->hostMap()); for (HostInfoManager::HostMap::ConstIterator it( hosts.begin() ), itEnd( hosts.end() ); it != itEnd; ++it ) { const unsigned int hostid( (*it)->id() ); checkNode( hostid ); } } QWidget* DetailedHostView::widget() { return this; } #include "detailedhostview.moc" icecc-monitor-2.9.90~git20140222/src/detailedhostview.h000066400000000000000000000035701230140027500223700ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2004-2006 Andre Wöbbeking 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_DETAILEDHOSTVIEW_H #define ICEMON_DETAILEDHOSTVIEW_H #include "statusview.h" #include class HostListModel; class JobListView; class JobListModel; class HostListView; class QSortFilterProxyModel; class DetailedHostView : public QWidget, public StatusView { Q_OBJECT public: DetailedHostView( HostInfoManager* manager, QWidget *parent ); void update( const Job &job ); QWidget* widget(); QString id() const { return "detailedhost"; } void checkNode( unsigned int hostid ); void removeNode( unsigned int hostid ); void updateSchedulerState( bool online ); private slots: void slotNodeActivated(); private: void createKnownHosts(); HostListModel* mHostListModel; HostListView* mHostListView; QSortFilterProxyModel* mSortedHostListModel; JobListModel* mLocalJobsModel; JobListView* mLocalJobsView; QSortFilterProxyModel* mSortedLocalJobsModel; JobListModel* mRemoteJobsModel; JobListView* mRemoteJobsView; QSortFilterProxyModel* mSortedRemoteJobsModel; }; #endif icecc-monitor-2.9.90~git20140222/src/fakemonitor.cc000066400000000000000000000055541230140027500215040ustar00rootroot00000000000000#include "fakemonitor.h" #include "statusview.h" #include "job.h" #include "hostinfo.h" #include #include #include // counter variable static int JOB_ID = 0; static const int MAX_JOB_COUNT = 10; static const QVector HOST_IDS(QVector() << 1 << 2 << 3); static const QStringList JOB_FILENAMES(QStringList() << QLatin1String("/tmp/filename.cc") << QLatin1String("/some/very/long/path/containing/filename.cc") << QLatin1String("/some/very/long/path/containing/averyverylongfilename.cc") ); FakeMonitor::FakeMonitor(HostInfoManager* manager, QObject* parent) : Monitor(manager, parent) , m_view(0) , m_updateTimer(new QTimer(this)) { m_updateTimer->setInterval(1000); m_updateTimer->start(); connect(m_updateTimer, SIGNAL(timeout()), SLOT(update())); init(); } void FakeMonitor::init() { { HostInfo info(1); info.setIp("1.0.0.1"); info.setColor(Qt::red); info.setMaxJobs(5); info.setName("Host1"); info.setOffline(false); info.setPlatform("Linux 3.6"); info.setServerLoad(1.0); info.setServerSpeed(10); hostInfoManager()->checkNode(info); } { HostInfo info(2); info.setIp("1.0.0.2"); info.setColor(Qt::blue); info.setMaxJobs(10); info.setName("Host2"); info.setOffline(false); info.setPlatform("Linux 3.4"); info.setServerLoad(1.0); info.setServerSpeed(10); hostInfoManager()->checkNode(info); } { HostInfo info(3); info.setIp("1.0.0.3"); info.setColor(Qt::green); info.setMaxJobs(5); info.setName("Host3"); info.setOffline(false); info.setPlatform("Windows 3.1"); info.setServerLoad(1.0); info.setServerSpeed(10); hostInfoManager()->checkNode(info); } } void FakeMonitor::setCurrentView( StatusView *view, bool rememberJobs ) { m_view = view; m_view->updateSchedulerState(true); } void FakeMonitor::update() { if (!m_view) return; // create job const int clientId = HOST_IDS[JOB_ID % HOST_IDS.size()]; const QString fileName = JOB_FILENAMES[JOB_ID % JOB_FILENAMES.length()]; Job job(JOB_ID++, clientId, fileName); time_t rawtime; time(&rawtime); job.setStartTime(rawtime); job.setState(Job::Compiling); const int serverId = HOST_IDS[(JOB_ID+1) % HOST_IDS.size()]; job.setServer(serverId); m_view->update(job); m_activeJobs << job; // clean up old jobs if (m_activeJobs.size() > MAX_JOB_COUNT) { Job job = m_activeJobs.first(); m_activeJobs.removeFirst(); job.setState(Job::Finished); m_view->update(job); } Q_FOREACH(const HostInfo* info, hostInfoManager()->hostMap().values()) { if ( info->isOffline() ) { m_view->removeNode( info->id() ); } else { m_view->checkNode( info->id() ); } } } #include "fakemonitor.moc" icecc-monitor-2.9.90~git20140222/src/fakemonitor.h000066400000000000000000000013461230140027500213410ustar00rootroot00000000000000#ifndef ICEMON_FAKEMONITOR_H #define ICEMON_FAKEMONITOR_H #include "monitor.h" #include "job.h" class HostInfoManager; class StatusView; class QTimer; class FakeMonitor : public Monitor { Q_OBJECT public: explicit FakeMonitor(HostInfoManager* manager, QObject* parent = 0); virtual void setCurrentView(StatusView* view, bool rememberJobs); virtual void setCurrentNet(const QByteArray& net) { Q_UNUSED(net); } virtual void setSchedulerState(bool online) { Q_UNUSED(online); } virtual bool schedulerState() const { return true; } private Q_SLOTS: void update(); private: void init(); StatusView* m_view; QList m_activeJobs; QTimer* m_updateTimer; }; #endif // ICEMON_FAKEMONITOR_H icecc-monitor-2.9.90~git20140222/src/flowtableview.cc000066400000000000000000000143311230140027500220310ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2011 Daniel Molkentin 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "flowtableview.h" #include #include #include #include #include ProgressWidget::ProgressWidget(HostInfo *info, StatusView *statusView, QWidget *parent) : QWidget(parent), m_hostInfo(info), m_statusView(statusView), m_isVirgin(true) { setAutoFillBackground(false); setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); m_backingStore = QImage(size(), QImage::Format_RGB32); m_backingStore.fill(palette().base().color().rgb()); } void ProgressWidget::paintEvent(QPaintEvent *) { QImage temp(size(), QImage::Format_RGB32); QPainter p(&temp); p.drawImage(-1,0, m_backingStore); if (m_isVirgin) { p.fillRect(rect(), palette().base()); m_isVirgin = false; } if (m_currentJob.state() == Job::Compiling || m_currentJob.state() == Job::LocalOnly) { QLinearGradient gradient; gradient.setCoordinateMode(QGradient::ObjectBoundingMode); gradient.setColorAt(0, palette().base().color()); gradient.setColorAt(1, m_statusView->hostColor(m_currentJob.client())); p.fillRect(width()-1,0, 1, height(), gradient); } else { p.fillRect(width()-1,0, 1, height(), palette().base().color()); } QPainter screenp(this); screenp.drawImage(0, 0, temp); m_backingStore = temp; } void ProgressWidget::resizeEvent(QResizeEvent *) { m_isVirgin = true; } //////////////////////////////////////////////////////////////////////////////// FlowTableView::FlowTableView(HostInfoManager *hostInfoManager, QWidget *parent) : QTableWidget(parent), StatusView(hostInfoManager), m_updateTimer(new QTimer) { setColumnCount(4); QStringList labels; labels << tr("Host") << tr("File") << tr("History") << tr("State"); setHorizontalHeaderLabels(labels); horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); verticalHeader()->hide(); setSelectionMode(QAbstractItemView::NoSelection); m_updateTimer->setInterval(50); m_updateTimer->start(); } void FlowTableView::update(const Job &job) { int serverId = job.server(); if (serverId == 0) return; // checkNode hasn't been run for this server yet. if (!m_idToRowMap.contains(serverId)) return; int serverRow = m_idToRowMap.value(serverId); QTableWidgetItem *fileNameItem = item(serverRow, 1); QTableWidgetItem *jobStateItem = item(serverRow, 3); if (job.state() == Job::Finished) { fileNameItem->setText(""); jobStateItem->setText(""); } else { QString filePath = job.fileName(); QString fileName = filePath.mid(filePath.lastIndexOf('/')+1); fileNameItem->setText(fileName); fileNameItem->setToolTip(job.fileName()); fileNameItem->setFlags(Qt::ItemIsEnabled); jobStateItem->setText(job.stateAsString()); jobStateItem->setToolTip(job.stateAsString()); jobStateItem->setFlags(Qt::ItemIsEnabled); } if (ProgressWidget *progressWidget = static_cast(cellWidget(serverRow, 2))) { progressWidget->setCurrentJob(job); } // update the host column for the server requesting the job QTableWidgetItem *hostNameItem = item(serverRow, 0); int usageCount = hostNameItem->data(Qt::UserRole).toInt(); if (job.state() == Job::LocalOnly || job.state() == Job::Compiling) ++usageCount; else if (job.state() == Job::Finished || job.state() == Job::Failed) --usageCount; hostNameItem->setData(Qt::UserRole, usageCount); QFont f = font(); f.setBold(usageCount > 0); hostNameItem->setFont(f); hostNameItem->setText(hostInfoText(hostInfoManager()->find(serverId), usageCount)); } QString FlowTableView::hostInfoText(HostInfo *hostInfo, int runningProcesses) { if (hostInfo->serverSpeed() == 0) // host disabled return tr("%1 (Disabled)").arg(hostInfo->name()); else return tr("%1 (%2/%3)").arg(hostInfo->name()).arg(runningProcesses).arg(hostInfo->maxJobs()); } void FlowTableView::checkNode(unsigned int hostId) { if (m_idToRowMap.contains(hostId)) return; HostInfo *hostInfo = hostInfoManager()->hostMap().value(hostId); QTableWidgetItem *widgetItem = new QTableWidgetItem(hostInfoText(hostInfo)); widgetItem->setIcon(QIcon(":/images/icemonnode.png")); widgetItem->setToolTip(hostInfo->toolTip()); widgetItem->setBackgroundColor(hostInfo->color()); // usage count widgetItem->setData(Qt::UserRole, 0); widgetItem->setFlags(Qt::ItemIsEnabled); int insertRow = rowCount(); setRowCount(insertRow + 1); m_idToRowMap.insert(hostId, insertRow); setItem(insertRow, 0, widgetItem); // adjust column width int width = QFontMetrics(widgetItem->font()).width(widgetItem->text())+32; horizontalHeader()->resizeSection(0, qMax(horizontalHeader()->sectionSize(0), width)); widgetItem = new QTableWidgetItem; widgetItem->setFlags(Qt::ItemIsEnabled); setItem(insertRow, 1, widgetItem); widgetItem = new QTableWidgetItem; widgetItem->setFlags(Qt::ItemIsEnabled); setItem(insertRow, 3, widgetItem); ProgressWidget *pw = new ProgressWidget(hostInfo, this); connect(m_updateTimer, SIGNAL(timeout()), pw, SLOT(update())); setCellWidget(insertRow, 2, pw); } void FlowTableView::removeNode(unsigned int hostId) { removeRow(m_idToRowMap.value(hostId)); m_idToRowMap.remove(hostId); } #include "flowtableview.moc" icecc-monitor-2.9.90~git20140222/src/flowtableview.h000066400000000000000000000044211230140027500216720ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2011 Daniel Molkentin 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef FLOWTABLEVIEW_H #define FLOWTABLEVIEW_H #include #include #include "statusview.h" #include "hostinfo.h" #include "job.h" class Job; typedef QHash HostIdRowMap; class ProgressWidget : public QWidget { Q_OBJECT public: ProgressWidget(HostInfo *info, StatusView *statusView, QWidget *parent = 0); void setCurrentJob(const Job &job) { m_currentJob = job; } Job currentJob() const { return m_currentJob; } void resizeEvent(QResizeEvent *); void paintEvent(QPaintEvent *); private: HostInfo *m_hostInfo; StatusView *m_statusView; Job m_currentJob; QImage m_backingStore; bool m_isVirgin; }; class FlowTableView : public QTableWidget, public StatusView { Q_OBJECT public: explicit FlowTableView(HostInfoManager *, QWidget *parent = 0); // status view reimpls QWidget* widget() { return this; } void update( const Job &job); void checkNode( unsigned int hostid ); void removeNode( unsigned int hostid ); void updateSchedulerState( bool online ) {} void checkNodes() {} QString id() const { return "flow"; } void stop() {} void start() {} bool canCheckNodes() { return false; } bool isPausable() { return false; } bool isConfigurable() { return false; } private: QString hostInfoText(HostInfo *hostInfo, int runningProcesses = 0); HostIdRowMap m_idToRowMap; QTimer *m_updateTimer; }; #endif // FLOWTABLEVIEW_H icecc-monitor-2.9.90~git20140222/src/ganttstatusview.cc000066400000000000000000000432501230140027500224350ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "ganttstatusview.h" #include "job.h" #include "hostinfo.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include GanttConfigDialog::GanttConfigDialog( QWidget *parent ) : QDialog( parent ) { QBoxLayout *topLayout = new QVBoxLayout( this ); topLayout->setMargin( 10 ); topLayout->setSpacing( 10 ); mTimeScaleVisibleCheck = new QCheckBox( tr("Show time scale"), this ); topLayout->addWidget( mTimeScaleVisibleCheck ); connect( mTimeScaleVisibleCheck, SIGNAL( clicked() ), SIGNAL( configChanged() ) ); QFrame *hline = new QFrame( this ); hline->setFrameShape( QFrame::HLine ); topLayout->addWidget( hline ); QBoxLayout *buttonLayout = new QHBoxLayout(); topLayout->addLayout( buttonLayout ); buttonLayout->addStretch( 1 ); QPushButton *button = new QPushButton( tr("&Close"), this ); buttonLayout->addWidget( button ); connect( button, SIGNAL( clicked() ), SLOT( hide() ) ); setWindowTitle(tr("Configure Gantt View")); // apply some minimum size resize(300, 100); } bool GanttConfigDialog::isTimeScaleVisible() { return mTimeScaleVisibleCheck->isChecked(); } GanttTimeScaleWidget::GanttTimeScaleWidget( QWidget *parent ) : QWidget( parent ), mPixelsPerSecond( 40 ) { QPalette pal = palette(); pal.setColor( backgroundRole(), Qt::white ); setPalette( pal ); } void GanttTimeScaleWidget::setPixelsPerSecond( int v ) { mPixelsPerSecond = v; } void GanttTimeScaleWidget::paintEvent( QPaintEvent *pe ) { const QRect r = pe->rect(); QPainter p( this ); const QFontMetrics fm = p.fontMetrics(); // Maybe the rectangle overlaps the right half of a number, check whether // that is the case and repaint that number if necessary. if ( r.x() % 100 != 0 ) { const int lastNumberXPos = r.x() - ( r.x() % 100 ); QString lastNumber = QString::number( lastNumberXPos / 100 * 5 ); if ( r.x() % 100 < p.fontMetrics().width( lastNumber ) ) { p.drawText( lastNumberXPos - r.x() + 2, fm.ascent(), lastNumber ); } } // Now draw all the bars and numbers, very straightforward. for ( int x = 0; x < r.width(); ++x ) { const int absX = x + r.x(); if ( absX % ( mPixelsPerSecond * 10 ) == 0 ) { p.drawLine( x, -r.y(), x, height() / 2 - r.y() ); p.drawText( x + 2, fm.ascent() - r.y(), QString::number( absX / mPixelsPerSecond ) ); } else if ( absX % ( mPixelsPerSecond * 5 ) == 0 ) { p.drawLine( x, -r.y(), x, height() / 4 - r.y() ); p.drawText( x + 2, fm.ascent() - r.y(), QString::number( absX / mPixelsPerSecond ) ); } else if ( absX % ( mPixelsPerSecond ) == 0 ) { p.drawLine( x, -r.y(), x, height() / 8 - r.y() ); } } } GanttProgress::GanttProgress( StatusView *statusView, QWidget *parent ) : QWidget( parent ), mStatusView( statusView ), mClock( 0 ), mIsFree( true ) { QPalette pal = palette(); pal.setColor( backgroundRole(), Qt::white ); setPalette( pal ); } void GanttProgress::progress() { mClock += 1; adjustGraph(); QWidget::update(); } void GanttProgress::adjustGraph() { // Remove non-visible jobs if ( m_jobs.count() >= 2 && mClock - m_jobs[ m_jobs.count() - 2 ].clock > width() ) { m_jobs.removeAt( m_jobs.count() - 1 ); } } void GanttProgress::update( const Job &job ) { #if 0 qDebug() << "GanttProgress::update( job ): " << job.fileName() << endl; qDebug() << " num jobs: " << m_jobs.count() << endl; if (!m_jobs.isEmpty()) qDebug() << " first id: " << m_jobs.first().job.jobId() << endl; qDebug() << " this id: " << job.jobId() << endl; #endif if ( !m_jobs.isEmpty() && m_jobs.first().job == job ) { // qDebug() << " Known Job. State: " << job.state() << endl; if ( job.state() == Job::Finished || job.state() == Job::Failed ) { Job j = IdleJob(); m_jobs.prepend( JobData( j, mClock ) ); mIsFree = true; } } else { // qDebug() << " New Job" << endl; m_jobs.prepend( JobData( job, mClock ) ); mIsFree = ( job.state() == Job::Idle ); } // qDebug() << "num jobs: " << m_jobs.count() << " jobs" << endl; } void GanttProgress::drawGraph( QPainter &p ) { // qDebug() << "drawGraph() " << m_jobs.count() << " jobs" << endl; if( height() == 0 ) return; bool lastBox = false; int xStart = 0; QList< JobData >::ConstIterator it = m_jobs.constBegin(); for ( ; ( it != m_jobs.constEnd() ) && !lastBox; ++it ) { int xEnd = mClock - (*it).clock; if ( xEnd > width() ) { xEnd = width(); lastBox = true; } int xWidth = xEnd - xStart; if( xWidth == 0 ) continue; // qDebug() << "XStart: " << xStart << " xWidth: " << xWidth << endl; // Draw the rectangle for the current job QColor color = colorForStatus( ( *it ).job ); p.fillRect( xStart, 0, xWidth, height(), color ); p.setPen( color.dark() ); p.drawRect( xStart, 0, xWidth, height() ); if( xWidth > 4 && height() > 4 ) { int width = xWidth - 4; QString s = ( *it ).job.fileName(); if ( !s.isEmpty() ) { s = s.mid( s.lastIndexOf( '/' ) + 1, s.length() ); // s = s.left( s.lastIndexOf( '.' ) ); // s[0] = s[0].upper(); // Optimization - cache the drawn text in a pixmap, and update the cache // only if the pixmap height doesn't match, if the pixmap width is too large, // or if the shortened text with another character added (next_text_width) would fit if( width >= (*it).next_text_width || width < (*it).text_cache.width() || height() - 4 != (*it).text_cache.height()) { // If we print the filename, check whether we need to truncate it and // append "..." at the end. int text_width = p.fontMetrics().width( s ); if( text_width > width ) { int threeDotsWidth = p.fontMetrics().width( "..." ); int next_width = 0; int newLength = 0; for(; next_width <= width; ++newLength ) { text_width = next_width; next_width = p.fontMetrics().width( s.left( newLength ) ) + threeDotsWidth; } (*it).next_text_width = next_width; s = s.left( newLength > 2 ? newLength - 2 : 0 ) + "..."; } else { (*it).next_text_width = 1000000; // large number (no next width) } // Finally draw the text. if( text_width > 0 ) { (*it).text_cache = QPixmap( text_width, height() - 4 ); (*it).text_cache.fill( color ); QPainter painter( &(*it).text_cache ); painter.setPen( StatusView::textColor( color ) ); painter.drawText( 0, 0, text_width, height() - 4, Qt::AlignVCenter | Qt::AlignLeft, s ); } } if( !(*it).text_cache.isNull()) p.drawPixmap( xStart + 2, 2, (*it).text_cache ); } } xStart = xEnd; } } QColor GanttProgress::colorForStatus( const Job &job ) const { if ( job.state() == Job::Idle ) { return Qt::gray; } else { QColor c = mStatusView->hostColor( job.client() ); if ( job.state() == Job::LocalOnly ) return c.light(); else return c; } } void GanttProgress::paintEvent( QPaintEvent * ) { QPainter p( this ); p.setBackgroundMode(Qt::OpaqueMode); p.setBackground(palette().background()); drawGraph( p ); } void GanttProgress::resizeEvent( QResizeEvent * ) { adjustGraph(); } GanttStatusView::GanttStatusView( HostInfoManager *m, QWidget *parent) : QScrollArea( parent ), StatusView( m ), mTopWidget(new QWidget( viewport() )) { mConfigDialog = new GanttConfigDialog( this ); connect( mConfigDialog, SIGNAL( configChanged() ), SLOT( slotConfigChanged() ) ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setWidget( mTopWidget ); setWidgetResizable( true ); QPalette palette = mTopWidget->palette(); palette.setColor( mTopWidget->backgroundRole(), Qt::white ); mTopWidget->setPalette( palette ); m_topLayout = new QGridLayout( mTopWidget ); m_topLayout->setSpacing( 5 ); m_topLayout->setMargin( 4 ); m_topLayout->setColumnStretch( 1, 10 ); mTimeScale = new GanttTimeScaleWidget( mTopWidget ); mTimeScale->setFixedHeight( 50 ); m_topLayout->addWidget( mTimeScale, 0, 1 ); m_progressTimer = new QTimer( this ); connect( m_progressTimer, SIGNAL( timeout() ), SLOT( updateGraphs() ) ); m_ageTimer = new QTimer( this ); connect( m_ageTimer, SIGNAL( timeout() ), SLOT( checkAge() ) ); mUpdateInterval = 25; mTimeScale->setPixelsPerSecond( 1000 / mUpdateInterval ); mMinimumProgressHeight = QFontMetrics( font() ).height() + 6; slotConfigChanged(); start(); } void GanttStatusView::update( const Job &job ) { if ( !mRunning ) return; if ( job.state() == Job::WaitingForCS ) return; #if 0 qDebug() << "GanttStatusView::update(): ID: " << job.jobId() << " " << job.fileName() << " Status:" << int( job.state() ) << " Server: " << job.server() << endl; #endif QMap::Iterator it; it = mJobMap.find( job.jobId() ); if ( it != mJobMap.end() ) { // qDebug() << " Job found" << endl; it.value()->update( job ); if ( job.state() == Job::Finished || job.state() == Job::Failed ) { mJobMap.erase( it ); } return; } if ( job.state() == Job::Finished || job.state() == Job::Failed ) return; GanttProgress *slot = 0; unsigned int processor; if ( job.state() == Job::LocalOnly ) processor = job.client(); else processor = job.server(); if ( !processor ) { #if 0 qDebug() << "GanttStatusView::update(): processor for job " << job.jobId() << " is empty."; #endif return; } NodeMap::ConstIterator it2 = mNodeMap.constFind( processor ); if ( it2 == mNodeMap.constEnd() ) { // qDebug() << " Server not known" << endl; slot = registerNode( processor ); } else { SlotList slotList = it2.value(); SlotList::ConstIterator it3; for( it3 = slotList.constBegin(); it3 != slotList.constEnd(); ++it3 ) { if ( (*it3)->isFree() ) { // qDebug() << " Found free slot" << endl; slot = *it3; break; } } if ( it3 == slotList.constEnd() ) { // qDebug() << " Create new slot" << endl; slot = registerNode( processor ); } } Q_ASSERT(slot); mJobMap.insert( job.jobId(), slot ); slot->update( job ); mAgeMap[ processor ] = 0; } QWidget * GanttStatusView::widget() { return this; } void GanttStatusView::checkNode( unsigned int hostid ) { if ( !mRunning ) return; if ( mNodeMap.find( hostid ) == mNodeMap.end()) registerNode( hostid )->update( IdleJob()); unsigned int max_kids = hostInfoManager()->maxJobs( hostid ); for( unsigned int i = mNodeMap[ hostid ].count(); i < max_kids; ++i ) registerNode( hostid )->update( IdleJob()); mAgeMap[ hostid ] = 0; SlotList slotList = mNodeMap[ hostid ]; // make a copy int to_remove = slotList.count() - max_kids; if( to_remove <= 0 ) return; QListIterator it2( slotList ); it2.toBack(); while ( it2.hasPrevious() ) { GanttProgress *progress = it2.previous(); if( progress->isFree() && progress->fullyIdle()) { removeSlot( hostid, progress ); if( --to_remove == 0 ) return; } } } GanttProgress *GanttStatusView::registerNode( unsigned int hostid ) { // qDebug() << "GanttStatusView::registerNode(): " << ip << endl; static int lastRow = 0; QColor color = hostColor( hostid ); QVBoxLayout *nodeLayout; NodeLayoutMap::ConstIterator it = mNodeLayouts.constFind( hostid ); if ( it == mNodeLayouts.constEnd() ) { ++lastRow; nodeLayout = new QVBoxLayout(); nodeLayout->setObjectName( ( QString::number( hostid ) + "_layout" ).toLatin1() ); m_topLayout->addLayout( nodeLayout, lastRow, 1 ); mNodeLayouts.insert( hostid, nodeLayout ); mNodeRows.insert( hostid, lastRow ); } else { nodeLayout = it.value(); } NodeRowMap::ConstIterator rowIt = mNodeRows.constFind( hostid ); if ( rowIt == mNodeRows.constEnd() ) { #if 0 qDebug() << "Unknown node row."; #endif } else { int row = *rowIt; NodeLabelMap::ConstIterator labelIt = mNodeLabels.constFind( hostid ); if ( labelIt == mNodeLabels.constEnd() ) { QString name = nameForHost( hostid ); QLabel *l = new QLabel( name, mTopWidget ); QPalette palette = l->palette(); palette.setColor( l->foregroundRole(), color ); palette.setColor( l->backgroundRole(), Qt::white ); l->setPalette( palette ); m_topLayout->addWidget( l, row, 0 ); QFont f = l->font(); f.setBold( true ); l->setFont( f ); l->show(); mNodeLabels.insert( hostid, l ); } } GanttProgress *w = new GanttProgress( this, mTopWidget ); w->setMinimumHeight( mMinimumProgressHeight ); nodeLayout->addWidget( w ); mNodeMap[ hostid ].append( w ); mAgeMap[ hostid ] = 0; m_topLayout->setRowStretch( mNodeRows[ hostid ], mNodeMap[ hostid ].size() ); w->show(); return w; } void GanttStatusView::removeSlot( unsigned int hostid, GanttProgress* slot ) { NodeLayoutMap::ConstIterator it = mNodeLayouts.constFind( hostid ); if ( it == mNodeLayouts.constEnd() ) return; mNodeMap[ hostid ].removeAll( slot ); JobMap newJobMap; for( QMap::Iterator it = mJobMap.begin(); it != mJobMap.end(); // QMap::remove doesn't return an iterator like ++it ) { // e.g. in QValueList, and I'm not sure if 'it' if( (*it) != slot ) // or '++it' would be still valid, so let's copy newJobMap[ it.key() ] = *it; // still valid items to a new map } mJobMap = newJobMap; m_topLayout->setRowStretch( mNodeRows[ hostid ], mNodeMap[ hostid ].size() ); delete slot; } void GanttStatusView::unregisterNode( unsigned int hostid ) { NodeLayoutMap::ConstIterator it = mNodeLayouts.constFind( hostid ); if ( it == mNodeLayouts.constEnd() ) return; while( !mNodeMap[ hostid ].isEmpty()) removeSlot( hostid, mNodeMap[ hostid ].first()); NodeLabelMap::Iterator labelIt = mNodeLabels.find( hostid ); if ( labelIt != mNodeLabels.end() ) { delete *labelIt; mNodeLabels.erase( labelIt ); } mAgeMap[ hostid ] = -1; } void GanttStatusView::updateGraphs() { NodeMap::ConstIterator it; for ( it = mNodeMap.constBegin(); it != mNodeMap.constEnd(); ++it ) { SlotList::ConstIterator it2; for( it2 = (*it).constBegin(); it2 != (*it).constEnd(); ++it2 ) { (*it2)->progress(); } } } void GanttStatusView::stop() { mRunning = false; m_progressTimer->stop(); m_ageTimer->stop(); } void GanttStatusView::start() { mRunning = true; m_progressTimer->start( mUpdateInterval ); m_ageTimer->start( 10000 ); } void GanttStatusView::checkNodes() { checkAge(); } void GanttStatusView::checkAge() { QList to_unregister; for( AgeMap::Iterator it = mAgeMap.begin(); it != mAgeMap.end(); ++it ) { if( *it > 1 ) to_unregister.append( it.key() ); else if( *it < 0 ) ; // unregistered ones else ++(*it); } for( QList::ConstIterator it = to_unregister.constBegin(); it != to_unregister.constEnd(); ++it ) unregisterNode( *it ); } void GanttStatusView::configureView() { mConfigDialog->show(); mConfigDialog->raise(); } void GanttStatusView::slotConfigChanged() { if ( mConfigDialog->isTimeScaleVisible() ) mTimeScale->show(); else mTimeScale->hide(); } #include "ganttstatusview.moc" icecc-monitor-2.9.90~git20140222/src/ganttstatusview.h000066400000000000000000000103661230140027500223010ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef GANTTSTATUSVIEW_H #define GANTTSTATUSVIEW_H #include "job.h" #include "statusview.h" #include #include #include #include #include class QCheckBox; class QGridLayout; class QTimer; class QVBoxLayout; class GanttConfigDialog : public QDialog { Q_OBJECT public: GanttConfigDialog( QWidget *parent ); bool isTimeScaleVisible(); signals: void configChanged(); private: QCheckBox *mTimeScaleVisibleCheck; }; class GanttTimeScaleWidget : public QWidget { Q_OBJECT public: GanttTimeScaleWidget( QWidget *parent ); void setPixelsPerSecond( int ); protected: virtual void paintEvent( QPaintEvent *e ); private: int mPixelsPerSecond; }; class GanttProgress : public QWidget { Q_OBJECT public: GanttProgress( StatusView *statusView, QWidget *parent ); bool isFree() const { return mIsFree; } bool fullyIdle() const { return m_jobs.count() == 1 && isFree(); } public slots: void progress(); void update( const Job &job ); protected: virtual void paintEvent( QPaintEvent *e ); virtual void resizeEvent( QResizeEvent *e ); private: void adjustGraph(); void drawGraph( QPainter &p ); QColor colorForStatus( const Job &job ) const; struct JobData { JobData( const Job& j, int c ) : job( j ), clock( c ), next_text_width( 0 ) {} JobData() {} // stupid QValueList bool operator==( const JobData& d ) { return job == d.job && clock == d.clock; } Job job; int clock; mutable int next_text_width; mutable QPixmap text_cache; }; StatusView *mStatusView; QList< JobData > m_jobs; int mClock; bool mIsFree; }; class GanttStatusView : public QScrollArea, public StatusView { Q_OBJECT public: GanttStatusView( HostInfoManager *, QWidget *parent ); virtual ~GanttStatusView() {} QString id() const { return "gantt"; } virtual void checkNode( unsigned int hostid ); void start(); void stop(); void checkNodes(); void configureView(); bool canCheckNodes() { return true; } bool isPausable() { return true; } bool isConfigurable() { return true; } public slots: virtual void update( const Job &job ); virtual QWidget *widget(); private slots: void slotConfigChanged(); void updateGraphs(); void checkAge(); private: GanttProgress *registerNode( unsigned int hostid ); void removeSlot( unsigned int hostid, GanttProgress* slot ); void unregisterNode( unsigned int hostid ); GanttConfigDialog *mConfigDialog; QWidget *mTopWidget; QGridLayout *m_topLayout; GanttTimeScaleWidget *mTimeScale; typedef QList SlotList; typedef QMap NodeMap; NodeMap mNodeMap; typedef QMap AgeMap; AgeMap mAgeMap; typedef QMap JobMap; JobMap mJobMap; typedef QMap NodeLayoutMap; NodeLayoutMap mNodeLayouts; typedef QMap NodeRowMap; NodeRowMap mNodeRows; typedef QMap NodeLabelMap; NodeLabelMap mNodeLabels; QTimer *m_progressTimer; QTimer *m_ageTimer; bool mRunning; int mUpdateInterval; int mMinimumProgressHeight; }; #endif // vim:ts=4:sw=4:noet icecc-monitor-2.9.90~git20140222/src/hostinfo.cc000066400000000000000000000161321230140027500210110ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "hostinfo.h" #include #include #include QVector HostInfo::mColorTable; QMap HostInfo::mColorNameMap; void HostInfo::initColorTable() { initColor( "#A5080B", QApplication::tr("cherry") ); initColor( "#76d26f", QApplication::tr("pistachio")); initColor( "#664a08", QApplication::tr("chocolate")); initColor( "#4c9dff", QApplication::tr("smurf")); initColor( "#6c2ca8", QApplication::tr("blueberry")); initColor( "#fa8344", QApplication::tr("orange")); initColor( "#55CFBD", QApplication::tr("mint")); initColor( "#db1230", QApplication::tr("strawberry")); initColor( "#a6ea5e", QApplication::tr("apple")); initColor( "#D6A3D8", QApplication::tr("bubblegum")); initColor( "#f2aa4d", QApplication::tr("peach")); initColor( "#aa1387", QApplication::tr("plum")); initColor( "#26c3f7", QApplication::tr("polar sea")); initColor( "#b8850e", QApplication::tr("nut")); initColor( "#6a188d", QApplication::tr("blackberry")); initColor( "#24b063", QApplication::tr("woodruff")); initColor( "#ffff0f", QApplication::tr("banana")); initColor( "#1e1407", QApplication::tr("mocha")); initColor( "#29B450", QApplication::tr("kiwi")); initColor( "#F8DD31", QApplication::tr("lemon")); initColor( "#fa7e91", QApplication::tr("raspberry")); initColor( "#c5a243", QApplication::tr("caramel")); initColor( "#b8bcff", QApplication::tr("blueberry")); // try to make the count a prime number (reminder: 19, 23, 29, 31) // initColor( "#ffb8c0", QApplication::tr("blackcurrant")); // initColor( "#f7d36f", QApplication::tr("passionfruit")); // initColor( "#d51013", QApplication::tr("pomegranate")); // initColor( "#C2C032", QApplication::tr("pumpkin" ) ); } void HostInfo::initColor( const QString &value , const QString &name ) { QColor c( value ); // modify colors so they become readable c.setHsv( c.hsvHue(), c.hsvSaturation()/2, (c.value()/3)+150 ); mColorTable.append( c ); mColorNameMap.insert( c.red() + c.green() * 256 + c.blue() * 65536, name ); } QString HostInfo::colorName( const QColor &c ) { int key = c.red() + c.green() * 256 + c.blue() * 65536; return mColorNameMap.value( key, QApplication::tr("") ); } HostInfo::HostInfo( unsigned int id ) : mId( id ) { } QString HostInfo::toolTip() const { return QApplication::translate(("tooltip"), "

" "
%1" "
" "" "" "" "" "" "" "
IP:%2
Platform:%3
Flavor: %4
Id:%5
Speed:%6

") .arg(name()).arg(ip()) .arg(platform()).arg(colorName(color())) .arg(QString::number(id())) .arg(QString::number(serverSpeed())); } void HostInfo::updateFromStatsMap( const StatsMap &stats ) { #if 0 qDebug() << "HostInfo::updateFromStatsMap():" << endl; StatsMap::ConstIterator it; for( it = stats.begin(); it != stats.end(); it++ ) { qDebug() << " STAT: " << it.key() << ": " << it.data() << endl; } #endif QString name = stats["Name"]; if ( name != mName ) { mName = name; mColor = createColor( mName ); mIp = stats["IP"]; mPlatform = stats["Platform"]; } mMaxJobs = stats["MaxJobs"].toUInt(); mOffline = ( stats["State"] == "Offline" ); mServerSpeed = stats["Speed"].toFloat(); mServerLoad = stats["Load"].toUInt(); } QColor HostInfo::createColor( const QString &name ) { unsigned long h = 0; unsigned long g; int ch; for( uint i = 0; i < (uint)name.length(); ++i ) { ch = name[i].unicode(); h = (h << 4) + ch; if ((g = (h & 0xf0000000)) != 0) { h ^= g >> 24; h ^= g; } } h += name.length() + ( name.length() << 17 ); h ^= h >> 2; // qDebug() << "HostInfo::createColor: " << h % mColorTable.count() << ": " << name << endl; return mColorTable[ h % mColorTable.count() ]; } QColor HostInfo::createColor() { static int num = 0; return mColorTable.at( num++ % mColorTable.count() ); #if 0 QColor color( num, 255 - num, ( num * 3 ) % 255 ); num += 48; num %= 255; return color; #endif } HostInfoManager::HostInfoManager() { HostInfo::initColorTable(); } HostInfoManager::~HostInfoManager() { qDeleteAll(mHostMap); } HostInfo *HostInfoManager::find( unsigned int hostid ) const { return mHostMap.value( hostid, 0 ); } void HostInfoManager::checkNode(const HostInfo &info) { HostMap::ConstIterator it = mHostMap.constFind(info.id()); if (it == mHostMap.constEnd()) { HostInfo *hostInfo = new HostInfo(info); mHostMap.insert(info.id(), hostInfo); } else { // no-op } } HostInfo *HostInfoManager::checkNode( unsigned int hostid, const HostInfo::StatsMap &stats ) { HostMap::ConstIterator it = mHostMap.constFind( hostid ); HostInfo *hostInfo; if ( it == mHostMap.constEnd() ) { hostInfo = new HostInfo( hostid ); mHostMap.insert( hostid, hostInfo ); } else { hostInfo = *it; } hostInfo->updateFromStatsMap( stats ); return hostInfo; } QString HostInfoManager::nameForHost( unsigned int id ) const { HostInfo *hostInfo = find( id ); if ( hostInfo ) return hostInfo->name(); return QApplication::tr(""); } QColor HostInfoManager::hostColor( unsigned int id ) const { if ( id ) { HostInfo *hostInfo = find( id ); if ( hostInfo ) { QColor tmp = hostInfo->color(); assert( tmp.isValid() && ( tmp.red() + tmp.green() + tmp.blue() )); return tmp; } } //qDebug() << "id " << id << " got no color\n"; assert( false ); return QColor( 0, 0, 0 ); } unsigned int HostInfoManager::maxJobs( unsigned int id ) const { if ( id ) { HostInfo *hostInfo = find( id ); if ( hostInfo ) return hostInfo->maxJobs(); } return 0; } HostInfoManager::HostMap HostInfoManager::hostMap() const { return mHostMap; } void HostInfoManager::setSchedulerName( const QString& schedulerName ) { mSchedulerName = schedulerName; } void HostInfoManager::setNetworkName( const QString& networkName ) { mNetworkName = networkName; } icecc-monitor-2.9.90~git20140222/src/hostinfo.h000066400000000000000000000072441230140027500206570ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_HOSTINFO_H #define ICEMON_HOSTINFO_H #include #include #include #include class HostInfo { public: explicit HostInfo( unsigned int id = 0 ); unsigned int id() const { return mId; } void setName(const QString& name) { mName = name; } QString name() const { return mName; } void setColor(const QColor& color) { mColor = color; } QColor color() const { return mColor; } void setIp(const QString& ip) { mIp = ip; } QString ip() const { return mIp; } void setPlatform(const QString& platform) { mPlatform = platform; } QString platform() const { return mPlatform; } void setMaxJobs(unsigned int jobs) { mMaxJobs = jobs; } unsigned int maxJobs() const { return mMaxJobs; } void setOffline(bool offline) { mOffline = offline; } bool isOffline() const { return mOffline; } typedef QMap StatsMap; void updateFromStatsMap( const StatsMap &stats ); static void initColorTable(); static QString colorName( const QColor & ); void setServerSpeed(float serverSpeed) { mServerSpeed = serverSpeed; } float serverSpeed() const { return mServerSpeed; } void setServerLoad(unsigned int load) { mServerLoad = load; } unsigned int serverLoad() const { return mServerLoad; } QString toolTip() const; bool operator==( const HostInfo &rhs ) const { return mId == rhs.mId; } bool operator!=( const HostInfo &rhs ) const { return mId != rhs.mId; } int operator<( const HostInfo &rhs ) const{ return mId < rhs.mId; } protected: static void initColor( const QString &value, const QString &name ); QColor createColor(); QColor createColor( const QString &name ); private: unsigned int mId; QString mName; QColor mColor; QString mPlatform; QString mIp; unsigned int mMaxJobs; bool mOffline; float mServerSpeed; unsigned int mServerLoad; static QVector mColorTable; static QMap mColorNameMap; }; class HostInfoManager { public: HostInfoManager(); ~HostInfoManager(); HostInfo *find( unsigned int hostid ) const; typedef QMap HostMap; HostMap hostMap() const; void checkNode(const HostInfo &info); HostInfo *checkNode( unsigned int hostid, const HostInfo::StatsMap &statmsg ); QString nameForHost( unsigned int id ) const; QColor hostColor( unsigned int id ) const; unsigned int maxJobs( unsigned int id ) const; QString schedulerName() const { return mSchedulerName; } void setSchedulerName( const QString& schedulerName ); QString networkName() const { return mNetworkName; } void setNetworkName( const QString& networkName ); private: HostMap mHostMap; QString mSchedulerName; QString mNetworkName; }; #endif // vim:ts=4:sw=4:noet icecc-monitor-2.9.90~git20140222/src/hostlistmodel.cc000066400000000000000000000114661230140027500220570ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2012 Kevin Funk 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "hostlistmodel.h" #include #include HostListModel::HostListModel(HostInfoManager* manager, QObject* parent) : QAbstractListModel(parent) , m_hostInfoManager(manager) { } QVariant HostListModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch(section) { case ColumnID: return tr("ID"); case ColumnName: return tr("Name"); case ColumnColor: return tr("Color"); case ColumnIP: return tr("IP"); case ColumnPlatform: return tr("Platform"); case ColumnMaxJobs: return tr("Max Jobs"); case ColumnSpeed: return tr("Speed"); case ColumnLoad: return tr("Load"); default: break; } } return QAbstractItemModel::headerData(section, orientation, role); } QVariant HostListModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); const HostInfo info = hostInfoForIndex(index); const int column = index.column(); if (role == HostIdRole) { return info.id(); } else if (role == Qt::DisplayRole) { switch (column) { case ColumnID: return info.id(); case ColumnName: return info.name(); case ColumnColor: return HostInfo::colorName(info.color()); case ColumnIP: return info.ip(); case ColumnPlatform: return info.platform(); case ColumnMaxJobs: return info.maxJobs(); case ColumnSpeed: return int(info.serverSpeed()); case ColumnLoad: return info.serverLoad(); default: break; } } else if (role == Qt::TextAlignmentRole) { switch (column) { case ColumnID: return Qt::AlignRight; case ColumnMaxJobs: return Qt::AlignRight; case ColumnSpeed: return Qt::AlignRight; case ColumnLoad: return Qt::AlignRight; default: break; } } return QVariant(); } int HostListModel::columnCount(const QModelIndex& parent) const { return _ColumnCount; } int HostListModel::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent); return m_hostInfos.size(); } QModelIndex HostListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } HostInfo HostListModel::hostInfoForIndex(const QModelIndex& index) const { return m_hostInfos.value(index.row()); } QModelIndex HostListModel::indexForHostInfo(const HostInfo& info, int column) const { const int i = m_hostInfos.indexOf(info); return index(i, column); } void HostListModel::checkNode(unsigned int hostid) { const HostInfo* info = m_hostInfoManager->find( hostid ); if (!info) return; const int index = m_hostInfos.indexOf(*info); if (index != -1) { m_hostInfos[index] = *info; emit dataChanged(indexForHostInfo(*info, 0), indexForHostInfo(*info, _ColumnCount - 1)); } else { beginInsertRows(QModelIndex(), m_hostInfos.size(), m_hostInfos.size()); m_hostInfos << *info; endInsertRows(); } } struct find_hostid : public std::unary_function { public: find_hostid(unsigned int hostId) : m_hostId(hostId) {} bool operator()(const HostInfo& info) const { return info.id() == m_hostId; } private: unsigned int m_hostId; }; void HostListModel::removeNodeById(unsigned int hostId) { QVector::iterator it = std::find_if(m_hostInfos.begin(), m_hostInfos.end(), find_hostid(hostId)); int index = std::distance(m_hostInfos.begin(), it); beginRemoveRows(QModelIndex(), index, index); m_hostInfos.erase(it); endRemoveRows(); } void HostListModel::clear() { m_hostInfos.clear(); reset(); } #include "hostlistmodel.moc" icecc-monitor-2.9.90~git20140222/src/hostlistmodel.h000066400000000000000000000040641230140027500217150ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2012 Kevin Funk 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_HOSTLISTMODEL_H #define ICEMON_HOSTLISTMODEL_H #include #include "hostinfo.h" class HostListModel : public QAbstractListModel { Q_OBJECT public: enum Column { ColumnID, ColumnName, ColumnColor, ColumnIP, ColumnPlatform, ColumnMaxJobs, ColumnSpeed, ColumnLoad, _ColumnCount }; enum Role { HostIdRole = Qt::UserRole }; explicit HostListModel(HostInfoManager* manager, QObject* parent = 0); virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; virtual QVariant data(const QModelIndex& index, int role) const; virtual int columnCount(const QModelIndex& parent) const; virtual int rowCount(const QModelIndex& parent) const; virtual QModelIndex parent(const QModelIndex& child) const; void checkNode(unsigned int hostId); void removeNodeById(unsigned int hostId); void clear(); HostInfo hostInfoForIndex(const QModelIndex& index) const; QModelIndex indexForHostInfo(const HostInfo& info, int column) const; private: const HostInfoManager* m_hostInfoManager; QVector m_hostInfos; }; #endif // ICEMON_HOSTLISTMODEL_H icecc-monitor-2.9.90~git20140222/src/hostlistview.cc000066400000000000000000000026171230140027500217270ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2004-2006 Andre Wöbbeking Copyright (c) 2012 Kevin Funk 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "hostlistview.h" #include "hostlistmodel.h" HostListView::HostListView( HostInfoManager* manager, QWidget* parent ) : QTreeView( parent ) , mHostInfoManager( manager ) { setAllColumnsShowFocus(true); setRootIsDecorated(false); setSortingEnabled(true); setWindowTitle(tr("Hosts")); } void HostListView::setModel(QAbstractItemModel* model) { if (model) { sortByColumn(HostListModel::ColumnID); } QTreeView::setModel(model); } #include "hostlistview.moc" icecc-monitor-2.9.90~git20140222/src/hostlistview.h000066400000000000000000000023111230140027500215600ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2004 Andre Wöbbeking Copyright (c) 2012 Kevin Funk 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_HOSTLISTVIEW_H #define ICEMON_HOSTLISTVIEW_H #include "hostinfo.h" #include class HostListView :public QTreeView { Q_OBJECT public: HostListView( HostInfoManager* manager, QWidget* parent ); virtual void setModel(QAbstractItemModel* model); private: HostInfoManager* mHostInfoManager; }; #endif icecc-monitor-2.9.90~git20140222/src/icecreammonitor.cc000066400000000000000000000251031230140027500223360ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2003,2004 Cornelius Schumacher Copyright (c) 2007 Dirk Mueller 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "icecreammonitor.h" #include "hostinfo.h" #include "statusview.h" #include #include #include #include #include #include #include using namespace std; IcecreamMonitor::IcecreamMonitor( HostInfoManager *manager, QObject *parent) : Monitor(manager, parent) , m_scheduler( 0 ) , m_schedulerState( false ) , m_discover( 0 ) , m_fd_notify( 0 ) , m_fd_type(QSocketNotifier::Exception) { setupDebug(); checkScheduler(); } IcecreamMonitor::~IcecreamMonitor() { delete m_scheduler; delete m_discover; } void IcecreamMonitor::checkScheduler(bool deleteit) { #if 0 qDebug() << "checkScheduler " << deleteit << endl; #endif if ( deleteit ) { m_rememberedJobs.clear(); delete m_scheduler; m_scheduler = 0; delete m_fd_notify; m_fd_notify = 0; m_fd_type = QSocketNotifier::Exception; delete m_discover; m_discover = 0; setSchedulerState(false); } else if ( m_scheduler ) return; QTimer::singleShot( 1000+(qrand()&1023), this, SLOT( slotCheckScheduler() ) ); // TODO: check if correct } void IcecreamMonitor::registerNotify(int fd, QSocketNotifier::Type type, const char* slot) { if (m_fd_notify) { m_fd_notify->disconnect(this); m_fd_notify->deleteLater(); } m_fd_notify = new QSocketNotifier(fd, type, this); m_fd_type = type; QObject::connect(m_fd_notify, SIGNAL(activated(int)), slot); } void IcecreamMonitor::slotCheckScheduler() { if ( m_scheduler ) return; list names; if ( !m_current_netname.isEmpty() ) names.push_front( m_current_netname.data() ); else names.push_front("ICECREAM"); if (!qgetenv("USE_SCHEDULER").isEmpty()) names.push_front(""); // try $USE_SCHEDULER for ( list::const_iterator it = names.begin(); it != names.end(); ++it ) { m_current_netname = it->c_str(); if (!m_discover || m_discover->timed_out()) { delete m_discover; m_discover = new DiscoverSched ( m_current_netname.data() ); } m_scheduler = m_discover->try_get_scheduler (); if ( m_scheduler ) { hostInfoManager()->setSchedulerName( QString::fromLatin1(m_discover->schedulerName().data()) ); hostInfoManager()->setNetworkName( QString::fromLatin1(m_discover->networkName().data()) ); m_scheduler->setBulkTransfer(); delete m_discover; m_discover = 0; registerNotify(m_scheduler->fd, QSocketNotifier::Read, SLOT(msgReceived())); if ( !m_scheduler->send_msg ( MonLoginMsg() ) ) { checkScheduler(true); QTimer::singleShot(0, this, SLOT(slotCheckScheduler())); } else { setSchedulerState( true ); } return; } if (m_fd_type != QSocketNotifier::Write && m_discover->connect_fd() >= 0) { registerNotify(m_discover->connect_fd(), QSocketNotifier::Write, SLOT(slotCheckScheduler())); return; } else if (m_fd_type != QSocketNotifier::Read && m_discover->listen_fd() >= 0) { registerNotify(m_discover->listen_fd(), QSocketNotifier::Read, SLOT(slotCheckScheduler())); } if (m_fd_type == QSocketNotifier::Read) QTimer::singleShot(1000+(qrand()&1023), this, SLOT(slotCheckScheduler())); } setSchedulerState( false ); } void IcecreamMonitor::msgReceived() { while (!m_scheduler->read_a_bit() || m_scheduler->has_msg()) if (!handle_activity()) break; } bool IcecreamMonitor::handle_activity() { Msg *m = m_scheduler->get_msg (); if ( !m ) { #if 0 qDebug() << "lost connection to scheduler\n"; #endif checkScheduler( true ); setSchedulerState( false ); return false; } switch ( m->type ) { case M_MON_GET_CS: handle_getcs( m ); break; case M_MON_JOB_BEGIN: handle_job_begin( m ); break; case M_MON_JOB_DONE: handle_job_done( m ); break; case M_END: std::cout << "END" << endl; checkScheduler( true ); break; case M_MON_STATS: handle_stats( m ); break; case M_MON_LOCAL_JOB_BEGIN: handle_local_begin( m ); break; case M_JOB_LOCAL_DONE: handle_local_done( m ); break; default: cout << "UNKNOWN" << endl; break; } delete m; return true; } void IcecreamMonitor::handle_getcs( Msg *_m ) { MonGetCSMsg *m = dynamic_cast( _m ); if ( !m ) return; m_rememberedJobs[m->job_id] = Job( m->job_id, m->clientid, m->filename.c_str(), m->lang == CompileJob::Lang_C ? "C" : "C++" ); m_view->update( m_rememberedJobs[m->job_id] ); } void IcecreamMonitor::handle_local_begin( Msg *_m ) { MonLocalJobBeginMsg *m = dynamic_cast( _m ); if ( !m ) return; m_rememberedJobs[m->job_id] = Job( m->job_id, m->hostid, m->file.c_str(), "C++" ); m_rememberedJobs[m->job_id].setState( Job::LocalOnly ); m_view->update( m_rememberedJobs[m->job_id] ); } void IcecreamMonitor::handle_local_done( Msg *_m ) { JobLocalDoneMsg *m = dynamic_cast( _m ); if ( !m ) return; JobList::iterator it = m_rememberedJobs.find( m->job_id ); if ( it == m_rememberedJobs.end() ) { // we started in between return; } ( *it ).setState( Job::Finished ); m_view->update( *it ); if ( m_rememberedJobs.size() > 3000 ) { // now remove 1000 uint count = 1000; while ( --count ) m_rememberedJobs.erase( m_rememberedJobs.begin() ); } } void IcecreamMonitor::handle_stats( Msg *_m ) { MonStatsMsg *m = dynamic_cast( _m ); if ( !m ) return; QStringList statmsg = QString( m->statmsg.c_str() ).split( '\n' ); HostInfo::StatsMap stats; for ( QStringList::ConstIterator it = statmsg.constBegin(); it != statmsg.constEnd(); ++it ) { QString key = *it; key = key.left( key.indexOf( ':' ) ); QString value = *it; value = value.mid( value.indexOf( ':' ) + 1 ); stats[key] = value; } HostInfo *hostInfo = hostInfoManager()->checkNode( m->hostid, stats ); if ( hostInfo->isOffline() ) { m_view->removeNode( m->hostid ); } else { m_view->checkNode( m->hostid ); } } void IcecreamMonitor::handle_job_begin( Msg *_m ) { MonJobBeginMsg *m = dynamic_cast( _m ); if ( !m ) return; JobList::iterator it = m_rememberedJobs.find( m->job_id ); if ( it == m_rememberedJobs.end() ) { // we started in between return; } ( *it ).setServer( m->hostid ); ( *it ).setStartTime( m->stime ); ( *it ).setState( Job::Compiling ); #if 0 qDebug() << "BEGIN: " << (*it).fileName() << " (" << (*it).jobId() << ")" << endl; #endif m_view->update( *it ); } void IcecreamMonitor::handle_job_done( Msg *_m ) { MonJobDoneMsg *m = dynamic_cast( _m ); if ( !m ) return; JobList::iterator it = m_rememberedJobs.find( m->job_id ); if ( it == m_rememberedJobs.end() ) { // we started in between return; } ( *it ).exitcode = m->exitcode; if ( m->exitcode ) { ( *it ).setState( Job::Failed ); } else { ( *it ).setState( Job::Finished ); ( *it ).real_msec = m->real_msec; ( *it ).user_msec = m->user_msec; ( *it ).sys_msec = m->sys_msec; /* system time used */ ( *it ).pfaults = m->pfaults; /* page faults */ ( *it ).in_compressed = m->in_compressed; ( *it ).in_uncompressed = m->in_uncompressed; ( *it ).out_compressed = m->out_compressed; ( *it ).out_uncompressed = m->out_uncompressed; } #if 0 qDebug() << "DONE: " << (*it).fileName() << " (" << (*it).jobId() << ")" << endl; #endif m_view->update( *it ); } void IcecreamMonitor::setCurrentView( StatusView *view, bool rememberJobs ) { m_view = view; m_view->updateSchedulerState( m_schedulerState ); if ( rememberJobs ) { JobList::ConstIterator it = m_rememberedJobs.constBegin(); for ( ; it != m_rememberedJobs.constEnd(); ++it ) m_view->update( *it ); } } void IcecreamMonitor::setCurrentNet( const QByteArray &netName ) { m_current_netname = netName; } void IcecreamMonitor::setSchedulerState( bool online ) { if (m_schedulerState == online) return; m_schedulerState = online; emit schedulerStateChanged( online ); m_view->updateSchedulerState( online ); } void IcecreamMonitor::setupDebug() { char *env = getenv("ICECC_DEBUG"); int debug_level = Error; if (env) { if (!strcasecmp(env, "info")) { debug_level |= Info | Warning; } else if (!strcasecmp(env, "warnings")) { debug_level |= Warning; // taking out warning } else { // any other value debug_level |= Info | Debug | Warning; } } std::string logfile; if (const char *logfileEnv = getenv("ICECC_LOGFILE")) { logfile = logfileEnv; } setup_debug(debug_level, logfile, "ICEMON"); } #include "icecreammonitor.moc" icecc-monitor-2.9.90~git20140222/src/icecreammonitor.h000066400000000000000000000044531230140027500222050ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2003,2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_ICECREAMMONITOR_H #define ICEMON_ICECREAMMONITOR_H #include "monitor.h" #include "job.h" #include class HostInfoManager; class Msg; class MsgChannel; class StatusView; class DiscoverSched; class QSocketNotifier; class IcecreamMonitor : public Monitor { Q_OBJECT public: IcecreamMonitor(HostInfoManager *, QObject *parent); ~IcecreamMonitor(); void setCurrentView( StatusView *, bool rememberJobs ); void setSchedulerState( bool ); void setCurrentNet( const QByteArray & ); bool schedulerState() const { return m_schedulerState; } private slots: void slotCheckScheduler(); void msgReceived(); private: void checkScheduler(bool deleteit = false); void registerNotify(int fd, QSocketNotifier::Type type, const char* slot); void setupDebug(); bool handle_activity(); void handle_getcs( Msg *m ); void handle_job_begin( Msg *m ); void handle_job_done( Msg *m ); void handle_stats( Msg *m ); void handle_local_begin( Msg *m ); void handle_local_done( Msg *m ); StatusView *m_view; JobList m_rememberedJobs; MsgChannel *m_scheduler; QByteArray m_current_netname; bool m_schedulerState; DiscoverSched *m_discover; QSocketNotifier *m_fd_notify; QSocketNotifier::Type m_fd_type; }; #endif // ICEMON_ICECREAMMONITOR_H // vim:ts=4:sw=4:noet icecc-monitor-2.9.90~git20140222/src/icemon.desktop000066400000000000000000000061711230140027500215200ustar00rootroot00000000000000[Desktop Entry] GenericName=Icecream Monitor GenericName[ca]=Monitor Icecream GenericName[ca@valencia]=Monitor Icecream GenericName[el]=Επόπτης Icecream GenericName[en_GB]=Icecream Monitor GenericName[es]=Monitor Icecream GenericName[et]=Icecreami jälgija GenericName[fr]=Moniteur Icecream GenericName[ga]=Monatóir Icecream GenericName[gl]=Vixilante Icecream GenericName[hne]=आइसक्रीम मानीटर GenericName[hu]=Icecream figyelő GenericName[it]=Monitor Icecream GenericName[ja]=Icecream モニタ GenericName[ms]=Monitor Icecream GenericName[nds]=Icecream-Kieker GenericName[nl]=Icecream-monitor GenericName[pa]=ਆਈਸਕਰੀਮ ਮਾਨੀਟਰ GenericName[pl]=Monitor Icecream GenericName[pt]=Monitor Icecream GenericName[pt_BR]=Monitor Icecream GenericName[ro]=Monitor Icecream GenericName[sv]=Övervakare av Icecream GenericName[tr]=Icecream İzleyici GenericName[uk]=Монітор Icecream GenericName[x-test]=xxIcecream Monitorxx GenericName[zh_TW]=Icecream 監視器 Name=Icemon Name[ca]=Icemon Name[ca@valencia]=Icemon Name[cs]=Icemon Name[de]=Icemon Name[el]=Icemon Name[en_GB]=Icemon Name[eo]=Icemon Name[es]=Icemon Name[et]=Icemon Name[fr]=Icemon Name[ga]=Icemon Name[gl]=Icemon Name[hne]=आइसमान Name[hu]=Icemon Name[it]=Icemon Name[ja]=Icemon Name[ms]=Icemon Name[nds]=Icemon Name[nl]=Icemon Name[pa]=ਆਈਸਮੋਨ Name[pl]=Icemon Name[pt]=Icemon Name[pt_BR]=Icemon Name[ro]=Icemon Name[sk]=Icemon Name[sv]=Icemon Name[tr]=Icemon Name[ug]=Icemon Name[uk]=Icemon Name[x-test]=xxIcemonxx Name[zh_TW]=Icemon Comment=A monitor for an Icecream compilation network Comment[ca]=Un monitor per a una xarxa de compilació Icecream Comment[ca@valencia]=Un monitor per a una xarxa de compilació Icecream Comment[el]=Ένας επόπτης ενός μιας σύνθεσης δικτύου Icecream Comment[en_GB]=A monitor for an Icecream compilation network Comment[es]=Un monitor para una red de compilación Icecream Comment[et]=Icecreami kompileerimisvõrgu jälgija Comment[fr]=Un moniteur pour une compilation réseau de Icecream Comment[ga]=Monatóir do líonra tiomsaithe Icecream Comment[gl]=Un vixilante para unha compilación de rede Icecream Comment[hne]=आईसक्रीम कम्पायलर नेटवर्क बर एक मानीटर Comment[it]=Monitor per una rete di compilazione Icecream Comment[ms]=Peninjau jaringan kompilasi Icecream Comment[nds]=En Kieker för en Icecream-Kompileernettwark Comment[nl]=Een monitor voor een Icecream Compilatienetwerk Comment[pl]=Monitor dla sieci kompilacji Icecream Comment[pt]=Um monitor para uma rede de compilação Icecream Comment[pt_BR]=Um monitor para uma rede de compilação Icecream Comment[sv]=En övervakare av ett Icecream-kompileringsnätverk Comment[tr]=Icecream derleme ağı için bir izleyici Comment[ug]=Icecream تارقاق يۇغۇرۇش تورىنى كۆزەتكۈچ Comment[uk]=Монітор мережі компіляції Icecream Comment[x-test]=xxA monitor for an Icecream compilation networkxx Exec=icemon Type=Application Terminal=false Categories=Qt;Development; Icon=icemon Keywords=icecc;icecream;monitor;network; icecc-monitor-2.9.90~git20140222/src/icemon.qrc000066400000000000000000000005241230140027500206300ustar00rootroot00000000000000 images/hi128-app-icemon.png images/icemonnode.png images/hi16-app-icemon.png images/hi48-app-icemon.png images/hi22-app-icemon.png images/hi32-app-icemon.png icecc-monitor-2.9.90~git20140222/src/images/000077500000000000000000000000001230140027500201135ustar00rootroot00000000000000icecc-monitor-2.9.90~git20140222/src/images/CMakeLists.txt000066400000000000000000000000501230140027500226460ustar00rootroot00000000000000kde4_install_icons(${ICON_INSTALL_DIR}) icecc-monitor-2.9.90~git20140222/src/images/hi128-app-icemon.png000066400000000000000000000251661230140027500235140ustar00rootroot00000000000000PNG  IHDR>asBIT|d pHYs$$P$tEXtSoftwarewww.inkscape.org<tEXtTitleIcecream MonitorȏTvtEXtAuthorJakub Steiner/ IDATxyU眪{ol$(3ƍHeq^_uܘ:ƅ\^%$(qpATH$k'.UuTխ{F:ݒrkyyγSJDxf/fYYz,g0ɛizgۖYm_H4j/"xo_*{gL{>Z8!T+yT81\aDΚ)!o}%<&9O;@6CKB`|MQU˞S;73~Ҵ󹯢s<Yyet v ;Q}ye?6LX+:ݼ4kQ9,-q|ﳻ$O>4Hm8@Du[*M+!M+\/<#Odqq}f}'9@R;wH(yRpyܢ `y(>:,ז;q:khZm% _ ϡf&v.yeT-Dxpcxд`j*w@zAvMF )l((Xq`=4m(KZYo7SM3 %A`9]4c`+!N@MCME: v GAnu]$1thЦ*?@U#d0DM$24B~:|WjNo%NGGkw^"chڼuo}#P``+Hņו:)`|(Ts7|!lMܷ( U0OTx48Ȥ\}i\g0:bR9=1أ`Ybava˓9 ZtKx& f$a);4X:KU֦j`׊lof= Lh!Dkhu" NU5gXҬ'[Ɨ#IZ~9p-}v >aX}<3+>PUJI D S) pU8p睷\)9.wW- )@j1/ Y כNE;/"eignhV]=ś\yfY [o>oV ehh@J⬝B>rϘTҬntojCo20/pO/ {֭[w@+f%"~v>pgN>;Et/ƠNjЖ5_ceG׭F99̺.o98@g~fկH-"3p2Jz(nX \}?jfX~}knUQN;4o¹UJeCWWXkj} \W_W浟*^fz߅;8qE{{;b\.G\fhx}Sصk"(uEY;aR>h=3G{/"b /k~~J56D??x'@.caC9c[ `Μ.X`K,Ivfn{ Q\o>U?bıET,tRƛ$|-eyt'OW.뼉ЬϤϪ{9Tgy?w\-^ ѸKHww7==iŹ Y<6mwrRouʳ=|Y|Rhx}:;;1EJjǠ7xc1_2HYy 6]3h T*z~?x)^m c'9%XM3{vǛ{>S?pO2>y-'mɻ=ayv& &PJw˴޻jRxS#+/{/PJξu8zt/V:88vc7p$"QssU믿~R]xc}P}j5R^/Ukp~mӆ'ɋ/'F3!{=8tɡZ?Z;穧Q(~[ᣔ ]v>a\ᅟ[.s͛C[>O0YɊz. BJ@`;w;zs?ZDqgGכ7J ;8s9]}ꓔȝ@A)G9Ykٴi3{da֭d-hлjm x7~;@{ {X8v7Er'P50 ٵ{/va>n,)-s+ϙɤƣJrC[zu䚋/x%Nvvvh!7 ? CΝ;)'xjνk>4|O)zW}7&]UT#pA|,0U7T8t??!'gǣg9l#D0S[aˮA ~׻6hMLD ̀ ^!b~cO;7mlܷu답W!=PLOMv?&.|QK9l<51qY(:9~b9ď [9M jρumM.ўn~DXC]%E_iSO=wۤ^0M  p:Cs&¦D?4i[^M,/[ ('2X3xOWU|Vg׬Mla(۱׷X{83֞nmw\Mx3Xyιa]U_ O-R J0sڡXq̡#á+IG ^hZ2.e_]{<|9<ҺoknJWlQ8 }фʙ{R`k$o< k?t?hCd\\J 1R~7HK(rin }glO&B-Y℣D]vr5ZWv> ]Pp%@;.[n+QRKuA K^$ɡhU#4CAرg΢K'`~blTҏ"yp(_XΨ]8 A;d 'f,D!'^= LV o&"@Ykt}ڋyVI/( Ϥ o= 2jMS+o!ZHF` B̆s}&3"dgU礁?X2(%Q%uB{Ԥ }:Z)Km+NIkT7x]2 Pg-ozF B˛?T4/E}5*-#70_W՟jwr%z@x>TP~wmO).}Qv'6qKZkgho/BDrUTȪ.'Ͱd~S ºAH 0RC4FPJ1^j{p5S[ NNX 񗡼(Ӎ_nkt yj3N9POoF s6uB,Wh 54|d?\ ,CƔ|1oQ AZdg5jAhyh\rqXx('pZ{%%Lw@hsm߳N3_Vםʣ u|f"-?FEZS(Tk.("s^j߀`cub'iYZٔp4M5QH=B +Vˆ8yr}ޝзm᱇h\=<M.JԳz_@Ɗ$];tdk&VsP)lh> +1- R䥸qBoV(Wqnzkj.}<έ0ǁAĩ`c#@Q"&<5Nzs#*Հ6+&/Q C"qg [tm w0cǔTBpSpyJ?[|3J/Dk+Y6]% SOG.h+o񓙼r,]OnP/Kl/ κ9ۚ3n`ʷv%*PRaM8@n@"9Z-y_M.>Vr-.?Olx)>{/TkE!185g]8 H+(4`*EU5ªx4I(i&p1 qRJV s̷f: r5p(4B|Cs;ipܸ"HFIbw (Σ(9T6jCbè_Gׯ-\ HTyA/T6SyыBmE܋ UcCM(I5ZiZa4.vJr/+$0$fti vh*fsWB ljUn}W̠mA~{e2"Tj-Ċ4}j(RhQX"b@9S¦ڝX++  Fiq@s@4 eUQ[뢛C m>3h̑A ȕra.YbBO@Fc4Sc0FMqt9DvqJ J+wNMi $-_*K.X\X}L IDAT(=4Ћ$ZVX+ '*YSF=g4F+<1Ќ1 zY0E:inR&Kĩ b k0<\MDH ;٬\q^1`ؼIY;TϹbc>VSI @kgk\%_^Ҙy; >Ã|wOGf\عlyF7JWl -4xSK b⡇T~\pê j1KsקBwZyh<-Q-Z֮[<-`͑'?"FF+0"T0wW\q&HB  Y?_W=lZ!C*mPRާ\XkqEq$w[wm q>~TJ1kot:~ )Ko(KLyFN6N\l~˛a72!E3N/6=~̉ϹMkHmŶF{( F[:uכD%qL¼ .t :槇:(%"QD6† tUgLD__D8דI@ rQ,N 7uttxm:z居ntj(Ph|%tֺT>[6g$mݍqMIdN4YQ{h0 .רTRk?W_P~vI@Vd.|xJ^{sSsKZc |Y&KhLv ;&Fh24Һ1tܷk-'5lQo-6r-?Bj rwy&ӹ߱ڗSzI61|߫y=u6Ty \EVma߽:c_Ek&}{GhA k 2۾yyy9OK^r|ڏ& 8>gqOzumskJDD6"ljFNQmhwFZEQaD&|h@Psw 337s^鈕'z069WecF)D&.kl\8bmRnI QyOm=E0VQAxx1y$y~in+C_b+:I7K9Q" b['?.y'7jA07I -3V2Ksqx<7&od#@لPbi3I.sNPy"?gc<%gP80B BED6"( 6TaDU*j`N",qBgE"-PBc5 Z,ϋHN㋯>^RV)$XE@a&5x[۬m1_>@@PMnmFc4m6w*@XXJ&¨B,R#+fܢ[3CY bHV`Huz3`7kk[Ot^m"'4R* VZo;Iz+Pu܎Y(Ǩk1F"KZ7LMr*sbYNS Qo2MU z37ڊcCIENDB`icecc-monitor-2.9.90~git20140222/src/images/hi16-app-icemon.png000066400000000000000000000013551230140027500234220ustar00rootroot00000000000000PNG  IHDRasBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<jIDAT8RKHTa L *CZ`&AEmDFkkVQڔ5¢I'_u{EPgqwތ9yrKXڪ7F:G[=!? "Kc݌bCX8sşDl`V0}jin :Xx{Pzc]G-oHd<:<0wJpM#;#"7:4Mnݽ+-*Ki|Mر)qhY 'q>}eg,YromMw"{Q^Õ#؜ ۭ=k]t75c`іp+ |^. Y%=k ZQ-nGׅ} DZ1g*PV@Yeesd0 9[`tl Sl)` T^00ԟ|ij$ҋd0&22P%3iXxp_?9ֱ$H`cgOC%Ӂ4E QS2^m<ۖ5>1z4yT,̧JMZqq U$@Զ~.QIENDB`icecc-monitor-2.9.90~git20140222/src/images/hi22-app-icemon.png000066400000000000000000000021541230140027500234150ustar00rootroot00000000000000PNG  IHDRĴl;sBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<IDAT8mhU?nnkKUVHX2FQ \Q#D̉oJ4)HQ0z]v{ Ms}9~_΃Jp6ԛ@IW[ܤuzn o]TSE꭛ _:b5~`T~g"#t0 yƲy֦z8+3|Aֿ; w$ be(@pɉI&2f1r;I +lpEm2y׳#h$(mXtiXߩg1 #"RL~h.CvaBRԙ_T:dTm94hIENDB`icecc-monitor-2.9.90~git20140222/src/images/hi32-app-icemon.png000066400000000000000000000035321230140027500234170ustar00rootroot00000000000000PNG  IHDR szzsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<IDATXlU?q=G/*(G,)1 YWE@1mY"0:6 .e7#87La`h`7HJ[{ϽxQ ʓ<=~?y=(a('baZK+¦׿U* 6X^)_?cZ+hyx}ZưACM'(K `5 _D= ^p5[Z&Ъ4mȪ [g>֋lVI۶Xs_VjU@TG9E/za%[][LWW8Cmq +PWka~ۖ-{MS#WDP"A@G45O Xd3?DExzȊ_q d;wh.{ líjnnԧXf1 3~)~}dY&CfLo)5n y}-\|׮?V%SIԩ~_"J `x#s}ڷzqH5G -%Yߔ* FS*妺z= tEPwNRFD@@kMOt*2 )V؉6Ox3瘶}K68?,_1Zy6l^#/c@WZ*Ec,'IJÈibB81D"KAʗxE7a';rdqP8D!GgWo> ;w' cnBeW E"6nƶ estlow> dRhJ 3s46LemL #JE/^>>{#y8 ="R- z<5n\ō_Z]%tsȘpd¸ζTcBg4*̛Jd%l7FzZ,-&КH[VCuܒ+@{?& H#2. ,$5 t%UR WJjEڲθ馲f pWK -t$GbݮnI -׌'&^-d$z/z_ 0F%K\F_$M=:<{a.sg_$ڽ_J}ef gw 4km.@/*~mjZ;vpL`{(=4Վ_rx㫕pj3`m0ZѢ@ۯU00~*J%%im%%=ۧHi\r c=^L `k_ɑ|Jy#O/ZVl@FkZ0~h޼/DBW^9q$=ۗTUQB}HjkǕ544Fbemm}%kN&1ofϞz{Za6l2EuHNל@Og[fQ3J5WH$+JA{<Y0YBmXmQP;w'C]\SSE}&D DFUv+#,uز޾D4hy5,:ilzr]=dOoʪ[ @{q܄O mnU>)Ž&$H)_"`I- `,u8cg4͛ёQbjH^аD$̋K"ÅȖ-#V+߮8冺ШJqb I!$`"Bwo>'S[6掻ko4   Xr<}C<%2PO4` <8܃+ <0܇2{TIoV6ڳ+xb_s 26Kρ4 ! IJ; RPP`(ָГWfahnǤ=v%Q`^%pvtexR =qQFB|oNBٗ@ 1U)o;4E`Kz9KTOϞ`k17R4#}Ih"š99 'a@NwrY˷AP\xAghbo8R]Kʱ%B-FKb8,iē:Ӳxiw3{j/: (σlhh.Dzª^kc`ޛL:ʐb4ZV3r@^{.ru`! DJyok:Z1ssz.Bubyǘ9?x @H`f0+ hCbHH[6j>XĺڰK 1*SH9Q. Cd2f%Fv@ IA HP

6e|d)&yI< &sCl6ʨ̨sU ]iUl]~$*9 o})_*_Ck@IENDB`icecc-monitor-2.9.90~git20140222/src/images/hisc-app-icemon.svgz000066400000000000000000000063111230140027500240030ustar00rootroot00000000000000R(Fhisc-app-icemon.svgksJOgpII&IG 1hQ$H~Njil{ǁv6ˣ4'Mt%7W_//dib&I:œ?w٠ .*n7ymQgj J3aey 6gjRӯ7Y\-©&E>%L'yؑ9lnb}lHa'w$"Ƙ)SJ}~?- -):Өfpp3%/L?*]Ңӗl>FbcX~ w$X|66r](n&\nn Z\M@C*1)=(ˆъfGqv-pmߢ*74N F]8<{&W 5oEb)cM==ShM^˅]Q{Y,xY P+0cՂ.'-.e˚)͋tЂ} 9l?KP ދy>֤enA0J ya42*MVt7##gQQ mF2㘴3#3ȍơ1V,+R6nDшX\?XvF,GEeό<yЌ(.lvWp"iu1'ja$m%9Xr![hS PC;ՎҢl< ƛCuF]oO¥Rk(qfŧ#x4>n @Ro[3b$մsʖ-EXG PvЛZدIT@ùm5mH~mgOGxGy$jΐJh$}r&?M>䏡l:qAqeP'k)U ŁB"Z]fs5mCK$9̺*(h TF! ݓO#D !f(L>ŎI Sh/.ZDQAwBf#&Ts3姈/.ƗttŇbOܧr1DGB D+ĥ!..4{aXbE05mF(hcՈ#&sz׉18x;1'vrJhŴƣݕKwCxٻ'-7wS X7l!تFlaeλ[m "|.%CXdtH ϖL,Xނ*? Q~dIԡ<EC/pJM]cZJ'oQwQH_LU4$;@rwIM+[Xi T2[,g?0;t!y]]3+E]_E Vl{ѻEܢ"dY3ؾ1afS Krj@ w7o{]XHޣAgRRs(I)[8ЫUURQ{Z{Wz] wu5ES.M)nd4Hm"&df ˛$FXU: [?LHh9x盧mسۻ 8KY&\%C\@͈o`*DZ]qp$U@Yy6hbLvPkw-.g}l'rDW1^Ia/޵܋qS=>GZSE$Ag7 "dS~:拹Fq!WF0z\ǖ•[Njn@sFy 0 C R ! $]#H 5 BO dma0Q a#)g _/b !av3.8F0b֛zQcrrZ]ĤbJ#%I+?x<.$:u""@mc#(1X֗;F"ʲ$38aI:cL ^3m 0 ܝ"Pş}Yz4]&;i!h;Ou \B/d 1'%ð6KΣZѯhP po5SRKCS8ҡ˜PS,97B:18CH&XZI9vhC^khq !`Y(7cvObĐ7%ʯ)p2)$ Y_z/q@"pՊi$#C{CUSZU#P17H S޵s Jr"5`(%%4Rp0xn^g8zI/{kfj ņsDzDZ@]) &(EzS%@)F(bl-wv=1(i=@ 8fwm[J Xz02w8uB v&#Uisv@zsꨗpee : (FQhڤ>^{l7Rs~]أhsdl8D8,?>&h BǾzHcZfAǚJs8O8=Pd)Li>lsħ#нgG 'Ɨ>S н$aYN,ԝ]Dsy'lFu!]S-rwReri'a*iRy(^oWUWAI1ݕ`SoXaM2ˋ +;*.(wfqzQަYQs}A7o-YiYʩ VQ|?{i ^,Z>a0Ȼnj^P(LT (LJPHt0IejT4J9(ڈM9`ZKnpv |"0HFsH((;9.+%G>i_&z)\+D12KZw !0PaH 09W`v:kv~6_Lj*5֚j5*ܽH7=7a8X`&T9C1zyHGw*"ȫ|kszɥ6'T@icecc-monitor-2.9.90~git20140222/src/images/icemonnode.png000066400000000000000000000074521230140027500227510ustar00rootroot00000000000000PNG  IHDR00WgAMA7IDATxkUՕ{}wyJaVJ1IT$)a2J(SBgB(:2Mhtu{pQյ=}zcX>xsԧN+g?6`Iz꩙LoRן?4/9s,ٹs9qٷoY~OZz' /7L\6w.vvvT馛_=AP.I&,\𖑑ѣGOMrwyᇟg?nD"<\u>:OZn)%&{3wӧO+_7ޥr9_]`Acww7cp]0 X,ƒ%Kp])%Or@=h?g޼yw+&f͚uc__߿瀁YfܺuS˗/Ǚ1cd2\%ɐL&$L2sLa۶m'|Z[[vttu-|_3j+JyO,̙Ckk+MMMq28Gw٦M?۾zw7+WEJI ضZ|yP(:tUV=t;f͚'&&&RRT}qp]qb$Iִ>|g&> U^|֮^\.ŋr(VT*E__"a>LmB)g)Ӳ,9222qwv@Q\X,6]]]Kk{zjNzxaꢡ)%Blj6`rY6n믿+(TUHJ%U*( ~L>_פR)8L|> 2uTb#mƏB|'2 X BA D Jk h BE(PƒrLꉤeݺuׯ_?ܹ(oc8x ###q* aR*8r) ".+ePJsPwTHъR.T*!^mx#@~y:kl믿~ KU J$-:u~&&&bJzErtvv#HHI"T `@HFb0B4+2sQ,zÌXjzٚ,T`@lȑ# S,m˲Ν;wڵ%`?paxxRQ -D(K!(} JcaI(eF(n*JHhm@VrllL?c |!Ο?O<'aYb {9{\I!p\DZ)Oh5Ah0h)A,0@ǩ)FKc`쥗^zX,>PWxҤIeFFF>ꫯ+W@vt:E*rS8XXJlYDD)dl6=E"acAY0Ԡ5n̂XyT}`z뭷̞={y:nr\9ܹgΜMCIkku}+Z%\%m,̆OA I"* 5R*ױm6/W&R#WU8wU0 %FDZ$ɄZuJَ:)nrlhe FJ %vƲ%Z.n/n%cwj @L"gunݺPJiW2 ]3hc" dwc( @dQR)lFڀ֠{DiSq)$Ҳ0QZ"LH*bݻpMϟK_:!D]HIR("~ȺQTH$UG}gB08NLJicDaOO_|qk`[r( d1 Sg6 ]v8puO a0zMDyvbȅ XlA066Fsss;5@|Sr7>cs{رD3 0y0˖-/M1xGP L5311MMMÖ{СC9qk5:VϟR> n]D)E*T*Q,9{,Bj˭"ڶ6o~ĉe>>X.O'r\,6$qDq(e>aՙfIENDB`icecc-monitor-2.9.90~git20140222/src/job.cc000066400000000000000000000035171230140027500177350ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2003,2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "job.h" #include #include QString Job::stateAsString() const { switch ( m_state ) { case WaitingForCS: return QApplication::tr( "Waiting" ); break; case Compiling: return QApplication::tr( "Compiling" ); break; case Finished: return QApplication::tr( "Finished" ); break; case Failed: return QApplication::tr( "Failed" ); break; case Idle: return QApplication::tr( "Idle" ); break; case LocalOnly: return QApplication::tr( "Local Only" ); break; } return QString(); } QDebug operator<<(QDebug dbg, const Job& job) { return dbg.nospace() << "Job[id=" << job.jobId() << ", client=" << job.client() << ", server=" << job.server() << ", fileName=" << job.fileName() << ", state=" << job.stateAsString() << "]"; } icecc-monitor-2.9.90~git20140222/src/job.h000066400000000000000000000062601230140027500175750ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2003,2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_JOB_H #define ICEMON_JOB_H #include #include #include #include class Job { public: enum State { WaitingForCS, LocalOnly, Compiling, Finished, Failed, Idle }; explicit Job(unsigned int id = 0, unsigned int client = 0, const QString &filename = QString(), const QString &lang = QString()) { m_id = id; m_fileName = filename; m_lang = lang; m_state = WaitingForCS; m_client = client; real_msec = 0; user_msec = 0; sys_msec = 0; pfaults = 0; exitcode = 0; m_server = 0; in_compressed = in_uncompressed = out_compressed = out_uncompressed = 0; } bool operator==( const Job &rhs ) const { return m_id == rhs.m_id; } bool operator!=( const Job &rhs ) const { return m_id != rhs.m_id; } int operator<( const Job &rhs ) const{ return m_id < rhs.m_id; } unsigned int jobId() const { return m_id; } QString fileName() const { return m_fileName; } unsigned int client() const { return m_client; } unsigned int server() const { return m_server; } State state() const { return m_state; } QString stateAsString() const; time_t stime() const { return m_stime; } void setServer( unsigned int hostid ) { m_server = hostid; } void setStartTime( time_t t ) { m_stime = t; } void setState( State ss ) { m_state = ss; } private: unsigned int m_id; QString m_fileName; unsigned int m_server; unsigned int m_client; QString m_lang; State m_state; time_t m_stime; public: unsigned int real_msec; /* real time it used */ unsigned int user_msec; /* user time used */ unsigned int sys_msec; /* system time used */ unsigned int pfaults; /* page faults */ int exitcode; /* exit code */ unsigned int in_compressed; unsigned int in_uncompressed; unsigned int out_compressed; unsigned int out_uncompressed; }; QDebug operator<<(QDebug dbg, const Job& job); class IdleJob : public Job { public: IdleJob() : Job() { setState( Job::Idle ); } }; class JobList : public QMap { public: JobList() {} }; #endif // vim:ts=4:sw=4:noet icecc-monitor-2.9.90~git20140222/src/joblistmodel.cc000066400000000000000000000215611230140027500216510ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2012 Kevin Funk 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "joblistmodel.h" #include "hostinfo.h" #include #include #include #include #include #include #include #include static QString formatByteSize(unsigned int value) { static const char* const units[] = { "B", "KiB", "MiB" }; unsigned int unit = 0; while( unit < sizeof( units ) / sizeof( units[ 0 ] ) && value > 1024 ) { ++unit; value /= 1024; } return QCoreApplication::tr("%1 %2").arg( QLocale::system().toString(value), units[unit]); } /** * Remove some of the parts of a file path * * @param numberOfFilePathParts * If 0 => Return the file name, excluding the path * If 1 => Return '.../ancestorDir/file.ext' if possible * If 2 => ... */ static QString trimFilePath(const QString& filePath, int numberOfFilePathParts) { const QChar separator = QDir::separator(); if (numberOfFilePathParts == 0) { return filePath.mid(filePath.lastIndexOf( separator ) + 1); } int counter = numberOfFilePathParts; int index = 0; do { index = filePath.lastIndexOf( separator, index - 1); } while ( counter-- && index > 0 ); if ( index > 0 ) return QString::fromLatin1( "..." ) + filePath.mid( index ); return filePath; } JobListModel::JobListModel(HostInfoManager* manager, QObject* parent) : QAbstractListModel(parent) , m_hostInfoManager(manager) , m_numberOfFilePathParts(2) , m_expireDuration(-1) , m_expireTimer(new QTimer(this)) { connect(m_expireTimer, SIGNAL(timeout()), this, SLOT(slotExpireFinishedJobs())); } void JobListModel::update(const Job& job) { const int index = m_jobs.indexOf(job); if (index != -1) { m_jobs[index] = job; emit dataChanged(indexForJob(job, 0), indexForJob(job, _JobColumnCount - 1 )); } else { beginInsertRows(QModelIndex(), m_jobs.size(), m_jobs.size()); m_jobs << job; endInsertRows(); } const bool finished = (job.state() == Job::Finished || job.state() == Job::Failed); if (finished) expireItem(job); } void JobListModel::clear() { m_jobs.clear(); m_finishedJobs.clear(); reset(); } int JobListModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); return _JobColumnCount; } Job JobListModel::jobForIndex(const QModelIndex& index) const { return m_jobs.value(index.row()); } QModelIndex JobListModel::indexForJob(const Job& job, int column) { const int i = m_jobs.indexOf(job); return index(i, column); } QVariant JobListModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { case JobColumnID: return tr("ID"); case JobColumnFilename: return tr("File name"); case JobColumnClient: return tr("Client"); case JobColumnServer: return tr("Server"); case JobColumnState: return tr("State"); case JobColumnReal: return tr("Real"); case JobColumnUser: return tr("User"); case JobColumnFaults: return tr("Faults"); case JobColumnSizeIn: return tr("Size In"); case JobColumnSizeOut: return tr("Size Out"); } } return QAbstractListModel::headerData(section, orientation, role); } QVariant JobListModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); const Job job = jobForIndex(index); const int column = index.column(); const HostInfoManager* manager = m_hostInfoManager; if (role == Qt::DisplayRole) { switch (column) { case JobColumnID: return job.jobId(); case JobColumnFilename: return trimFilePath(job.fileName(), m_numberOfFilePathParts); case JobColumnClient: return manager->nameForHost(job.client()); case JobColumnServer: return manager->nameForHost(job.server()); case JobColumnState: return job.stateAsString(); case JobColumnReal: return job.real_msec; case JobColumnUser: return job.user_msec; case JobColumnFaults: return job.pfaults; case JobColumnSizeIn: return formatByteSize(job.in_uncompressed); case JobColumnSizeOut: return formatByteSize(job.out_uncompressed); default: break; } } else if (role == Qt::TextAlignmentRole) { switch (column) { case JobColumnID: return Qt::AlignRight; case JobColumnReal: return Qt::AlignRight; case JobColumnUser: return Qt::AlignRight; case JobColumnFaults: return Qt::AlignRight; case JobColumnSizeIn: return Qt::AlignRight; case JobColumnSizeOut: return Qt::AlignRight; default: break; } } return QVariant(); } QModelIndex JobListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } int JobListModel::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent); return m_jobs.size(); } struct find_jobid : public std::unary_function { public: find_jobid(unsigned int jobId) : m_jobId(jobId) {} bool operator()(const Job& job) const { return job.jobId() == m_jobId; } private: unsigned int m_jobId; }; void JobListModel::slotExpireFinishedJobs() { const uint currentTime = QDateTime::currentDateTime().toTime_t(); // this list is sorted by the age of the finished jobs, the oldest is the first // so we've to find the first job which isn't old enough to expire FinishedJobs::iterator it = m_finishedJobs.begin(); for (const FinishedJobs::iterator itEnd = m_finishedJobs.end(); it != itEnd; ++it) { if (currentTime - (*it).time < (uint)m_expireDuration) break; unsigned int jobId = (*it).jobId; removeItemById(jobId); } m_finishedJobs.erase(m_finishedJobs.begin(), it); if (m_finishedJobs.empty()) m_expireTimer->stop(); } void JobListModel::removeItem(const Job& job) { removeItemById(job.jobId()); } void JobListModel::removeItemById(unsigned int jobId) { QVector::iterator it = std::find_if(m_jobs.begin(), m_jobs.end(), find_jobid(jobId)); int index = std::distance(m_jobs.begin(), it); beginRemoveRows(QModelIndex(), index, index); m_jobs.erase(it); endRemoveRows(); } void JobListModel::expireItem(const Job& job) { if (m_expireDuration == 0) { removeItem( job ); return; } const uint currentTime = QDateTime::currentDateTime().toTime_t(); m_finishedJobs.push_back(FinishedJob(currentTime, job.jobId())); if (!m_expireTimer->isActive()) m_expireTimer->start(1000); } JobListSortFilterProxyModel::JobListSortFilterProxyModel(QObject* parent) : QSortFilterProxyModel( parent ) { } bool JobListSortFilterProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const { if ((left.column() != JobListModel::JobColumnSizeIn && left.column() != JobListModel::JobColumnSizeOut) || (right.column() != JobListModel::JobColumnSizeIn && right.column() != JobListModel::JobColumnSizeOut)) { return QSortFilterProxyModel::lessThan(left, right); } // Sort file sizes correctly, the view shows them already formatted in a way that wouldn't be correctly numerically // compared. const JobListModel* model = static_cast< JobListModel* >( sourceModel()); Job jobLeft = model->jobForIndex(left); Job jobRight = model->jobForIndex(right); unsigned int leftValue = left.column() == JobListModel::JobColumnSizeIn ? jobLeft.in_uncompressed : jobLeft.out_uncompressed; unsigned int rightValue = right.column() == JobListModel::JobColumnSizeIn ? jobRight.in_uncompressed : jobRight.out_uncompressed; return leftValue < rightValue; } #include "joblistmodel.moc" icecc-monitor-2.9.90~git20140222/src/joblistmodel.h000066400000000000000000000072151230140027500215130ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2012 Kevin Funk 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef JOBLISTMODEL_H #define JOBLISTMODEL_H #include #include #include "job.h" #include class HostInfoManager; class QTimer; class JobListModel : public QAbstractListModel { Q_OBJECT public: enum Column { JobColumnID, JobColumnFilename, JobColumnClient, JobColumnServer, JobColumnState, JobColumnReal, JobColumnUser, JobColumnFaults, JobColumnSizeIn, JobColumnSizeOut, _JobColumnCount }; explicit JobListModel(HostInfoManager* manager, QObject* parent = 0); void update(const Job& job); void clear(); int expireDuration() const { return m_expireDuration; } void setExpireDuration( int duration ) { m_expireDuration = duration; } virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; virtual QModelIndex parent(const QModelIndex& child) const; virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; Job jobForIndex(const QModelIndex& index) const; QModelIndex indexForJob(const Job& job, int column); const HostInfoManager* hostInfoManager() const { return m_hostInfoManager; } private Q_SLOTS: void slotExpireFinishedJobs(); private: QVector m_jobs; void expireItem(const Job& job); void removeItem(const Job& job); void removeItemById(unsigned int jobId); const HostInfoManager* m_hostInfoManager; /** * Number of parts (directories) of the file path which should be displayed. * - < 0 for complete file path * - == 0 for the pure file name without path * - > 0 for only parts of the file path. If there are not enough parts * the complete file path is displayed else .../partN/.../part1/fileName. * Default is 2. */ int m_numberOfFilePathParts; /** * The number of seconds after which finished jobs should be expired. * - < 0 never * - == 0 at once * - > 0 after some seconds. * Default is -1. */ int m_expireDuration; struct FinishedJob { FinishedJob(uint _time = 0, uint _jobId = 0) : time(_time), jobId(_jobId) {} uint time; uint jobId; }; typedef QVector FinishedJobs; /// List with job ids that are expired FinishedJobs m_finishedJobs; QTimer* m_expireTimer; }; class JobListSortFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT public: JobListSortFilterProxyModel( QObject* parent = NULL ); protected: virtual bool lessThan( const QModelIndex& left, const QModelIndex& right ) const; }; #endif icecc-monitor-2.9.90~git20140222/src/joblistview.cc000066400000000000000000000051451230140027500215230ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2004, 2005 Andre Wöbbeking Copyright (c) 2012 Kevin Funk 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "joblistview.h" #include "joblistmodel.h" #include #include JobListView::JobListView(QWidget* parent) : QTreeView( parent ) { setAllColumnsShowFocus(true); setRootIsDecorated(false); setSortingEnabled(true); setWindowTitle(tr("Jobs")); } JobListModel* JobListView::jobListModel() const { return qobject_cast(model()); } void JobListView::setModel(QAbstractItemModel* model) { if (model) { sortByColumn(JobListModel::JobColumnID); } QTreeView::setModel(model); } void JobListView::update( const Job& job ) { JobListModel* model = jobListModel(); if (!model) return; model->update(job); } bool JobListView::isClientColumnVisible() const { return !isColumnHidden(JobListModel::JobColumnClient); } void JobListView::setClientColumnVisible( bool visible ) { if ( visible == isClientColumnVisible() ) return; if ( visible ) { setColumnHidden(JobListModel::JobColumnClient, false); resizeColumnToContents(JobListModel::JobColumnClient); } else { setColumnHidden(JobListModel::JobColumnClient, true); } } bool JobListView::isServerColumnVisible() const { return !isColumnHidden(JobListModel::JobColumnServer); } void JobListView::setServerColumnVisible( bool visible ) { if ( visible == isServerColumnVisible() ) return; if ( visible ) { setColumnHidden(JobListModel::JobColumnServer, false); resizeColumnToContents(JobListModel::JobColumnServer); } else { setColumnHidden(JobListModel::JobColumnServer, true); } } #include "joblistview.moc" icecc-monitor-2.9.90~git20140222/src/joblistview.h000066400000000000000000000030611230140027500213600ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2004 Andre Wöbbeking Copyright (c) 2012 Kevin Funk 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_JOBLISTVIEW_H #define ICEMON_JOBLISTVIEW_H #include #include "job.h" class JobListModel; class HostInfoManager; class JobListView : public QTreeView { Q_OBJECT public: JobListView(QWidget* parent = 0); void update( const Job& job ); virtual void setModel(QAbstractItemModel* model); bool isClientColumnVisible() const; void setClientColumnVisible( bool visible ); bool isServerColumnVisible() const; void setServerColumnVisible( bool visible ); void clear(); private: JobListModel* jobListModel() const; }; #endif icecc-monitor-2.9.90~git20140222/src/listview.cc000066400000000000000000000035051230140027500210260ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2004 Andre Wöbbeking Copyright (c) 2014 Allan Sandfeld Jensen 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "listview.h" #include "joblistview.h" #include "joblistmodel.h" #include #include ListStatusView::ListStatusView( HostInfoManager* manager, QWidget* parent ) : QWidget( parent ), StatusView( manager ), mJobsListView( new JobListView(this) ) { mJobsListModel = new JobListModel(manager, this); mSortedJobsListModel = new QSortFilterProxyModel(this); mSortedJobsListModel->setDynamicSortFilter(true); mSortedJobsListModel->setSourceModel(mJobsListModel); mJobsListView->setModel(mSortedJobsListModel); QVBoxLayout* topLayout = new QVBoxLayout( this ); topLayout->setMargin(0); topLayout->addWidget( mJobsListView ); } void ListStatusView::update( const Job &job ) { mJobsListModel->update( job ); } #include "listview.moc" icecc-monitor-2.9.90~git20140222/src/listview.h000066400000000000000000000030161230140027500206650ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2004 Andre Wöbbeking 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_LISTVIEW_H #define ICEMON_LISTVIEW_H #include "statusview.h" #include class JobListModel; class JobListView; class QSortFilterProxyModel; class ListStatusView :public QWidget, public StatusView { Q_OBJECT public: ListStatusView( HostInfoManager* manager, QWidget* parent ); virtual QWidget* widget() { return this; } virtual void update( const Job& job ); virtual QString id() const { return "list"; } private: JobListView* mJobsListView; JobListModel* mJobsListModel; QSortFilterProxyModel* mSortedJobsListModel; }; #endif // vim:ts=4:sw=4:noet icecc-monitor-2.9.90~git20140222/src/main.cc000066400000000000000000000051321230140027500201020ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2003,2004 Cornelius Schumacher Copyright (c) 2007 Dirk Mueller 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include "mainwindow.h" #include "version.h" #include void printHelp() { QString help; help += QApplication::translate("Usage", "Usage: %1 [options]").arg(Icemon::Version::appShortName); help += '\n'; help += '\n'; help += QApplication::translate("Description", Icemon::Version::description); help += '\n'; help += '\n'; help += QApplication::translate("Options", "Options:"); help += '\n'; help += QApplication::translate("Netname Options", "\t-n, netname \tIcecream network name"); help += '\n'; help += '\n'; fputs(qPrintable(help), stdout); } int main( int argc, char **argv ) { QByteArray netName; bool enableTestMode = false; for (int i = 1; i < argc; ++i ) { if (qstrcmp(argv[i], "-help") == 0 || qstrcmp(argv[i], "-h") == 0) { printHelp(); return 0; } if (qstrcmp(argv[i], "-netname") == 0 || qstrcmp(argv[i], "-n") == 0) { if (i+1 < argc) netName = argv[++i]; } if (qstrcmp(argv[i], "-testmode") == 0) { enableTestMode = true; } } QApplication app(argc, argv); QApplication::setOrganizationDomain("kde.org"); QApplication::setApplicationName(Icemon::Version::appShortName); QApplication::setApplicationVersion(Icemon::Version::version); MainWindow *mainWidget = new MainWindow; if (!netName.isEmpty()) { mainWidget->setCurrentNet(netName); } if (enableTestMode) { mainWidget->setTestModeEnabled(true); } mainWidget->show(); return app.exec(); } icecc-monitor-2.9.90~git20140222/src/mainwindow.cc000066400000000000000000000242661230140027500213430ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2003,2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "mainwindow.h" #include "starview.h" #include "summaryview.h" #include "detailedhostview.h" #include "ganttstatusview.h" #include "listview.h" //#include "poolview.h" #include "flowtableview.h" #include "hostinfo.h" #include "monitor.h" #include "version.h" #include "fakemonitor.h" #include "icecreammonitor.h" #include #include #include #include #include #include #include MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), m_view( 0 ) { QIcon appIcon = QIcon(); appIcon.addFile(":/images/hi128-app-icemon.png", QSize(128, 128)); appIcon.addFile(":/images/hi48-app-icemon.png", QSize(48, 48)); appIcon.addFile(":/images/hi32-app-icemon.png", QSize(32, 32)); appIcon.addFile(":/images/hi22-app-icemon.png", QSize(22, 22)); appIcon.addFile(":/images/hi16-app-icemon.png", QSize(16, 16)); setWindowIcon(appIcon); setWindowTitle(QApplication::translate("appName", Icemon::Version::appName)); m_hostInfoManager = new HostInfoManager; m_monitor = new IcecreamMonitor( m_hostInfoManager, this ); connect(m_monitor, SIGNAL( schedulerStateChanged( bool ) ), SLOT( setSchedulerState( bool ) )); QMenu* fileMenu = menuBar()->addMenu(tr("&File")); QMenu* viewMenu = menuBar()->addMenu(tr("&View")); QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); m_currNetWidget = new QLabel; statusBar()->addPermanentWidget(m_currNetWidget); m_schedStatusWidget = new QLabel; statusBar()->addPermanentWidget(m_schedStatusWidget); QAction* action = fileMenu->addAction(tr("&Quit"), this, SLOT(close()), tr("Ctrl+Q")); action->setIcon(QIcon::fromTheme("application-exit")); action->setMenuRole(QAction::QuitRole); m_viewMode = new QActionGroup(this); QMenu* modeMenu = viewMenu->addMenu(tr("Mode")); action = m_viewMode->addAction(tr( "&List View" )); action->setCheckable(true); modeMenu->addAction(action); connect( action, SIGNAL( triggered() ), this, SLOT( setupListView() ) ); action = m_viewMode->addAction(tr( "&Star View" )); action->setCheckable(true); modeMenu->addAction(action); connect( action, SIGNAL( triggered() ), this, SLOT( setupStarView() ) ); action = m_viewMode->addAction(tr( "&Pool View" )); action->setDisabled(true); // FIXME action->setCheckable(true); modeMenu->addAction(action); connect( action, SIGNAL( triggered() ), this, SLOT( setupPoolView() ) ); action = m_viewMode->addAction(tr( "&Gantt View" )); action->setCheckable(true); modeMenu->addAction(action); connect( action, SIGNAL( triggered() ), this, SLOT( setupGanttView() ) ); action = m_viewMode->addAction(tr( "Summary &View" )); action->setCheckable(true); modeMenu->addAction(action); connect( action, SIGNAL( triggered() ), this, SLOT( setupSummaryView() ) ); action = m_viewMode->addAction(tr( "&Flow View" )); action->setCheckable(true); modeMenu->addAction(action); connect( action, SIGNAL( triggered() ), this, SLOT( setupFlowTableView() ) ); action = m_viewMode->addAction(tr( "&Detailed Host View" )); action->setCheckable(true); modeMenu->addAction(action); connect( action, SIGNAL( triggered() ), this, SLOT( setupDetailedHostView() ) ); viewMenu->addSeparator(); action = viewMenu->addAction(tr("Pause")); action->setIcon(QIcon::fromTheme("media-playback-pause")); action->setCheckable(true); connect( action, SIGNAL( triggered() ), this, SLOT( pauseView() ) ); m_pauseViewAction = action; viewMenu->addSeparator(); action = viewMenu->addAction(tr("Check Nodes")); connect( action, SIGNAL( triggered() ), this, SLOT( checkNodes() ) ); viewMenu->addAction(action); m_checkNodesAction = action; viewMenu->addSeparator(); action = viewMenu->addAction(tr("Configure View...")); action->setIcon(QIcon::fromTheme("configure")); connect( action, SIGNAL( triggered() ), this, SLOT( configureView() ) ); m_configureViewAction = action; action = helpMenu->addAction(tr("About Qt...")); connect(action, SIGNAL(triggered()), this, SLOT(aboutQt())); action->setMenuRole(QAction::AboutQtRole); action = helpMenu->addAction(tr("About...")); action->setIcon(appIcon); connect(action, SIGNAL(triggered()), this, SLOT(about())); action->setMenuRole(QAction::AboutRole); readSettings(); setSchedulerState(m_monitor->schedulerState()); } void MainWindow::closeEvent( QCloseEvent *e ) { writeSettings(); delete m_hostInfoManager; e->accept(); } void MainWindow::readSettings() { QSettings settings; resize(600, 400); restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("windowState").toByteArray()); QString viewId = settings.value("currentView").toString(); m_viewMode->blockSignals(true); if ( viewId == "gantt" ) { setupGanttView(); (m_viewMode->actions()[GanttViewType])->setChecked(true); } else if ( viewId == "list" ) { setupListView(); (m_viewMode->actions()[ListViewType])->setChecked(true); } else if ( viewId == "star" ) { setupStarView(); (m_viewMode->actions()[StarViewType])->setChecked(true); } else if ( viewId == "pool" ) { setupPoolView(); (m_viewMode->actions()[PoolViewType])->setChecked(true); } else if ( viewId == "detailedhost" ) { setupDetailedHostView(); (m_viewMode->actions()[DetailedHostViewType])->setChecked(true); } else if ( viewId == "flow" ) { setupFlowTableView(); (m_viewMode->actions()[FlowTableViewType])->setChecked(true); } else { setupSummaryView(); (m_viewMode->actions()[SummaryViewType])->setChecked(true); } m_viewMode->blockSignals(false); } void MainWindow::writeSettings() { QSettings settings; settings.setValue("geometry", saveGeometry()); settings.setValue("windowState", saveState()); settings.setValue("currentView", m_view->id()); settings.sync(); } void MainWindow::setupView( StatusView *view, bool rememberJobs ) { if (m_view != view) { delete m_view; m_view = view; } m_configureViewAction->setEnabled( view->isConfigurable() ); m_pauseViewAction->setEnabled( view->isPausable() ); m_checkNodesAction->setEnabled( view->canCheckNodes() ); m_monitor->setCurrentView( m_view, rememberJobs ); setCentralWidget( m_view->widget() ); } void MainWindow::setupListView() { setupView( new ListStatusView( m_hostInfoManager, this ), true ); } void MainWindow::setupSummaryView() { setupView( new SummaryView( m_hostInfoManager, this ), false ); } void MainWindow::setupGanttView() { setupView( new GanttStatusView( m_hostInfoManager, this ), false ); } void MainWindow::setupPoolView() { // setupView( new PoolView( m_hostInfoManager, this ), false ); } void MainWindow::setupStarView() { setupView( new StarView( m_hostInfoManager, this ), false ); } void MainWindow::setupFlowTableView() { setupView( new FlowTableView( m_hostInfoManager, this ), false ); } void MainWindow::setupDetailedHostView() { setupView( new DetailedHostView( m_hostInfoManager, this ), false ); } void MainWindow::pauseView() { m_view->togglePause(); } void MainWindow::checkNodes() { m_view->checkNodes(); } void MainWindow::configureView() { m_view->configureView(); } void MainWindow::about() { QString about = tr("%1
" "Version: %2

" "%3

" "Maintainers:
" "Daniel Molkentin <molkentin@kde.org>
" "Kevin Funk <kevin@kfunk.org>

" "Based on Icemon for KDE written by:
" "Frerich Raabe <raabe@kde.org>
" "Stephan Kulow <coolo@kde.org>
" "Cornelius Schumacher <schumacher@kde.org>

" "Homepage: %4

" "Licensed under the GPLv2.
") .arg(Icemon::Version::appName) .arg(Icemon::Version::version) .arg(Icemon::Version::description) .arg(Icemon::Version::homePage); QMessageBox::about(this, tr("About %1").arg(Icemon::Version::appShortName), about); } void MainWindow::aboutQt() { QMessageBox::aboutQt(this); } void MainWindow::setSchedulerState(bool online) { m_schedStatusWidget->setText(online ? tr("Scheduler is online.") : tr("Scheduler is offline.") ); } void MainWindow::setCurrentNet( const QByteArray &netName ) { m_monitor->setCurrentNet( netName ); m_currNetWidget->setText(tr("Current Network: %1").arg(QString::fromLatin1(netName))); } // It's nasty that we have to hard-code the implementations of Monitor // But we can't just add a setMonitor() method because we require the host info manager void MainWindow::setTestModeEnabled(bool testMode) { if (testMode) { delete m_monitor; m_monitor = new FakeMonitor(m_hostInfoManager, this); } else { delete m_monitor; m_monitor = new IcecreamMonitor(m_hostInfoManager, this); } setupView(m_view, false); connect(m_monitor, SIGNAL( schedulerStateChanged( bool ) ), SLOT( setSchedulerState( bool ) )); setSchedulerState(m_monitor->schedulerState()); } #include "mainwindow.moc" icecc-monitor-2.9.90~git20140222/src/mainwindow.h000066400000000000000000000045411230140027500211770ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2003,2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_MAINWINDOW_H #define ICEMON_MAINWINDOW_H #include class HostInfoManager; class Monitor; class StatusView; class QActionGroup; class QLabel; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0 ); void setCurrentNet(const QByteArray &netname); void setTestModeEnabled(bool testMode); protected: void closeEvent(QCloseEvent *e); private slots: void setupListView(); void setupStarView(); void setupPoolView(); void setupSummaryView(); void setupGanttView(); void setupDetailedHostView(); void setupFlowTableView(); void pauseView(); void checkNodes(); void configureView(); void about(); void aboutQt(); void setSchedulerState(bool online); private: void readSettings(); void writeSettings(); void setupView( StatusView *view, bool rememberJobs ); HostInfoManager *m_hostInfoManager; QLabel *m_schedStatusWidget; QLabel *m_currNetWidget; Monitor *m_monitor; StatusView *m_view; enum views { ListViewType, StarViewType, PoolViewType, GanttViewType, SummaryViewType, FlowTableViewType, DetailedHostViewType }; QActionGroup* m_viewMode; QAction *m_configureViewAction; QAction *m_pauseViewAction; QAction *m_checkNodesAction; }; #endif // ICEMON_MAINWINDOW_H // vim:ts=4:sw=4:et icecc-monitor-2.9.90~git20140222/src/monitor.cc000066400000000000000000000002761230140027500206510ustar00rootroot00000000000000#include "monitor.h" #include "statusview.h" Monitor::Monitor(HostInfoManager *manager, QObject *parent) : QObject(parent) , m_hostInfoManager(manager) { } #include "monitor.moc" icecc-monitor-2.9.90~git20140222/src/monitor.h000066400000000000000000000015271230140027500205130ustar00rootroot00000000000000#ifndef ICEMON_MONITOR_H #define ICEMON_MONITOR_H #include class StatusView; class HostInfoManager; /** * Abstract base class for monitoring a icecream-like scheduler */ class Monitor : public QObject { Q_OBJECT Q_PROPERTY(bool schedulerState READ schedulerState WRITE setSchedulerState NOTIFY schedulerStateChanged) public: explicit Monitor(HostInfoManager *manager, QObject* parent = 0); virtual void setCurrentView(StatusView *view, bool rememberJobs) = 0; virtual void setCurrentNet(const QByteArray &) = 0; virtual void setSchedulerState(bool online) = 0; virtual bool schedulerState() const = 0; HostInfoManager *hostInfoManager() const { return m_hostInfoManager; } Q_SIGNALS: void schedulerStateChanged(bool); private: HostInfoManager *m_hostInfoManager; }; #endif // ICEMON_MONITOR_H icecc-monitor-2.9.90~git20140222/src/poolview.cc000066400000000000000000000511611230140027500210250ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "poolview.h" #include "hostinfo.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static const qreal FRICTION_FACTOR = 0.05; static const qreal MAX_VELOCITY = 10.; static const qreal MIN_VELOCITY_FOR_BOUNCE = 0.1; static bool suppressDomain = false; static bool showJobLines = false; static bool clientsAttractHosts = false; PoolItem::PoolItem( const QString &text, PoolView *poolView, HostInfoManager *m ) : QGraphicsItemGroup( 0, poolView->canvas() ), mHostInfo( 0 ), mHostInfoManager( m ), m_stateItem( 0 ), mX( 0 ), mY( 0 ), m_poolView( poolView ) { init(); m_textItem->setText(text); updateName(); } PoolItem::PoolItem( HostInfo *hostInfo, PoolView *poolView, HostInfoManager *m ) : QGraphicsItemGroup( 0, poolView->canvas() ), mHostInfo( hostInfo ), mHostInfoManager( m ), m_stateItem( 0 ), m_poolView( poolView ) { init(); } PoolItem::~PoolItem() { foreach( QGraphicsLineItem *line, m_jobLines ) { if ( scene() ) scene()->removeItem( line ); } } void PoolItem::init() { m_boxItem = new QGraphicsEllipseItem( this, scene() ); m_boxItem->setZValue( 80 ); m_boxItem->setPen( QPen( Qt::NoPen ) ); setSize( m_poolView->poolItemWidth(), m_poolView->poolItemHeight() ); m_textItem = new QGraphicsSimpleTextItem( 0, scene() ); m_textItem->setZValue( 100 ); addToGroup( m_boxItem ); addToGroup( m_textItem ); setHostColor( QColor( 200, 200, 200 ) ); mIsActiveClient = false; mIsCompiling = false; m_client = 0; mVelocity = 0; mVelocityAngle = qrand() / (double)RAND_MAX * 2 * M_PI; if ( mHostInfo->name() == QHostInfo::localHostName() ) { QFont f; f.setBold( true ); f.setUnderline( true ); m_textItem->setFont( f ); m_textItem->show(); mIsLocalHost = true; } else { mIsLocalHost = false; m_textItem->hide(); } } void PoolItem::setHostColor( const QColor &color ) { m_boxItem->setBrush( color ); } QString PoolItem::hostName() const { return mHostInfo->name(); } void PoolItem::updateName() { if (mHostInfo) { QString s = mHostInfo->name(); if ( suppressDomain ) { int l = s.indexOf('.'); if (l>0) s.truncate(l); } m_textItem->setText(s); m_textItem->setPos( m_poolView->poolItemWidth() / 2. - m_textItem->boundingRect().width() / 2., m_poolView->poolItemHeight() / 2. - m_textItem->boundingRect().height() / 2. ); } } double PoolItem::centerPosX() const { return pos().x() + m_poolView->poolItemWidth() / 2.; } double PoolItem::centerPosY() const { return pos().y() + m_poolView->poolItemHeight() / 2.; } void PoolItem::setCenterPos( double x, double y ) { // move all items (also the sub items) mX = x; mY = y; setPos( x - m_poolView->poolItemWidth() / 2., y - m_poolView->poolItemHeight() / 2.); } void PoolItem::setRandPos() { int count = 0; qreal w = scene()->width(); qreal h = scene()->height(); qreal x,y; do { x = qrand()/(double)RAND_MAX * w; y = qrand()/(double)RAND_MAX * h; setCenterPos( x, y ); } while( collidingItems().count() && ++count < 40 ); show(); } void PoolItem::update( const Job &job ) { setIsCompiling( job.state() == Job::Compiling ); setClient( job.client() ); if ( isCompiling() || isActiveClient() || job.state() == Job::WaitingForCS ) { m_textItem->show(); setHostColor( mHostInfoManager->hostColor( hostInfo()->id() ).darker(130) ); } else { if ( !mIsLocalHost ) m_textItem->hide(); setHostColor( QColor( 200, 200, 200 ) ); } if ( job.state() == Job::WaitingForCS ) { return; } bool finished = job.state() == Job::Finished || job.state() == Job::Failed; JobList::Iterator it = m_jobs.find( job.jobId() ); bool newJob = ( it == m_jobs.end() ); if ( newJob && finished ) { delete m_jobLines[ job.jobId() ]; m_jobLines.remove( job.jobId() ); return; } if ( !newJob && !finished ) return; if ( newJob ) { m_jobs.insert( job.jobId(), job ); m_jobLines[ job.jobId() ] = new QGraphicsLineItem( 0, scene() ); m_jobLines[ job.jobId() ]->setZValue( 5 ); if ( ! ::showJobLines ) m_jobLines[ job.jobId()]->hide(); } else if ( finished ) { m_jobs.remove( job.jobId() ); delete m_jobLines[ job.jobId() ]; m_jobLines.remove( job.jobId() ); } } void PoolItem::setSize( qreal w, qreal h ) { m_boxItem->setRect( 0, 0, w, h ); } void PoolItem::checkBorders() { if ( centerPosX() - m_poolView->poolItemWidth() / 2. < 0 ) { mVelocityAngle = M_PI - mVelocityAngle; setCenterPos( m_poolView->poolItemWidth() / 2., centerPosY() ); } if ( centerPosX() + m_poolView->poolItemWidth() / 2. > m_poolView->canvas()->width() ) { mVelocityAngle = M_PI - mVelocityAngle; setCenterPos( m_poolView->canvas()->width() - m_poolView->poolItemWidth() / 2., centerPosY() ); } if ( centerPosY() - m_poolView->poolItemHeight() / 2. < 0 ) { mVelocityAngle = - mVelocityAngle; setCenterPos( centerPosX(), m_poolView->poolItemHeight() / 2. ); } if ( centerPosY() + m_poolView->poolItemHeight() / 2. > m_poolView->canvas()->height() ) { mVelocityAngle = - mVelocityAngle; setCenterPos( centerPosX(), m_poolView->canvas()->height() - m_poolView->poolItemHeight() / 2. ); } } void PoolItem::checkCollision() { // return; // Taking in account that our shapes are circles, we can do much faster than // qt collision detection QList cItems; foreach( PoolItem *item, m_poolView->m_poolItems ) { qreal length = QLineF( QPointF( centerPosX(), centerPosY() ), QPointF( item->centerPosX(), item->centerPosY() ) ).length(); if ( length < 2 * radius() && item != this ) cItems << item; } // Compute bouncing foreach( PoolItem *item, cItems ) { // Bounce direction QLineF lineBetween(QPointF(mX, mY), QPointF(item->mX, item->mY)); qreal angle = ::acos( lineBetween.dx() / lineBetween.length() ); if ( lineBetween.dy() < 0 ) angle = 2*M_PI - angle; // Position correction qreal centerX = ( mX + item->mX ) / 2.; qreal centerY = ( mY + item->mY ) / 2.; mX = centerX - radius() * 1.01 * cos( angle ); mY = centerY - radius() * 1.01 * sin( angle ); setCenterPos( mX, mY ); item->mX = centerX + item->radius()*1.01 * cos( angle ); item->mY = centerY + item->radius()*1.01 * sin( angle ); item->setCenterPos( item->mX, item->mY ); if ( mVelocity > MIN_VELOCITY_FOR_BOUNCE ) { qreal vNormalThis = mVelocity * cos( mVelocityAngle - angle ); qreal vTangentialThis = mVelocity * sin( mVelocityAngle - angle ); qreal vNormalOther = item->mVelocity * cos( item->mVelocityAngle - angle ); qreal vTangentialOther = item->mVelocity * sin( item->mVelocityAngle - angle ); /* "Energy transfer" */ qreal vNormal = sqrt( pow(vNormalThis, 2) + pow(vNormalOther, 2) ) / 2.; int sign = vNormalThis >= 0 ? 1 : -1; vNormalThis = - sign * vNormal; sign = vNormalOther >= 0 ? 1 : -1; vNormalOther = - sign * vNormal; // Reflection angles QLineF vLine( QPointF(0, 0), QPointF( vNormalThis, vTangentialThis) ); mVelocityAngle = ::acos( vLine.dx() / vLine.length() ); if ( vLine.dy() < 0 ) mVelocityAngle = 2 * M_PI - mVelocityAngle; mVelocityAngle += angle; // vLine = QLineF( QPointF(0, 0), QPointF( vNormalOther, vTangentialOther) ); item->mVelocityAngle = ::acos( vLine.dx() / vLine.length() ); if ( vLine.dy() < 0 ) item->mVelocityAngle = 2 * M_PI - item->mVelocityAngle; item->mVelocityAngle += angle; // Final velocities are: mVelocity = sqrt( pow(vNormalThis, 2) + pow(vTangentialThis, 2) ); item->mVelocity = sqrt( pow(vNormalOther, 2) + pow(vTangentialOther, 2) ); } } } void PoolItem::computeNewPosition() { int count = m_jobs.count(); // Goes toward barycenter of all its hosts qreal xBar = 0; qreal yBar = 0; qreal vX, vY; vX = 0; vY = 0; mVelocity = mVelocity * (1 - FRICTION_FACTOR); // Velocity values if there is no interactions/gravity for this item vX = mVelocity * cos( mVelocityAngle ); vY = mVelocity * sin( mVelocityAngle ); mVelocity = qMin( qreal( sqrt( pow(vX, 2) + pow(vY, 2) ) ), MAX_VELOCITY ); if ( count ) { QList poolItems; // autosort // Servers attract clients foreach( Job j, m_jobs ) { PoolItem* poolItem = m_poolView->findPoolItem( j.server() ); if ( poolItem && poolItem != this ) poolItems << poolItem; if ( ::clientsAttractHosts ) { PoolItem* poolItem2 = m_poolView->findPoolItem( j.client() ); if ( poolItem2 && poolItem2 != this ) poolItems << poolItem2; } } if ( poolItems.count() ) { foreach( PoolItem* poolItem, poolItems ) { xBar += poolItem->centerPosX(); yBar += poolItem->centerPosY(); setHostColor( poolItem->hostInfo()->color() ); } xBar = xBar / (qreal)poolItems.count(); yBar = yBar / (qreal)poolItems.count(); vX += ( xBar - centerPosX() ) / scene()->width() * 50 ; vY += ( yBar - centerPosY() ) / scene()->height() * 50 ; QLineF l = QLineF( QPointF(0, 0), QPointF(vX, vY) ); mVelocityAngle = ::acos( l.dx() / l.length() ); if ( l.dy() < 0 ) mVelocityAngle = 2 * M_PI - mVelocityAngle; mVelocity = qMin( qreal( sqrt( pow(vX, 2) + pow(vY, 2) ) ), MAX_VELOCITY); } } setCenterPos( centerPosX() + vX, centerPosY() + vY ); } void PoolItem::drawJobLines() { // Draw job lines foreach( Job j, m_jobs ) { PoolItem* poolItem = m_poolView->findPoolItem( j.server() ); if ( !poolItem || poolItem == this ) continue; if ( ::showJobLines ) { m_jobLines[ j.jobId() ]->show(); m_jobLines[ j.jobId() ]->setLine( centerPosX(), centerPosY(), poolItem->centerPosX(), poolItem->centerPosY() ); m_jobLines[ j.jobId() ]->setPen( poolItem->hostInfo()->color() ); } else { m_jobLines[ j.jobId() ]->hide(); } } } PoolViewConfigDialog::PoolViewConfigDialog( QWidget *parent ) : QDialog( parent ) { QBoxLayout *topLayout = new QVBoxLayout( this ); mArchFilterEdit = new QLineEdit( this ); topLayout->addWidget( mArchFilterEdit ); connect( mArchFilterEdit, SIGNAL( textChanged( const QString & ) ), SIGNAL( configChanged() ) ); mSuppressDomainName = new QCheckBox( tr("Suppress domain name"), this); topLayout->addWidget( mSuppressDomainName ); connect( mSuppressDomainName, SIGNAL( toggled ( bool ) ), SLOT( slotSuppressDomainName ( bool ) ) ); mShowJobLines = new QCheckBox( tr("Show job lines"), this ); topLayout->addWidget( mShowJobLines ); connect( mShowJobLines, SIGNAL( toggled( bool ) ), SLOT( slotShowJobLines( bool )) ); mClientsAttractHosts = new QCheckBox( tr("Clients attract hosts"), this); topLayout->addWidget( mClientsAttractHosts ); connect( mClientsAttractHosts, SIGNAL( toggled( bool ) ), SLOT( slotClientsAttractHosts( bool )) ); QFrame *hline = new QFrame( this ); hline->setFrameShape( QFrame::HLine ); topLayout->addWidget( hline ); QBoxLayout *buttonLayout = new QHBoxLayout(); topLayout->addLayout( buttonLayout ); buttonLayout->addStretch( 1 ); QPushButton *button = new QPushButton( tr("&Close"), this ); buttonLayout->addWidget( button ); connect( button, SIGNAL( clicked() ), SLOT( hide() ) ); } QString PoolViewConfigDialog::archFilter() { return mArchFilterEdit->text(); } void PoolViewConfigDialog::slotSuppressDomainName( bool b ) { ::suppressDomain = b; configChanged(); } void PoolViewConfigDialog::slotShowJobLines( bool b ) { ::showJobLines = b; configChanged(); } void PoolViewConfigDialog::slotClientsAttractHosts( bool b ) { ::clientsAttractHosts = b; configChanged(); } PoolView::PoolView( HostInfoManager *m, QWidget *parent ) : QWidget( parent ), StatusView( m ), m_poolItemWidth ( 30 ), m_poolItemHeight ( 30 ) { mConfigDialog = new PoolViewConfigDialog( this ); connect( mConfigDialog, SIGNAL( configChanged() ), SLOT( slotConfigChanged() ) ); m_canvas = new QGraphicsScene ( this ); m_canvas->setSceneRect( 0, 0, 1000, 1000 ); QHBoxLayout *layout = new QHBoxLayout( this ); layout->setMargin( 0 ); m_canvasView = new QGraphicsView( m_canvas, this ); m_canvasView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_canvasView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_canvasView->setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform ); m_canvasView->setViewportUpdateMode( QGraphicsView::FullViewportUpdate ); layout->addWidget( m_canvasView ); createKnownHosts(); QTimer::singleShot( 0, this, SLOT( arrangePoolItems() ) ); } void PoolView::update( const Job &job ) { unsigned int hostid = processor( job ); if ( !hostid ) { #if 0 qDebug() << "Empty host" << endl; #endif return; } PoolItem *poolItem = findPoolItem( hostid ); if ( !poolItem ) return; poolItem->update( job ); bool finished = job.state() == Job::Finished || job.state() == Job::Failed; QMap::Iterator it; it = mJobMap.find( job.jobId() ); if ( it != mJobMap.end() ) { (*it)->update( job ); if ( finished ) { mJobMap.erase( it ); unsigned int clientid = job.client(); PoolItem *clientItem = findPoolItem( clientid ); if ( clientItem ) clientItem->setIsActiveClient( false ); } return; } if ( !finished ) mJobMap.insert( job.jobId(), poolItem ); if ( job.state() == Job::Compiling ) { unsigned int clientid = job.client(); PoolItem *clientItem = findPoolItem( clientid ); if ( clientItem ) { clientItem->setClient( clientid ); clientItem->setIsActiveClient( true ); } } } PoolItem *PoolView::findPoolItem( unsigned int hostid ) { PoolItem *poolItem = 0; QMap::iterator it = m_poolItems.find( hostid ); if ( it != m_poolItems.end() ) poolItem = it.value(); return poolItem; } void PoolView::checkNode( unsigned int hostid ) { if ( !hostid ) return; if ( !filterArch( hostid ) ) return; PoolItem *poolItem = findPoolItem( hostid ); if ( !poolItem ) { poolItem = createPoolItem( hostid ); } } void PoolView::removeNode( unsigned int hostid ) { PoolItem *poolItem = findPoolItem( hostid ); if ( poolItem && poolItem->hostInfo()->isOffline() ) { removeItem( poolItem ); } } void PoolView::forceRemoveNode( unsigned int hostid ) { PoolItem *poolItem = findPoolItem( hostid ); if ( poolItem ) { removeItem( poolItem ); } } void PoolView::removeItem( PoolItem *poolItem ) { m_poolItems.remove( poolItem->hostInfo()->id() ); QList obsoleteJobs; QMap::Iterator it; for( it = mJobMap.begin(); it != mJobMap.end(); ++it ) { #if 0 qDebug() << " JOB: " << it.key() << " (" << int( it.value() ) << ")" << endl; #endif if ( it.value() == poolItem ) { #if 0 qDebug() << " Delete Job " << it.key() << endl; #endif obsoleteJobs.append( it.key() ); } } QList::ConstIterator it2; for( it2 = obsoleteJobs.constBegin(); it2 != obsoleteJobs.constEnd(); ++it2 ) { mJobMap.remove( *it2 ); } delete poolItem; } QWidget *PoolView::widget() { return this; } void PoolView::resizeEvent( QResizeEvent * ) { m_canvasView->fitInView( m_canvas->sceneRect(), Qt::KeepAspectRatio ); } bool PoolView::event ( QEvent* e ) { if (e->type() != QEvent::ToolTip) return QWidget::event(e); QPoint p ( static_cast(e)->pos()); PoolItem *item = 0; if ( QGraphicsItem* graphicsItem = m_canvasView->itemAt( p ) ) item = dynamic_cast( graphicsItem->parentItem() ); if ( item ) { HostInfo *hostInfo = item->hostInfo(); if ( !hostInfo ) return QWidget::event(e); QPoint gp( static_cast(e)->globalPos()); QToolTip::showText(gp+QPoint(10,10), "

" "
" + item->hostName() + "
" + "" + "" + "" "" + "" + "" + "" + "
" + tr("IP:") + "" + hostInfo->ip() + "
" + tr("Platform:") + "" + hostInfo->platform() + "
" + tr("Flavor:") + "" + HostInfo::colorName( hostInfo->color() ) + "
" + tr("Id:") + "" + QString::number( hostInfo->id() ) + "
" + tr("Speed:") + "" + QString::number( hostInfo->serverSpeed() ) + "
" + tr("Load:") + "" + QString::number( hostInfo->serverLoad() ) + "
" "

", this ); } return QWidget::event(e); } void PoolView::slotConfigChanged() { HostInfoManager::HostMap hostMap = hostInfoManager()->hostMap(); HostInfoManager::HostMap::ConstIterator it; for( it = hostMap.constBegin(); it != hostMap.constEnd(); ++it ) { if ( filterArch( *it ) ) checkNode( it.key() ); else forceRemoveNode( it.key() ); } foreach( PoolItem* item, m_poolItems ) item->drawJobLines(); } // Main loop void PoolView::arrangePoolItems() { foreach( PoolItem *it, m_poolItems ) { it->computeNewPosition(); it->updateName(); it->checkBorders(); // make it bounce on the scene boundaries it->checkCollision(); // make it bounce on other items } foreach( PoolItem *it, m_poolItems ) { it->drawJobLines(); } QTimer::singleShot( 0, this, SLOT( arrangePoolItems() ) ); } PoolItem *PoolView::createPoolItem( unsigned int hostid ) { HostInfo *i = hostInfoManager()->find( hostid ); if ( !i || i->isOffline() || i->name().isEmpty() ) return 0; PoolItem *poolItem = new PoolItem( i, this, hostInfoManager() ); m_poolItems.insert( hostid, poolItem ); poolItem->setRandPos(); return poolItem; } void PoolView::createKnownHosts() { HostInfoManager::HostMap hosts = hostInfoManager()->hostMap(); HostInfoManager::HostMap::ConstIterator it; for( it = hosts.constBegin(); it != hosts.constEnd(); ++it ) { unsigned int id = (*it)->id(); if ( !findPoolItem( id ) ) createPoolItem( id ); } } void PoolView::configureView() { mConfigDialog->show(); mConfigDialog->raise(); } bool PoolView::filterArch( unsigned int hostid ) { HostInfo *i = hostInfoManager()->find( hostid ); if ( !i ) { qWarning() << "No HostInfo for id " << hostid << endl; return false; } return filterArch( i ); } bool PoolView::filterArch( HostInfo *i ) { if ( mConfigDialog->archFilter().isEmpty() ) return true; QRegExp regExp( mConfigDialog->archFilter() ); if ( regExp.indexIn( i->platform() ) >= 0 ) { return true; } return false; } QGraphicsScene *PoolView::canvas() { return m_canvas; } bool PoolView::suppressDomain() { return ::suppressDomain; } bool PoolView::showJobLines() { return ::showJobLines; } #include "poolview.moc" icecc-monitor-2.9.90~git20140222/src/poolview.h000066400000000000000000000125621230140027500206710ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_POOLVIEW_H #define ICEMON_POOLVIEW_H #include "job.h" #include "statusview.h" #include #include #include #include class HostInfo; class PoolItem; class PoolView; class QSlider; class QLabel; class QLineEdit; class QCheckBox; class QGraphicsView; class QGraphicsLineItem; class PoolItem : public QGraphicsItemGroup { public: enum { RttiPoolItem = 1000 }; PoolItem( const QString &text, PoolView *poolView, HostInfoManager * ); PoolItem( HostInfo *hostInfo, PoolView *poolView, HostInfoManager * ); ~PoolItem(); void init(); HostInfo *hostInfo() const { return mHostInfo; } void setHostColor( const QColor &color ); void setIsActiveClient( bool active ) { mIsActiveClient = active; } bool isActiveClient() const { return mIsActiveClient; } void setIsCompiling( bool compiling ) { mIsCompiling = compiling; } bool isCompiling() const { return mIsCompiling; } void setStateItem( QGraphicsItem *item ) { m_stateItem = item; } QGraphicsItem *stateItem() { return m_stateItem; } void setClient( unsigned int client ) { m_client = client; } unsigned int client() const { return m_client; } QString hostName() const; void updateName(); double centerPosX() const; double centerPosY() const; double relativeCenterPosX() const { return m_textItem->boundingRect().width()/2; } double relativeCenterPosY() const { return m_textItem->boundingRect().height()/2; } void computeNewPosition(); void checkBorders(); void checkCollision(); void drawJobLines(); // Choose a random position for the item void setRandPos(); void setCenterPos( double x, double y ); void setSize( qreal w, qreal h ); void update( const Job &job ); qreal velocity() const { return mVelocity; } qreal radius() const { return m_boxItem->rect().height() / 2.; } private: HostInfo *mHostInfo; HostInfoManager *mHostInfoManager; JobList m_jobs; bool mIsActiveClient; bool mIsCompiling; QGraphicsItem *m_stateItem; QGraphicsSimpleTextItem* m_textItem; unsigned int m_client; // Position and velocity qreal mX; qreal mY; qreal mVelocityAngle; qreal mVelocity; QGraphicsEllipseItem *m_boxItem; QMap m_jobHalos; QMap m_jobLines; PoolView *m_poolView; bool mIsLocalHost; }; class PoolViewConfigDialog : public QDialog { Q_OBJECT public: PoolViewConfigDialog( QWidget *parent ); bool suppressDomainName() const; bool showJobLines() const; QString archFilter(); protected slots: void slotSuppressDomainName( bool ); void slotShowJobLines( bool ); void slotClientsAttractHosts( bool b ); signals: void configChanged(); private: QLineEdit *mArchFilterEdit; QCheckBox *mSuppressDomainName; QCheckBox *mShowJobLines; QCheckBox *mClientsAttractHosts; }; class PoolView : public QWidget, public StatusView { Q_OBJECT public: PoolView( HostInfoManager *, QWidget *parent ); void update( const Job &job ); QWidget *widget(); QString id() const { return "pool"; } PoolItem *findPoolItem( unsigned int hostid ); void checkNode( unsigned int hostid ); void removeNode( unsigned int hostid ); void configureView(); QGraphicsScene* canvas(); bool suppressDomain(); bool showJobLines(); int poolItemWidth() { return m_poolItemWidth; } int poolItemHeight() { return m_poolItemHeight; } QMap m_poolItems; protected: virtual void resizeEvent( QResizeEvent *e ); virtual bool event(QEvent *event); /** Return true if node should be shown and false if not. */ bool filterArch( unsigned int hostid ); /** Return true if node should be shown and false if not. */ bool filterArch( HostInfo * ); void removeItem( PoolItem * ); void forceRemoveNode( unsigned int hostid ); protected slots: void slotConfigChanged(); private slots: void arrangePoolItems(); private: void createKnownHosts(); PoolItem *createPoolItem( unsigned int hostid ); void drawNodeStatus(); // void drawState( PoolItem *node ); PoolViewConfigDialog *mConfigDialog; QGraphicsScene *m_canvas; QGraphicsView *m_canvasView; QMap mJobMap; const int m_poolItemWidth; const int m_poolItemHeight; qreal m_scaleFactor; }; #endif // vim:ts=4:sw=4:noet icecc-monitor-2.9.90~git20140222/src/starview.cc000066400000000000000000000437411230140027500210320ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "starview.h" #include "hostinfo.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include static bool suppressDomain = false; StarViewConfigDialog::StarViewConfigDialog( QWidget *parent ) : QDialog( parent ) { setWindowTitle(tr("Star View Settings")); QBoxLayout *topLayout = new QVBoxLayout( this ); QLabel *label = new QLabel( tr("Number of nodes per ring:") ); topLayout->addWidget( label ); QBoxLayout *nodesLayout = new QHBoxLayout(); topLayout->addLayout( nodesLayout ); int nodesPerRing = 25; mNodesPerRingSlider = new QSlider( Qt::Horizontal ); mNodesPerRingSlider->setMinimum( 1 ); mNodesPerRingSlider->setMaximum( 50 ); mNodesPerRingSlider->setSingleStep( 1 ); mNodesPerRingSlider->setValue( nodesPerRing ); nodesLayout->addWidget( mNodesPerRingSlider ); connect( mNodesPerRingSlider, SIGNAL( valueChanged( int ) ), SIGNAL( configChanged() ) ); connect( mNodesPerRingSlider, SIGNAL( valueChanged( int ) ), SLOT( slotNodesPerRingChanged( int ) ) ); mNodesPerRingLabel = new QLabel( QString::number( nodesPerRing ) ); nodesLayout->addWidget( mNodesPerRingLabel ); label = new QLabel( tr("Architecture filter:") ); topLayout->addWidget( label ); mArchFilterEdit = new QLineEdit; topLayout->addWidget( mArchFilterEdit ); connect( mArchFilterEdit, SIGNAL( textChanged( const QString & ) ), SIGNAL( configChanged() ) ); mSuppressDomainName = new QCheckBox( tr("Suppress domain name") ); topLayout->addWidget( mSuppressDomainName ); QFrame *hline = new QFrame; hline->setFrameShape( QFrame::HLine ); hline->setFrameShadow( QFrame::Sunken ); topLayout->addWidget( hline ); QPushButton *closeButton = new QPushButton(tr("&Close")); closeButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); topLayout->addWidget( closeButton, 0, Qt::AlignRight ); connect( mSuppressDomainName, SIGNAL( toggled ( bool ) ), SLOT( slotSuppressDomainName ( bool ) ) ); connect( closeButton, SIGNAL( clicked() ), SLOT( accept() ) ); } void StarViewConfigDialog::slotNodesPerRingChanged( int nodes ) { mNodesPerRingLabel->setText( QString::number( nodes ) ); } void StarViewConfigDialog::setMaxNodes( int maxNodes ) { mNodesPerRingSlider->setMaximum( maxNodes + 1 ); } int StarViewConfigDialog::nodesPerRing() { return mNodesPerRingSlider->value(); } QString StarViewConfigDialog::archFilter() { return mArchFilterEdit->text(); } void StarViewConfigDialog::slotSuppressDomainName( bool b ) { suppressDomain = b; configChanged(); } HostItem::HostItem( const QString &text, HostInfoManager *m ) : QGraphicsItemGroup( 0 ), mHostInfo( 0 ), mHostInfoManager( m ), m_stateItem( 0 ) { init(); m_textItem->setText(text); updateName(); } HostItem::HostItem( HostInfo *hostInfo, HostInfoManager *m ) : QGraphicsItemGroup( 0 ), mHostInfo( hostInfo ), mHostInfoManager( m ), m_stateItem( 0 ) { init(); } HostItem::~HostItem() { } void HostItem::init() { mBaseWidth = 0; mBaseHeight = 0; m_boxItem = new QGraphicsEllipseItem( this ); m_boxItem->setZValue( 80 ); m_boxItem->setPen( QPen( Qt::NoPen ) ); m_textItem = new QGraphicsSimpleTextItem( this ); m_textItem->setZValue( 100 ); setHostColor( QColor( 200, 200, 200 ) ); mIsActiveClient = false; mIsCompiling = false; m_client = 0; } void HostItem::setHostColor( const QColor &color ) { m_boxItem->setBrush( color ); m_textItem->setBrush( StatusView::textColor( color ) ); } QString HostItem::hostName() const { return mHostInfo->name(); } void HostItem::updateName() { if (mHostInfo) { QString s = mHostInfo->name(); if (suppressDomain) { int l = s.indexOf('.'); if (l>0) s.truncate(l); } m_textItem->setText(s); } QRectF r = m_textItem->boundingRect(); mBaseWidth = r.width() + 10 ; mBaseHeight = r.height() + 10 ; m_boxItem->setRect(-5, -5, mBaseWidth, mBaseHeight); updateHalos(); } void HostItem::setCenterPos( double x, double y ) { // move all items (also the sub items) setPos( x - m_textItem->boundingRect().width()/2, y - m_textItem->boundingRect().height()/2 ); // setPos( x, y ); } void HostItem::update( const Job &job ) { setIsCompiling( job.state() == Job::Compiling ); setClient( job.client() ); if ( job.state() == Job::WaitingForCS ) return; bool finished = job.state() == Job::Finished || job.state() == Job::Failed; JobList::Iterator it = m_jobs.find( job.jobId() ); bool newJob = ( it == m_jobs.end() ); if ( newJob && finished ) return; if ( !newJob && !finished ) return; if ( newJob ) { m_jobs.insert( job.jobId(), job ); createJobHalo( job ); } else if ( finished ) { deleteJobHalo( job ); m_jobs.erase( it ); } } void HostItem::createJobHalo( const Job &job ) { QGraphicsEllipseItem *halo = new QGraphicsEllipseItem( centerPosX(), centerPosY(), mBaseWidth, mBaseHeight, this ); halo->setZValue( 70 - m_jobHalos.size() ); halo->setPen(QPen(Qt::NoPen)); halo->show(); m_jobHalos.insert( job, halo ); updateHalos(); } void HostItem::deleteJobHalo( const Job &job ) { QMap::Iterator it = m_jobHalos.find( job ); if ( it == m_jobHalos.end() ) return; QGraphicsEllipseItem *halo = *it; delete halo; m_jobHalos.erase( it ); updateHalos(); } void HostItem::updateHalos() { int count = 1; QMap::Iterator it; for( it = m_jobHalos.begin(); it != m_jobHalos.end(); ++it ) { QGraphicsEllipseItem *halo = it.value(); halo->setRect( halo->x() - 5 - count * 3, halo->y() - 5 - count * 3, mBaseWidth + count * 6, mBaseHeight + count * 6 ); halo->setBrush( mHostInfoManager->hostColor( it.key().client() ) ); halo->setPen( Qt::NoPen ); ++count; } } StarView::StarView( HostInfoManager *m, QWidget *parent ) : QWidget( parent ), StatusView( m ) { mConfigDialog = new StarViewConfigDialog( this ); connect( mConfigDialog, SIGNAL( configChanged() ), SLOT( slotConfigChanged() ) ); m_canvas = new QGraphicsScene ( this ); m_canvas->setSceneRect( 0, 0, width(), height() ); QHBoxLayout *layout = new QHBoxLayout( this ); layout->setMargin( 0 ); m_canvasView = new QGraphicsView( m_canvas, this ); m_canvasView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_canvasView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_canvasView->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); layout->addWidget( m_canvasView ); m_schedulerItem = new HostItem( "", hostInfoManager() ); m_canvas->addItem(m_schedulerItem); m_schedulerItem->setZValue(150); centerSchedulerItem(); m_schedulerItem->show(); createKnownHosts(); } void StarView::update( const Job &job ) { #if 0 qDebug() << "StarView::update() " << job.jobId() << " server: " << job.server() << " client: " << job.client() << " state: " << job.stateAsString() << endl; #endif if (job.state() == Job::WaitingForCS) { drawNodeStatus(); return; } unsigned int hostid = processor( job ); if ( !hostid ) { #if 0 qDebug() << "Empty host" << endl; #endif return; } HostItem *hostItem = findHostItem( hostid ); if ( !hostItem ) return; hostItem->update( job ); bool finished = job.state() == Job::Finished || job.state() == Job::Failed; QMap::Iterator it; it = mJobMap.find( job.jobId() ); if ( it != mJobMap.end() ) { (*it)->update( job ); if ( finished ) { mJobMap.erase( it ); unsigned int clientid = job.client(); HostItem *clientItem = findHostItem( clientid ); if ( clientItem ) clientItem->setIsActiveClient( false ); } drawNodeStatus(); return; } if ( !finished ) mJobMap.insert( job.jobId(), hostItem ); if ( job.state() == Job::Compiling ) { unsigned int clientid = job.client(); HostItem *clientItem = findHostItem( clientid ); if ( clientItem ) { clientItem->setClient( clientid ); clientItem->setIsActiveClient( true ); } } drawNodeStatus(); } HostItem *StarView::findHostItem( unsigned int hostid ) { HostItem *hostItem = 0; QMap::iterator it = m_hostItems.find( hostid ); if ( it != m_hostItems.end() ) hostItem = it.value(); return hostItem; } void StarView::checkNode( unsigned int hostid ) { // qDebug() << "StarView::checkNode() " << hostid << endl; if ( !hostid ) return; if ( !filterArch( hostid ) ) return; HostItem *hostItem = findHostItem( hostid ); if ( !hostItem ) { hostItem = createHostItem( hostid ); arrangeHostItems(); } } void StarView::removeNode( unsigned int hostid ) { // qDebug() << "StarView::removeNode() " << hostid << endl; HostItem *hostItem = findHostItem( hostid ); if ( hostItem && hostItem->hostInfo()->isOffline() ) { removeItem( hostItem ); } } void StarView::forceRemoveNode( unsigned int hostid ) { HostItem *hostItem = findHostItem( hostid ); if ( hostItem ) { removeItem( hostItem ); } } void StarView::removeItem( HostItem *hostItem ) { #if 0 qDebug() << "StarView::removeItem() " << hostid << " (" << int( hostItem ) << ")" << endl; #endif m_hostItems.remove( hostItem->hostInfo()->id() ); QList obsoleteJobs; QMap::Iterator it; for( it = mJobMap.begin(); it != mJobMap.end(); ++it ) { #if 0 qDebug() << " JOB: " << it.key() << " (" << int( it.value() ) << ")" << endl; #endif if ( it.value() == hostItem ) { #if 0 qDebug() << " Delete Job " << it.key() << endl; #endif obsoleteJobs.append( it.key() ); } } QList::ConstIterator it2; for( it2 = obsoleteJobs.constBegin(); it2 != obsoleteJobs.constEnd(); ++it2 ) { mJobMap.remove( *it2 ); } delete hostItem->stateItem(); delete hostItem; arrangeHostItems(); } void StarView::updateSchedulerState( bool online ) { QString txt; if ( online ) { txt = tr("Scheduler"); } else { txt = ""; } delete m_schedulerItem; if ( !online ) { QMap::ConstIterator it; for( it = m_hostItems.constBegin(); it != m_hostItems.constEnd(); ++it ) { delete *it; } m_hostItems.clear(); mJobMap.clear(); } m_schedulerItem = new HostItem( txt, hostInfoManager() ); m_canvas->addItem(m_schedulerItem); m_schedulerItem->setZValue(100); m_schedulerItem->show(); centerSchedulerItem(); } QWidget *StarView::widget() { return this; } void StarView::resizeEvent( QResizeEvent * ) { m_canvas->setSceneRect( 0, 0, width(), height() ); centerSchedulerItem(); arrangeHostItems(); drawNodeStatus(); } bool StarView::event ( QEvent* e ) { if (e->type() != QEvent::ToolTip) return QWidget::event(e); QPoint p ( static_cast(e)->pos()); HostItem *item = 0; QGraphicsItem* graphicsItem = m_canvasView->itemAt( p ); if ( graphicsItem ) item = dynamic_cast( graphicsItem->parentItem() ); if ( item ) { HostInfo *hostInfo = item->hostInfo(); const QPoint gp( static_cast(e)->globalPos()); const QRect itemRect = m_canvasView->mapFromScene(graphicsItem->sceneBoundingRect()).boundingRect(); if ( hostInfo ) { QToolTip::showText(gp+QPoint(10,10), hostInfo->toolTip(), this, itemRect ); } else { QToolTip::showText(gp+QPoint(10,10), "

" "
" + tr("Scheduler") + "
" "" + "" + "" + "
" + tr("Host: %1").arg(hostInfoManager()->schedulerName()) + "
" + tr("Network name: %1").arg(hostInfoManager()->networkName()) + "
" "

", this, itemRect ); } } else { QToolTip::hideText(); } return QWidget::event(e); } void StarView::centerSchedulerItem() { m_schedulerItem->setCenterPos( width() / 2, height() / 2 ); } void StarView::slotConfigChanged() { // qDebug() << "StarView::slotConfigChanged()" << endl; HostInfoManager::HostMap hostMap = hostInfoManager()->hostMap(); HostInfoManager::HostMap::ConstIterator it; for( it = hostMap.constBegin(); it != hostMap.constEnd(); ++it ) { if ( filterArch( *it ) ) checkNode( it.key() ); else forceRemoveNode( it.key() ); } arrangeHostItems(); } void StarView::arrangeHostItems() { // qDebug() << "StarView::arrangeHostItems()" << endl; int count = m_hostItems.count(); // qDebug() << " Count: " << count << endl; int nodesPerRing = mConfigDialog->nodesPerRing(); int ringCount = int( count / nodesPerRing ) + 1; // qDebug() << " Rings: " << ringCount << endl; double radiusFactor = 2.5; if (suppressDomain) radiusFactor = 4; const int xRadius = qRound( m_canvas->width() / radiusFactor ); const int yRadius = qRound( m_canvas->height() / radiusFactor ); const double step = 2 * M_PI / count; double angle = 0.0; int i = 0; QMap::ConstIterator it; for ( it = m_hostItems.constBegin(); it != m_hostItems.constEnd(); ++it ) { double factor = 1 - ( 1.0 / ( ringCount + 1 ) ) * ( i % ringCount ); double xr = xRadius * factor; double yr = yRadius * factor; HostItem *item = it.value(); item->updateName(); item->setCenterPos( width() / 2 + cos( angle ) * xr, height() / 2 + sin( angle ) * yr ); angle += step; ++i; } } HostItem *StarView::createHostItem( unsigned int hostid ) { HostInfo *i = hostInfoManager()->find( hostid ); if ( !i || i->isOffline() || i->name().isEmpty() ) return 0; // qDebug() << "New node for " << hostid << " (" << i->name() << ")" << endl; //assert( !i->name().isEmpty() ); HostItem *hostItem = new HostItem( i, hostInfoManager() ); m_canvas->addItem(hostItem); hostItem->setHostColor( hostColor( hostid ) ); m_hostItems.insert( hostid, hostItem ); hostItem->show(); arrangeHostItems(); if ( m_hostItems.count() > 25 ) { mConfigDialog->setMaxNodes( m_hostItems.count() ); } return hostItem; } void StarView::drawNodeStatus() { QMap::ConstIterator it; for ( it = m_hostItems.constBegin(); it != m_hostItems.constEnd(); ++it ) { drawState( *it ); } } void StarView::drawState( HostItem *node ) { delete node->stateItem(); QGraphicsLineItem *newItem = 0; unsigned int client = node->client(); QColor color = client ? hostColor( client ) : Qt::green; if ( node->isCompiling() || node->isActiveClient() ) { newItem = new QGraphicsLineItem( qRound( node->centerPosX() ), qRound( node->centerPosY() ), qRound( m_schedulerItem->centerPosX() ), qRound( m_schedulerItem->centerPosY() ) ); if ( node->isCompiling() ) { newItem->setPen( QPen( color, 0 ) ); newItem->setZValue( -301 ); } else if ( node->isActiveClient() ) { newItem->setPen( QPen( color, 1, Qt::DashLine ) ); newItem->setZValue( -300 ); } m_canvas->addItem( newItem ); } node->setStateItem( newItem ); } void StarView::createKnownHosts() { HostInfoManager::HostMap hosts = hostInfoManager()->hostMap(); HostInfoManager::HostMap::ConstIterator it; for( it = hosts.constBegin(); it != hosts.constEnd(); ++it ) { unsigned int id = (*it)->id(); if ( !findHostItem( id ) ) createHostItem( id ); } } void StarView::configureView() { mConfigDialog->show(); mConfigDialog->raise(); } bool StarView::filterArch( unsigned int hostid ) { HostInfo *i = hostInfoManager()->find( hostid ); if ( !i ) { #if 0 qDebug() << "No HostInfo for id " << hostid; #endif return false; } return filterArch( i ); } bool StarView::filterArch( HostInfo *i ) { if ( mConfigDialog->archFilter().isEmpty() ) return true; QRegExp regExp( mConfigDialog->archFilter() ); if ( regExp.indexIn( i->platform() ) >= 0 ) { return true; } return false; } #include "starview.moc" icecc-monitor-2.9.90~git20140222/src/starview.h000066400000000000000000000115501230140027500206650ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_STARVIEW_H #define ICEMON_STARVIEW_H #include "job.h" #include "statusview.h" #include #include #include #include class HostInfo; class QSlider; class QLabel; class QLineEdit; class QCheckBox; class QGraphicsView; class StarViewConfigDialog : public QDialog { Q_OBJECT public: StarViewConfigDialog( QWidget *parent ); int nodesPerRing(); bool suppressDomainName() const; void setMaxNodes( int ); QString archFilter(); protected slots: void slotNodesPerRingChanged( int nodes ); void slotSuppressDomainName( bool ); signals: void configChanged(); private: QSlider *mNodesPerRingSlider; QLabel *mNodesPerRingLabel; QLineEdit *mArchFilterEdit; QCheckBox *mSuppressDomainName; }; class HostItem : public QGraphicsItemGroup { public: enum { RttiHostItem = 1000 }; HostItem( const QString &text, HostInfoManager * ); HostItem( HostInfo *hostInfo, HostInfoManager * ); ~HostItem(); void init(); HostInfo *hostInfo() const { return mHostInfo; } void setHostColor( const QColor &color ); void setIsActiveClient( bool active ) { mIsActiveClient = active; } bool isActiveClient() const { return mIsActiveClient; } void setIsCompiling( bool compiling ) { mIsCompiling = compiling; } bool isCompiling() const { return mIsCompiling; } void setStateItem( QGraphicsItem *item ) { m_stateItem = item; } QGraphicsItem *stateItem() { return m_stateItem; } void setClient( unsigned int client ) { m_client = client; } unsigned int client() const { return m_client; } QString hostName() const; void updateName(); double centerPosX() const { return pos().x()+m_textItem->boundingRect().width()/2; } double centerPosY() const { return pos().y()+m_textItem->boundingRect().height()/2; } double relativeCenterPosX() const { return m_textItem->boundingRect().width()/2; } double relativeCenterPosY() const { return m_textItem->boundingRect().height()/2; } void setCenterPos( double x, double y ); void update( const Job &job ); protected: void createJobHalo( const Job & ); void deleteJobHalo( const Job &job ); void updateHalos(); private: HostInfo *mHostInfo; HostInfoManager *mHostInfoManager; bool mIsActiveClient; bool mIsCompiling; QGraphicsItem *m_stateItem; QGraphicsSimpleTextItem* m_textItem; unsigned int m_client; qreal mBaseWidth; qreal mBaseHeight; QGraphicsEllipseItem *m_boxItem; QMap m_jobHalos; JobList m_jobs; }; class StarView : public QWidget, public StatusView { Q_OBJECT public: StarView( HostInfoManager *, QWidget *parent ); void update( const Job &job ); QWidget *widget(); QString id() const { return "star"; } HostItem *findHostItem( unsigned int hostid ); void checkNode( unsigned int hostid ); void removeNode( unsigned int hostid ); void updateSchedulerState( bool online ); void configureView(); bool isConfigurable() { return true; } protected: virtual void resizeEvent( QResizeEvent *e ); virtual bool event(QEvent *event); /** Return true if node should be shown and false if not. */ bool filterArch( unsigned int hostid ); /** Return true if node should be shown and false if not. */ bool filterArch( HostInfo * ); void removeItem( HostItem * ); void forceRemoveNode( unsigned int hostid ); protected slots: void slotConfigChanged(); private: void createKnownHosts(); void centerSchedulerItem(); HostItem *createHostItem( unsigned int hostid ); void arrangeHostItems(); void drawNodeStatus(); void drawState( HostItem *node ); StarViewConfigDialog *mConfigDialog; QGraphicsScene *m_canvas; QGraphicsView *m_canvasView; HostItem *m_schedulerItem; QMap m_hostItems; QMap mJobMap; }; #endif // vim:ts=4:sw=4:noet icecc-monitor-2.9.90~git20140222/src/statusview.cc000066400000000000000000000044261230140027500214010ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2003,2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "statusview.h" #include "hostinfo.h" #include "job.h" #include #include #include StatusView::StatusView( HostInfoManager *m ) : mHostInfoManager( m ), m_paused( false ) { } StatusView::~StatusView() { } void StatusView::checkNode( unsigned int ) { } void StatusView::removeNode( unsigned int ) { } void StatusView::updateSchedulerState( bool online ) { #if 0 qDebug() << "Scheduler is" << ( online ? "online" : "offline" ); #endif } QString StatusView::nameForHost( unsigned int id ) { return mHostInfoManager->nameForHost( id ); } QColor StatusView::hostColor( unsigned int id ) { return mHostInfoManager->hostColor( id ); } QColor StatusView::textColor( const QColor &color ) { QColor textColor; float luminance = ( color.red() * 0.299 ) + ( color.green() * 0.587 ) + ( color.blue() * 0.114 ); if ( luminance > 140.0 ) textColor = Qt::black; else textColor = Qt::white; return textColor; } unsigned int StatusView::processor( const Job &job ) { unsigned int ret = 0; if ( job.state() == Job::LocalOnly || job.state() == Job::WaitingForCS ) { ret = job.client(); } else { ret = job.server(); if ( !ret ) { // Q_ASSERT( job.state() == Job::Finished ); ret = job.client(); } } assert( ret ); return ret; } icecc-monitor-2.9.90~git20140222/src/statusview.h000066400000000000000000000043031230140027500212350ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2003 Frerich Raabe Copyright (c) 2003,2004 Stephan Kulow Copyright (c) 2003,2004 Cornelius Schumacher 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICEMON_STATUSVIEW_H #define ICEMON_STATUSVIEW_H class HostInfoManager; class Job; class QColor; class QString; class QWidget; class StatusView { public: StatusView( HostInfoManager * ); virtual ~StatusView(); HostInfoManager *hostInfoManager() const { return mHostInfoManager; } virtual void update( const Job &job ) = 0; virtual QWidget *widget() = 0; virtual void checkNode( unsigned int hostid ); virtual void removeNode( unsigned int hostid ); virtual void updateSchedulerState( bool online ); virtual void stop() {} virtual void start() {} void togglePause() { if (m_paused) start(); else stop(); m_paused = !m_paused; } virtual void checkNodes() {} virtual bool canCheckNodes() { return false; } virtual bool isPausable() { return false; } virtual bool isConfigurable() { return false; } virtual void configureView() {} virtual QString id() const = 0; unsigned int processor( const Job & ); QString nameForHost( unsigned int hostid ); QColor hostColor( unsigned int hostid ); static QColor textColor( const QColor &backGroundColor ); private: HostInfoManager *mHostInfoManager; bool m_paused; }; #endif // vim:ts=4:sw=4:noet icecc-monitor-2.9.90~git20140222/src/summaryview.cc000066400000000000000000000201711230140027500215460ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2004 Scott Wheeler 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "summaryview.h" #include "hostinfo.h" #include "job.h" #include #include #include #include #include #include class NodeInfoFrame : public QFrame { public: NodeInfoFrame(QWidget *parent, const QColor &frameColor) : QFrame(parent), m_frameColor(frameColor) { setObjectName("nodeInfoFrame"); setStyleSheet(QString("QFrame#nodeInfoFrame { border: 2px solid %1 }").arg(frameColor.name())); } private: QColor m_frameColor; }; //////////////////////////////////////////////////////////////////////////////// // SummaryViewItem implementation //////////////////////////////////////////////////////////////////////////////// SummaryViewItem::SummaryViewItem(unsigned int hostid, QWidget *parent, SummaryView *view, QGridLayout *layout) : m_jobCount(0), m_view(view) { const int row = layout->rowCount(); const QColor nodeColor = view->hostInfoManager()->hostColor(hostid); NodeInfoFrame *labelBox = new NodeInfoFrame(parent, nodeColor); layout->setMargin(5); layout->addWidget(labelBox, row, 0); labelBox->show(); labelBox->setMinimumWidth(75); m_widgets.append(labelBox); QVBoxLayout *labelLayout = new QVBoxLayout(labelBox); labelLayout->setMargin(10); labelLayout->setSpacing(5); QLabel *l; l = new QLabel(view->nameForHost(hostid), labelBox); l->setAlignment(Qt::AlignCenter); l->show(); labelLayout->addWidget( l ); const int maxJobs = view->hostInfoManager()->maxJobs(hostid); m_jobHandlers.resize(maxJobs); for(int i = 0; i < maxJobs; i++) { m_jobHandlers[i].stateWidget = new QFrame(labelBox); m_jobHandlers[i].stateWidget->setFrameStyle(QFrame::Box | QFrame::Plain); m_jobHandlers[i].stateWidget->setLineWidth(2); m_jobHandlers[i].stateWidget->setFixedHeight(15); QPalette palette = m_jobHandlers[i].stateWidget->palette(); palette.setColor( m_jobHandlers[i].stateWidget->backgroundRole(), Qt::black ); m_jobHandlers[i].stateWidget->setPalette( palette ); m_jobHandlers[i].stateWidget->show(); labelLayout->addWidget( m_jobHandlers[i].stateWidget ); } NodeInfoFrame *detailsBox = new NodeInfoFrame(parent, nodeColor); layout->setMargin(5); layout->addWidget(detailsBox, row, 1); detailsBox->show(); m_widgets.append(detailsBox); QGridLayout *grid = new QGridLayout(detailsBox); grid->setMargin(10); grid->setSpacing(5); m_jobsLabel = addLine(QApplication::tr("Jobs:"), detailsBox, grid, Qt::AlignBottom, "0"); for(int i = 0; i < maxJobs; i++) { if(maxJobs > 1) { QSpacerItem *spacer = new QSpacerItem(1, 8, QSizePolicy::Expanding); const int row = grid->rowCount(); grid->addItem(spacer, row, 0, 1, grid->columnCount() - 1); } m_jobHandlers[i].sourceLabel = addLine(QApplication::tr("Source:"), detailsBox, grid); m_jobHandlers[i].stateLabel = addLine(QApplication::tr("State:"), detailsBox, grid); } grid->setColumnStretch(grid->columnCount() - 1, 1); grid->setRowStretch(0, 1); grid->setRowStretch(grid->rowCount(), 1); } SummaryViewItem::~SummaryViewItem() { qDeleteAll( m_widgets ); m_widgets.clear(); } void SummaryViewItem::update(const Job &job) { switch(job.state()) { case Job::Compiling: { m_jobCount++; m_jobsLabel->setText(QString::number(m_jobCount)); QVector::Iterator it = m_jobHandlers.begin(); while(it != m_jobHandlers.end() && !(*it).currentFile.isNull()) ++it; if(it != m_jobHandlers.end()) { const QColor nodeColor = m_view->hostInfoManager()->hostColor(job.client()); QPalette palette = (*it).stateWidget->palette(); palette.setColor( (*it).stateWidget->backgroundRole(), nodeColor ); (*it).stateWidget->setPalette( palette ); const QString fileName = job.fileName().section('/', -1); const QString hostName = m_view->nameForHost(job.client()); (*it).sourceLabel->setText(QString("%1 (%2)").arg(fileName).arg(hostName)); (*it).stateLabel->setText(job.stateAsString()); (*it).currentFile = job.fileName(); } break; } case Job::Finished: case Job::Failed: { QVector::Iterator it = m_jobHandlers.begin(); while(it != m_jobHandlers.end() && (*it).currentFile != job.fileName()) ++it; if(it != m_jobHandlers.end()) { QPalette palette = (*it).stateWidget->palette(); palette.setColor( (*it).stateWidget->backgroundRole(), Qt::black ); (*it).stateWidget->setPalette( palette ); (*it).sourceLabel->clear(); (*it).stateLabel->setText(job.stateAsString()); (*it).currentFile = QString(); } break; } default: break; } } QLabel *SummaryViewItem::addLine(const QString &caption, QWidget *parent, QGridLayout *grid, Qt::Alignment flags, const QString &status) { QLabel *label = new QLabel(caption, parent); label->setAlignment(Qt::AlignRight | flags); const int row = grid->rowCount(); grid->addWidget(label, row, 0); QLabel *statusLabel = new QLabel(status, parent); //statusLabel->setAlignment(Qt::AlignLeft | flags); grid->addWidget(statusLabel, row, 1); label->show(); statusLabel->show(); return statusLabel; } //////////////////////////////////////////////////////////////////////////////// // SummaryView implementation //////////////////////////////////////////////////////////////////////////////// SummaryView::SummaryView(HostInfoManager *h, QWidget *parent) : QScrollArea(parent), StatusView(h) { m_base = new QWidget; m_base->setStyleSheet("QWidget { background-color: 'white'; }"); setWidget(m_base); m_layout = new QGridLayout(m_base); m_layout->setColumnStretch(1, 1); m_layout->setSpacing(5); m_layout->setMargin(5); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setMinimumHeight(150); } SummaryView::~SummaryView() { } QWidget *SummaryView::widget() { return this; } void SummaryView::update(const Job &job) { if(!job.server()) return; SummaryViewItem *i = m_items[job.server()]; if(!i) { i = new SummaryViewItem(job.server(), m_base, this, m_layout); m_items.insert(job.server(), i); } i->update(job); } void SummaryView::checkNode(unsigned int hostid) { HostInfo *hostInfo = hostInfoManager()->find(hostid); if(hostInfo && nameForHost(hostid).isNull()) { delete m_items[hostid]; m_items.remove(hostid); } else if(!m_items[hostid]) { SummaryViewItem *i = new SummaryViewItem(hostid, m_base, this, m_layout); m_items.insert(hostid, i); } } void SummaryView::resizeEvent(QResizeEvent *e) { QSize s = e->size(); setMinimumWidth(m_base->minimumSizeHint().width() + verticalScrollBar()->width()); m_base->setMinimumWidth(s.width()); if(m_base->height() <= s.height()) m_base->setMinimumHeight(s.height()); else m_base->setMinimumHeight(m_base->sizeHint().height()); QScrollArea::resizeEvent(e); } #include "summaryview.moc" icecc-monitor-2.9.90~git20140222/src/summaryview.h000066400000000000000000000044511230140027500214130ustar00rootroot00000000000000/* This file is part of Icecream. Copyright (c) 2004 Scott Wheeler 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef SUMMARYVIEW_H #define SUMMARYVIEW_H #include "statusview.h" #include #include class QLabel; class QGridLayout; class SummaryView; class SummaryViewItem { public: SummaryViewItem(unsigned int hostid, QWidget *parent, SummaryView *view, QGridLayout *layout); ~SummaryViewItem(); void update(const Job &job); private: QLabel *addLine(const QString &caption, QWidget *parent, QGridLayout *grid, Qt::Alignment flags = Qt::AlignTop, const QString &status = QString()); struct JobHandler { JobHandler() : stateWidget(0), sourceLabel(0), stateLabel(0) {} QFrame *stateWidget; QLabel *sourceLabel; QLabel *stateLabel; QString currentFile; }; QFrame *m_stateWidget; QLabel *m_jobsLabel; QLabel *m_sourceLabel; int m_jobCount; SummaryView *m_view; QVector m_jobHandlers; QList m_widgets; }; class SummaryView : public QScrollArea, public StatusView { Q_OBJECT public: SummaryView(HostInfoManager *h, QWidget *parent); ~SummaryView(); virtual QWidget *widget(); virtual void update(const Job &job); virtual void checkNode(unsigned int hostid); virtual QString id() const { return "summary"; } protected: virtual void resizeEvent(QResizeEvent *e); private: QMap m_items; QGridLayout *m_layout; QWidget *m_base; }; #endif icecc-monitor-2.9.90~git20140222/src/version.h000066400000000000000000000012041230140027500205010ustar00rootroot00000000000000#ifndef ICEMON_VERSION_H #define ICEMON_VERSION_H #include "config-icemon.h" #include namespace Icemon { namespace Version { const char * const appName = QT_TRANSLATE_NOOP("appName", "Icecream Monitor" ); const char * const appShortName = "icemon"; const char * const version = ICEMON_VERSION_STRING; const char * const homePage = "http://github.com/icecc/icemon"; const char * const description = QT_TRANSLATE_NOOP( "description", "Icecream monitor for Qt" ); const char * const copyright = QT_TRANSLATE_NOOP( "copyright", "(c) 2003, 2004, 2011 The Icecream developers" ); } // Version } // Icemon #endif // ICEMON_VERSION_H