@ -1,2 +0,0 @@
|
||||
BreakBeforeBraces: Allman
|
||||
IndentWidth: 4
|
@ -1 +0,0 @@
|
||||
translations='./src'
|
@ -1,92 +0,0 @@
|
||||
qps-1.10.20 / 2019-02-25
|
||||
========================
|
||||
|
||||
* Bumped version to 1.10.20
|
||||
* Only translations was changed.
|
||||
|
||||
qps-1.10.19 / 2019-01-25
|
||||
========================
|
||||
|
||||
* Bumped version to 1.10.19
|
||||
* Improved cmake scripting
|
||||
- set cmake_minimum_required to 3.1.0
|
||||
- removed locale compile definitons, use lxqt-build-tools instead
|
||||
- use lxqt-build-tools translation scripts
|
||||
* Added translation support and fixed some source strings
|
||||
* Translations updated
|
||||
* Added translation promo to README.md
|
||||
|
||||
qps-1.10.18 / 2018-05-21
|
||||
========================
|
||||
|
||||
* Bumped patch version to 18 (#45)
|
||||
* Update from Weblate. (#41)
|
||||
* Added transltion state to README.md
|
||||
* Add da translation
|
||||
* translation update
|
||||
* Added translation using Weblate (German)
|
||||
* Create qps_da.ts
|
||||
* Update qps.desktop.in
|
||||
* i18n: Update Polish translation
|
||||
* Drop Qt foreach
|
||||
* Fix links QtDesktop --> lxqt
|
||||
|
||||
1.10.17 / 2017-09-22
|
||||
====================
|
||||
|
||||
* Release 1.10.17: Update changelog
|
||||
* some whitespaces fixed
|
||||
* l10n: Polish translation
|
||||
* Remove obsolete cpack
|
||||
* Removed not needed ressource file
|
||||
* some small fixes
|
||||
* Fixed About page
|
||||
* Fixed outdated FSF address in license headers
|
||||
* Removed: It may be used, distributed and modified without limitation. - not exactly true.
|
||||
* Added license headers
|
||||
* Fix typo
|
||||
* Fix license headers for files with clearly known authorship
|
||||
* remove some empty files
|
||||
* fixed encoding and added a proper GPL2 file header
|
||||
* Renamed LICENSE -> COPYING
|
||||
* Another set of licenseheader fixes
|
||||
* Fixed some typos in comments (CMakeLists.txt) Fixed licenseheader: src/wchan.cpp UTF-8 and filename Fixed licenseheader: src/watchdogdialog.* filetype and UTF-8 Fixed licenseheader: src/watchcond.* UTF-8 Fixed licenseheader: src/ttystr.cpp filentype and UTF-8
|
||||
* Work around grep 2.23 new behaviour
|
||||
* Removes not needed file
|
||||
* Fixes CPack package version
|
||||
* Fixes misnaming of binary qps
|
||||
* Use CMAKE PROJECT_NAME instead of PROJECT
|
||||
* Removes Icon related commented code
|
||||
* Removes the custom QtIconLoader
|
||||
* Use QIcon::fromTheme() instead of the internal QtIconLoader
|
||||
* Adds the resources as an target dependency
|
||||
* Puts TableField sctruct on it's own file
|
||||
* Puts the QpsApp in it's own file
|
||||
* Splits the command file into several files
|
||||
* Puts Command utilities into it's own file
|
||||
* Updates translations sources
|
||||
* Removes toolTip, statusTip, whatsThis and accesibleName from watchdog.ui
|
||||
* Removes stylesheets commented stuff
|
||||
* Include a copy of the license
|
||||
* Install application icon
|
||||
* Updates translation sources
|
||||
* Adds desktop entry file
|
||||
* Adds application internationalization / localization
|
||||
* Set the minimum required CMake version to 3.0.2
|
||||
* Add install instruction in CMakeLists.txt
|
||||
* Add clang-format file and format all files
|
||||
|
||||
v1.10.16 / 2015-06-14
|
||||
=====================
|
||||
|
||||
* Ported to Qt5 and fixed all warnings
|
||||
* Added .gitignore
|
||||
* remove
|
||||
* fix
|
||||
* fix
|
||||
* fix
|
||||
* hashstr length up to 128*8
|
||||
* added
|
||||
* fixed
|
||||
* added source files
|
||||
* commit
|
@ -1,52 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||
# CMP0000: Call the cmake_minimum_required() command at the beginning of the top-level
|
||||
# CMakeLists.txt file even before calling the project() command.
|
||||
# The cmake_minimum_required(VERSION) command implicitly invokes the cmake_policy(VERSION)
|
||||
# command to specify that the current project code is written for the given range of CMake
|
||||
# versions.
|
||||
Project(qps)
|
||||
|
||||
option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
|
||||
|
||||
set(MAJOR_VERSION 1)
|
||||
set(MINOR_VERSION 10)
|
||||
set(PATCH_VERSION 20)
|
||||
set(QPS_VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION})
|
||||
add_definitions(
|
||||
-DQPS_VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}"
|
||||
)
|
||||
|
||||
# Minimum Versions
|
||||
set(LXQTBT_MINIMUM_VERSION "0.6.0")
|
||||
set(QT_MINIMUM_VERSION "5.7.1")
|
||||
find_package(Qt5 ${QT_MINIMUM_VERSION} REQUIRED COMPONENTS Widgets X11Extras DBus LinguistTools)
|
||||
find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(LXQtPreventInSourceBuilds)
|
||||
include(LXQtCompilerSettings)
|
||||
include(LXQtTranslateTs)
|
||||
include(LXQtTranslateDesktop)
|
||||
include(Qt5TranslationLoader)
|
||||
|
||||
# Must be defined after including GNUInstallDirs. Move with care.
|
||||
set(QPS_TRANSLATIONS_DIR
|
||||
"${CMAKE_INSTALL_FULL_DATAROOTDIR}/${PROJECT_NAME}/translations"
|
||||
)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
# install the man page
|
||||
install(FILES qps.1 DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/man/man1")
|
||||
|
||||
# install the app icon
|
||||
install(FILES
|
||||
icon/qps.png
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps"
|
||||
)
|
@ -1,280 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, 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 Lesser 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
|
@ -1,103 +0,0 @@
|
||||
THE Q PUBLIC LICENSE
|
||||
version 1.0
|
||||
|
||||
Copyright (C) 1999-2006 Trolltech AS, Norway.
|
||||
Everyone is permitted to copy and
|
||||
distribute this license document.
|
||||
|
||||
The intent of this license is to establish freedom to share and change the
|
||||
software regulated by this license under the open source model.
|
||||
|
||||
This license applies to any software containing a notice placed by the
|
||||
copyright holder saying that it may be distributed under the terms of
|
||||
the Q Public License version 1.0. Such software is herein referred to as
|
||||
the Software. This license covers modification and distribution of the
|
||||
Software, use of third-party application programs based on the Software,
|
||||
and development of free software which uses the Software.
|
||||
|
||||
Granted Rights
|
||||
|
||||
1. You are granted the non-exclusive rights set forth in this license
|
||||
provided you agree to and comply with any and all conditions in this
|
||||
license. Whole or partial distribution of the Software, or software
|
||||
items that link with the Software, in any form signifies acceptance of
|
||||
this license.
|
||||
|
||||
2. You may copy and distribute the Software in unmodified form provided
|
||||
that the entire package, including - but not restricted to - copyright,
|
||||
trademark notices and disclaimers, as released by the initial developer
|
||||
of the Software, is distributed.
|
||||
|
||||
3. You may make modifications to the Software and distribute your
|
||||
modifications, in a form that is separate from the Software, such as
|
||||
patches. The following restrictions apply to modifications:
|
||||
|
||||
a. Modifications must not alter or remove any copyright notices in
|
||||
the Software.
|
||||
|
||||
b. When modifications to the Software are released under this
|
||||
license, a non-exclusive royalty-free right is granted to the
|
||||
initial developer of the Software to distribute your modification
|
||||
in future versions of the Software provided such versions remain
|
||||
available under these terms in addition to any other license(s) of
|
||||
the initial developer.
|
||||
|
||||
4. You may distribute machine-executable forms of the Software or
|
||||
machine-executable forms of modified versions of the Software, provided
|
||||
that you meet these restrictions:
|
||||
|
||||
a. You must include this license document in the distribution.
|
||||
|
||||
b. You must ensure that all recipients of the machine-executable forms
|
||||
are also able to receive the complete machine-readable source code
|
||||
to the distributed Software, including all modifications, without
|
||||
any charge beyond the costs of data transfer, and place prominent
|
||||
notices in the distribution explaining this.
|
||||
|
||||
c. You must ensure that all modifications included in the
|
||||
machine-executable forms are available under the terms of this
|
||||
license.
|
||||
|
||||
5. You may use the original or modified versions of the Software to
|
||||
compile, link and run application programs legally developed by you
|
||||
or by others.
|
||||
|
||||
6. You may develop application programs, reusable components and other
|
||||
software items that link with the original or modified versions of the
|
||||
Software. These items, when distributed, are subject to the following
|
||||
requirements:
|
||||
|
||||
a. You must ensure that all recipients of machine-executable forms of
|
||||
these items are also able to receive and use the complete
|
||||
machine-readable source code to the items without any charge
|
||||
beyond the costs of data transfer.
|
||||
|
||||
b. You must explicitly license all recipients of your items to use
|
||||
and re-distribute original and modified versions of the items in
|
||||
both machine-executable and source code forms. The recipients must
|
||||
be able to do so without any charges whatsoever, and they must be
|
||||
able to re-distribute to anyone they choose.
|
||||
|
||||
|
||||
c. If the items are not available to the general public, and the
|
||||
initial developer of the Software requests a copy of the items,
|
||||
then you must supply one.
|
||||
|
||||
Limitations of Liability
|
||||
|
||||
In no event shall the initial developers or copyright holders be liable
|
||||
for any damages whatsoever, including - but not restricted to - lost
|
||||
revenue or profits or other direct, indirect, special, incidental or
|
||||
consequential damages, even if they have been advised of the possibility
|
||||
of such damages, except to the extent invariable law, if any, provides
|
||||
otherwise.
|
||||
|
||||
No Warranty
|
||||
|
||||
The Software and this license document are provided AS IS with NO WARRANTY
|
||||
OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
Choice of Law
|
||||
|
||||
This license is governed by the Laws of Norway. Disputes shall be settled
|
||||
by Oslo City Court.
|
@ -1,33 +0,0 @@
|
||||
/* This file has been generated by the CMake qt_translation_loader().
|
||||
* It loads Qt application translations.
|
||||
*
|
||||
* Attention: All changes will be overwritten!!!
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QLocale>
|
||||
#include <QTranslator>
|
||||
#include <QLibraryInfo>
|
||||
|
||||
static void loadQtTranslation()
|
||||
{
|
||||
QString locale = QLocale::system().name();
|
||||
QTranslator *qtTranslator = new QTranslator(qApp);
|
||||
|
||||
if (qtTranslator->load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
|
||||
qApp->installTranslator(qtTranslator);
|
||||
} else {
|
||||
delete qtTranslator;
|
||||
}
|
||||
|
||||
QTranslator *appTranslator = new QTranslator(qApp);
|
||||
if (appTranslator->load(QString("@translations_dir@/@catalog_name@_%1.qm").arg(locale))) {
|
||||
QCoreApplication::installTranslator(appTranslator);
|
||||
} else if (locale == QLatin1String("C") ||
|
||||
locale.startsWith(QLatin1String("en"))) {
|
||||
// English is the default. It's translated anyway.
|
||||
delete appTranslator;
|
||||
}
|
||||
}
|
||||
|
||||
Q_COREAPP_STARTUP_FUNCTION(loadQtTranslation)
|
@ -1,17 +0,0 @@
|
||||
## Qt Process Manager
|
||||
|
||||
### Building
|
||||
|
||||
* Requires Qt 5
|
||||
|
||||
### License
|
||||
|
||||
Qps is licensed under the terms of the
|
||||
[GPLv2](http://choosealicense.com/licenses/gpl-2.0/) or any later version.
|
||||
|
||||
|
||||
### Translation (Weblate)
|
||||
|
||||
<a href="https://weblate.lxqt.org/projects/lxqt/qps/">
|
||||
<img src="https://weblate.lxqt.org/widgets/lxqt/-/qps/multi-auto.svg" alt="Translation status" />
|
||||
</a>
|
@ -1,112 +0,0 @@
|
||||
#=============================================================================
|
||||
# Copyright 2005-2011 Kitware, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# * Neither the name of Kitware, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "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 COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS 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.
|
||||
#=============================================================================
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(QT5_PATCHED_CREATE_TRANSLATION _qm_files)
|
||||
set(options)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs OPTIONS)
|
||||
|
||||
cmake_parse_arguments(_LUPDATE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
set(_lupdate_files ${_LUPDATE_UNPARSED_ARGUMENTS})
|
||||
set(_lupdate_options ${_LUPDATE_OPTIONS})
|
||||
|
||||
set(_my_sources)
|
||||
set(_my_tsfiles)
|
||||
foreach(_file ${_lupdate_files})
|
||||
get_filename_component(_ext ${_file} EXT)
|
||||
get_filename_component(_abs_FILE ${_file} ABSOLUTE)
|
||||
if(_ext MATCHES "ts")
|
||||
list(APPEND _my_tsfiles ${_abs_FILE})
|
||||
else()
|
||||
list(APPEND _my_sources ${_abs_FILE})
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(_ts_file ${_my_tsfiles})
|
||||
if(_my_sources)
|
||||
# make a list file to call lupdate on, so we don't make our commands too
|
||||
# long for some systems
|
||||
# get_filename_component(_ts_name ${_ts_file} NAME_WE)
|
||||
|
||||
get_filename_component(_name ${_ts_file} NAME)
|
||||
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _ts_name ${_name})
|
||||
|
||||
set(_ts_lst_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lst_file")
|
||||
set(_lst_file_srcs)
|
||||
foreach(_lst_file_src ${_my_sources})
|
||||
set(_lst_file_srcs "${_lst_file_src}\n${_lst_file_srcs}")
|
||||
endforeach()
|
||||
|
||||
get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
|
||||
foreach(_pro_include ${_inc_DIRS})
|
||||
get_filename_component(_abs_include "${_pro_include}" ABSOLUTE)
|
||||
set(_lst_file_srcs "-I${_pro_include}\n${_lst_file_srcs}")
|
||||
endforeach()
|
||||
|
||||
file(WRITE ${_ts_lst_file} "${_lst_file_srcs}")
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${_ts_file}
|
||||
COMMAND ${Qt5_LUPDATE_EXECUTABLE}
|
||||
ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}
|
||||
DEPENDS ${_my_sources} ${_ts_lst_file} VERBATIM)
|
||||
endforeach()
|
||||
qt5_patched_add_translation(${_qm_files} ${_my_tsfiles})
|
||||
set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(QT5_PATCHED_ADD_TRANSLATION _qm_files)
|
||||
foreach(_current_FILE ${ARGN})
|
||||
get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
|
||||
# get_filename_component(qm ${_abs_FILE} NAME_WE)
|
||||
|
||||
get_filename_component(_name ${_abs_FILE} NAME)
|
||||
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" qm ${_name})
|
||||
|
||||
get_source_file_property(output_location ${_abs_FILE} OUTPUT_LOCATION)
|
||||
if(output_location)
|
||||
file(MAKE_DIRECTORY "${output_location}")
|
||||
set(qm "${output_location}/${qm}.qm")
|
||||
else()
|
||||
set(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${qm}
|
||||
COMMAND ${Qt5_LRELEASE_EXECUTABLE}
|
||||
ARGS ${_abs_FILE} -qm ${qm}
|
||||
DEPENDS ${_abs_FILE} VERBATIM
|
||||
)
|
||||
list(APPEND ${_qm_files} ${qm})
|
||||
endforeach()
|
||||
set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
|
||||
endfunction()
|
@ -1,25 +1,25 @@
|
||||
Source: qps
|
||||
Maintainer: LXQt Packaging Team <pkg-lxqt-devel@lists.alioth.debian.org>
|
||||
Uploaders: Alf Gaida <agaida@siduction.org>,
|
||||
ChangZhuo Chen (陳昌倬) <czchen@debian.org>,
|
||||
Andrew Lee (李健秋) <ajqlee@debian.org>
|
||||
Maintainer: Lubuntu Developers <lubuntu-devel@lists.ubuntu.com>
|
||||
XSBC-Original-Maintainer: LXQt Packaging Team <pkg-lxqt-devel@lists.alioth.debian.org>
|
||||
Uploaders: Simon Quigley <tsimonq2@ubuntu.com>
|
||||
Section: x11
|
||||
Priority: optional
|
||||
Build-Depends: debhelper-compat (= 12),
|
||||
cmake,
|
||||
libxrender-dev,
|
||||
Build-Depends: cmake,
|
||||
debhelper-compat (= 12),
|
||||
libqt5x11extras5-dev,
|
||||
libxrender-dev,
|
||||
lxqt-build-tools (>= 0.6.0~),
|
||||
qttools5-dev,
|
||||
qttools5-dev-tools
|
||||
Standards-Version: 4.3.0
|
||||
Vcs-Browser: https://salsa.debian.org/lxqt-team/qps
|
||||
Vcs-Git: https://salsa.debian.org/lxqt-team/qps.git
|
||||
Vcs-Browser: https://phab.lubuntu.me/source/qps/
|
||||
Vcs-Git: https://phab.lubuntu.me/source/qps.git
|
||||
XS-Debian-Vcs-Browser: https://salsa.debian.org/lxqt-team/qps
|
||||
XS-Debian-Vcs-Git: https://salsa.debian.org/lxqt-team/qps.git
|
||||
Homepage: https://github.com/lxqt/qps
|
||||
|
||||
Package: qps
|
||||
Architecture: linux-any
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends}
|
||||
Depends: ${misc:Depends}, ${shlibs:Depends}
|
||||
Description: Qt process manager
|
||||
Qt process manager ported to Qt5
|
||||
|
@ -1,196 +0,0 @@
|
||||
/* XPM */
|
||||
static char * icon_small_xpm[] = {
|
||||
"25 25 168 2",
|
||||
" c None",
|
||||
". c #181918",
|
||||
"+ c #3F413F",
|
||||
"@ c #242524",
|
||||
"# c #008600",
|
||||
"$ c #008000",
|
||||
"% c #000300",
|
||||
"& c #002000",
|
||||
"* c #00AF00",
|
||||
"= c #000000",
|
||||
"- c #004500",
|
||||
"; c #010101",
|
||||
"> c #2D2E2D",
|
||||
", c #139F13",
|
||||
"' c #000400",
|
||||
") c #007200",
|
||||
"! c #005800",
|
||||
"~ c #131313",
|
||||
"{ c #2CAB2C",
|
||||
"] c #033803",
|
||||
"^ c #001800",
|
||||
"/ c #00B200",
|
||||
"( c #030303",
|
||||
"_ c #2C2D2C",
|
||||
": c #039603",
|
||||
"< c #000700",
|
||||
"[ c #007100",
|
||||
"} c #005900",
|
||||
"| c #005000",
|
||||
"1 c #007A00",
|
||||
"2 c #001300",
|
||||
"3 c #333433",
|
||||
"4 c #020202",
|
||||
"5 c #006C00",
|
||||
"6 c #001900",
|
||||
"7 c #008800",
|
||||
"8 c #016101",
|
||||
"9 c #2B2C2B",
|
||||
"0 c #9A9A9A",
|
||||
"a c #494A49",
|
||||
"b c #001500",
|
||||
"c c #008900",
|
||||
"d c #033703",
|
||||
"e c #25CA25",
|
||||
"f c #9E9D9E",
|
||||
"g c #9E9A9E",
|
||||
"h c #828282",
|
||||
"i c #404240",
|
||||
"j c #007000",
|
||||
"k c #004200",
|
||||
"l c #040404",
|
||||
"m c #232423",
|
||||
"n c #9E9E9E",
|
||||
"o c #9B989B",
|
||||
"p c #7A7A7A",
|
||||
"q c #4F514F",
|
||||
"r c #3F423F",
|
||||
"s c #00B700",
|
||||
"t c #232323",
|
||||
"u c #9A979A",
|
||||
"v c #3F3F3F",
|
||||
"w c #8F8C8F",
|
||||
"x c #5C5B5C",
|
||||
"y c #696B69",
|
||||
"z c #484948",
|
||||
"A c #008500",
|
||||
"B c #9D999D",
|
||||
"C c #676567",
|
||||
"D c #3D3E3D",
|
||||
"E c #4E4C4E",
|
||||
"F c #2A292A",
|
||||
"G c #323132",
|
||||
"H c #666466",
|
||||
"I c #999699",
|
||||
"J c #535253",
|
||||
"K c #004A00",
|
||||
"L c #010401",
|
||||
"M c #252625",
|
||||
"N c #484748",
|
||||
"O c #4C4A4C",
|
||||
"P c #979597",
|
||||
"Q c #949294",
|
||||
"R c #949394",
|
||||
"S c #A1A3A1",
|
||||
"T c #000500",
|
||||
"U c #004800",
|
||||
"V c #2B6E2B",
|
||||
"W c #6D6A6D",
|
||||
"X c #545254",
|
||||
"Y c #9C989C",
|
||||
"Z c #272627",
|
||||
"` c #726F72",
|
||||
" . c #929192",
|
||||
".. c #BFC1BF",
|
||||
"+. c #A1C2A1",
|
||||
"@. c #003D00",
|
||||
"#. c #00C200",
|
||||
"$. c #1C1D1C",
|
||||
"%. c #8B8B8B",
|
||||
"&. c #878487",
|
||||
"*. c #373637",
|
||||
"=. c #9B979B",
|
||||
"-. c #787578",
|
||||
";. c #716E71",
|
||||
">. c #919091",
|
||||
",. c #BEC0BE",
|
||||
"'. c #9C9D9C",
|
||||
"). c #494949",
|
||||
"!. c #292929",
|
||||
"~. c #8B8E8B",
|
||||
"{. c #7D7E7D",
|
||||
"]. c #7E7B7E",
|
||||
"^. c #2E2C2E",
|
||||
"/. c #908F90",
|
||||
"(. c #BCBEBC",
|
||||
"_. c #999A99",
|
||||
":. c #4F4F4F",
|
||||
"<. c #001400",
|
||||
"[. c #00B600",
|
||||
"}. c #060606",
|
||||
"|. c #1D1D1D",
|
||||
"1. c #6B6F6B",
|
||||
"2. c #787978",
|
||||
"3. c #444244",
|
||||
"4. c #686668",
|
||||
"5. c #8F8F8F",
|
||||
"6. c #BABCBA",
|
||||
"7. c #969796",
|
||||
"8. c #555555",
|
||||
"9. c #004700",
|
||||
"0. c #151615",
|
||||
"a. c #8F8E8F",
|
||||
"b. c #B8BAB8",
|
||||
"c. c #949494",
|
||||
"d. c #5A5A5A",
|
||||
"e. c #001000",
|
||||
"f. c #6C6F6C",
|
||||
"g. c #8D8D8D",
|
||||
"h. c #B3B5B3",
|
||||
"i. c #929292",
|
||||
"j. c #608660",
|
||||
"k. c #001A00",
|
||||
"l. c #00B000",
|
||||
"m. c #141514",
|
||||
"n. c #6F726F",
|
||||
"o. c #8D8E8D",
|
||||
"p. c #646464",
|
||||
"q. c #007E00",
|
||||
"r. c #004C00",
|
||||
"s. c #153215",
|
||||
"t. c #656565",
|
||||
"u. c #005400",
|
||||
"v. c #007600",
|
||||
"w. c #000900",
|
||||
"x. c #009800",
|
||||
"y. c #004000",
|
||||
"z. c #004100",
|
||||
"A. c #038603",
|
||||
"B. c #03A003",
|
||||
"C. c #2C4D2C",
|
||||
"D. c #00AD00",
|
||||
"E. c #002800",
|
||||
"F. c #008700",
|
||||
"G. c #139113",
|
||||
"H. c #002500",
|
||||
"I. c #00BB00",
|
||||
"J. c #00A100",
|
||||
"K. c #007C00",
|
||||
" ",
|
||||
" . + @ # $ % & * = = - = = = = = = = = = @ + . ",
|
||||
" + ; > , ' = = ) ! = - = = = = = = = = ~ > ; + ",
|
||||
" @ > { ] = = = ^ / = - = = = = = = = = ( _ > @ ",
|
||||
" = ~ : < = = = = [ } - = = = = = = = = = ( ~ = ",
|
||||
" = | 1 = = = = = 2 [ - = 3 4 = = = = = = = = = ",
|
||||
" = 5 6 = = = = = = 7 8 9 0 a ( = = = = = = = = ",
|
||||
" b c = = = = = = = d e f g h i ( = = = = = = = ",
|
||||
" j k = = = = = = l m n g o p q r ( = = = = = = ",
|
||||
" s 2 = = = = = l t n g u v w x y z ( = = = = = ",
|
||||
" A = = = = = ( m n B C D E F G H I J = = = = = ",
|
||||
" K % % % % L M n g I F N O P Q g R S % % % % T ",
|
||||
" U k k k k V f g W X Y Z ` g g ...+.@.@.@.@.#. ",
|
||||
" = = = = = $.%.&.*.=.-.Y ;.g >.,.'.).= = = = A ",
|
||||
" = = = = = !.~.{.Z ].^.g g /.(._.:.= = = = <.[. ",
|
||||
" = = = = = }.|.1.2.3.4.g 5.6.7.8.= = = = = 9.j ",
|
||||
" = = = = = = = 0.1.%.g a.b.c.d.= = = = = = 7 e. ",
|
||||
" = = = = = = = = 0.f.g.h.i.j.= = = = = = k.l.= ",
|
||||
" = = = = = = = = = m.n.o.p.j <.= = = = = q.r.= ",
|
||||
" = = = = = = = = = = s.t.= u.v.= = = = w.x.= = ",
|
||||
" = ~ ( = = = = = = = y.= = = l.k.= = = z.A.~ = ",
|
||||
" @ > _ ( = = = = = = y.= = = u.v.= = < B.C.> @ ",
|
||||
" + ; > ~ = = = = = = y.= = = = D.E.T F.G.> ; + ",
|
||||
" . + @ = = = = = = = y.= = = = H.I.J.K.= @ + . ",
|
||||
" "};
|
@ -1,57 +0,0 @@
|
||||
/* XPM */
|
||||
static const char *icon_xpm[] = {
|
||||
"48 48 6 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"X c #00FF00",
|
||||
"o c #7A7E7A",
|
||||
"O c #FFFFFF",
|
||||
"+ c #9E9A9E",
|
||||
" ",
|
||||
" .......XX..XX............................. ",
|
||||
" ..oo...XX....XX.....X...................oo.. ",
|
||||
" ..o..o.XX......X........................o..o.. ",
|
||||
" .o....oX.......XX....X.................o....o. ",
|
||||
" .o....oX........X......................o....o. ",
|
||||
" ..o..oX.........XX...X..................o..o.. ",
|
||||
" ...ooXX..........X.......................oo... ",
|
||||
" .....X...........XX..X........................ ",
|
||||
" .....X............X........................... ",
|
||||
" ....XX............X..X........................ ",
|
||||
" ....X..............X....Oo.................... ",
|
||||
" ....X..............X.X..o+o................... ",
|
||||
" ...X...............XX.Oo+++o.................. ",
|
||||
" ...X................XXo++++oo................. ",
|
||||
" ..XX................Oo++++o.oo................ ",
|
||||
" ..X.................o++++++o.oo............... ",
|
||||
" ..X...............Oo++++o+++o.oo.............. ",
|
||||
" .XX...............o+++++..+++.o+o............. ",
|
||||
" .X..............Oo++++oo+..++..++o............ ",
|
||||
" .X..............o++++....+....+++++........... ",
|
||||
" XX............Oo++++..++.++oo++++oO........... ",
|
||||
" X.............o++++++....++++++++oO........... ",
|
||||
" XX.X.X.X.X.XOo++++++++..+++++++oOoOX.X.X.X.XXX ",
|
||||
" ............o++++...+++..++++++oOoO.........X. ",
|
||||
" ............o+++..++++++.++++oOoO.O.........X. ",
|
||||
" ............oo++.++++.+++++++oOoO...........X. ",
|
||||
" ............ooo+..+++.+++++oOoO.O..........XX. ",
|
||||
" ............Oooo+..+..+++++oOoO............X.. ",
|
||||
" ..............ooo+...++++oOoO.O............X.. ",
|
||||
" ...............ooo+++++++oOoO.............XX.. ",
|
||||
" ................ooo++++oOoO.O.............X... ",
|
||||
" .................ooo+++oOoO...............X... ",
|
||||
" ..................ooo+OoO.O..............XX... ",
|
||||
" ...................oooOoO.X..............X.... ",
|
||||
" ....................ooO.O..X............XX.... ",
|
||||
" .....................oO....X............X..... ",
|
||||
" ......................O....XX...........X..... ",
|
||||
" .....................X......X..........XX..... ",
|
||||
" ............................XX.........X...... ",
|
||||
" ...oo................X.......X........XX.oo... ",
|
||||
" ..o..o.......................XX.......X.o..o.. ",
|
||||
" .o....o..............X........X......XXo....o. ",
|
||||
" .o....o.......................XX....XX.o....o. ",
|
||||
" ..o..o...............X.........XX..XX...o..o.. ",
|
||||
" ..oo...........................XXXX.....oo.. ",
|
||||
" ...................X...................... ",
|
||||
" "};
|
Before Width: | Height: | Size: 720 B |
@ -1,19 +0,0 @@
|
||||
/* XPM */
|
||||
static char * letters_xpm[] = {
|
||||
"570 9 7 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #00473E",
|
||||
"@ c #007D71",
|
||||
"# c #51ECB7",
|
||||
"$ c #FFFFFF",
|
||||
"% c #00A390",
|
||||
" ",
|
||||
" +++ @###@ @###@ @###@ @### @@ +++ +#@ ### ### @ +@+ +++ +++ +++ +++ ### +%+ @###@ @###@ @+++@ @###@ @###@ @###@ @###@ @###@ +++ @###@ @###@ @###@ @###@ @###@ @###@ ### ###% +###@ @### @###@ @###@ @###@ @+++@ +#+ +++@ @+++@ @+++ # # #### @###@ ####@ @###@ %### @###@ @###@ %+++% %+++% %+++% @+++@ %+++% @###@ @##+ +++ +++ ### +++ +++ +++ %+++ +++ +++% @###@ @###@ ###@ @+++@ + + @+++@ %+++@ %+++ +++ +++ +++ @###@ @###@ #### ###@ %###% %+++% %+++% @+++% %+++% %+++% @###@ +++ +%+ +++ +++ ",
|
||||
" + + # @ # + + # # # @# # + + + @%+ # # # # + # + + + + + + + + # # # + # + + # + # # # # + # + + # # # # # + # + # # # # # # # # # # # # # # # # # + # # # + # + # + # # + # + + # # # # + ## ## # # # # # # # # # # # + + # + # # # # # # # # # # + # # + # + + + % % + + + + + + # + + + + # # + # + # + # # + + + # # # # + + + + + + + # # # # # # # + + # + # # # # # # # # # # + # + + + # + + + + +",
|
||||
" + + # @ # + + # # # + # + + + + # # #%# + # + + + + + + + + #+ # ## + # + + # + # # # # + # + + # # # # # + @ + + # + # + # + # + # # # # # # # # + # # # + # + # + # # + # + + # # #+ # + # # # # # # # # # # # # # # + + # + # # # # # # +# #+ #+ +# + #+ # + +# + + + # # + + + + + % # + + + + # # + # + # + # # + # + + # # #+ # + + + + + + + # # # # # # # + + # + # # # # # # +# #+ #+ +# + #+ + + + # + + + + +",
|
||||
" +++ @###@ @###@ ###@ ### # +++ +++ %#% ##@## +++ ##@## +++ +%+ %+#+% +%+ @###@ ###@ @###@ @###@ @###@ +++@ @###@ @###@ +++ +@#@ +@#@ +@#@ +@#@ +@#@ @+##@ %###% %### @+++ @+++@ @### @### @+##@ @###@ +@+ +++@ @##+ @+++ @+++@ @+++@ @+++@ %###@ @#++@ ###% @###@ +@+ @+++@ @+++@ @+++@ # ### +#+ @+++ +%+ @+++@ +++ +++ +++ #### %###+ @###@ @###@ @###@ @###@ % ##@ @###@ +++ +++@ @##+@ @+++ %#+#% ##%+ ### @###@ @#++@ #### ### +@+ @+++@ @+++@ @+++@ # ### +#+ +++ + + +++ +++ ",
|
||||
" + + @ # # # + # # # # + + + + # # #%# + # + + + + + + + +# + ## # + # + # + + # + # + # # # + # # # + # + @ + + # + + # + + # + + # + + # + # ##+ # # # # # + # # # + # + # # # # + # + + # # #+ # + # # # # # # # + # # # # # + # + # + # # # # # # # +# #+ + # + +# + # + + #+ + + + + + + + + # # # # # + # # # + # + # # # # + # + + # # ##+ # + # # # # #+ # # # + # # # # # + # + # + # # # # # # # +# #+ + # + +# + + + + # + + + + +",
|
||||
" + + @ # # # + # # # # #@ + + + + # # # # + # + + @ + + + + + # + # # + # + # + + # + # + # # # + # # # + # + # + + + + + + + + + + + # + # # # # # + # # # + # + # # # # + # + + # # # # + # # # # # # # + # ## # # + # + # + # # +# #+ ## ## # # + # + # + # + + # + + + + + + + + # # # # # + # # # + # + # # # # + # + + # # # # + # # # # #+ # # # + # ## # # + # + # + # # +# #+ ## ## # # + # + # + + + + # + + + + +",
|
||||
" +++ %###@ @###@ ###@ @###@ @@ +++ +++ ### ### @ +@+ @#+ +++ +#+ +++ ### +#+ @###@ @###@ +++@ @###@ @###@ +++@ @###@ @###@ +++ +#+ +#+ +#+ +#+ +#+ @###@ %+++% ###% +###@ #### @###@ #+++ @###@ @+++@ +#+ @###@ @+++@ @###+ %+++% #+++# @###@ %+++ @###@ %+++% @###@ +%+ ### # #+ +# %+++% +#+ %###@ @##+ +++ +++ +++ @###@ @###@ @###% %### @###@ +#### @###@ #+++ ###% @+++@ +#+ @###@ %+++@ @###+ # % # #++# ### %+++ @###@ %+++% %### +%+ +###+ # #+++# %+++% #+ @###@ +++ +%+ +++ +++ ",
|
||||
" # "};
|
Before Width: | Height: | Size: 502 B |
Before Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 686 B |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 656 B |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 660 B |
@ -1,25 +0,0 @@
|
||||
/* XPM */
|
||||
static char * vpointer_xpm[] = {
|
||||
"16 16 6 1",
|
||||
" c None",
|
||||
". c #00A097",
|
||||
"+ c #43A687",
|
||||
"@ c #00DAA4",
|
||||
"# c #56C4A9",
|
||||
"$ c #2FFDBB",
|
||||
" ",
|
||||
" ",
|
||||
" .. ",
|
||||
" .. ",
|
||||
" ",
|
||||
" ++ ",
|
||||
" ++ ",
|
||||
" ",
|
||||
" @@ ## @@ ",
|
||||
" @@ ## @@ ",
|
||||
" @@ @@ ",
|
||||
" @@ @@ ",
|
||||
" $$ ",
|
||||
" $$ ",
|
||||
" ",
|
||||
" "};
|
@ -1,46 +0,0 @@
|
||||
/* XPM */
|
||||
static const char *warn_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 39 35 4 1",
|
||||
/* colors */
|
||||
". c none",
|
||||
"# c #000000",
|
||||
"a c #ffff00",
|
||||
"b c #ffffff",
|
||||
/* pixels */
|
||||
"..................###..................",
|
||||
".................#####.................",
|
||||
".................#####.................",
|
||||
"................#######................",
|
||||
"...............#########...............",
|
||||
"...............#########...............",
|
||||
"..............####aba####..............",
|
||||
"..............####baa####..............",
|
||||
".............####abaaa####.............",
|
||||
"............####aba#aaa####............",
|
||||
"............####ab###aa####............",
|
||||
"...........####aba###aaa####...........",
|
||||
"..........#####ab#####aa#####..........",
|
||||
"..........####aba#####aaa####..........",
|
||||
".........####abaa#####aaaa####.........",
|
||||
".........####abaa#####aaaa####.........",
|
||||
"........####abaaa#####aaaaa####........",
|
||||
".......#####abaaa#####aaaaa#####.......",
|
||||
".......####abaaaa#####aaaaaa####.......",
|
||||
"......####abaaaaa#####aaaaaaa####......",
|
||||
"......####abaaaaa#####aaaaaaa####......",
|
||||
".....####abaaaaaa#####aaaaaaaa####.....",
|
||||
"....####aabaaaaaaa###aaaaaaaaaa####....",
|
||||
"....####abaaaaaaaa###aaaaaaaaaa####....",
|
||||
"...####abaaaaaaaaaa#aaaaaaaaaaaa####...",
|
||||
"..#####abaaaaaaaaaaaaaaaaaaaaaaa####...",
|
||||
"..####abaaaaaaaaaaa#aaaaaaaaaaaaa####..",
|
||||
".####aabaaaaaaaaaa###aaaaaaaaaaaaa####.",
|
||||
".####abaaaaaaaaaa#####aaaaaaaaaaaa####.",
|
||||
"####aabaaaaaaaaaaa###aaaaaaaaaaaaaa####",
|
||||
"####abaaaaaaaaaaaaa#aaaaaaaaaaaaaaa####",
|
||||
"#####aaaaaaaaaaaaaaaaaaaaaaaaaaaaa#####",
|
||||
"#######################################",
|
||||
".#####################################.",
|
||||
"..###################################.."
|
||||
};
|
@ -1,98 +0,0 @@
|
||||
/* XPM */
|
||||
static const char * x1_xpm[] = {
|
||||
"12 12 83 1",
|
||||
" c None",
|
||||
". c #545454",
|
||||
"+ c #333333",
|
||||
"@ c #3D3D3D",
|
||||
"# c #373737",
|
||||
"$ c #303030",
|
||||
"% c #353535",
|
||||
"& c #555555",
|
||||
"* c #585858",
|
||||
"= c #0B1D0A",
|
||||
"- c #184B17",
|
||||
"; c #020202",
|
||||
"> c #040404",
|
||||
", c #060606",
|
||||
"' c #0E0E0E",
|
||||
") c #101810",
|
||||
"! c #163C15",
|
||||
"~ c #040E04",
|
||||
"{ c #535653",
|
||||
"] c #123711",
|
||||
"^ c #4BEF47",
|
||||
"/ c #1E5F1C",
|
||||
"( c #040C04",
|
||||
"_ c #020602",
|
||||
": c #010101",
|
||||
"< c #133C12",
|
||||
"[ c #4EF94B",
|
||||
"} c #133D12",
|
||||
"| c #2E2E2E",
|
||||
"1 c #030A03",
|
||||
"2 c #10350F",
|
||||
"3 c #43D840",
|
||||
"4 c #0D2A0C",
|
||||
"5 c #051105",
|
||||
"6 c #010501",
|
||||
"7 c #0B260B",
|
||||
"8 c #44E444",
|
||||
"9 c #123E12",
|
||||
"0 c #000000",
|
||||
"a c #343434",
|
||||
"b c #48F548",
|
||||
"c c #061606",
|
||||
"d c #0C290C",
|
||||
"e c #45E645",
|
||||
"f c #051305",
|
||||
"g c #0A0A0A",
|
||||
"h c #323232",
|
||||
"i c #313131",
|
||||
"j c #4AFC4A",
|
||||
"k c #091F09",
|
||||
"l c #0C0C0C",
|
||||
"m c #2D2D2D",
|
||||
"n c #071907",
|
||||
"o c #4AFA4A",
|
||||
"p c #030D03",
|
||||
"q c #363636",
|
||||
"r c #061506",
|
||||
"s c #4CFE4C",
|
||||
"t c #051405",
|
||||
"u c #3FD23F",
|
||||
"v c #081D08",
|
||||
"w c #383838",
|
||||
"x c #103810",
|
||||
"y c #46EB46",
|
||||
"z c #144314",
|
||||
"A c #164715",
|
||||
"B c #4CFD4C",
|
||||
"C c #010401",
|
||||
"D c #0C280C",
|
||||
"E c #4FFC4B",
|
||||
"F c #164714",
|
||||
"G c #4D4D4D",
|
||||
"H c #113A11",
|
||||
"I c #154514",
|
||||
"J c #020402",
|
||||
"K c #525252",
|
||||
"L c #464646",
|
||||
"M c #202020",
|
||||
"N c #2A2A2A",
|
||||
"O c #242424",
|
||||
"P c #282828",
|
||||
"Q c #272727",
|
||||
"R c #515151",
|
||||
" .+@#+$$#%& ",
|
||||
"*=-;>,'')!~{",
|
||||
"$]^/(_::<[}|",
|
||||
"%1234567890a",
|
||||
"%065bcdef0gh",
|
||||
"i0065jbk60lh",
|
||||
"m000noj7p6>q",
|
||||
"h00rs6tuv56w",
|
||||
"%0xyr065uz_w",
|
||||
"%AB7000CDEFw",
|
||||
"G;H000000IJK",
|
||||
" LMNOPQQQ|R "};
|
@ -1,49 +0,0 @@
|
||||
/* XPM */
|
||||
static const char * x2_xpm[] = {
|
||||
"12 12 34 1",
|
||||
" c None",
|
||||
". c #565656",
|
||||
"+ c #353535",
|
||||
"@ c #3E3E3E",
|
||||
"# c #373737",
|
||||
"$ c #333333",
|
||||
"% c #303030",
|
||||
"& c #555555",
|
||||
"* c #595959",
|
||||
"= c #030303",
|
||||
"- c #010101",
|
||||
"; c #050505",
|
||||
"> c #060606",
|
||||
", c #0E0E0E",
|
||||
"' c #000000",
|
||||
") c #545454",
|
||||
"! c #313131",
|
||||
"~ c #383838",
|
||||
"{ c #363636",
|
||||
"] c #0C0C0C",
|
||||
"^ c #323232",
|
||||
"/ c #2D2D2D",
|
||||
"( c #040404",
|
||||
"_ c #4D4D4D",
|
||||
": c #020202",
|
||||
"< c #525252",
|
||||
"[ c #464646",
|
||||
"} c #202020",
|
||||
"| c #2A2A2A",
|
||||
"1 c #242424",
|
||||
"2 c #282828",
|
||||
"3 c #272727",
|
||||
"4 c #2E2E2E",
|
||||
"5 c #515151",
|
||||
" .+@#$%%#+& ",
|
||||
"*=-=;>,,,>')",
|
||||
"!---------'~",
|
||||
"{'''''''''-#",
|
||||
"+''''''''']^",
|
||||
"!''''''''']^",
|
||||
"/'''''''''({",
|
||||
"^''''''''''~",
|
||||
"+'''''''''-~",
|
||||
"+'''''''''-~",
|
||||
"_:'''''''':<",
|
||||
" [}|1233345 "};
|
@ -1,317 +0,0 @@
|
||||
.\" -*-nroff-*-
|
||||
.TH QPS 1 "Sept 30 1999"
|
||||
.UC 4
|
||||
.SH NAME
|
||||
qps \- Visual Process Manager
|
||||
.SH SYNOPSIS
|
||||
.B qps
|
||||
[
|
||||
.I options
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
.B qps
|
||||
is a monitor that displays the status of the processes currently in existence,
|
||||
much like top(1) or ps(1).
|
||||
The user interface uses the Qt toolkit, and most operations should be
|
||||
fairly intuitive.
|
||||
.PP
|
||||
The process list is sorted by the highlighted field. Click on another
|
||||
title to change; click again to reverse the sorting order. Rearrange the
|
||||
columns by dragging the titles.
|
||||
.PP
|
||||
Left-clicking on a process selects or deselects it. Shift-click to select
|
||||
multiple processes. The PIDs of selected processes can be pasted into other
|
||||
applications (this option can be disabled).
|
||||
.PP
|
||||
The right mouse button pops up a context menu, which duplicates some
|
||||
functions from the main menu for convenience. It works both on processes and
|
||||
on the column headings.
|
||||
.PP
|
||||
Control-clicking in the process table selects all processes with the same
|
||||
displayed value in the particular column clicked in. For instance, to select
|
||||
all processes owned by "joshua", keep Control pressed while clicking on
|
||||
"joshua". Shift and Control together produces the expected result.
|
||||
.PP
|
||||
In Tree mode, the parent-child relations between processes is shown in a
|
||||
more obvious way. Click on the triangles to show or hide an entire subtree.
|
||||
Sorting only affects siblings; the tree structure imposes the global order.
|
||||
.PP
|
||||
To change the time-sharing priority of the selected processes, type the new
|
||||
priority in the
|
||||
.I Renice...
|
||||
dialog. The new nice value should be in the range -20 to 20; 0 is the
|
||||
default. A larger number means that the process gets less CPU time.
|
||||
Only the super-user may decrease the nice value.
|
||||
.PP
|
||||
The
|
||||
.I Change Scheduling...
|
||||
dialog allows the super-user to change the scheduling policy of the
|
||||
selected processes (using Posix.1b scheduling control).
|
||||
Normal processes are set to SCHED_OTHER and have static priority 0;
|
||||
(soft) real-time processes have the policy SCHED_FIFO or SCHED_RR and
|
||||
a static priority in the range of 1 to 99. (See
|
||||
sched_setscheduler(2).) Solaris has additional scheduling policies,
|
||||
but right now qps doesn't allow setting these.
|
||||
.PP
|
||||
By default, the process display updates every 5 seconds. To change, type the
|
||||
new update period in the
|
||||
.I Update Period...
|
||||
dialog. The units min, s and ms may be used (if none, seconds are
|
||||
assumed). You can force an update by pressing the space bar or
|
||||
clicking the
|
||||
.I Update
|
||||
button. qps will consume a lot of CPU time if the update period is
|
||||
short or zero. If iconified, however, qps will use very little CPU.
|
||||
.PP
|
||||
The USER field shows the real user ID. If the effective user ID of a
|
||||
process is different from its real user ID, a plus sign (+) is appended to
|
||||
the user name; if it is the super-user, an asterisk (*) is appended.
|
||||
.PP
|
||||
The load, CPU, memory and swap displays in the status bar can be
|
||||
toggled between graphic and text representations by clicking on them,
|
||||
or by settings in the
|
||||
.I Preferences...
|
||||
dialog. The load numbers shown are the number of jobs in the run queue
|
||||
averaged over 1, 5 and 15 minutes.
|
||||
.PP
|
||||
The swap bar will turn red if free swap space falls below a certain value,
|
||||
which can be changed in the
|
||||
.I Preferences...
|
||||
dialog. The number can be entered in K, M (megabytes) or % (percent of total
|
||||
swap space). The default is 10%.
|
||||
.PP
|
||||
On SMP (multi-CPU) machines running Solaris 2.6 or Linux 2.1.x or
|
||||
later, the CPU stats will be shown for each processor in vertical
|
||||
mode, and the average of all CPUs in horizontal mode.
|
||||
.PP
|
||||
For displaying the WCHAN field as symbols, the kernel symbol file
|
||||
System.map is needed. qps will search for it in the following
|
||||
locations:
|
||||
.PP
|
||||
.nf
|
||||
/boot/System.map-\c
|
||||
.I RELEASE
|
||||
/boot/System.map
|
||||
/lib/modules/\c
|
||||
.I RELEASE\c
|
||||
/System.map
|
||||
/usr/src/linux-\c
|
||||
.I RELEASE\c
|
||||
/System.map
|
||||
/usr/src/linux/System.map
|
||||
/usr/local/src/linux-\c
|
||||
.I RELEASE\c
|
||||
/System.map
|
||||
/usr/local/src/linux/System.map
|
||||
.fi
|
||||
.PP
|
||||
where
|
||||
.I RELEASE
|
||||
is the kernel release number, for instance "2.0.29". If the
|
||||
System.map file isn't found or unreadable, hexadecimal addresses will be
|
||||
displayed instead. The prefixes "sys_" and "do_" are stripped from the
|
||||
symbols before they are displayed.
|
||||
Under Solaris, symbolic names are currently not supported and hexadecimal
|
||||
addresses will always be shown.
|
||||
.PP
|
||||
The
|
||||
.I View Details
|
||||
menu item opens a window that shows different aspects of the selected
|
||||
processes. Double-clicking on a process has the same effect. All
|
||||
information is only available to the owner of the process (and to the
|
||||
super-user).
|
||||
.PP
|
||||
The
|
||||
.I Sockets
|
||||
table (Linux only) shows the currently used TCP and UDP sockets. If
|
||||
.I Host Name Lookup
|
||||
is checked in the
|
||||
.I Preferences
|
||||
dialog, a host name lookup will be done for each IP address. This is
|
||||
done by a background process but can take a while for difficult cases
|
||||
(but once looked up, addresses are cached).
|
||||
.PP
|
||||
The
|
||||
.I Memory Maps
|
||||
table shows the process's memory mappings. In Linux 2.0.x and Solaris,
|
||||
the file names are not given. Anonymous mappings (allocated memory not
|
||||
bound to a file or device) are marked (anonymous).
|
||||
.PP
|
||||
The
|
||||
.I Files
|
||||
table shows the process's open files. In Linux 2.0.x, the files
|
||||
are given on the form [\c
|
||||
.I AABB\c
|
||||
]:\c
|
||||
.I inode,
|
||||
where
|
||||
.I AA
|
||||
and
|
||||
.I BB
|
||||
are the device major/minor numbers in hexadecimal.
|
||||
.PP
|
||||
The
|
||||
.I Environment
|
||||
table shows the process's environment variables. Note that this is the
|
||||
environment with which the process was started, not necessarily
|
||||
incorporating later changes. Some processes that modify their command
|
||||
line, notably sendmail(8) and ftpd(8), may use the environment space
|
||||
for this, showing nonsense in this table. Clicking on the field
|
||||
headings changes sorting order as usual. (On Solaris, only the first
|
||||
8K of the environment are shown. It will be fixed if it turns out to
|
||||
be a limitation.)
|
||||
.PP
|
||||
.I Find Parent
|
||||
and
|
||||
.I Find Children
|
||||
will select the parent/children of the selected processes, and center the
|
||||
table on the first of them.
|
||||
.I Find Descendants
|
||||
will select the tree of all children of the selected processes.
|
||||
.PP
|
||||
If
|
||||
.I Include Child Times
|
||||
is selected in the
|
||||
.I Options
|
||||
menu, the TIME field will show the sum of the CPU times used by the process
|
||||
and all of its children.
|
||||
.PP
|
||||
You can specify commands to be run on the selected processes by bringing
|
||||
up the
|
||||
.I Edit Commands...
|
||||
dialog. The "Description" of each command is what appears in the menu;
|
||||
the "Command Line" is a shell command (executed with /bin/sh). Before the
|
||||
command is passed to the shell, the following substitutions are made:
|
||||
.TP
|
||||
.B %p
|
||||
with the PID (Process ID) of the selected process
|
||||
.TP
|
||||
.B %c
|
||||
with the short command name of the process
|
||||
.TP
|
||||
.B %C
|
||||
with the complete command line of the process
|
||||
.TP
|
||||
.B %u
|
||||
with the name of the (real) owner of the process
|
||||
.TP
|
||||
.B %%
|
||||
with a literal '%'.
|
||||
.PP
|
||||
Any other % + letter combination is removed. The command line will be run
|
||||
once for each selected process (in unspecified order).
|
||||
.PP
|
||||
.SH KEYBOARD ACCELERATORS
|
||||
(valid in most contexts)
|
||||
.TP
|
||||
.B "Meta-W"
|
||||
Close the active window (except the main window)
|
||||
.TP
|
||||
.B "Q, Meta-Q"
|
||||
Quit qps.
|
||||
.TP
|
||||
.B "Space"
|
||||
Force an update of the displayed tables.
|
||||
.TP
|
||||
.B "Control-Z"
|
||||
Iconify qps.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.RI \-display \ display
|
||||
sets the X display (default is $DISPLAY)
|
||||
.TP
|
||||
.RI \-geometry \ geometry
|
||||
sets the geometry of the main window of qps
|
||||
.TP
|
||||
.RI \-background \ color
|
||||
sets the default background color and an application palette (light and dark
|
||||
shades are calculated). This doesn't work very well at the moment.
|
||||
.TP
|
||||
.RI \-foreground \ color
|
||||
sets the default foreground color. This has limited use as well.
|
||||
.TP
|
||||
.RI \-title \ title
|
||||
sets the application title (caption).
|
||||
.TP
|
||||
.RI \-style \ style
|
||||
sets the application GUI style. Possible styles are
|
||||
.I motif
|
||||
and
|
||||
.I windows.
|
||||
(If you are using Qt 2.x, the styles
|
||||
.I cde
|
||||
and
|
||||
.I platinum
|
||||
are also available.)
|
||||
.TP
|
||||
.RI \-font \ font
|
||||
sets the application font
|
||||
.TP
|
||||
.RI \-iconic
|
||||
starts the application iconified.
|
||||
.TP
|
||||
.RI \-version
|
||||
prints the version of qps and the Qt library, and exits.
|
||||
.TP
|
||||
.RI \-help
|
||||
prints a summary of command-line options and exits.
|
||||
.PP
|
||||
.SH ENVIRONMENT
|
||||
QPS_COLORS contains color specifications of comma-separated
|
||||
.I name\c
|
||||
:\c
|
||||
.I value
|
||||
pairs, where
|
||||
.I name
|
||||
is one of the following:
|
||||
.PP
|
||||
cpu-user, cpu-nice (Linux), cpu-sys, cpu-wait (Solaris), cpu-idle,
|
||||
mem-used, mem-buff, mem-cache, mem-free,
|
||||
swap-used, swap-free, swap-warn,
|
||||
load-bg, load-fg, load-lines,
|
||||
selection-bg, selection-fg
|
||||
.PP
|
||||
.I value
|
||||
is an X11 color name, either a symbolic name like "salmon" or an RGB color
|
||||
like #c5b769.
|
||||
.PP
|
||||
.SH FILES
|
||||
.br
|
||||
.DT
|
||||
.ta \w'$HOME/.qps-settings\ \ \ 'u
|
||||
/proc kernel information pseudo-filesystem
|
||||
.br
|
||||
$HOME/.qps-settings saved settings between invocations
|
||||
.br
|
||||
/etc/services port number to service name mapping (Linux)
|
||||
.br
|
||||
System.map kernel symbol map for WCHAN (Linux)
|
||||
.br
|
||||
.SH SEE ALSO
|
||||
ps(1), top(1), kill(1), free(1), renice(8), proc(5), sched_setscheduler(2)
|
||||
.SH AUTHOR
|
||||
.PP
|
||||
Mattias Engdegard (f91-men@nada.kth.se)
|
||||
.SH LICENSE
|
||||
qps is free software and may be redistributed under certain
|
||||
conditions. See the GNU General Public License for details.
|
||||
.PP
|
||||
.SH BUGS
|
||||
qps is too big and too slow.
|
||||
|
||||
The %CPU number isn't accurate at very short update intervals due to
|
||||
timer granularity.
|
||||
|
||||
The %WCPU field isn't recalculated when qps is iconified, so it might take
|
||||
a while to readjust when the window is deiconified again.
|
||||
|
||||
The WCHAN field doesn't show a function name if a process sleeps in a
|
||||
location outside those in System.map (for instance, in a kernel
|
||||
module), but a hex address instead. The function name can then be
|
||||
found in /proc/ksyms but has to be found by hand right now.
|
||||
|
||||
The CPU indicator in the status bar will display nonsense in SMP systems
|
||||
running Linux 2.0.x due to a kernel bug.
|
||||
|
||||
Adding/removing CPUs at runtime will probably confuse qps.
|
@ -1,21 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=qps
|
||||
GenericName=Qt process manager
|
||||
GenericName[ca]=Gestor de processos Qt
|
||||
GenericName[da]=Qt-proceshåndtering
|
||||
GenericName[lt]=Qt procesų tvarkytuvė
|
||||
GenericName[pl]=Menedżer procesów Qt
|
||||
Comment=Qt application to display and manage running processes
|
||||
Comment[ca]=Aplicació Qt per visualitzar i gestionar els processos en execució
|
||||
Comment[da]=Qt-program til at vise og håndtere kørende processer
|
||||
Comment[lt]=Qt programa, skirta rodyti ir tvarkyti vykdomus procesus
|
||||
Comment[pl]=Aplikacja Qt do wyświetlania i zarządzania uruchomionymi procesami
|
||||
Icon=qps
|
||||
Categories=System;
|
||||
TryExec=qps
|
||||
Exec=qps
|
||||
Terminal=false
|
||||
StartupNotify=false
|
||||
|
||||
#TRANSLATIONS_DIR=src/translations
|
@ -1,10 +0,0 @@
|
||||
<RCC>
|
||||
<qresource>
|
||||
<file>icon/letters.png</file>
|
||||
<file>icon/vista.png</file>
|
||||
<file>icon/vpointer.png</file>
|
||||
<file>icon/vcross.png</file>
|
||||
<file>icon/pause.png</file>
|
||||
<file>icon/superman.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,111 +0,0 @@
|
||||
set(SOURCES
|
||||
proc.cpp
|
||||
qpsapp.cpp
|
||||
qps.cpp
|
||||
screenshot.cpp
|
||||
pstable.cpp
|
||||
uidstr.cpp
|
||||
ttystr.cpp
|
||||
dialogs.cpp
|
||||
infobar.cpp
|
||||
fieldsel.cpp
|
||||
wchan.cpp
|
||||
prefs.cpp
|
||||
lookup.cpp
|
||||
details.cpp
|
||||
command.cpp
|
||||
commandutils.cpp
|
||||
commandmodel.cpp
|
||||
commanddialog.cpp
|
||||
checkboxdelegate.cpp
|
||||
execwindow.cpp
|
||||
watchcond.cpp
|
||||
listmodel.cpp
|
||||
watchdogdialog.cpp
|
||||
misc.cpp
|
||||
trayicon.cpp
|
||||
htable.cpp
|
||||
# htable2.cpp
|
||||
# pstable2.cpp
|
||||
qttableview.cpp
|
||||
)
|
||||
|
||||
SET(HEADERS
|
||||
qpsapp.h
|
||||
qps.h
|
||||
screenshot.h
|
||||
pstable.h
|
||||
dialogs.h
|
||||
fieldsel.h
|
||||
prefs.h
|
||||
infobar.h
|
||||
lookup.h
|
||||
details.h
|
||||
tablefield.h
|
||||
command.h
|
||||
commandutils.h
|
||||
commandmodel.h
|
||||
commanddialog.h
|
||||
checkboxdelegate.h
|
||||
execwindow.h
|
||||
watchcond.h
|
||||
listmodel.h
|
||||
watchdogdialog.h
|
||||
misc.h
|
||||
trayicon.h
|
||||
htable.h
|
||||
# htable2.h
|
||||
# pstable2.h
|
||||
qttableview.h
|
||||
)
|
||||
|
||||
set(UIS
|
||||
watchdog.ui
|
||||
message.ui
|
||||
)
|
||||
|
||||
set(RESOURCES "../qps.qrc")
|
||||
#-----------------------------------------------------------------------------
|
||||
# Translations
|
||||
#-----------------------------------------------------------------------------
|
||||
lxqt_translate_ts(QM_FILES
|
||||
UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS}
|
||||
SOURCES ${SOURCES} ${HEADERS} ${UIS}
|
||||
INSTALL_DIR "${QPS_TRANSLATIONS_DIR}"
|
||||
)
|
||||
|
||||
qt5_translation_loader(
|
||||
QM_LOADER
|
||||
"${QPS_TRANSLATIONS_DIR}"
|
||||
${PROJECT_NAME}
|
||||
)
|
||||
|
||||
lxqt_translate_desktop(DESKTOP_FILES
|
||||
SOURCES "${CMAKE_SOURCE_DIR}/qps.desktop.in"
|
||||
)
|
||||
#-----------------------------------------------------------------------------
|
||||
# End of translations
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
${SOURCES}
|
||||
${HEADERS}
|
||||
${UIS}
|
||||
${QM_FILES}
|
||||
${QM_LOADER}
|
||||
${DESKTOP_FILES}
|
||||
${RESOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
Qt5::Widgets
|
||||
Qt5::X11Extras
|
||||
Qt5::DBus
|
||||
)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
|
||||
install(FILES
|
||||
${DESKTOP_FILES}
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
|
||||
)
|
@ -1,110 +0,0 @@
|
||||
/*
|
||||
* checkboxdelegate.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 "checkboxdelegate.h"
|
||||
#include <QSpinBox>
|
||||
|
||||
checkBoxDelegate::checkBoxDelegate(QObject *parent) : QItemDelegate(parent) {}
|
||||
//! [0]
|
||||
|
||||
//! [1]
|
||||
QWidget *checkBoxDelegate::createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("createEditor\n");
|
||||
// return 0;
|
||||
if (index.column() == 1)
|
||||
{
|
||||
QSpinBox *editor = new QSpinBox(parent);
|
||||
editor->setMinimum(0);
|
||||
editor->setMaximum(100);
|
||||
return editor;
|
||||
}
|
||||
return QItemDelegate::createEditor(parent, option, index);
|
||||
return 0;
|
||||
}
|
||||
//! [1]
|
||||
|
||||
//! [2]
|
||||
void checkBoxDelegate::setEditorData(QWidget *editor,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("setEditorData\n");
|
||||
return;
|
||||
// if(index
|
||||
if (index.column() == 1)
|
||||
{
|
||||
int value = index.model()->data(index, Qt::EditRole).toInt();
|
||||
// int value=0;
|
||||
QSpinBox *spinBox = static_cast<QSpinBox *>(editor);
|
||||
spinBox->setValue(value);
|
||||
}
|
||||
}
|
||||
//! [2]
|
||||
|
||||
//! [3]
|
||||
void checkBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("setModelData\n");
|
||||
return;
|
||||
if (index.column() == 1)
|
||||
{
|
||||
QSpinBox *spinBox = static_cast<QSpinBox *>(editor);
|
||||
spinBox->interpretText();
|
||||
int value = spinBox->value();
|
||||
model->setData(index, value, Qt::EditRole);
|
||||
}
|
||||
}
|
||||
//! [3]
|
||||
|
||||
//! [4]
|
||||
void checkBoxDelegate::updateEditorGeometry(QWidget *editor,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("updateEditorGeometry\n");
|
||||
// if(index.column()==1)
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
//! [4]
|
||||
|
||||
void checkBoxDelegate::paint(QPainter *painter,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("paint\n");
|
||||
if (index.column() == 1)
|
||||
{
|
||||
QVariant value = 0; // index.model()->data(index, Qt::UserRole);
|
||||
/* if (!isSupportedType(value.type())) {
|
||||
QStyleOptionViewItem myOption = option;
|
||||
myOption.state &= ~QStyle::State_Enabled;
|
||||
QItemDelegate::paint(painter, myOption, index);
|
||||
return;
|
||||
} */
|
||||
}
|
||||
QItemDelegate::paint(painter, option, index);
|
||||
}
|
||||
// QSize QAbstractItemDelegate::sizeHint ( const QStyleOptionViewItem & option,
|
||||
// const QModelIndex & index ) const [pure virtual]
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* checkboxdelegate.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 CHECKBOXDELEGATE_H
|
||||
#define CHECKBOXDELEGATE_H
|
||||
|
||||
#include <QItemDelegate>
|
||||
class checkBoxDelegate : public QItemDelegate
|
||||
// class checkBoxDelegate : public QAbstractItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
checkBoxDelegate(QObject *parent = 0);
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const;
|
||||
void updateEditorGeometry(QWidget *editor,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
};
|
||||
|
||||
#endif // CHECKBOXDELEGATE_H
|
@ -1,309 +0,0 @@
|
||||
/*
|
||||
* command.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "command.h"
|
||||
#include "commandutils.h"
|
||||
#include "checkboxdelegate.h"
|
||||
#include "watchcond.h"
|
||||
#include "execwindow.h"
|
||||
#include "listmodel.h"
|
||||
#include "watchdogdialog.h"
|
||||
#include "qps.h"
|
||||
#include "proc.h"
|
||||
#include "uidstr.h"
|
||||
#include "dialogs.h"
|
||||
|
||||
extern Qps *qps;
|
||||
extern ControlBar *controlbar;
|
||||
extern QList<Command *> commands;
|
||||
|
||||
Command::Command(QString n, QString cmd, bool flag)
|
||||
{
|
||||
// printf("Command init\n");
|
||||
name = n;
|
||||
cmdline = cmd;
|
||||
toolbar = false;
|
||||
popup = false;
|
||||
|
||||
// toolbutton=new CommandButton(controlbar,name);
|
||||
// toolbutton->hide();
|
||||
|
||||
////toolbutton->setTextLabel (name) ;
|
||||
////toolbutton->setUsesTextLabel ( true );
|
||||
/// toolbutton->setAutoRaise(true);
|
||||
// QObject::connect(toolbutton, SIGNAL(clicked()),toolbutton,
|
||||
// SLOT(exec_command()));
|
||||
}
|
||||
|
||||
Command::~Command()
|
||||
{
|
||||
// toolbutton->hide();
|
||||
// delete toolbutton;
|
||||
}
|
||||
|
||||
QString Command::getString()
|
||||
{
|
||||
QString str;
|
||||
str.append(name);
|
||||
str.append(",");
|
||||
str.append(cmdline);
|
||||
return str;
|
||||
}
|
||||
|
||||
void Command::putString(QString str)
|
||||
{
|
||||
int idx = str.indexOf(",");
|
||||
// idx=str.indexOf(",",idx);
|
||||
name = str.mid(0, idx);
|
||||
cmdline = str.mid(idx + 1, str.size());
|
||||
}
|
||||
|
||||
// dirty code...
|
||||
// Description : this command need "select process"
|
||||
bool Command::IsNeedProc()
|
||||
{
|
||||
int i, len;
|
||||
len = cmdline.length();
|
||||
|
||||
for (i = 0; i < len;)
|
||||
{
|
||||
int v = cmdline.indexOf('%', i);
|
||||
if (v < 0)
|
||||
break;
|
||||
if (++v >= len)
|
||||
break;
|
||||
|
||||
char c = cmdline[v].cell(); //.toLatin1().data();
|
||||
switch (c)
|
||||
{
|
||||
case 'p':
|
||||
case 'c':
|
||||
case 'C':
|
||||
case 'u':
|
||||
if (cmdline.indexOf("update", v) == v)
|
||||
{
|
||||
v += 5;
|
||||
break;
|
||||
}
|
||||
// printf("true\n");
|
||||
return true;
|
||||
default:
|
||||
;
|
||||
}
|
||||
i = v + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString substString(QString str, Procinfo *p)
|
||||
{
|
||||
QString s;
|
||||
int len = str.length();
|
||||
for (int i = 0;;)
|
||||
{
|
||||
int v = str.indexOf('%', i);
|
||||
if (v < 0)
|
||||
{
|
||||
s.append(str.right(len - i));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.append(str.mid(i, v - i));
|
||||
if (++v >= len)
|
||||
break;
|
||||
QString subst;
|
||||
// need change to LOCALE(by fasthyun@magicn.com)
|
||||
char c = str[v].cell();
|
||||
switch (c)
|
||||
{
|
||||
case 'p':
|
||||
subst.setNum(p->pid);
|
||||
break;
|
||||
case 'c':
|
||||
subst = p->command;
|
||||
break;
|
||||
case 'C':
|
||||
subst = p->cmdline;
|
||||
break;
|
||||
case 'u':
|
||||
subst = Uidstr::userName(p->uid);
|
||||
break;
|
||||
case '%':
|
||||
subst = "%";
|
||||
break;
|
||||
}
|
||||
s.append(subst);
|
||||
i = v + 1;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// execute command
|
||||
void Command::call(Procinfo *p)
|
||||
{
|
||||
QString s;
|
||||
QString msg;
|
||||
|
||||
printf("called !\n");
|
||||
int len = cmdline.length();
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
if (cmdline == "%update")
|
||||
{
|
||||
qps->refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
s = cmdline;
|
||||
}
|
||||
else
|
||||
s = substString(cmdline, p);
|
||||
|
||||
int ret = system(s.toLatin1().data()); ///
|
||||
/*
|
||||
pr=new QProcess; // leak?
|
||||
if(!wc->command.isEmpty()) //conflict pid's command
|
||||
{
|
||||
pr->start(wc->command); // thread run, if
|
||||
null then
|
||||
segfault occurs. ?
|
||||
}
|
||||
|
||||
connect(pr, SIGNAL(started()), this, SLOT(cmd_started()));
|
||||
connect(pr, SIGNAL(finished ( int , QProcess::ExitStatus
|
||||
)),this,SLOT(cmd_finished ( int , QProcess::ExitStatus )));
|
||||
connect(pr, SIGNAL(error ( QProcess::ProcessError )),this,
|
||||
SLOT(cmd_error(QProcess::ProcessError)));
|
||||
*/
|
||||
|
||||
if (ret)
|
||||
{
|
||||
msg = tr( "The command:\n\n" );
|
||||
msg.append(s);
|
||||
if (ret == -1)
|
||||
{
|
||||
msg.append( tr( "\n\nfailed with the error:\n\n" ) );
|
||||
const char *e = static_cast< const char * >( 0 );
|
||||
msg.append( ( errno == EAGAIN )
|
||||
? tr( "Too many processes" )
|
||||
: ( ( e = strerror( errno ) ) )
|
||||
? QString::fromLocal8Bit( e )
|
||||
: tr( "Unknown error" ) );
|
||||
}
|
||||
else if (ret & 0xff)
|
||||
{
|
||||
msg.append("\n\nwas terminated by signal ");
|
||||
msg.append(QString().setNum(ret & 0xff));
|
||||
msg.append(".");
|
||||
}
|
||||
else if (ret == 0x7f00)
|
||||
{
|
||||
msg.append( tr( "\n\ncould not be executed because it was not "
|
||||
"found,\nor you did not have execute permission." ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.append( tr( "\n\nexited with status " ) );
|
||||
msg.append(QString().setNum(ret >> 8));
|
||||
msg.append(".");
|
||||
}
|
||||
QMessageBox::warning(0, tr( "Command Failed" ), msg);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
QList<watchCond *> watchlist;
|
||||
|
||||
extern WatchdogDialog *watchdogDialog;
|
||||
|
||||
// except threads, already running process
|
||||
void watchdog_check_if_start(QString cmd, Procinfo *pi)
|
||||
{
|
||||
/// printf("cmd=%s\n", cmd.toLatin1().data());
|
||||
for (int i = 0; i < watchlist.size(); ++i)
|
||||
{
|
||||
watchCond *wc = watchlist.at(i);
|
||||
if (wc->enable == false)
|
||||
continue;
|
||||
if (wc->cond == WATCH_PROCESS_START)
|
||||
if (wc->procname == cmd)
|
||||
{
|
||||
// printf("Watchdog: start\n");
|
||||
if (!pi->isThread())
|
||||
// ExecWindow *mw=new
|
||||
// ExecWindow(wc->message,wc->command,pi->pid,pi->command);
|
||||
// // leak
|
||||
ExecWindow *mw =
|
||||
new ExecWindow(wc, pi->pid, pi->command); // leak
|
||||
|
||||
// note :
|
||||
// 1.system("./loop"); //block !!
|
||||
// 2.pr.setEnvironment(QProcess::systemEnvironment
|
||||
//());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void watchdog_check_if_finish(QString cmd, Procinfo *pi)
|
||||
{
|
||||
for (int i = 0; i < watchlist.size(); ++i)
|
||||
{
|
||||
watchCond *w = watchlist.at(i);
|
||||
if (w->enable == false)
|
||||
continue;
|
||||
if (w->cond == WATCH_PROCESS_FINISH)
|
||||
{
|
||||
if (w->procname == cmd)
|
||||
{
|
||||
// printf("Watchdog: finish\n");
|
||||
if (!pi->isThread())
|
||||
// if(pi->pid==pi->tgid) // not a thread
|
||||
// !
|
||||
ExecWindow *mw =
|
||||
new ExecWindow(w, pi->pid, pi->command); // leak
|
||||
// ExecWindow *mw=new
|
||||
// ExecWindow(w->message,w->command,pi->pid,pi->command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTYET
|
||||
void watchdog_syscpu(int cpu)
|
||||
{
|
||||
// printf("Watchdog: watchdog_syscpu\n");
|
||||
// if(watchdogDialog->flag_ifsyscpu)
|
||||
{
|
||||
// if(cpu> watchdogDialog->syscpu_over)
|
||||
// printf("Watchdog: event %d%\n",cpu);
|
||||
// QMessageBox::warning(0, "Watchdog", "aaaaa"); //blocking
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* command.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 COMMAND_H
|
||||
#define COMMAND_H
|
||||
|
||||
#ifndef USING_PCH
|
||||
#include <QDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QToolButton>
|
||||
#include <QPushButton>
|
||||
#include <QListView>
|
||||
#endif
|
||||
|
||||
#include "proc.h"
|
||||
#include "misc.h"
|
||||
|
||||
class ListModel;
|
||||
|
||||
class Command
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Command)
|
||||
public:
|
||||
Command(){};
|
||||
Command(QString n, QString cmd, bool toolbar = false);
|
||||
~Command();
|
||||
void call(Procinfo *p);
|
||||
bool IsNeedProc();
|
||||
QString getString();
|
||||
void putString(QString str);
|
||||
|
||||
// CommandButton *toolbutton;
|
||||
|
||||
QString name; // appears in the menu
|
||||
QString cmdline; // may contain variables (%p etc)
|
||||
int menu; // index in menu
|
||||
bool toolbar;
|
||||
bool popup;
|
||||
};
|
||||
|
||||
#endif // COMMAND_H
|
@ -1,273 +0,0 @@
|
||||
/*
|
||||
* commanddialog.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 "commanddialog.h"
|
||||
|
||||
#include "qps.h"
|
||||
#include "command.h"
|
||||
#include "commandutils.h"
|
||||
#include "commandmodel.h"
|
||||
|
||||
#include <QListView>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QModelIndex>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFrame>
|
||||
|
||||
extern QList<Command *> commands;
|
||||
|
||||
CommandDialog::CommandDialog()
|
||||
{
|
||||
setWindowTitle( tr( "Edit Commands 0.1 alpha" ) );
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
|
||||
QHBoxLayout *hbox = new QHBoxLayout(this); // TOP
|
||||
CommandModel *cmdModel = new CommandModel(this);
|
||||
// item list
|
||||
listview = new QListView(this);
|
||||
listview->setModel(cmdModel);
|
||||
listview->setFixedWidth(fontMetrics().width("0") * 16);
|
||||
hbox->addWidget(listview);
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout; // TOP-> RIGHT
|
||||
hbox->addLayout(vbox);
|
||||
|
||||
QHBoxLayout *h1 = new QHBoxLayout;
|
||||
vbox->addLayout(h1);
|
||||
QLabel *l1 = new QLabel( tr( "Name:" ), this);
|
||||
h1->addWidget(l1);
|
||||
name = new QLineEdit(this);
|
||||
name->setMinimumWidth(170);
|
||||
name->setText("");
|
||||
h1->addWidget(name);
|
||||
|
||||
QHBoxLayout *hbox2 = new QHBoxLayout;
|
||||
vbox->addLayout(hbox2);
|
||||
// qcheck1 = new QCheckBox (this);
|
||||
// qcheck1->setText("Toolbar");
|
||||
// qcheck1->setEnabled(false);
|
||||
// hbox2->addWidget(qcheck1);
|
||||
if (0)
|
||||
{
|
||||
qcheck2 = new QCheckBox(this);
|
||||
qcheck2->setText( tr( "Popup" ) );
|
||||
qcheck2->setEnabled(false);
|
||||
hbox2->addWidget(qcheck2);
|
||||
}
|
||||
|
||||
QLabel *l2 = new QLabel( tr( "Command Line:" ), this);
|
||||
l2->setFixedHeight(l2->sizeHint().height());
|
||||
l2->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
||||
vbox->addWidget(l2);
|
||||
|
||||
cmdline = new QLineEdit(this);
|
||||
cmdline->setFixedHeight(cmdline->sizeHint().height());
|
||||
cmdline->setMinimumWidth(250);
|
||||
cmdline->setText("");
|
||||
vbox->addWidget(cmdline);
|
||||
|
||||
QLabel *l3 = new QLabel( tr( "Substitutions:\n"
|
||||
"%p\tPID\n"
|
||||
"%c\tCOMMAND\n%C\tCMDLINE\n%u\tUSER\n"
|
||||
"%%\t%\n"
|
||||
"\n" ),
|
||||
this);
|
||||
|
||||
l3->setFrameStyle(QFrame::Panel);
|
||||
l3->setFrameShadow(QFrame::Sunken);
|
||||
l3->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); // | Qt::ExpandTabs);
|
||||
vbox->addWidget(l3);
|
||||
|
||||
QHBoxLayout *hl = new QHBoxLayout;
|
||||
vbox->addLayout(hl);
|
||||
new0 = new QPushButton( tr( "New..." ), this);
|
||||
hl->addWidget(new0);
|
||||
add = new QPushButton( tr( "Add..." ), this);
|
||||
hl->addWidget(add);
|
||||
del = new QPushButton( tr( "Delete" ), this);
|
||||
hl->addWidget(del);
|
||||
button_ok = new QPushButton( tr( "Close" ), this);
|
||||
hl->addWidget(button_ok);
|
||||
|
||||
connect(listview, SIGNAL(clicked(const QModelIndex &)),
|
||||
SLOT(set_select(const QModelIndex &)));
|
||||
connect(new0, SIGNAL(clicked()), SLOT(new_cmd()));
|
||||
connect(add, SIGNAL(clicked()), SLOT(add_new()));
|
||||
connect(del, SIGNAL(clicked()), SLOT(del_current()));
|
||||
connect(button_ok, SIGNAL(clicked()), SLOT(close()));
|
||||
connect(name, SIGNAL(textChanged(const QString &)),
|
||||
SLOT(event_name_midified(const QString &)));
|
||||
connect(cmdline, SIGNAL(textChanged(const QString &)),
|
||||
SLOT(event_cmd_modified()));
|
||||
// connect(qcheck1, SIGNAL(toggled ( bool ) ),
|
||||
// SLOT(event_toolbar_checked(bool
|
||||
// )));
|
||||
|
||||
TBloon *bloon = new TBloon(this);
|
||||
/// for(int i = 0; i < commands.size(); i++)
|
||||
/// listview->insertItem(commands[i]->name);
|
||||
/// listview->addItem(commands[i]->name);
|
||||
/// vbox->freeze();
|
||||
}
|
||||
|
||||
// DEL
|
||||
void CommandDialog::event_toolbar_checked(bool on)
|
||||
{
|
||||
// name->text();
|
||||
int idx = find_command(name->text());
|
||||
if (idx >= 0)
|
||||
commands[idx]->toolbar = on;
|
||||
|
||||
/// controlbar->update_bar();
|
||||
}
|
||||
|
||||
void CommandDialog::event_name_midified(const QString &new_name)
|
||||
{
|
||||
int idx;
|
||||
FUNC_START;
|
||||
// printf("debug:changed_description() start \n");
|
||||
idx = find_command(new_name);
|
||||
if (idx == -1)
|
||||
{
|
||||
add->setEnabled(1);
|
||||
}
|
||||
else
|
||||
add->setEnabled(0);
|
||||
|
||||
// printf("debug:changed_description() end \n");
|
||||
}
|
||||
|
||||
// if modified then call this function
|
||||
void CommandDialog::event_cmd_modified()
|
||||
{
|
||||
int idx;
|
||||
// if(name->text()=="") return;
|
||||
if (find_command(name->text()) < 0)
|
||||
return;
|
||||
|
||||
idx = find_command(name->text());
|
||||
|
||||
commands[idx]->name = name->text();
|
||||
commands[idx]->cmdline = cmdline->text();
|
||||
emit command_change();
|
||||
}
|
||||
|
||||
// set the description,cmdline from current selected QListBox item
|
||||
void CommandDialog::set_buttons(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
{
|
||||
new_cmd();
|
||||
return;
|
||||
}
|
||||
/*
|
||||
//bool sel = (lb->currentRow() >= 0);
|
||||
Command *c ;
|
||||
if(sel)
|
||||
//c = commands[find_command(lb->currentText())];
|
||||
c = commands[find_command(lb->currentText())];
|
||||
else
|
||||
c = commands[find_command(lb->text(index))];
|
||||
name->setText(c->name);
|
||||
cmdline->setText(c->cmdline);
|
||||
del->setEnabled(sel);
|
||||
*/
|
||||
}
|
||||
|
||||
// called when clicked !
|
||||
void CommandDialog::set_select(const QModelIndex &index)
|
||||
{
|
||||
Command *c =
|
||||
static_cast<Command *>(index.internalPointer()); // never Null ?
|
||||
/*
|
||||
if (item==NULL) return; // important
|
||||
Command *c = commands[find_command(item->text())];
|
||||
*/
|
||||
name->setText(c->name);
|
||||
cmdline->setText(c->cmdline);
|
||||
// DEL qcheck1->setChecked(c->toolbar);
|
||||
// qcheck2->setChecked(c->popup);
|
||||
|
||||
// bool sel = (listview->currentItem() >= 0);
|
||||
if (c->name == "Update")
|
||||
del->setEnabled(false);
|
||||
else
|
||||
del->setEnabled(true);
|
||||
}
|
||||
|
||||
void CommandDialog::reset()
|
||||
{
|
||||
listview->reset();
|
||||
name->setText("");
|
||||
cmdline->setText("");
|
||||
add->setText( tr( "Add..." ) );
|
||||
add->setEnabled(0);
|
||||
button_ok->setEnabled(1);
|
||||
listview->clearSelection();
|
||||
}
|
||||
|
||||
void CommandDialog::new_cmd()
|
||||
{
|
||||
reset();
|
||||
add->setEnabled(1);
|
||||
name->setFocus();
|
||||
}
|
||||
|
||||
void CommandDialog::add_new()
|
||||
{
|
||||
if (name->text() == "")
|
||||
return;
|
||||
|
||||
// commands.add(new Command(name->text(),
|
||||
// cmdline->text(),qcheck1->isChecked
|
||||
// () ));
|
||||
commands.append(new Command(name->text(), cmdline->text(), false));
|
||||
check_commandAll(); // TEMP
|
||||
|
||||
listview->reset();
|
||||
add->setEnabled(0);
|
||||
del->setEnabled(0);
|
||||
button_ok->setEnabled(1);
|
||||
|
||||
emit command_change(); // notice to refresh Qps::make_command_menu()
|
||||
// control_bar->update_bar(); // ** important
|
||||
}
|
||||
|
||||
void CommandDialog::del_current()
|
||||
{
|
||||
int idx = find_command(name->text());
|
||||
if (idx >= 0)
|
||||
{
|
||||
// printf("del\n");
|
||||
commands.removeAt(idx);
|
||||
listview->reset(); // listview->reset();
|
||||
// control_bar->update_bar();
|
||||
emit command_change(); // notice to refresh menu_commands
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* commanddialog.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 COMMANDDIALOG_H
|
||||
#define COMMANDDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QListView;
|
||||
class QPushButton;
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class QModelIndex;
|
||||
|
||||
// class CommandDialog : public QWidget
|
||||
class CommandDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CommandDialog();
|
||||
|
||||
signals:
|
||||
void command_change();
|
||||
|
||||
protected slots:
|
||||
void new_cmd();
|
||||
void add_new();
|
||||
void del_current();
|
||||
void set_buttons(int);
|
||||
void reset();
|
||||
void set_select(const QModelIndex &);
|
||||
void event_name_midified(const QString &new_name);
|
||||
void event_cmd_modified();
|
||||
void event_toolbar_checked(bool);
|
||||
|
||||
private:
|
||||
QListView *listview;
|
||||
QPushButton *new0, *add, *del, *edit, *button_ok;
|
||||
QLineEdit *name, *cmdline;
|
||||
QCheckBox *qcheck1;
|
||||
QCheckBox *qcheck2;
|
||||
};
|
||||
|
||||
#endif // COMMANDDIALOG_H
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* commandmodel.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 "commandmodel.h"
|
||||
#include "command.h"
|
||||
|
||||
extern QList<Command *> commands;
|
||||
|
||||
CommandModel::CommandModel(QObject *parent) {}
|
||||
CommandModel::~CommandModel() {}
|
||||
|
||||
QModelIndex CommandModel::index(int row, int column,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
if (row >= 0 and column >= 0 and row < commands.size() and column < 1)
|
||||
{
|
||||
Command *cmd = commands[row];
|
||||
return createIndex(row, column, cmd);
|
||||
}
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
QModelIndex CommandModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
int CommandModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return commands.size();
|
||||
}
|
||||
// int CommandModel::columnCount(const QModelIndex &parent) const{return 1;};
|
||||
QVariant CommandModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
Command *cmd = static_cast<Command *>(index.internalPointer());
|
||||
return cmd->name;
|
||||
}
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
void CommandModel::update() {} // TEMP
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* commandmodel.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 <QAbstractItemModel>
|
||||
|
||||
class CommandModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CommandModel(QObject *parent = 0);
|
||||
~CommandModel();
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||
QModelIndex parent(const QModelIndex &child) const;
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
int columnCount(const QModelIndex &parent) const { return 1; };
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
// Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
void update(); // TEMP
|
||||
};
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* commandutils.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 "commandutils.h"
|
||||
#include <command.h>
|
||||
|
||||
extern QList<Command *> commands;
|
||||
|
||||
int find_command(QString s)
|
||||
{
|
||||
for (int i = 0; i < commands.size(); i++)
|
||||
if (s == commands[i]->name)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// DEL has "&" end of the string ?
|
||||
bool hasAmpersand(QString cmdline)
|
||||
{
|
||||
QString str;
|
||||
int len;
|
||||
str = cmdline.simplified();
|
||||
|
||||
if (str == "%update")
|
||||
return true; // internal command
|
||||
|
||||
len = str.length();
|
||||
if (str[len - 1] == '&')
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void check_command(int idx) {}
|
||||
|
||||
//
|
||||
void check_commandAll()
|
||||
{
|
||||
int i, idx;
|
||||
|
||||
return;
|
||||
for (int i = 0; i < commands.size(); i++)
|
||||
{
|
||||
if (hasAmpersand(commands[i]->cmdline) == false)
|
||||
commands[i]->cmdline.append("&");
|
||||
}
|
||||
}
|
||||
|
||||
// after read ~/.qpsrc
|
||||
void add_default_command()
|
||||
{
|
||||
|
||||
int idx;
|
||||
|
||||
/*
|
||||
idx=find_command("Update");
|
||||
if (idx>=0)
|
||||
commands[idx]->cmdline="%update";
|
||||
else
|
||||
commands.add(new Command("Update","%update",true));
|
||||
*/
|
||||
|
||||
/*
|
||||
* PAUSED
|
||||
idx=find_command("Quit");
|
||||
if (idx>=0)
|
||||
commands[idx]->cmdline="killall qps";
|
||||
else commands.add(new Command("Quit","killall qps",false));
|
||||
*/
|
||||
|
||||
// check_commandAll(); DEL?
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* commandutils.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 COMMANDUTILS_H
|
||||
#define COMMANDUTILS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
int find_command(QString s);
|
||||
bool hasAmpersand(QString cmdline);
|
||||
void check_command(int idx);
|
||||
void check_commandAll();
|
||||
void add_default_command();
|
||||
|
||||
#endif // COMMANDUTILS_H
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* config.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#if defined(__linux__)
|
||||
#define LINUX
|
||||
|
||||
#elif defined(sun) && defined(__SVR4)
|
||||
#define SOLARIS
|
||||
|
||||
#else
|
||||
#error Only Linux >= 2.0 and Solaris >= 2.6 supported, sorry
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_H
|
@ -1,757 +0,0 @@
|
||||
/*
|
||||
* details.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "details.h"
|
||||
//#include "proc.h" // static flag
|
||||
#include "qps.h" // static flag
|
||||
Details::Details(Procinfo *p, Proc *proc) : QWidget(0)
|
||||
{
|
||||
pi = p;
|
||||
pi->detail = this;
|
||||
pr = proc;
|
||||
// printf("pi=%x\n",pi);
|
||||
setWindowTitle( tr( "Process %1 ( %2 ) - details" ).arg( pi->pid )
|
||||
.arg( pi->command ) );
|
||||
|
||||
tbar = new QTabWidget(this);
|
||||
// tbar->setMargin(5);
|
||||
|
||||
// if(pi->fd_files) //if(pi->fd_files->size())
|
||||
if (pi->read_fds())
|
||||
{
|
||||
tbar->addTab(new Files(this), tr( "Files" ) );
|
||||
|
||||
// if(pi->read_fds()) // create sock_inodes
|
||||
#ifdef LINUX
|
||||
// printf(" pi->socks.size=%d\n", p->sock_inodes->size() );
|
||||
// this means if a process dont have socket then
|
||||
// no socket pane show in Detail dialog.
|
||||
// Procinfo::read_sockets();
|
||||
if (pi->sock_inodes.size() != 0)
|
||||
tbar->addTab(new Sockets(this), tr( "Sockets" ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
if (pi->read_maps())
|
||||
tbar->addTab(new Maps(this), tr( "Memory Maps" ) );
|
||||
if (pi->read_environ())
|
||||
tbar->addTab(new Environ(this), tr( "Environment" ) );
|
||||
tbar->addTab(new AllFields(this), tr( "All Fields" ) );
|
||||
|
||||
tbar->adjustSize();
|
||||
QSize s0 = tbar->sizeHint();
|
||||
if (s0.width() > 800)
|
||||
s0.setWidth(800);
|
||||
resize(s0);
|
||||
}
|
||||
|
||||
Details::~Details()
|
||||
{
|
||||
// printf("~Details()\n");
|
||||
if (pi)
|
||||
pi->detail = 0;
|
||||
int i;
|
||||
/// for(i=0;i<tbar->count();i++) delete tbar->page(i);
|
||||
delete tbar;
|
||||
}
|
||||
|
||||
void Details::set_procinfo(Procinfo *p)
|
||||
{
|
||||
// printf("p=%x, pi=%x\n",p,pi);
|
||||
}
|
||||
void Details::refresh()
|
||||
{
|
||||
printf("Details::refresh()\n");
|
||||
QWidget *w = NULL; // tbar->currentPage ();
|
||||
// QWidget *w= tbar->currentPage ();
|
||||
if (w != NULL)
|
||||
{
|
||||
/// printf("refresh()\n");
|
||||
((SimpleTable *)w)->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void Details::process_gone()
|
||||
{
|
||||
/// printf("process_gone() *******************************\n");
|
||||
pi = 0;
|
||||
// for now, we just close the window. Another possibility would be
|
||||
// to leave it with a "process terminated" note.
|
||||
close();
|
||||
}
|
||||
|
||||
// slot: react to changes in preferences
|
||||
void Details::config_change() { return; }
|
||||
|
||||
void Details::resizeEvent(QResizeEvent *s)
|
||||
{
|
||||
tbar->resize(s->size()); //**
|
||||
QWidget::resizeEvent(s);
|
||||
}
|
||||
|
||||
// user closed the window (via window manager)
|
||||
void Details::closeEvent(QCloseEvent *) { emit closed(this); }
|
||||
|
||||
SimpleTable::SimpleTable(QWidget *parent, int nfields, TableField *f,
|
||||
int options)
|
||||
: HeadedTable(parent, options), fields(f)
|
||||
{
|
||||
detail = (Details *)parent;
|
||||
setNumCols(nfields);
|
||||
}
|
||||
|
||||
QSize SimpleTable::sizeHint() const
|
||||
{
|
||||
/// return QSize(tableWidth(), 300);
|
||||
return QSize(480, 300);
|
||||
}
|
||||
|
||||
QString SimpleTable::title(int col) { return fields[col].name; }
|
||||
|
||||
int SimpleTable::colWidth(int col) { return fields[col].width; }
|
||||
|
||||
inline int SimpleTable::alignment(int col) { return fields[col].align; }
|
||||
|
||||
int SimpleTable::leftGap(int col) { return fields[col].gap; }
|
||||
|
||||
QString SimpleTable::tipText(int col) { return fields[col].tooltip; }
|
||||
|
||||
#ifdef LINUX
|
||||
|
||||
// declaration of static members
|
||||
bool Sockets::have_services = false;
|
||||
QHash<int, char *> Sockets::servdict;
|
||||
Lookup *Sockets::lookup = 0;
|
||||
|
||||
TableField *Sockets::fields()
|
||||
{
|
||||
static QVector< TableField > fields( { { tr( "Fd" ), 5, 8, Qt::AlignRight, tr( "File descriptor" ) }
|
||||
, { tr( "Proto" ), 4, 8, Qt::AlignLeft, tr( "Protocol (TCP or UDP)" ) }
|
||||
, { tr( "Recv-Q" ), 9, 8, Qt::AlignRight, tr( "Bytes in receive queue" ) }
|
||||
, { tr( "Send-Q" ), 9, 8, Qt::AlignRight, tr( "Bytes in send queue" ) }
|
||||
, { tr( "Local Addr" ), -1, 8, Qt::AlignLeft, tr( "Local IP address" ) }
|
||||
, { tr( "Port" ), 6, 8, Qt::AlignLeft, tr( "Local port" ) }
|
||||
, { tr( "Remote Addr" ), -1, 8, Qt::AlignLeft, tr( "Remote IP address" ) }
|
||||
, { tr( "Port" ), 6, 8, Qt::AlignLeft, tr( "Remote port" ) }
|
||||
, { tr( "State" ), 18, 8, Qt::AlignLeft, tr( "Connection state" ) } } );
|
||||
return fields.data();
|
||||
}
|
||||
|
||||
Sockets::Sockets(QWidget *parent) : SimpleTable(parent, SOCKFIELDS, fields() )
|
||||
{
|
||||
if (!lookup)
|
||||
lookup = new Lookup();
|
||||
connect(lookup, SIGNAL(resolved(unsigned)),
|
||||
SLOT(update_hostname(unsigned)));
|
||||
doing_lookup = Qps::hostname_lookup;
|
||||
refresh();
|
||||
// compute total width = window width
|
||||
int totw = 400;
|
||||
// for(int i = 0; i < SOCKFIELDS; i++)
|
||||
// totw += actualColWidth(i);
|
||||
resize(totw, 200);
|
||||
}
|
||||
|
||||
Sockets::~Sockets()
|
||||
{
|
||||
// why seg?
|
||||
// if(lookup) delete lookup;
|
||||
}
|
||||
|
||||
static const char *tcp_states[] = {
|
||||
"ESTABLISHED", // 1
|
||||
"SYN_SENT", "SYN_RECV", "FIN_WAIT1", "FIN_WAIT2", "TIME_WAIT",
|
||||
"CLOSE", "CLOSE_WAIT", "LAST_ACK", "LISTEN",
|
||||
"CLOSING" // 11
|
||||
};
|
||||
|
||||
static inline const char *tcp_state_name(int st)
|
||||
{
|
||||
return (st < 1 || st > 11) ? "UNKNOWN" : tcp_states[st - 1];
|
||||
}
|
||||
|
||||
QString Sockets::text(int row, int col)
|
||||
{
|
||||
Procinfo *p = procinfo();
|
||||
if (p->sock_inodes.size() == 0)
|
||||
refresh_sockets();
|
||||
SockInode *sock_ino = p->sock_inodes[row];
|
||||
// SockInode *sock_ino = p->sock_inodes[row];
|
||||
Sockinfo *si = p->proc->socks.value(sock_ino->inode, NULL);
|
||||
if (!si)
|
||||
return ""; // process gone, return empty string
|
||||
|
||||
QString s;
|
||||
switch (col)
|
||||
{
|
||||
case FD:
|
||||
s.setNum(sock_ino->fd);
|
||||
break;
|
||||
|
||||
case PROTO:
|
||||
s = (si->proto == Sockinfo::TCP) ? "tcp" : "udp";
|
||||
break;
|
||||
|
||||
case RECVQ:
|
||||
s.setNum(si->rx_queue);
|
||||
break;
|
||||
|
||||
case SENDQ:
|
||||
s.setNum(si->tx_queue);
|
||||
break;
|
||||
|
||||
case LOCALADDR:
|
||||
s = ipAddr(si->local_addr);
|
||||
break;
|
||||
|
||||
case LOCALPORT:
|
||||
if (Qps::service_lookup)
|
||||
{
|
||||
const char *serv = servname(si->local_port);
|
||||
if (serv)
|
||||
{
|
||||
s = serv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
s.setNum(si->local_port);
|
||||
break;
|
||||
|
||||
case REMOTEADDR:
|
||||
s = ipAddr(si->rem_addr);
|
||||
break;
|
||||
|
||||
case REMOTEPORT:
|
||||
if (Qps::service_lookup)
|
||||
{
|
||||
const char *serv = servname(si->rem_port);
|
||||
if (serv)
|
||||
{
|
||||
s = serv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
s.setNum(si->rem_port);
|
||||
break;
|
||||
|
||||
case STATE:
|
||||
s = tcp_state_name(si->st);
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
QString Sockets::ipAddr(unsigned addr)
|
||||
{
|
||||
unsigned a = htonl(addr);
|
||||
QString s;
|
||||
if (doing_lookup)
|
||||
{
|
||||
s = lookup->hostname(addr);
|
||||
if (s.isNull())
|
||||
{
|
||||
s.sprintf("(%d.%d.%d.%d)", (a >> 24) & 0xff, (a >> 16) & 0xff,
|
||||
(a >> 8) & 0xff, a & 0xff);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a == 0)
|
||||
s = "*";
|
||||
else
|
||||
s.sprintf("%d.%d.%d.%d", (a >> 24) & 0xff, (a >> 16) & 0xff,
|
||||
(a >> 8) & 0xff, a & 0xff);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void Sockets::refresh_window()
|
||||
{
|
||||
Procinfo *p = procinfo();
|
||||
if (!p)
|
||||
return;
|
||||
int rows = p->sock_inodes.size();
|
||||
/// resetWidths();
|
||||
setNumRows(rows);
|
||||
setNumCols(SOCKFIELDS);
|
||||
/// repaint_changed();
|
||||
repaintAll();
|
||||
}
|
||||
|
||||
void Sockets::refresh()
|
||||
{
|
||||
if (refresh_sockets())
|
||||
refresh_window();
|
||||
}
|
||||
|
||||
// return true if sockets could be read successfully, false otherwise
|
||||
bool Sockets::refresh_sockets()
|
||||
{
|
||||
// Procinfo::read_sockets();
|
||||
return procinfo()->read_fds();
|
||||
}
|
||||
|
||||
// react to changes in preferences
|
||||
void Sockets::config_change()
|
||||
{
|
||||
if (doing_lookup != Qps::hostname_lookup)
|
||||
{
|
||||
doing_lookup = Qps::hostname_lookup;
|
||||
////setNumCols(SOCKFIELDS);
|
||||
// for(int col = 0; col < SOCKFIELDS; col++)
|
||||
// widthChanged(col);
|
||||
////updateTableSize();
|
||||
////repaintAll();
|
||||
}
|
||||
}
|
||||
|
||||
// slot: called when a host name has been looked up
|
||||
void Sockets::update_hostname(unsigned addr)
|
||||
{
|
||||
// if(widthChanged(REMOTEADDR) || widthChanged(LOCALADDR)) {
|
||||
if (1)
|
||||
{
|
||||
//// updateTableSize();
|
||||
/// repaintAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
// just repaint some rows
|
||||
Procinfo *p = procinfo();
|
||||
if (!p->sock_inodes.size())
|
||||
{
|
||||
/// Procinfo::read_sockets();
|
||||
p->read_fds();
|
||||
}
|
||||
int rows = p->sock_inodes.size();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
int inode = p->sock_inodes[i]->inode;
|
||||
/// Sockinfo *si = Procinfo::socks[inode];
|
||||
/// if(si->local_addr == addr) updateCell(i, LOCALADDR);
|
||||
/// if(si->rem_addr == addr) updateCell(i,
|
||||
/// REMOTEADDR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *Sockets::servname(unsigned port)
|
||||
{
|
||||
if (!have_services)
|
||||
{
|
||||
have_services = true;
|
||||
// fill servdict from /etc/services (just try once)
|
||||
setservent(1);
|
||||
struct servent *s;
|
||||
while ((s = getservent()) != 0)
|
||||
{
|
||||
unsigned short hport = ntohs((unsigned short)s->s_port);
|
||||
if (!servdict.value(hport, NULL))
|
||||
{
|
||||
servdict.insert(hport, strdup(s->s_name));
|
||||
}
|
||||
}
|
||||
endservent();
|
||||
}
|
||||
return servdict.value(port, NULL);
|
||||
}
|
||||
|
||||
#endif // LINUX
|
||||
|
||||
#ifdef SOLARIS
|
||||
|
||||
// Stupid code to make up for moc:s inability to grok preprocessor conditionals
|
||||
void Sockets::refresh() {}
|
||||
QString Sockets::text(int, int) { return 0; }
|
||||
void Sockets::config_change() {}
|
||||
Sockets::~Sockets() {}
|
||||
void Sockets::update_hostname(unsigned int) {}
|
||||
|
||||
#endif
|
||||
TableField *Maps::fields()
|
||||
{
|
||||
static QVector< TableField > fields( { { tr( "Address Range" ), -1, 8, Qt::AlignLeft, tr( "Mapped addresses (hex) )" ) }
|
||||
, { tr( "Size" ), 8, 8, Qt::AlignRight, tr( "Kbytes mapped (dec)" ) }
|
||||
, { tr( "Perm" ), 5, 8, Qt::AlignLeft, tr( "Permission flags" ) }
|
||||
, { tr( "Offset" ), -1, 8, Qt::AlignRight, tr( "File offset at start of mapping (hex)" ) }
|
||||
, { tr( "Device" ), 8, 8, Qt::AlignLeft, tr( "Major,Minor device numbers (dec)" ) }
|
||||
, { tr( "Inode" ), 10, 8, Qt::AlignRight, tr( "Inode number (dec)" ) }
|
||||
, { tr( "File" ), -9, 8, Qt::AlignLeft, tr( "File name (if available)" ) } } );
|
||||
return fields.data();
|
||||
}
|
||||
|
||||
// memory leak
|
||||
Maps::Maps(QWidget *parent) : SimpleTable(parent, MAPSFIELDS, fields() )
|
||||
{
|
||||
// monospaced font looks best in the table body since it contains
|
||||
// hex numerals and flag fields. Pick Courier (why not)
|
||||
body->setFont(QFont("Courier", font().pointSize()));
|
||||
bool mono = true;
|
||||
QFont f = font();
|
||||
if (f.rawMode())
|
||||
{
|
||||
/* see if the font is monospaced enough for our needs */
|
||||
QFontMetrics fm(f);
|
||||
int zw = fm.width('0');
|
||||
const char *test = "abcdef";
|
||||
for (const char *p = test; *p; p++)
|
||||
if (fm.width(*p) != zw)
|
||||
{
|
||||
mono = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
mono = f.fixedPitch();
|
||||
if (mono)
|
||||
{
|
||||
////setBodyFont(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
int ps = f.pointSize();
|
||||
/// setBodyFont(QFont("Courier", ps ? ps : 10));
|
||||
}
|
||||
|
||||
refresh();
|
||||
// compute total width = window width
|
||||
int totw = 300;
|
||||
// for(int i = 0; i < MAPSFIELDS; i++) totw += actualColWidth(i);
|
||||
resize(totw + 20, 200);
|
||||
}
|
||||
|
||||
Maps::~Maps()
|
||||
{
|
||||
// if(maps)
|
||||
// maps->clear();
|
||||
}
|
||||
|
||||
QString Maps::text(int row, int col)
|
||||
{
|
||||
Procinfo *p = procinfo();
|
||||
if (p->maps.size() == 0)
|
||||
{
|
||||
refresh_maps();
|
||||
if (p->maps.size() == 0)
|
||||
return "";
|
||||
}
|
||||
Mapsinfo *mi = p->maps[row];
|
||||
|
||||
QString s;
|
||||
char buf[80];
|
||||
switch (col)
|
||||
{
|
||||
case ADDRESS:
|
||||
sprintf(buf, (sizeof(void *) == 4) ? "%08lx-%08lx" : "%016lx-%016lx",
|
||||
mi->from, mi->to);
|
||||
s = buf;
|
||||
break;
|
||||
case SIZE:
|
||||
s.setNum((mi->to - mi->from) >> 10);
|
||||
s += "kb";
|
||||
break;
|
||||
case PERM:
|
||||
s = " ";
|
||||
for (int i = 0; i < 4; i++)
|
||||
s[i] = mi->perm[i];
|
||||
break;
|
||||
case OFFSET:
|
||||
sprintf(buf, (sizeof(void *) == 4) ? "%08lx" : "%016lx", mi->offset);
|
||||
s = buf;
|
||||
break;
|
||||
case DEVICE:
|
||||
s.sprintf("%2u,%2u", mi->major, mi->minor);
|
||||
break;
|
||||
case INODE:
|
||||
s.setNum(mi->inode);
|
||||
break;
|
||||
case FILENAME:
|
||||
s = mi->filename;
|
||||
if (!Qps::show_file_path)
|
||||
{
|
||||
int i = s.lastIndexOf('/');
|
||||
if (i >= 0)
|
||||
s.remove(0, i + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void Maps::refresh_window()
|
||||
{
|
||||
if (!procinfo())
|
||||
return;
|
||||
int rows = procinfo()->maps.size();
|
||||
////resetWidths();
|
||||
setNumRows(rows);
|
||||
setNumCols(MAPSFIELDS);
|
||||
repaintAll();
|
||||
}
|
||||
|
||||
void Maps::refresh()
|
||||
{
|
||||
if (refresh_maps())
|
||||
refresh_window();
|
||||
}
|
||||
|
||||
bool Maps::refresh_maps() { return procinfo()->read_maps(); }
|
||||
|
||||
TableField *Files::fields()
|
||||
{
|
||||
static QVector< TableField > fields( { { tr( "Fd" ), 5, 8, Qt::AlignRight, tr( "File descriptor" ) }
|
||||
#ifdef LINUX
|
||||
, { tr( "Mode" ), 3, 8, Qt::AlignLeft, tr( "Open mode" ) }
|
||||
#endif
|
||||
, { tr( "Name" ), -1, 8, Qt::AlignLeft, tr( "File name (if available)" )} } );
|
||||
return fields.data();
|
||||
}
|
||||
|
||||
Files::Files(QWidget *parent) : SimpleTable(parent, FILEFIELDS, fields() )
|
||||
{
|
||||
// compute total width = window width
|
||||
refresh_window();
|
||||
}
|
||||
|
||||
Files::~Files() {}
|
||||
|
||||
void Files::refresh()
|
||||
{
|
||||
printf("Files::refresh()\n");
|
||||
// return true if fds could be read successfully, false otherwise
|
||||
if (procinfo()->read_fds())
|
||||
refresh_window();
|
||||
}
|
||||
|
||||
bool Files::refresh_fds() { return false; }
|
||||
|
||||
void Files::refresh_window()
|
||||
{
|
||||
Procinfo *p = procinfo();
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
// if(p->fd_files==NULL) printf("qps :dddds\n");
|
||||
|
||||
int rows = p->fd_files.size();
|
||||
|
||||
resetWidths();
|
||||
// printf("size=%d\n",rows);
|
||||
setNumRows(rows);
|
||||
setNumCols(FILEFIELDS);
|
||||
repaintAll(); // useless ?
|
||||
}
|
||||
|
||||
QString Files::text(int row, int col)
|
||||
{
|
||||
Procinfo *p = procinfo(); // alot!!
|
||||
if (p == 0)
|
||||
return "zero";
|
||||
// printf("p=%x px=%x\n",p,px);
|
||||
if (p->fd_files.size() == 0)
|
||||
{ //???????????///////
|
||||
refresh_fds();
|
||||
if (p->fd_files.size() == 0)
|
||||
return "";
|
||||
}
|
||||
if (row >= p->fd_files.size())
|
||||
return "";
|
||||
|
||||
Fileinfo *fi = p->fd_files[row];
|
||||
QString s;
|
||||
switch (col)
|
||||
{
|
||||
case FILEDESC:
|
||||
s.setNum(fi->fd);
|
||||
break;
|
||||
|
||||
#ifdef LINUX
|
||||
case FILEMODE:
|
||||
if (fi->mode & OPEN_READ)
|
||||
s.append("R");
|
||||
if (fi->mode & OPEN_WRITE)
|
||||
s.append("W");
|
||||
break;
|
||||
#endif
|
||||
|
||||
case FILENAME:
|
||||
s = fi->filename;
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
TableField *Environ::fields()
|
||||
{
|
||||
static QVector< TableField > fields( { { tr( "Variable" ), -1, 8, Qt::AlignLeft, tr( "Variable name" ) }
|
||||
, { tr( "Value" ), -1, 8, Qt::AlignLeft, tr( "Variable value" ) } } );
|
||||
return fields.data();
|
||||
}
|
||||
|
||||
Environ *Environ::static_env = 0;
|
||||
Environ::Environ(QWidget *parent)
|
||||
: SimpleTable(parent, ENVFIELDS, fields() ), rev(false)
|
||||
{
|
||||
connect(this, SIGNAL(titleClicked(int)), SLOT(sort_change(int)));
|
||||
refresh();
|
||||
}
|
||||
|
||||
Environ::~Environ() {}
|
||||
|
||||
QString Environ::text(int row, int col)
|
||||
{
|
||||
Procinfo *p = procinfo(); // if dead process then
|
||||
if (row >= p->environ.size())
|
||||
printf("size dddd=row=%d\n", row);
|
||||
NameValue nv = p->environ[row]; // Segfault !!
|
||||
return (col == ENVNAME) ? nv.name : nv.value;
|
||||
}
|
||||
|
||||
void Environ::refresh_window()
|
||||
{
|
||||
if (!procinfo())
|
||||
return;
|
||||
/// resetWidths();
|
||||
int rows = procinfo()->environ.size();
|
||||
setNumRows(rows);
|
||||
setNumCols(ENVFIELDS);
|
||||
repaintAll();
|
||||
}
|
||||
|
||||
void Environ::refresh()
|
||||
{
|
||||
if (procinfo()->read_environ())
|
||||
{
|
||||
// sort();
|
||||
refresh_window();
|
||||
}
|
||||
}
|
||||
|
||||
void Environ::sort_change(int col)
|
||||
{
|
||||
Procinfo *p = procinfo();
|
||||
/*
|
||||
if(!p->environ) {
|
||||
refresh_environ();
|
||||
if(!p->environ)
|
||||
return;
|
||||
}*/
|
||||
////rev = (col == sortedCol()) ? !rev : false;
|
||||
setSortedCol(col);
|
||||
sort();
|
||||
refresh_window();
|
||||
}
|
||||
|
||||
// sort table according to current settings
|
||||
void Environ::sort()
|
||||
{
|
||||
/////if(sortedCol() >= 0)
|
||||
{
|
||||
static_env = this;
|
||||
// if(procinfo()->environ==NULL)
|
||||
// printf("qps : Environ::sort() error ???\n");
|
||||
// else
|
||||
// procinfo()->environ.sort(compare);
|
||||
}
|
||||
}
|
||||
|
||||
int Environ::compare(const NameValue *a, const NameValue *b)
|
||||
{
|
||||
Environ *e = Environ::static_env;
|
||||
int r;
|
||||
/*
|
||||
if(e->sortedCol() == ENVNAME)
|
||||
r = strcmp(a->name, b->name);
|
||||
else
|
||||
r = strcmp(a->value, b->value); SimpleTable(QWidget *parent,
|
||||
int
|
||||
nfields, TableField *f, int options = 0);
|
||||
*/
|
||||
return e->rev ? -r : r;
|
||||
}
|
||||
|
||||
TableField *AllFields::fields()
|
||||
{
|
||||
static QVector< TableField > fields( { { tr( "Field" ), -1, 8, Qt::AlignLeft, tr( "Field name" ) }
|
||||
, { tr( "Description" ), -1, 8, Qt::AlignLeft, tr( "Field description" ) }
|
||||
, { tr( "Value" ), -1, 8, Qt::AlignLeft, tr( "Field value" ) } } );
|
||||
return fields.data();
|
||||
}
|
||||
|
||||
|
||||
AllFields::AllFields(QWidget *parent)
|
||||
: SimpleTable(parent, FIELDSFIELDS, fields() )
|
||||
{
|
||||
refresh();
|
||||
// compute total width = window width
|
||||
int totw = 0;
|
||||
// for(int i = 0; i < FIELDSFIELDS; i++) totw += actualColWidth(i);
|
||||
resize(totw + 20, 200);
|
||||
}
|
||||
|
||||
AllFields::~AllFields() {}
|
||||
|
||||
// Proc not changed ?
|
||||
QString AllFields::text(int row, int col)
|
||||
{
|
||||
QString s;
|
||||
// printf("text start r=%d , c=%d\n",row,col);
|
||||
// if( ((Details *)parent())->proc()==NULL)
|
||||
// printf("size=%d\n", ((Details *)parent())->proc()->allcats.size() );
|
||||
// printf("size=%d\n", proc()->allcats.size() );
|
||||
|
||||
Category *cat = proc()->categories.values()[row];
|
||||
// Category *cat = proc()->allcats[row];
|
||||
switch (col)
|
||||
{
|
||||
case FIELDNAME:
|
||||
s = cat->name;
|
||||
break;
|
||||
case FIELDDESC:
|
||||
s = cat->help;
|
||||
break;
|
||||
case FIELDVALUE:
|
||||
s = cat->string(procinfo());
|
||||
break;
|
||||
}
|
||||
// printf("text end\n");
|
||||
return s;
|
||||
}
|
||||
|
||||
// parent will be tbar(TabWidget) !!!
|
||||
void AllFields::refresh_window()
|
||||
{
|
||||
// printf("refresh_window\n");
|
||||
if (!procinfo())
|
||||
return;
|
||||
setNumRows(proc()->categories.size());
|
||||
setNumCols(FIELDSFIELDS);
|
||||
// DEL resetWidths();
|
||||
// repaint_changed();
|
||||
repaintAll();
|
||||
}
|
||||
|
||||
void AllFields::refresh() { refresh_window(); }
|
@ -1,245 +0,0 @@
|
||||
/*
|
||||
* details.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 DETAILS_H
|
||||
#define DETAILS_H
|
||||
|
||||
#ifndef USING_PCH
|
||||
#include <QTabWidget>
|
||||
#include <QFrame>
|
||||
#include <QHash>
|
||||
#include <QCloseEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QLayout>
|
||||
#endif
|
||||
|
||||
#include "proc.h"
|
||||
#include "lookup.h"
|
||||
#include "tablefield.h"
|
||||
|
||||
class Details : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Details(Procinfo *p, Proc *proc);
|
||||
~Details();
|
||||
|
||||
void refresh();
|
||||
void config_change();
|
||||
void process_gone();
|
||||
Procinfo *get_procinfo() { return pi; }
|
||||
Proc *proc() { return pr; }
|
||||
void set_procinfo(Procinfo *p);
|
||||
|
||||
signals:
|
||||
void closed(Details *);
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *);
|
||||
virtual void closeEvent(QCloseEvent *);
|
||||
|
||||
private:
|
||||
QTabWidget *tbar;
|
||||
Procinfo *pi;
|
||||
Proc *pr;
|
||||
};
|
||||
|
||||
// SimpleTable: a HeadedTable with fixed number of columns
|
||||
#include "htable.h"
|
||||
class SimpleTable : public HeadedTable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SimpleTable(QWidget *parent, int nfields, TableField *f, int options = 0);
|
||||
QSize sizeHint() const;
|
||||
virtual void refresh(){};
|
||||
|
||||
protected:
|
||||
virtual QString title(int col);
|
||||
virtual QString text(int row, int col) = 0;
|
||||
virtual int colWidth(int col);
|
||||
virtual int alignment(int col);
|
||||
virtual int leftGap(int col);
|
||||
virtual QString tipText(int col);
|
||||
// Procinfo *procinfo() { return ((Details
|
||||
// *)parentWidget())->procinfo(); }
|
||||
Procinfo *procinfo() { return detail->get_procinfo(); }
|
||||
Proc *proc() { return detail->proc(); }
|
||||
|
||||
private:
|
||||
const TableField *fields;
|
||||
Details *detail;
|
||||
};
|
||||
|
||||
class Sockets : public SimpleTable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Sockets(QWidget *parent);
|
||||
~Sockets();
|
||||
|
||||
void refresh();
|
||||
void refresh_window();
|
||||
bool refresh_sockets();
|
||||
const char *servname(unsigned port);
|
||||
QString ipAddr(unsigned addr);
|
||||
QString hostname(unsigned addr);
|
||||
void config_change();
|
||||
|
||||
public slots:
|
||||
void update_hostname(unsigned addr);
|
||||
|
||||
protected:
|
||||
virtual QString text(int row, int col);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
FD,
|
||||
PROTO,
|
||||
RECVQ,
|
||||
SENDQ,
|
||||
LOCALADDR,
|
||||
LOCALPORT,
|
||||
REMOTEADDR,
|
||||
REMOTEPORT,
|
||||
STATE,
|
||||
SOCKFIELDS
|
||||
};
|
||||
static TableField *fields();
|
||||
|
||||
bool doing_lookup; // if table painted with host lookup
|
||||
|
||||
static Lookup *lookup;
|
||||
static bool have_services; // true if we have tried reading services
|
||||
static QHash<int, char *> servdict;
|
||||
};
|
||||
|
||||
class Maps : public SimpleTable
|
||||
{
|
||||
public:
|
||||
Maps(QWidget *parent);
|
||||
~Maps();
|
||||
|
||||
void refresh();
|
||||
void refresh_window();
|
||||
bool refresh_maps();
|
||||
|
||||
protected:
|
||||
virtual QString text(int row, int col);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
ADDRESS,
|
||||
SIZE,
|
||||
PERM,
|
||||
OFFSET,
|
||||
DEVICE,
|
||||
INODE,
|
||||
FILENAME,
|
||||
MAPSFIELDS
|
||||
};
|
||||
static TableField *fields();
|
||||
};
|
||||
|
||||
class Files : public SimpleTable
|
||||
{
|
||||
public:
|
||||
Files(QWidget *parent);
|
||||
~Files();
|
||||
|
||||
void refresh();
|
||||
void refresh_window();
|
||||
bool refresh_fds();
|
||||
|
||||
protected:
|
||||
virtual QString text(int row, int col);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
FILEDESC,
|
||||
#ifdef LINUX
|
||||
FILEMODE,
|
||||
#endif
|
||||
FILENAME,
|
||||
FILEFIELDS
|
||||
};
|
||||
static TableField *fields();
|
||||
};
|
||||
|
||||
class Environ : public SimpleTable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Environ(QWidget *parent);
|
||||
~Environ();
|
||||
|
||||
void refresh();
|
||||
void refresh_window();
|
||||
|
||||
public slots:
|
||||
void sort_change(int);
|
||||
|
||||
protected:
|
||||
virtual QString text(int row, int col);
|
||||
|
||||
void sort();
|
||||
static int compare(const NameValue *a, const NameValue *b);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
ENVNAME,
|
||||
ENVVALUE,
|
||||
ENVFIELDS
|
||||
};
|
||||
bool rev; // sorting reversed
|
||||
static Environ *static_env; // for sorting, must have static pointer
|
||||
static TableField *fields();
|
||||
};
|
||||
|
||||
class AllFields : public SimpleTable
|
||||
{
|
||||
public:
|
||||
AllFields(QWidget *parent);
|
||||
~AllFields();
|
||||
|
||||
void refresh();
|
||||
void refresh_window();
|
||||
|
||||
protected:
|
||||
virtual QString text(int row, int col);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
FIELDNAME,
|
||||
FIELDDESC,
|
||||
FIELDVALUE,
|
||||
FIELDSFIELDS
|
||||
};
|
||||
static TableField *fields();
|
||||
};
|
||||
|
||||
#endif // DETAILS_H
|
@ -1,415 +0,0 @@
|
||||
/*
|
||||
* dialogs.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 "qps.h"
|
||||
#include "dialogs.h"
|
||||
#include <sched.h>
|
||||
|
||||
extern Qps *qps;
|
||||
|
||||
// center window a with respect to main application window
|
||||
static void center_window(QWidget *a)
|
||||
{
|
||||
QWidget *b = QApplication::activeWindow();
|
||||
// QWidget *b = qApp->mainWidget();
|
||||
a->move(b->x() + (b->width() - a->width()) / 2,
|
||||
b->y() + (b->height() - a->height()) / 2);
|
||||
}
|
||||
|
||||
static void move_mouse_window(QWidget *a)
|
||||
{
|
||||
// QWidget *b = qApp->mainWidget();
|
||||
QWidget *b = QApplication::activeWindow();
|
||||
a->move(b->x() + (b->width() - a->width()) / 2,
|
||||
b->y() + (b->height() - a->height()) / 2);
|
||||
}
|
||||
|
||||
static void fix_size(QWidget *w) { w->setFixedSize(w->sizeHint()); }
|
||||
|
||||
// Modal dialog
|
||||
IntervalDialog::IntervalDialog(const char *ed_txt, bool enabled) : QDialog()
|
||||
{
|
||||
setWindowTitle( tr( "Change Update Period" ) );
|
||||
QVBoxLayout *tl = new QVBoxLayout;
|
||||
QHBoxLayout *h1 = new QHBoxLayout;
|
||||
setLayout(tl);
|
||||
tl->addLayout(h1);
|
||||
|
||||
QLabel *label1 = new QLabel( tr( "New Update Period" ), this);
|
||||
h1->addWidget(label1);
|
||||
h1->addStretch(1);
|
||||
|
||||
lined = new QLineEdit(this);
|
||||
QFont f = font();
|
||||
lined->setMaxLength(7);
|
||||
lined->setText(ed_txt);
|
||||
if (enabled)
|
||||
{
|
||||
lined->selectAll();
|
||||
lined->setFocus();
|
||||
}
|
||||
// lined->setEnabled(enabled);
|
||||
lined->setEnabled(true);
|
||||
fix_size(lined);
|
||||
lined->setFixedWidth(64);
|
||||
h1->addWidget(lined);
|
||||
|
||||
label = new QLabel(this);
|
||||
label->setFrameStyle(QFrame::Panel);
|
||||
label->setFrameShadow(QFrame::Sunken);
|
||||
label->setText("");
|
||||
label->setAlignment(Qt::AlignRight);
|
||||
tl->addWidget(label);
|
||||
|
||||
/*
|
||||
toggle = new CrossBox("Dynamic Update (under devel)", this);
|
||||
fix_size(toggle);
|
||||
toggle->setChecked(enabled);
|
||||
//toggle->setChecked(false);
|
||||
toggle->setChecked(true);
|
||||
toggle->setEnabled(false);
|
||||
tl->addWidget(toggle);
|
||||
*/
|
||||
QHBoxLayout *h2 = new QHBoxLayout;
|
||||
// h2->addStretch(1);
|
||||
cancel = new QPushButton( tr( "Cancel" ), this);
|
||||
h2->addWidget(cancel);
|
||||
ok = new QPushButton( tr( "OK" ), this);
|
||||
// ok->setFocus();
|
||||
h2->addWidget(ok);
|
||||
tl->addLayout(h2);
|
||||
|
||||
connect(ok, SIGNAL(clicked()), SLOT(done_dialog()));
|
||||
connect(cancel, SIGNAL(clicked()), SLOT(reject()));
|
||||
connect(lined, SIGNAL(returnPressed()), SLOT(done_dialog()));
|
||||
connect(lined, SIGNAL(textChanged(const QString &)),
|
||||
SLOT(event_label_changed()));
|
||||
// connect(toggle, SIGNAL(toggled(bool)), lined,
|
||||
// SLOT(setEnabled(bool)));
|
||||
|
||||
ok->setDefault(true);
|
||||
|
||||
/// Q3Accel *acc = new Q3Accel(this);
|
||||
/// acc->connectItem(acc->insertItem(Qt::Key_Escape), this,
|
||||
/// SLOT(reject()));
|
||||
// tl->setSizeConstraint(QLayout::SetFixedSize);
|
||||
// center_window(this);
|
||||
}
|
||||
|
||||
void IntervalDialog::event_label_changed()
|
||||
{
|
||||
QString txt;
|
||||
int i = 0;
|
||||
ed_result = lined->text();
|
||||
ed_result = ed_result.simplified();
|
||||
|
||||
// if(toggle->isChecked())
|
||||
|
||||
QString s = ed_result;
|
||||
if (s.length() == 0)
|
||||
{
|
||||
label->setText( tr( "No UPDATE" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
while ((s[i] >= '0' && s[i] <= '9') || s[i] == '.')
|
||||
i++;
|
||||
|
||||
float period = (i > 0) ? s.left(i).toFloat() : -1;
|
||||
|
||||
s = s.mid(i, 3).simplified();
|
||||
if (s.length() == 0 || s == "s")
|
||||
period *= 1000;
|
||||
else if (s == "min")
|
||||
period *= 60000;
|
||||
else if (s != "ms")
|
||||
period = -1;
|
||||
if (period <= 0)
|
||||
{
|
||||
label->setText( tr( "Invalid value" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
txt.sprintf("%d ms", (int)period);
|
||||
label->setText(txt);
|
||||
}
|
||||
|
||||
void IntervalDialog::done_dialog()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
ed_result = lined->text();
|
||||
ed_result = ed_result.simplified();
|
||||
|
||||
// if(toggle->isChecked())
|
||||
QString s = ed_result;
|
||||
while ((s[i] >= '0' && s[i] <= '9') || s[i] == '.')
|
||||
i++;
|
||||
|
||||
float period = (i > 0) ? s.left(i).toFloat() : -1;
|
||||
|
||||
s = s.mid(i, 3).simplified();
|
||||
if (s.length() == 0 || s == "s")
|
||||
period *= 1000;
|
||||
else if (s == "min")
|
||||
period *= 60000;
|
||||
else if (s != "ms")
|
||||
period = -1;
|
||||
if (period < 0)
|
||||
return;
|
||||
|
||||
qps->set_update_period((int)period);
|
||||
qps->update_timer();
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
SliderDialog::SliderDialog(int defaultval, int minval, int maxval) : QDialog()
|
||||
{
|
||||
setWindowTitle( tr( "Renice Process" ) );
|
||||
QVBoxLayout *tl = new QVBoxLayout;
|
||||
QHBoxLayout *h1 = new QHBoxLayout;
|
||||
setLayout(tl);
|
||||
tl->addLayout(h1);
|
||||
|
||||
label = new QLabel( tr( "New nice value:" ), this);
|
||||
h1->addWidget(label);
|
||||
|
||||
h1->addStretch(1);
|
||||
|
||||
lined = new QLineEdit(this);
|
||||
lined->setMaxLength(3);
|
||||
lined->setText(QString::number(defaultval));
|
||||
lined->setFocus();
|
||||
lined->setFixedWidth(64);
|
||||
h1->addWidget(lined);
|
||||
|
||||
slider = new QSlider(Qt::Horizontal, this);
|
||||
slider->setMaximum(maxval);
|
||||
slider->setMinimum(minval);
|
||||
slider->setTickInterval(10);
|
||||
slider->setTickPosition(QSlider::TicksBelow);
|
||||
slider->setValue(defaultval);
|
||||
tl->addWidget(slider);
|
||||
|
||||
QHBoxLayout *h2 = new QHBoxLayout;
|
||||
tl->addLayout(h2);
|
||||
|
||||
// decorate slider
|
||||
QLabel *left = new QLabel(this);
|
||||
QLabel *mid = new QLabel(this);
|
||||
QLabel *right = new QLabel(this);
|
||||
left->setNum(minval);
|
||||
mid->setNum((minval + maxval) / 2);
|
||||
right->setNum(maxval);
|
||||
h2->addWidget(left);
|
||||
h2->addStretch(1);
|
||||
h2->addWidget(mid);
|
||||
h2->addStretch(1);
|
||||
h2->addWidget(right);
|
||||
|
||||
QHBoxLayout *h3 = new QHBoxLayout;
|
||||
tl->addLayout(h3);
|
||||
|
||||
h3->addStretch(1);
|
||||
cancel = new QPushButton( tr( "Cancel" ), this);
|
||||
// fix_size(cancel);
|
||||
h3->addWidget(cancel);
|
||||
|
||||
ok = new QPushButton( tr( "OK" ), this);
|
||||
ok->setFixedSize(cancel->sizeHint());
|
||||
h3->addWidget(ok);
|
||||
|
||||
connect(ok, SIGNAL(clicked()), SLOT(done_dialog()));
|
||||
ok->setDefault(true);
|
||||
connect(cancel, SIGNAL(clicked()), SLOT(reject()));
|
||||
connect(lined, SIGNAL(returnPressed()), SLOT(done_dialog()));
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slider_change(int)));
|
||||
// Q3Accel *acc = new Q3Accel(this);
|
||||
// acc->connectItem(acc->insertItem(Qt::Key_Escape), this,
|
||||
// SLOT(reject()));
|
||||
// tl->freeze();
|
||||
|
||||
center_window(this);
|
||||
}
|
||||
|
||||
void SliderDialog::done_dialog()
|
||||
{
|
||||
ed_result = lined->text();
|
||||
ed_result = ed_result.simplified();
|
||||
accept();
|
||||
}
|
||||
|
||||
void SliderDialog::slider_change(int val)
|
||||
{
|
||||
QString s;
|
||||
s.setNum(val);
|
||||
lined->setText(s);
|
||||
lined->selectAll();
|
||||
}
|
||||
|
||||
// DRAFT CODE,
|
||||
PermissionDialog::PermissionDialog(QString msg, QString passwd) : QDialog()
|
||||
{
|
||||
setWindowTitle( tr( "Permission" ) );
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
label = new QLabel(msg, this);
|
||||
vbox->addWidget(label);
|
||||
|
||||
setLayout(vbox);
|
||||
|
||||
QHBoxLayout *hbox = new QHBoxLayout;
|
||||
vbox->addLayout(hbox);
|
||||
label = new QLabel( tr( "Root password" ), this);
|
||||
hbox->addWidget(label);
|
||||
lined = new QLineEdit(this);
|
||||
hbox->addWidget(lined);
|
||||
|
||||
hbox = new QHBoxLayout;
|
||||
vbox->addLayout(hbox);
|
||||
QPushButton *cancel = new QPushButton( tr( "Cancel" ), this);
|
||||
hbox->addWidget(cancel);
|
||||
|
||||
QPushButton *ok = new QPushButton( tr( "OK" ), this);
|
||||
hbox->addWidget(ok);
|
||||
|
||||
connect(ok, SIGNAL(clicked()), SLOT(accept()));
|
||||
connect(cancel, SIGNAL(clicked()), SLOT(reject()));
|
||||
}
|
||||
|
||||
SchedDialog::SchedDialog(int policy, int prio) : QDialog()
|
||||
{
|
||||
setWindowTitle( tr( "Change scheduling" ) );
|
||||
QVBoxLayout *vl = new QVBoxLayout;
|
||||
setLayout(vl);
|
||||
|
||||
bgrp = new QGroupBox( tr( "Scheduling Policy" ), this);
|
||||
vl->addWidget(bgrp); // bgrp->setCheckable(1);
|
||||
rb_other = new QRadioButton( tr( "SCHED_OTHER (time-sharing)" ), bgrp);
|
||||
rb_fifo = new QRadioButton( tr( "SCHED_FIFO (real-time)" ), bgrp);
|
||||
rb_rr = new QRadioButton( tr( "SCHED_RR (real-time)" ), bgrp);
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
vbox->addWidget(rb_other);
|
||||
vbox->addWidget(rb_fifo);
|
||||
vbox->addWidget(rb_rr);
|
||||
bgrp->setLayout(vbox);
|
||||
|
||||
connect(rb_other, SIGNAL(clicked(bool)), SLOT(button_clicked(bool)));
|
||||
connect(rb_fifo, SIGNAL(clicked(bool)), SLOT(button_clicked(bool)));
|
||||
connect(rb_rr, SIGNAL(clicked(bool)), SLOT(button_clicked(bool)));
|
||||
|
||||
QHBoxLayout *hbox1 = new QHBoxLayout;
|
||||
QPushButton *ok, *cancel;
|
||||
ok = new QPushButton( tr( "OK" ), this);
|
||||
ok->setDefault(true);
|
||||
cancel = new QPushButton( tr( "Cancel" ), this);
|
||||
hbox1->addWidget(ok);
|
||||
hbox1->addWidget(cancel);
|
||||
vl->addLayout(hbox1);
|
||||
|
||||
connect(ok, SIGNAL(clicked()), SLOT(done_dialog()));
|
||||
connect(cancel, SIGNAL(clicked()), SLOT(reject()));
|
||||
|
||||
int active = 0;
|
||||
QRadioButton *rb;
|
||||
switch (policy)
|
||||
{
|
||||
case SCHED_OTHER:
|
||||
active = 0;
|
||||
rb = rb_other;
|
||||
break;
|
||||
case SCHED_FIFO:
|
||||
active = 1;
|
||||
rb = rb_fifo;
|
||||
break;
|
||||
case SCHED_RR:
|
||||
active = 2;
|
||||
rb = rb_rr;
|
||||
break;
|
||||
}
|
||||
rb->setChecked(true);
|
||||
out_policy = policy;
|
||||
out_prio = prio;
|
||||
|
||||
QHBoxLayout *hbox = new QHBoxLayout;
|
||||
lbl = new QLabel( tr( "Priority (1-99):" ), this);
|
||||
lined = new QLineEdit(this);
|
||||
hbox->addWidget(lbl);
|
||||
hbox->addWidget(lined);
|
||||
vbox->addLayout(hbox);
|
||||
QFont f = font();
|
||||
f.setBold(false);
|
||||
lined->setFont(f);
|
||||
lined->resize(60, lined->sizeHint().height());
|
||||
lined->setMaxLength(4);
|
||||
QString s;
|
||||
s.setNum(prio);
|
||||
lined->setText(s);
|
||||
button_clicked(active);
|
||||
|
||||
// make sure return and escape work as accelerators
|
||||
connect(lined, SIGNAL(returnPressed()), SLOT(done_dialog()));
|
||||
}
|
||||
|
||||
void SchedDialog::done_dialog()
|
||||
{
|
||||
if (rb_rr->isChecked())
|
||||
out_policy = SCHED_RR;
|
||||
else if (rb_fifo->isChecked())
|
||||
out_policy = SCHED_FIFO;
|
||||
else
|
||||
out_policy = SCHED_OTHER;
|
||||
QString s(lined->text());
|
||||
bool ok;
|
||||
out_prio = s.toInt(&ok);
|
||||
if (out_policy != SCHED_OTHER && (!ok || out_prio < 1 || out_prio > 99))
|
||||
{
|
||||
QMessageBox::warning( this
|
||||
, tr( "Invalid Input" )
|
||||
, tr( "The priority must be in the range 1..99" ) );
|
||||
}
|
||||
else
|
||||
accept();
|
||||
}
|
||||
|
||||
void SchedDialog::button_clicked(bool val)
|
||||
{
|
||||
// printf("SchedDialog::checked()\n");
|
||||
if (rb_other->isChecked())
|
||||
{
|
||||
lbl->setEnabled(false);
|
||||
lined->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString s(lined->text());
|
||||
bool ok;
|
||||
int n = s.toInt(&ok);
|
||||
if (ok && n == 0)
|
||||
lined->setText("1");
|
||||
lbl->setEnabled(true);
|
||||
lined->setEnabled(true);
|
||||
lined->setFocus();
|
||||
lined->selectAll();
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* dialogs.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
// misc. handy dialogs for use everywhere
|
||||
|
||||
#ifndef DIALOGS_H
|
||||
#define DIALOGS_H
|
||||
|
||||
#ifndef USING_PCH
|
||||
#include <QDialog>
|
||||
#include <QSlider>
|
||||
#include <QGroupBox>
|
||||
#include <QLineEdit>
|
||||
#include <QPixmap>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QFrame>
|
||||
#include <QPushButton>
|
||||
#endif
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
class IntervalDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
IntervalDialog(const char *ed_txt, bool toggle_state);
|
||||
|
||||
protected slots:
|
||||
void done_dialog();
|
||||
void event_label_changed();
|
||||
|
||||
public:
|
||||
QString ed_result;
|
||||
CrossBox *toggle;
|
||||
|
||||
protected:
|
||||
QPushButton *ok, *cancel;
|
||||
QLabel *label;
|
||||
QLineEdit *lined;
|
||||
};
|
||||
|
||||
class SliderDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SliderDialog(int defaultval, int minval, int maxval);
|
||||
|
||||
QString ed_result;
|
||||
|
||||
protected slots:
|
||||
void slider_change(int val);
|
||||
void done_dialog();
|
||||
|
||||
protected:
|
||||
QPushButton *ok, *cancel;
|
||||
QLabel *label;
|
||||
QLineEdit *lined;
|
||||
QSlider *slider;
|
||||
};
|
||||
|
||||
class PermissionDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PermissionDialog(QString msg, QString passwd);
|
||||
QLineEdit *lined;
|
||||
QLabel *label;
|
||||
|
||||
// protected slots:
|
||||
// void slider_change(int val);
|
||||
// void done_dialog();
|
||||
/*
|
||||
protected:
|
||||
QPushButton *ok, *cancel;
|
||||
QLabel *label;
|
||||
QSlider *slider; */
|
||||
};
|
||||
|
||||
class SchedDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SchedDialog(int policy, int prio);
|
||||
|
||||
int out_prio;
|
||||
int out_policy;
|
||||
|
||||
protected slots:
|
||||
void done_dialog();
|
||||
void button_clicked(bool);
|
||||
|
||||
private:
|
||||
QGroupBox *bgrp;
|
||||
QRadioButton *rb_other, *rb_fifo, *rb_rr;
|
||||
QLabel *lbl;
|
||||
QLineEdit *lined;
|
||||
};
|
||||
#endif // DIALOGS_H
|
@ -1,124 +0,0 @@
|
||||
/*
|
||||
* execwindow.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 "execwindow.h"
|
||||
#include "watchcond.h"
|
||||
|
||||
QList<ExecWindow *> execlist;
|
||||
|
||||
// ExecWindow
|
||||
ExecWindow::ExecWindow()
|
||||
{
|
||||
setupUi(this);
|
||||
// connect(okButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||
// show();
|
||||
}
|
||||
|
||||
ExecWindow::~ExecWindow() {}
|
||||
|
||||
// eventcat_id;
|
||||
ExecWindow::ExecWindow(watchCond *wc, int pid, QString cmd)
|
||||
{
|
||||
setupUi(this);
|
||||
setWindowTitle( tr( "Qps Watchdog" ) );
|
||||
|
||||
wcond = wc;
|
||||
|
||||
QString str;
|
||||
|
||||
if (wc->cond == WATCH_PROCESS_START)
|
||||
{
|
||||
textEdit->append(cmd + "(" + QString::number(pid) + ")" + " start");
|
||||
}
|
||||
if (wc->cond == WATCH_PROCESS_FINISH)
|
||||
textEdit->append(cmd + "(" + QString::number(pid) + ")" + " finished");
|
||||
|
||||
flag_started = false;
|
||||
|
||||
pr = new QProcess; // leak?
|
||||
if (!wc->command.isEmpty()) // conflict pid's command
|
||||
{
|
||||
pr->start(wc->command); // thread run, if null then segfault occurs. ?
|
||||
}
|
||||
|
||||
connect(okButton, SIGNAL(clicked()), this, SLOT(cmd_ok()));
|
||||
|
||||
connect(pr, SIGNAL(started()), this, SLOT(cmd_started()));
|
||||
connect(pr, SIGNAL(finished(int, QProcess::ExitStatus)), this,
|
||||
SLOT(cmd_finished(int, QProcess::ExitStatus)));
|
||||
connect(pr, SIGNAL(error(QProcess::ProcessError)), this,
|
||||
SLOT(cmd_error(QProcess::ProcessError)));
|
||||
|
||||
show();
|
||||
|
||||
execlist.append(this);
|
||||
}
|
||||
|
||||
ExecWindow::ExecWindow(QString str, QString exec_cmd, int pid, QString cmd)
|
||||
{
|
||||
setupUi(this);
|
||||
//
|
||||
}
|
||||
|
||||
// QProcess: Destroyed while process is still running.(Segmentation fault)
|
||||
void ExecWindow::cmd_ok()
|
||||
{
|
||||
if (pr->state() == QProcess::Running)
|
||||
{
|
||||
// pr->kill();
|
||||
pr->terminate();
|
||||
return;
|
||||
}
|
||||
close(); // Qt::WA_DeleteOnClose
|
||||
}
|
||||
|
||||
// slot : catch terminate signal.
|
||||
void ExecWindow::cmd_finished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
textEdit->append( tr( "%1 exit with code %2" ).arg( wcond->command )
|
||||
.arg( exitStatus ) );
|
||||
okButton->setText( tr( "Close" ) );
|
||||
delete pr;
|
||||
}
|
||||
|
||||
void ExecWindow::cmd_started()
|
||||
{
|
||||
textEdit->append( tr( "%1 [running]" ).arg( wcond->command ) );
|
||||
okButton->setText( tr( "terminate command" ) );
|
||||
flag_started = true;
|
||||
}
|
||||
|
||||
void ExecWindow::cmd_error(QProcess::ProcessError e)
|
||||
{
|
||||
// not found command
|
||||
// Error ? :
|
||||
if (e == QProcess::FailedToStart)
|
||||
textEdit->append( tr( "Error %1 : [%2] Maybe command not found" ).arg( e )
|
||||
.arg( wcond->command ) );
|
||||
delete pr;
|
||||
}
|
||||
|
||||
void ExecWindow::setText(QString str)
|
||||
{
|
||||
textEdit->append(str);
|
||||
// label->setText(str);
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* execwindow.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 EXECWINDOW_H
|
||||
#define EXECWINDOW_H
|
||||
|
||||
#include <QProcess>
|
||||
#include <QString>
|
||||
|
||||
#include "ui_message.h"
|
||||
|
||||
class watchCond;
|
||||
|
||||
class ExecWindow : public QWidget, private Ui_ExecWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ExecWindow();
|
||||
ExecWindow(QString str, QString exec_cmd, int pid = 0, QString cmd = "");
|
||||
ExecWindow(watchCond *wc, int pid = 0, QString cmd = "");
|
||||
~ExecWindow();
|
||||
void setText(QString str);
|
||||
QProcess *pr;
|
||||
// QProcess proc;
|
||||
QString execmd;
|
||||
int flag_started;
|
||||
watchCond *wcond;
|
||||
protected slots:
|
||||
void cmd_started();
|
||||
void cmd_finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void cmd_error(QProcess::ProcessError error);
|
||||
void cmd_ok();
|
||||
};
|
||||
|
||||
#endif // EXECWINDOW_H
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* fieldsel.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 "fieldsel.h"
|
||||
|
||||
FieldSelect::FieldSelect(Procview *pv)
|
||||
{
|
||||
nbuttons = pv->categories.size();
|
||||
disp_fields.resize(64);
|
||||
procview = pv;
|
||||
|
||||
int half = (nbuttons + 1) / 2;
|
||||
updating = false;
|
||||
|
||||
setWindowTitle(tr( "Select Custom Fields " ) );
|
||||
QBoxLayout *v_layout = new QVBoxLayout;
|
||||
setLayout(v_layout);
|
||||
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
grid->setSpacing(0);
|
||||
grid->setColumnMinimumWidth(2, 17);
|
||||
v_layout->addLayout(grid);
|
||||
|
||||
buts = new QCheckBox *[nbuttons];
|
||||
|
||||
QList<int> keys = pv->categories.keys();
|
||||
|
||||
for (int i = 0; i < nbuttons; i++)
|
||||
{
|
||||
Category *cat = pv->categories[keys.takeFirst()]; // fieldlist
|
||||
|
||||
QCheckBox *but = new QCheckBox(cat->name, this);
|
||||
QLabel *desc = new QLabel(cat->help, this);
|
||||
if (i < half)
|
||||
{
|
||||
grid->addWidget(but, i, 0);
|
||||
grid->addWidget(desc, i, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
grid->addWidget(but, i - half, 3);
|
||||
grid->addWidget(desc, i - half, 4);
|
||||
}
|
||||
buts[i] = but;
|
||||
connect(but, SIGNAL(toggled(bool)), this, SLOT(field_toggled(bool)));
|
||||
}
|
||||
update_boxes();
|
||||
|
||||
QPushButton *closebut = new QPushButton( tr( "Close" ), this);
|
||||
connect(closebut, SIGNAL(clicked()), SLOT(closed()));
|
||||
closebut->setFocus();
|
||||
|
||||
v_layout->addWidget(closebut);
|
||||
// v_layout->freeze(); ///!!!
|
||||
}
|
||||
|
||||
// CALLBACK : one of the fields was toggled (we don't know which one yet)
|
||||
void FieldSelect::field_toggled(bool)
|
||||
{
|
||||
if (updating)
|
||||
return;
|
||||
set_disp_fields();
|
||||
|
||||
for (int i = 0; i < nbuttons; i++)
|
||||
{
|
||||
Category *cat = procview->cat_by_name(buts[i]->text());
|
||||
|
||||
if (buts[i]->isChecked() != disp_fields.testBit(cat->id))
|
||||
{
|
||||
if (buts[i]->isChecked())
|
||||
emit added_field(cat->id); // send cat_index
|
||||
else
|
||||
emit removed_field(cat->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FieldSelect::closed() { hide(); }
|
||||
|
||||
void FieldSelect::closeEvent(QCloseEvent *) { closed(); }
|
||||
|
||||
void FieldSelect::set_disp_fields()
|
||||
{
|
||||
disp_fields.fill(false);
|
||||
int n = procview->cats.size();
|
||||
for (int i = 0; i < n; i++)
|
||||
disp_fields.setBit(procview->cats[i]->id);
|
||||
}
|
||||
|
||||
void FieldSelect::showEvent(QShowEvent *) { update_boxes(); }
|
||||
|
||||
// init check button ?
|
||||
void FieldSelect::update_boxes()
|
||||
{
|
||||
set_disp_fields();
|
||||
|
||||
updating = true;
|
||||
for (int i = 0; i < nbuttons; i++)
|
||||
{
|
||||
Category *cat = procview->cat_by_name(buts[i]->text());
|
||||
buts[i]->setChecked(disp_fields.testBit(cat->id));
|
||||
}
|
||||
updating = false;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* fieldsel.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 FIELDSEL_H
|
||||
#define FIELDSEL_H
|
||||
|
||||
#include <QBitArray>
|
||||
#include <QDialog>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QGridLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include "proc.h"
|
||||
|
||||
class FieldSelect : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FieldSelect(Procview *pv);
|
||||
|
||||
void update_boxes();
|
||||
|
||||
public slots:
|
||||
void field_toggled(bool);
|
||||
void closed();
|
||||
|
||||
signals:
|
||||
void added_field(int);
|
||||
void removed_field(int);
|
||||
|
||||
protected:
|
||||
QCheckBox **buts;
|
||||
int nbuttons;
|
||||
QBitArray disp_fields;
|
||||
bool updating;
|
||||
Procview *procview;
|
||||
|
||||
void set_disp_fields();
|
||||
void closeEvent(QCloseEvent *);
|
||||
virtual void showEvent(QShowEvent *);
|
||||
};
|
||||
|
||||
#endif // FIELDSEL_H
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* stable.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 2014 dae hyun, yang <daehyun.yang@gmail.com>
|
||||
* Copyright 2015 Paulo Lieuthier <paulolieuthier@gmail.com>
|
||||
*
|
||||
* 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 GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#include "qps.h"
|
||||
#include "misc.h"
|
||||
|
||||
extern QList<Command *> commands;
|
||||
extern ControlBar *controlbar;
|
||||
extern int default_font_height;
|
||||
extern bool flag_show_thread;
|
||||
extern int flag_thread_ok;
|
||||
extern bool previous_flag_show_thread;
|
||||
extern int num_opened_files;
|
||||
|
||||
extern Qps *qps;
|
||||
extern SearchBox *search_box;
|
||||
extern TFrame *infobox;
|
||||
|
||||
#endif // GLOBAL_H
|
@ -1,379 +0,0 @@
|
||||
/*
|
||||
* htable.h
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// This file defines the HeadedTable class.
|
||||
// A HeadedTable is a QTableView with one line of headers over each column.
|
||||
|
||||
#ifndef HTABLE_H
|
||||
#define HTABLE_H
|
||||
|
||||
#include "qttableview.h"
|
||||
|
||||
#ifndef USING_PCH
|
||||
#include <QHash>
|
||||
#include <QToolTip>
|
||||
#include <QVBoxLayout>
|
||||
#endif
|
||||
|
||||
// table options (bits to be ORed together)
|
||||
#define HTBL_ROW_SELECTION 1 // rows are selectable
|
||||
#define HTBL_ROW_DOUBLE_CLICK 2 // rows can be double-clicked
|
||||
#define HTBL_ROW_CONTEXT_MENU 4 // right button menu on rows
|
||||
#define HTBL_HEADING_TOOLTIPS 8 // tooltips on headings
|
||||
#define HTBL_HEADING_CONTEXT_MENU 16 // right button menu on headings
|
||||
#define HTBL_HEADING_CLICK 32 // able to click on heading (change sort order)
|
||||
#define HTBL_REORDER_COLS 64 // able to reorder columns
|
||||
|
||||
class HeadedTable;
|
||||
|
||||
class CellAttribute
|
||||
{
|
||||
public:
|
||||
QString text;
|
||||
bool selected;
|
||||
bool sorted;
|
||||
QSize size;
|
||||
QColor backColor; // table share
|
||||
QColor foreColor; // rows share
|
||||
int xpos; // cols share
|
||||
int ypos; // rows share
|
||||
int w; // cols share
|
||||
int depth; // rows share
|
||||
int folded; //
|
||||
int lastchild; //
|
||||
CellAttribute()
|
||||
{
|
||||
text = "";
|
||||
sorted = selected = false;
|
||||
xpos = -1, ypos = -1, w = 0, depth = -1, folded = -1;
|
||||
lastchild = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct TableRow
|
||||
{
|
||||
public:
|
||||
CellAttribute cells[64]; // enough
|
||||
};
|
||||
|
||||
class TableCache
|
||||
{
|
||||
int nrow, ncol;
|
||||
QList<TableRow *> rows;
|
||||
|
||||
public:
|
||||
TableCache()
|
||||
{
|
||||
// for(int i=0;i<1;i++) // tmp
|
||||
rows.append(new TableRow);
|
||||
nrow = 0;
|
||||
ncol = 0;
|
||||
}
|
||||
|
||||
void reset() {} // clear cache
|
||||
void setSize(int row, int col);
|
||||
void setRow(int row);
|
||||
void setCol(int col);
|
||||
|
||||
CellAttribute *value(int row, int col)
|
||||
{
|
||||
if (row < 0)
|
||||
qFatal("Qps: Error ! TableCache() under size !! row=%d \n", row);
|
||||
|
||||
if (row >= rows.size())
|
||||
{
|
||||
row = rows.size();
|
||||
rows.append(new TableRow);
|
||||
}
|
||||
// if(row<0 or row>rows.size())
|
||||
return &(rows[row]->cells[col]);
|
||||
}
|
||||
|
||||
void cutUp(int n)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
rows.append(rows.takeFirst());
|
||||
}
|
||||
}
|
||||
void cutDown(int n)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
TableRow *row = rows.takeLast();
|
||||
rows.prepend(row);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class VPointer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VPointer(QWidget *parent);
|
||||
QPixmap *pix;
|
||||
QPixmap *pix_vcross;
|
||||
void setMovable(bool b) { flag_movable = b; }
|
||||
bool flag_movable;
|
||||
protected slots:
|
||||
// void event_cursor_moved(QMouseEvent *e);
|
||||
protected:
|
||||
// virtual void drawButton 3( QPainter * ) ;
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
// void resizeEvent(QResizeEvent *p);
|
||||
};
|
||||
|
||||
class FloatingHead : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FloatingHead(QWidget *parent);
|
||||
QPixmap *pix;
|
||||
void setTitle(QString str, int w, int h);
|
||||
QString title;
|
||||
protected slots:
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
};
|
||||
|
||||
class TableHead : public QtTableView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TableCache tablecache;
|
||||
TableHead(HeadedTable *parent = 0);
|
||||
virtual bool isCellChanged(int row, int col);
|
||||
virtual void checkProfile();
|
||||
|
||||
protected slots:
|
||||
void scrollSideways(int);
|
||||
|
||||
protected:
|
||||
virtual void paintCell(QPainter *p, int row, int col, bool update);
|
||||
virtual int cellWidth(int col);
|
||||
virtual void mousePressEvent(QMouseEvent *e);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *e);
|
||||
virtual void mouseMoveEvent(QMouseEvent *e);
|
||||
virtual void eraseRight(QPainter *, QRect &r);
|
||||
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dragLeaveEvent(QDragLeaveEvent *event);
|
||||
|
||||
FloatingHead *floatHead;
|
||||
|
||||
HeadedTable *htable; // to access parent class
|
||||
QPoint press;
|
||||
int click_col; // physical column clicked in
|
||||
bool dragging;
|
||||
int drag_pos; // previous dragging position
|
||||
int drag_offset;
|
||||
signals:
|
||||
void rightClicked(QPoint where, int col);
|
||||
void toolTip(QPoint where, int col);
|
||||
|
||||
friend class HeadedTable;
|
||||
};
|
||||
|
||||
class TableBody : public QtTableView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TableCache tablecache;
|
||||
TableBody(HeadedTable *parent = 0);
|
||||
void drawGhostCol(int x, int w);
|
||||
// int zerowidth; // width of the digit 0
|
||||
|
||||
virtual bool isCellChanged(int row, int col);
|
||||
virtual void checkProfile();
|
||||
protected slots:
|
||||
// for keyboard accelerators
|
||||
void jumpTop();
|
||||
void jumpBottom();
|
||||
void centerVertically(int row);
|
||||
void showRange(int from, int to);
|
||||
|
||||
protected:
|
||||
virtual void scrollTrigger(int x, int y); // tmp
|
||||
|
||||
virtual void paintCell(QPainter *p, int row, int col, bool forced);
|
||||
virtual int cellWidth(int col);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
void timerEvent(QTimerEvent *);
|
||||
void updateRow(int row);
|
||||
void dragSelectTo(int row);
|
||||
QColor getXorColor();
|
||||
HeadedTable *htable; // to access parent class
|
||||
int first_drag_row; // row where drag started
|
||||
int prev_drag_row; // row where drag was at last event
|
||||
bool autoscrolling; // true if we are autoscrolling right now
|
||||
enum
|
||||
{
|
||||
UP,
|
||||
DOWN
|
||||
} scrolldir;
|
||||
static const int scroll_delay = 10; // time delay when autoscrolling, in ms
|
||||
bool gadget_click; // whether mouse press was on folding gadget
|
||||
private:
|
||||
QColor background;
|
||||
QColor color_text;
|
||||
friend class HeadedTable;
|
||||
};
|
||||
|
||||
class HeadedTable : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HeadedTable(QWidget *parent, int opts = 0);
|
||||
~HeadedTable();
|
||||
TableHead *header() { return head; } // interface
|
||||
|
||||
TableHead *head;
|
||||
TableBody *body;
|
||||
|
||||
CellAttribute *attr; // DEL temporarily buffer
|
||||
enum NodeState
|
||||
{
|
||||
Leaf,
|
||||
Open,
|
||||
Closed
|
||||
};
|
||||
|
||||
void repaint_changed();
|
||||
int updateColWidth(int col);
|
||||
|
||||
void resetWidths();
|
||||
void resetWidth(int col) { max_widths[col] = -1; } // dont use ?
|
||||
void setProxy(QWidget *w) { body->setFocusProxy(w); }
|
||||
void setSortedCol(int col);
|
||||
int sortedCol() { return sorted_col; }
|
||||
int numRows() { return nrows; }
|
||||
int numCols() { return ncols; }
|
||||
void setNumRows(int rows);
|
||||
void setNumCols(int cols);
|
||||
int clickedColumn() { return head->click_col; }
|
||||
void deleteCol(int col, bool update = true);
|
||||
int leftCell() { return body->leftCell(); };
|
||||
int lastColVisible() { return body->lastColVisible(); };
|
||||
int topCell() { return body->topCell(); };
|
||||
int lastRowVisible() { return body->lastRowVisible(); };
|
||||
void updateCell(int row, int col, bool erase = false);
|
||||
void updateHeading(int col){/* head->updateCell(0, col); */};
|
||||
void setAutoUpdate(bool update)
|
||||
{
|
||||
head->setAutoUpdate(update);
|
||||
body->setAutoUpdate(update);
|
||||
};
|
||||
void centerVertically(int row) { body->centerVertically(row); };
|
||||
void showRange(int from, int to) { body->showRange(from, to); };
|
||||
void repaintColumns(int col0, int col1 = -1);
|
||||
void setTreeMode(bool tm);
|
||||
bool treeMode() { return treemode; };
|
||||
int tableWidth() const
|
||||
{
|
||||
return body->totalWidth() + body->verticalScrollBar()->width();
|
||||
}
|
||||
|
||||
void selectOnlyOne(int row);
|
||||
int numSelected() { return 0; }
|
||||
void clearAllSelections();
|
||||
|
||||
virtual void setSelected(int row, bool sel){};
|
||||
virtual bool isSelected(int row) { return false; }
|
||||
virtual void checkTableModel(){};
|
||||
signals:
|
||||
void titleClicked(int col);
|
||||
void selectionChanged();
|
||||
void doubleClicked(int row);
|
||||
void rightClicked(QPoint where);
|
||||
void foldSubTree(int row);
|
||||
void colMoved(int col, int place);
|
||||
void flyOnCell(int row, int col);
|
||||
void flyOnHCell(int col);
|
||||
void outOfCell();
|
||||
void outOfHCell();
|
||||
|
||||
public slots:
|
||||
void selectAll();
|
||||
void repaintAll();
|
||||
|
||||
protected:
|
||||
void fontChange(const QFont &oldFont);
|
||||
// These must be implemented in subclasses
|
||||
virtual QString title(int col) = 0;
|
||||
virtual QString text(int row, int col) = 0;
|
||||
virtual char *total_selectedRow(int col);
|
||||
// colWidth returns width in digit units; negative means variable width.
|
||||
virtual int colWidth(int col) = 0; // head_width
|
||||
virtual int alignment(int col) { return 0; }
|
||||
virtual int sizeHintForColumn(int col) const { return -1; }
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
virtual void hideEvent(QHideEvent *event);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
||||
// may be reimplemented (default exists)
|
||||
virtual void moveCol(int col, int place);
|
||||
|
||||
virtual QString tipText(int col);
|
||||
virtual int rowDepth(int row) { return 0; };
|
||||
virtual NodeState folded(int row) { return Leaf; };
|
||||
virtual int parentRow(int row) { return 0; };
|
||||
virtual bool lastChild(int row) { return false; };
|
||||
virtual bool columnMovable(int col) { return true; };
|
||||
// virtual bool modified(int row){return true;};
|
||||
virtual void overpaintCell(QPainter *p, int row, int col, int xpos){};
|
||||
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
bool treemode;
|
||||
int treestep; // indentation for each tree level
|
||||
|
||||
private:
|
||||
inline int computedWidth(int col);
|
||||
int colOffset(int col);
|
||||
inline int colXPos(int col);
|
||||
void updateCols(int deltacols, int place, bool update);
|
||||
|
||||
int alignment_col[64];
|
||||
int headwidth_col[64];
|
||||
int max_widths[64]; // row widths, indexed by columns
|
||||
// Svec<int> widths; // row widths, indexed by columns
|
||||
|
||||
int sorted_col; // column to emphasize
|
||||
int reversed_sort; // true if sorting backwards
|
||||
int options;
|
||||
int nrows;
|
||||
int ncols;
|
||||
|
||||
// text cache is in logical columns (reorder causes no flush)
|
||||
bool folding; // true if folding gadgets are used
|
||||
bool lines; // true if tree lines are drawn
|
||||
int gadget_space; // horizontal space for show/hide tree gadget
|
||||
|
||||
friend class TableHead;
|
||||
friend class TableBody;
|
||||
};
|
||||
#endif // HTABLE_H
|
@ -1,232 +0,0 @@
|
||||
/*
|
||||
* htable2.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 2014 dae hyun, yang <daehyun.yang@gmail.com>
|
||||
* Copyright 2015 Paulo Lieuthier <paulolieuthier@gmail.com>
|
||||
*
|
||||
* 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 "htable2.h"
|
||||
HtableModel::HtableModel(QObject *parent) : QAbstractItemModel(parent)
|
||||
{
|
||||
htable = (HeadedTable2 *)parent;
|
||||
}
|
||||
|
||||
QModelIndex HtableModel::index(int row, int column,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
// printf("index %d %d\n",row,column);
|
||||
if (row >= 0 and column >= 0 and row < htable->nrows)
|
||||
{
|
||||
// if( column <2)
|
||||
{
|
||||
// watchCond *item=watchlist[row];
|
||||
return createIndex(row, column, NULL);
|
||||
}
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
// Pure Virtual
|
||||
QModelIndex HtableModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
int row, col;
|
||||
row = child.row();
|
||||
col = child.column();
|
||||
if (row >= 0 and col >= 0 and row < htable->nrows)
|
||||
return createIndex(htable->parentRow(row), col, NULL);
|
||||
return QModelIndex(); // no parent!
|
||||
}
|
||||
|
||||
// return chilren count
|
||||
int HtableModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return htable->nrows;
|
||||
}
|
||||
// why segfault?
|
||||
int HtableModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return htable->ncols;
|
||||
};
|
||||
|
||||
QVariant HtableModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
|
||||
// printf("headerData\n");
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return htable->title(section);
|
||||
}
|
||||
else
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return htable->alignment(section);
|
||||
// return Qt::AlignCenter;
|
||||
else if (role == Qt::ToolTipRole)
|
||||
return htable->tipText(section);
|
||||
else
|
||||
/*
|
||||
if (role == Qt::FontRole)
|
||||
{
|
||||
QFont f=QFont();
|
||||
f.setBold(false);
|
||||
return f;
|
||||
} */
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
// return QSize(18,18);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant HtableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
// printf("data\n");
|
||||
// watchCond *item=
|
||||
// static_cast<watchCond*>(index.internalPointer());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return htable->text(index.row(), index.column());
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
{
|
||||
}
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
}
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
// if(item->enable)
|
||||
// return Qt::Checked;
|
||||
// else
|
||||
// return Qt::Unchecked;
|
||||
}
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignRight;
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
}
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
// return QSize(18,18);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags HtableModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
// HtableHeader //////////////////////////
|
||||
|
||||
HtableHeader::HtableHeader(QWidget *parent)
|
||||
: QHeaderView(Qt::Horizontal, parent)
|
||||
{
|
||||
htable = (HeadedTable2 *)parent;
|
||||
setMovable(true);
|
||||
}
|
||||
|
||||
void HtableHeader::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
QHeaderView::mousePressEvent(e);
|
||||
int col = logicalIndexAt(e->pos());
|
||||
// printf("col=%d\n",col);
|
||||
if (e->button() == Qt::RightButton)
|
||||
{
|
||||
// printf("pressed col=%d\n",col); //ok
|
||||
emit rightClicked(e->globalPos(), col);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
HeadedTable2::HeadedTable2(QWidget *parent, int opts) : QTreeView(parent)
|
||||
// :QTreeWidget(parent)
|
||||
{
|
||||
nrows = ncols = 0;
|
||||
model = new HtableModel(this);
|
||||
HtableHeader *header = new HtableHeader(this);
|
||||
setHeader(header);
|
||||
setModel(model);
|
||||
// setEditTriggers (QAbstractItemView::SelectedClicked );
|
||||
// tableView->setItemDelegateForColumn(1,&delegate);
|
||||
// tableView->setItemDelegate(&delegate);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
// setSelectionMode (QAbstractItemView::ExtendedSelection);
|
||||
// setSelectionMode (QAbstractItemView::MultiSelection);
|
||||
|
||||
setUniformRowHeights(true);
|
||||
setAllColumnsShowFocus(true);
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
setAlternatingRowColors(true);
|
||||
|
||||
// v->setResizeMode (0,QHeaderView::Stretch);
|
||||
// QHeaderView *h=header ();
|
||||
header->setResizeMode(
|
||||
QHeaderView::ResizeToContents); // use sizeHintForColumn()
|
||||
header->setClickable(true);
|
||||
// header->setVisible(false);
|
||||
}
|
||||
|
||||
void HeadedTable2::setTreeMode(bool mode) {}
|
||||
|
||||
void HeadedTable2::setSortedCol(int c) {}
|
||||
|
||||
void HeadedTable2::setNumCols(int c) { ncols = c; }
|
||||
void HeadedTable2::setNumRows(int row) { nrows = row; }
|
||||
void HeadedTable2::selectAll() {}
|
||||
void HeadedTable2::repaintAll() {}
|
||||
void HeadedTable2::repaint_changed() {}
|
||||
|
||||
extern int flag_x;
|
||||
void HeadedTable2::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
printf("mousePressEvent() \n");
|
||||
QTreeView::mousePressEvent(e);
|
||||
// falg_x=1;
|
||||
flag_x = !flag_x;
|
||||
if (e->button() == Qt::RightButton)
|
||||
{
|
||||
emit rightClicked(e->globalPos());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// TEST & DRAFT: loop ..
|
||||
void HeadedTable2::modelIterate(const QModelIndex &parent)
|
||||
{
|
||||
int rows = model->rowCount(parent);
|
||||
// printf("rows=%d\n",rows);
|
||||
// expand(parent);
|
||||
setExpanded(parent, true); // expand(ci);
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
QModelIndex ci = model->index(i, 0, parent);
|
||||
// Procinfo *pi= static_cast<Procinfo*>(ci.internalPointer());
|
||||
// if(!pi->hidekids)// setExpanded(ci,true); //
|
||||
// expand(ci);
|
||||
// if(!pi->hidekids and !isExpanded(ci)) expand(ci);
|
||||
// if(!folded(ci) and !isExpanded(ci)) expand(ci);
|
||||
// if(!folded(ci) and !isExpanded(ci))
|
||||
|
||||
if (model->rowCount(ci) > 0)
|
||||
modelIterate(ci);
|
||||
}
|
||||
}
|
@ -1,207 +0,0 @@
|
||||
/*
|
||||
* htable2.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 2014 dae hyun, yang <daehyun.yang@gmail.com>
|
||||
* Copyright 2015 Paulo Lieuthier <paulolieuthier@gmail.com>
|
||||
*
|
||||
* 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 <QTreeView>
|
||||
#include <QMouseEvent>
|
||||
#include <QStandardItemModel>
|
||||
#include <QHeaderView>
|
||||
#include <QTreeWidget>
|
||||
|
||||
class HeadedTable2;
|
||||
class CellAttribute2
|
||||
{
|
||||
public:
|
||||
QString text;
|
||||
bool selected;
|
||||
bool sorted;
|
||||
|
||||
QColor backColor; // table share
|
||||
QColor foreColor; // rows share
|
||||
int xpos; // cols share
|
||||
int ypos; // rows share
|
||||
int w; // cols share
|
||||
int depth; // rows share
|
||||
int folded; //
|
||||
};
|
||||
|
||||
class HtableModel : public QAbstractItemModel
|
||||
// class HtableModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HtableModel(QObject *parent = 0);
|
||||
~HtableModel(){};
|
||||
virtual QModelIndex
|
||||
index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const; // pure
|
||||
virtual QModelIndex parent(const QModelIndex &child) const; // pure virtual
|
||||
virtual int rowCount(const QModelIndex &parent) const;
|
||||
virtual QVariant data(const QModelIndex &index, int role) const;
|
||||
int columnCount(const QModelIndex &parent) const;
|
||||
QVariant headerData(int section, Qt::Orientation o, int role) const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
// Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
// QMap<int, QVariant> itemData ( const QModelIndex & index ) const
|
||||
//;
|
||||
// void update(){ reset();}
|
||||
void update() { emit layoutChanged(); }
|
||||
// void update(const QModelIndex &idx);
|
||||
// void update(int row);
|
||||
// void update(); //TEMP
|
||||
HeadedTable2 *htable;
|
||||
};
|
||||
|
||||
class HtableHeader : public QHeaderView
|
||||
// QHeaderView ( Qt::Orientation orientation, QWidget * parent = 0 )
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HtableHeader(QWidget *parent = 0);
|
||||
~HtableHeader(){};
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *e);
|
||||
signals:
|
||||
void rightClicked(QPoint where, int col);
|
||||
void toolTip(QPoint where, int col);
|
||||
|
||||
private:
|
||||
HeadedTable2 *htable;
|
||||
};
|
||||
|
||||
class HeadedTable2 : public QTreeView
|
||||
// class HeadedTable2 : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HeadedTable2(QWidget *parent, int opts = 0);
|
||||
~HeadedTable2(){};
|
||||
|
||||
friend class HtableModel;
|
||||
HtableModel *model;
|
||||
|
||||
enum NodeState
|
||||
{
|
||||
Leaf,
|
||||
Open,
|
||||
Closed
|
||||
};
|
||||
void repaint_changed();
|
||||
int clickedColumn() { return 0; }; // need imp
|
||||
int sortedCol() { return sorted_col; } // ok
|
||||
|
||||
/*
|
||||
void deleteCol(int col, bool update = TRUE);
|
||||
void topAndRepaint();
|
||||
int lastRowVisible() { return body->lastRowVisible(); };
|
||||
void updateCell(int row, int col, bool erase=false);
|
||||
void updateHeading(int col) { };
|
||||
void selectionNotify();
|
||||
void repaintColumns(int col0, int col1 = -1);
|
||||
bool treeMode() { return treemode; };
|
||||
int tableWidth() const { return body->totalWidth()+
|
||||
body->verticalScrollBar()->width(); }
|
||||
bool isCellContentsChanged(int row,int col,bool head);
|
||||
|
||||
|
||||
void selectOnly(int row);
|
||||
void clearAllSelections();
|
||||
*/
|
||||
|
||||
int numRows() { return nrows; }
|
||||
int numCols() { return ncols; }
|
||||
int numSelected() { return 0; }
|
||||
void setTreeMode(bool mode);
|
||||
void setSortedCol(int col);
|
||||
void setNumRows(int rows);
|
||||
void setNumCols(int cols);
|
||||
virtual bool isSelected(int row) { return false; }
|
||||
virtual void setSelected(int row, bool sel){};
|
||||
void modelIterate(const QModelIndex &idx);
|
||||
signals:
|
||||
void titleClicked(int col);
|
||||
void doubleClicked(int row);
|
||||
void rightClicked(QPoint where);
|
||||
void foldSubTree(int row);
|
||||
void colMoved(int col, int place);
|
||||
|
||||
public slots:
|
||||
void selectAll();
|
||||
void repaintAll();
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *e);
|
||||
virtual int rowDepth(int row) { return 0; };
|
||||
virtual NodeState folded(int row) { return Leaf; };
|
||||
virtual bool folded(QModelIndex &idx) { return false; };
|
||||
virtual int parentRow(int row) { return 0; };
|
||||
virtual bool lastChild(int row) { return false; };
|
||||
virtual bool columnMovable(int col) { return true; };
|
||||
virtual int colWidth(int col) = 0; // head_width
|
||||
virtual void moveCol(int col, int place){};
|
||||
virtual QString title(int col) = 0;
|
||||
virtual QString text(int row, int col) = 0;
|
||||
|
||||
virtual QString tipText(int col) { return ""; };
|
||||
virtual int alignment(int col) { return 0; };
|
||||
|
||||
/*
|
||||
virtual char *total_selectedRow(int col);
|
||||
virtual int sizeHintForColumn(int col) const;
|
||||
virtual void hideEvent ( QHideEvent * event );
|
||||
virtual void showEvent ( QShowEvent * event );
|
||||
virtual void resizeEvent(QResizeEvent *);
|
||||
*/
|
||||
// colWidth returns width in digit units; negative means variable width.
|
||||
|
||||
// virtual void drawCellContents(int row, int col, int w, int
|
||||
// h,
|
||||
// QPainter *painter);
|
||||
// virtual bool modified(int row){return true;};
|
||||
bool treemode;
|
||||
|
||||
private:
|
||||
// to make signals originate from the right object
|
||||
/* void emit_click_signal(int col);
|
||||
void emit_double_click_signal(int row);
|
||||
void emit_right_click_signal(QPoint where);
|
||||
void emit_fold(int row);
|
||||
|
||||
inline int computedWidth(int col);
|
||||
int colOffset(int col);
|
||||
inline int colXPos(int col);
|
||||
void updateCols(int deltacols, int place, bool update);
|
||||
*/
|
||||
int sorted_col; // column to emphasize
|
||||
int reversed_sort; // true if sorting backwards
|
||||
int options;
|
||||
|
||||
int nrows;
|
||||
int ncols;
|
||||
|
||||
// text cache is in logical columns (reorder causes no flush)
|
||||
QHash<int, CellAttribute2 *>
|
||||
cached_attr; // indexed by (row << 16) + log_col
|
||||
QHash<int, CellAttribute2 *>
|
||||
cached_attr_h; // indexed by (row << 16) + log_col
|
||||
};
|
@ -1,232 +0,0 @@
|
||||
/*
|
||||
* infobar.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 INFOBAR_H
|
||||
#define INFOBAR_H
|
||||
|
||||
#include "proc.h"
|
||||
|
||||
#ifndef USING_PCH
|
||||
#include <QString>
|
||||
#include <QPixmap>
|
||||
#include <QResizeEvent>
|
||||
#include <QFrame>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
class subcpuRack : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
subcpuRack(QWidget *parent, Procview *p);
|
||||
void refresh();
|
||||
// void update_load();
|
||||
// void show_and_hide(bool, QWidget *, QWidget *);
|
||||
// signals: void config_change();
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
|
||||
private:
|
||||
// List<gwidget*> wlist;
|
||||
QWidget *parent;
|
||||
Procview *procview; // temp
|
||||
bool is_vertical;
|
||||
};
|
||||
|
||||
class gwidget
|
||||
{
|
||||
public:
|
||||
gwidget() { x = 0, y = 0, width = 0, height = 0; };
|
||||
gwidget(QWidget *p) { parent = p; };
|
||||
virtual void draw(QPainter *p) { printf("gwidget\n"); };
|
||||
virtual void setPosition(int parent_width, int parent_height){};
|
||||
virtual const char *info() { return NULL; };
|
||||
void setParent(QWidget *p, Procview *procv)
|
||||
{
|
||||
parent = p;
|
||||
procview = procv;
|
||||
};
|
||||
void resize(int x_, int y_, int w, int h)
|
||||
{
|
||||
x = x_;
|
||||
y = y_;
|
||||
width = w;
|
||||
height = h;
|
||||
};
|
||||
bool intersect(int cx, int cy)
|
||||
{
|
||||
cx = cx - x;
|
||||
cy = cy - y;
|
||||
if (cx > 0 and cx < width)
|
||||
if (cy > 0 and cy < height)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int xpluswidth() { return x + width; };
|
||||
Procview *procview; // temp
|
||||
|
||||
protected:
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
QRect rect;
|
||||
QWidget *parent;
|
||||
};
|
||||
|
||||
class Infobar : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Infobar(){};
|
||||
|
||||
Infobar(QWidget *parent, Procview *);
|
||||
~Infobar();
|
||||
|
||||
void configure(); // respond to configuration change
|
||||
|
||||
QPixmap *make_icon(int w, int h);
|
||||
// DEL QPixmap *load_icon(int w, int h) { return make_icon(w, h); }
|
||||
void refresh(); // update();
|
||||
void update_load();
|
||||
void drawGraphOnPixmap();
|
||||
bool swaplim_exceeded();
|
||||
void show_and_hide(bool, QWidget *, QWidget *);
|
||||
void showup();
|
||||
signals:
|
||||
void clicked();
|
||||
void config_change();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
virtual void enterEvent(QEvent *event);
|
||||
void hideEvent(QHideEvent *event);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
void add_history_point(unsigned value);
|
||||
void add_history_point2(float value);
|
||||
void make_graph(int w, int h, QPainter *p, bool test = false);
|
||||
Procview *procview;
|
||||
|
||||
private:
|
||||
// history points are stored in fixed point, scaled by history_scale
|
||||
static const unsigned int history_scale = 256;
|
||||
static const int time_dist = 60; // time between vertical lines (seconds)
|
||||
|
||||
QList<gwidget *> wlist;
|
||||
int hist_size; // history buffer size DEL
|
||||
int npoints; // nr of history points currently remembered
|
||||
float *history; // (circular) history buffer DEL
|
||||
int h_index; // next history index to use
|
||||
float peak; // largest value in history
|
||||
|
||||
bool dirty; // history changed since pixmap was drawn
|
||||
QPixmap pixmap;
|
||||
QPixmap icon_pm;
|
||||
|
||||
int px, py; // pointer position
|
||||
|
||||
bool is_vertical;
|
||||
int official_height;
|
||||
};
|
||||
|
||||
class GraphBase : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GraphBase(QWidget *parent, Procview *);
|
||||
void drawGraphOnPixmap();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
virtual void mousePressEvent(QMouseEvent *);
|
||||
virtual void mouseMoveEvent(QMouseEvent *);
|
||||
virtual void leaveEvent(QEvent *);
|
||||
// virtual void enterEvent ( QEvent * event ) ;
|
||||
// void resizeEvent ( QResizeEvent * e );
|
||||
|
||||
virtual void make_graph(int w, int h, QPainter *p);
|
||||
virtual QString doHistoryTXT(SysHistory *sysh);
|
||||
|
||||
Procview *procview;
|
||||
int official_height;
|
||||
int npoints; // nr of history points currently remembered
|
||||
private:
|
||||
// history points are stored in fixed point, scaled by history_scale
|
||||
static const unsigned int history_scale = 256;
|
||||
|
||||
int hist_size; // history buffer size DEL
|
||||
float *history; // (circular) history buffer DEL
|
||||
int h_index; // next history index to use
|
||||
float peak; // largest value in history
|
||||
|
||||
bool dirty; // history changed since pixmap was drawn
|
||||
QPixmap pixmap;
|
||||
QPixmap icon_pm;
|
||||
|
||||
int px, py; // pointer position
|
||||
};
|
||||
|
||||
class IO_Graph : public GraphBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
IO_Graph(QWidget *parent, Procview *);
|
||||
|
||||
protected:
|
||||
void make_graph(int w, int h, QPainter *p);
|
||||
QString doHistoryTXT(SysHistory *sysh);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
// class Infobar2 : public Infobar
|
||||
class Infobar2 : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Infobar2(QWidget *parent, Procview *);
|
||||
void updatePixmap(); // TEMP
|
||||
QPixmap *load_icon(int w, int h) { return basic->make_icon(w, h); }
|
||||
void refresh(); // update();
|
||||
Infobar *basic;
|
||||
IO_Graph *io_graph;
|
||||
|
||||
private:
|
||||
int official_height;
|
||||
};
|
||||
|
||||
class PDisplay : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PDisplay(QWidget *parent);
|
||||
Infobar2 *addSystem(Procview *p);
|
||||
};
|
||||
|
||||
#endif // INFOBAR_H
|
@ -1,122 +0,0 @@
|
||||
/*
|
||||
* listmodel.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 "listmodel.h"
|
||||
#include "watchcond.h"
|
||||
|
||||
extern QList<watchCond *> watchlist;
|
||||
|
||||
QModelIndex ListModel::index(int row, int column,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
// printf("index %d %d\n",row,column);
|
||||
if (row >= 0 and column >= 0 and row < watchlist.size())
|
||||
{
|
||||
if (column < 2)
|
||||
{
|
||||
watchCond *item = watchlist[row];
|
||||
return createIndex(row, column, item);
|
||||
}
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
void ListModel::update(int row)
|
||||
{
|
||||
emit dataChanged(index(row, 0), index(row, 1));
|
||||
}
|
||||
|
||||
void ListModel::update(const QModelIndex &idx) { emit dataChanged(idx, idx); }
|
||||
|
||||
// Pure Virtual
|
||||
QModelIndex ListModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
return QModelIndex(); // no parent!
|
||||
}
|
||||
int ListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return watchlist.size();
|
||||
}
|
||||
QVariant ListModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
// printf("headerData\n");
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
if (section == 0)
|
||||
return QString(tr( "Event Category" ) );
|
||||
if (section == 1)
|
||||
return QString( tr( "Enable" ) );
|
||||
}
|
||||
/*
|
||||
if (role == Qt::FontRole)
|
||||
{
|
||||
QFont f=QFont();
|
||||
f.setBold(false);
|
||||
return f;
|
||||
} */
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
// return QSize(18,18);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant ListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
// printf("data\n");
|
||||
watchCond *item = static_cast<watchCond *>(index.internalPointer());
|
||||
if (index.column() == 0)
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return QString(item->getstring());
|
||||
}
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
}
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (index.column() == 1)
|
||||
{
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
if (item->enable)
|
||||
return Qt::Checked;
|
||||
else
|
||||
return Qt::Unchecked;
|
||||
}
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignRight;
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
// return QSize(18,18);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* listmodel.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 LISTMODEL_H
|
||||
#define LISTMODEL_H
|
||||
|
||||
#include <QStandardItemModel>
|
||||
// class ListModel : public QAbstractItemModel
|
||||
class ListModel : public QAbstractTableModel
|
||||
// class ListModel : public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ListModel(QObject *parent = 0){};
|
||||
~ListModel(){};
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const; // pure
|
||||
QModelIndex parent(const QModelIndex &child) const; // pure virtual
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
int columnCount(const QModelIndex &parent) const { return 2; };
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation o, int role) const;
|
||||
// QMap<int, QVariant> itemData ( const QModelIndex & index ) const
|
||||
//;
|
||||
void update()
|
||||
{ // reset();
|
||||
}
|
||||
void update(const QModelIndex &idx);
|
||||
void update(int row);
|
||||
// Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
// void update(); //TEMP
|
||||
};
|
||||
|
||||
#endif // LISTMODEL_H
|
@ -1,284 +0,0 @@
|
||||
/*
|
||||
* lookup.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// This module implements asynchronous address->hostname lookup.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <signal.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "lookup.h"
|
||||
#include "svec.cpp"
|
||||
|
||||
// declarations of static members
|
||||
char *Lookup::argv0;
|
||||
int Lookup::maxtitlelen;
|
||||
|
||||
UintQueue::UintQueue() { first = last = 0; };
|
||||
|
||||
void UintQueue::enqueue(unsigned x)
|
||||
{
|
||||
if (last < 0)
|
||||
{
|
||||
// make room for inserting more elements
|
||||
int step = qMax(first + 1, 8);
|
||||
queue.setSize(first + step + 1);
|
||||
for (int i = first; i > last; i--)
|
||||
queue[i + step] = queue[i];
|
||||
first += step;
|
||||
last += step;
|
||||
}
|
||||
queue.set(last--, x);
|
||||
}
|
||||
|
||||
unsigned UintQueue::dequeue()
|
||||
{
|
||||
if (isEmpty())
|
||||
fatal("UintQueue: queue empty");
|
||||
return queue[first--];
|
||||
}
|
||||
|
||||
// constructor for node head
|
||||
Hostnode::Hostnode() : next(this), prev(this) {}
|
||||
|
||||
// create a new cache node, initialized with null string
|
||||
Hostnode::Hostnode(unsigned addr) : ipaddr(addr), next(0), prev(0) {}
|
||||
|
||||
// must be called on the head of the list
|
||||
void Hostnode::moveToFront(Hostnode *node)
|
||||
{
|
||||
if (next != node)
|
||||
{
|
||||
Hostnode *p = node->prev, *n = node->next;
|
||||
p->next = n;
|
||||
n->prev = p;
|
||||
node->next = next;
|
||||
node->prev = this;
|
||||
next->prev = node;
|
||||
next = node;
|
||||
}
|
||||
}
|
||||
|
||||
// must be called on the head of the list
|
||||
void Hostnode::deleteLast()
|
||||
{
|
||||
Hostnode *nuke = prev;
|
||||
prev = nuke->prev;
|
||||
prev->next = this;
|
||||
delete nuke;
|
||||
}
|
||||
|
||||
// must be called on the head of the list
|
||||
void Hostnode::insertFirst(Hostnode *node)
|
||||
{
|
||||
node->prev = this;
|
||||
node->next = next;
|
||||
next->prev = node;
|
||||
next = node;
|
||||
}
|
||||
|
||||
Lookup::Lookup() // : hostdict(17)
|
||||
{
|
||||
sockfd = -1; // no lookup helper is running
|
||||
readsn = writesn = 0;
|
||||
outstanding = 0;
|
||||
}
|
||||
|
||||
// empty destructor, workaround for gcc bug
|
||||
Lookup::~Lookup() {}
|
||||
|
||||
// look up host name (addr is in host byte order)
|
||||
// a null name means it is been looked up (signal will be sent when done)
|
||||
QString Lookup::hostname(unsigned addr)
|
||||
{
|
||||
// first look in our cache
|
||||
Hostnode *hn = hostdict.value(addr, NULL);
|
||||
if (hn)
|
||||
{
|
||||
hostlru.moveToFront(hn);
|
||||
}
|
||||
else
|
||||
{
|
||||
hn = new Hostnode(addr);
|
||||
if (hostdict.count() >= hostname_cache_size)
|
||||
{
|
||||
// remove least recently used item
|
||||
hostdict.remove(hostlru.last()->ipaddr);
|
||||
hostlru.deleteLast();
|
||||
}
|
||||
hostlru.insertFirst(hn);
|
||||
hostdict.insert(addr, hn);
|
||||
// if(hostdict.count() > hostdict.size() * 3)
|
||||
// hostdict.resize(hostdict.count());
|
||||
if (addr == 0)
|
||||
hn->name = "*";
|
||||
else
|
||||
request(addr);
|
||||
}
|
||||
return hn->name;
|
||||
}
|
||||
|
||||
void Lookup::request(unsigned addr)
|
||||
{
|
||||
addrqueue.enqueue(addr);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
int socks[2];
|
||||
socketpair(AF_UNIX, SOCK_STREAM, 0, socks);
|
||||
// launch a new helper
|
||||
signal(SIGCHLD, SIG_IGN); // Linux does automatic child reaping, nice
|
||||
switch (fork())
|
||||
{
|
||||
case -1: // error
|
||||
return; // don't bother, we'll try again next time
|
||||
case 0: // child
|
||||
close(socks[0]);
|
||||
do_child(socks[1]);
|
||||
break;
|
||||
default: // parent
|
||||
close(socks[1]);
|
||||
sockfd = socks[0];
|
||||
readsn = new QSocketNotifier(sockfd, QSocketNotifier::Read, this);
|
||||
connect(readsn, SIGNAL(activated(int)), SLOT(receive_result(int)));
|
||||
writesn = new QSocketNotifier(sockfd, QSocketNotifier::Write, this);
|
||||
connect(writesn, SIGNAL(activated(int)), SLOT(send_request(int)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
writesn->setEnabled(true);
|
||||
}
|
||||
|
||||
// the child helper process loop
|
||||
void Lookup::do_child(int fd)
|
||||
{
|
||||
setproctitle("qps-dns-helper");
|
||||
// close unused fds
|
||||
for (int i = 0; i < fd; i++)
|
||||
close(i);
|
||||
for (;;)
|
||||
{
|
||||
unsigned addr;
|
||||
int ret = read(fd, &addr, sizeof(addr));
|
||||
if (ret <= 0)
|
||||
{
|
||||
_exit(0); // connection closed
|
||||
}
|
||||
struct hostent *h = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
|
||||
char buf[256];
|
||||
if (!h)
|
||||
{
|
||||
unsigned a = htonl(addr);
|
||||
sprintf(buf, "%d.%d.%d.%d", (a >> 24) & 0xff, (a >> 16) & 0xff,
|
||||
(a >> 8) & 0xff, a & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(buf, h->h_name, sizeof(buf));
|
||||
}
|
||||
// if parent died, we'll get SIGPIPE here and terminate
|
||||
// automatically
|
||||
write(fd, &addr, sizeof(addr));
|
||||
int len = strlen(buf);
|
||||
write(fd, &len, sizeof(len));
|
||||
write(fd, buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
// slot: receive result from helper
|
||||
void Lookup::receive_result(int)
|
||||
{
|
||||
unsigned addr;
|
||||
int len;
|
||||
char buf[256];
|
||||
|
||||
if (read(sockfd, &addr, sizeof(addr)) <= 0 ||
|
||||
read(sockfd, &len, sizeof(len)) <= 0 || read(sockfd, buf, len) <= 0)
|
||||
{
|
||||
// helper has died
|
||||
delete readsn;
|
||||
delete writesn;
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
return;
|
||||
}
|
||||
buf[len] = '\0';
|
||||
Hostnode *hn = hostdict.value(addr, NULL);
|
||||
if (!hn)
|
||||
return; // gone from cache
|
||||
hn->name = buf;
|
||||
emit resolved(addr);
|
||||
|
||||
outstanding--;
|
||||
// if there is nothing more in the queue, kill the helper
|
||||
if (addrqueue.isEmpty() && outstanding == 0)
|
||||
{
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
delete readsn;
|
||||
delete writesn;
|
||||
}
|
||||
}
|
||||
|
||||
// slot: send request to the helper
|
||||
void Lookup::send_request(int)
|
||||
{
|
||||
if (addrqueue.isEmpty())
|
||||
{
|
||||
writesn->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned addr = addrqueue.dequeue();
|
||||
if (write(sockfd, &addr, sizeof(addr)) < 0)
|
||||
{
|
||||
// This shouldn't happen, try to repair it anyway
|
||||
addrqueue.enqueue(addr);
|
||||
delete readsn;
|
||||
delete writesn;
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
return;
|
||||
}
|
||||
outstanding++;
|
||||
}
|
||||
|
||||
// register and measure the space for modifying the visible command line
|
||||
void Lookup::initproctitle(char **argv, char **envp)
|
||||
{
|
||||
argv0 = argv[0];
|
||||
while (*envp)
|
||||
envp++;
|
||||
maxtitlelen = envp[-1] + strlen(envp[-1]) - argv0 - 2;
|
||||
}
|
||||
|
||||
// set the process title (idea snarfed from sysvinit (thanks Miquel) and
|
||||
// refined by peeking into wu-ftpd)
|
||||
void Lookup::setproctitle(const char *txt)
|
||||
{
|
||||
memset(argv0, 0, maxtitlelen);
|
||||
strncpy(argv0, txt, maxtitlelen - 1);
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* lookup.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 LOOKUP_H
|
||||
#define LOOKUP_H
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qsocketnotifier.h>
|
||||
#include "svec.h"
|
||||
#include <QHash>
|
||||
|
||||
// queue (fifo) of unsigned ints (inet addresses)
|
||||
class UintQueue
|
||||
{
|
||||
public:
|
||||
UintQueue();
|
||||
|
||||
bool isEmpty() { return first == last; };
|
||||
void enqueue(unsigned x);
|
||||
unsigned dequeue();
|
||||
|
||||
private:
|
||||
Svec<unsigned> queue;
|
||||
int first; // index of first item in queue
|
||||
int last; // index where next item will be put (< first)
|
||||
};
|
||||
|
||||
// list node for LRU cache of hostnames:
|
||||
// This list is doubly-linked circular (to reduce the amount of special cases),
|
||||
// with a head node that carries no data. In addition, each node is
|
||||
// entered into a hash table for rapid lookup
|
||||
class Hostnode
|
||||
{
|
||||
public:
|
||||
Hostnode();
|
||||
Hostnode(unsigned addr);
|
||||
|
||||
// these must be called on the head of the list
|
||||
void moveToFront(Hostnode *node);
|
||||
void deleteLast();
|
||||
void insertFirst(Hostnode *node);
|
||||
Hostnode *last() { return prev; };
|
||||
|
||||
QString name;
|
||||
unsigned ipaddr; // hash key
|
||||
Hostnode *next, *prev;
|
||||
};
|
||||
|
||||
class Lookup : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Lookup();
|
||||
~Lookup();
|
||||
QString hostname(unsigned addr);
|
||||
|
||||
static void initproctitle(char **argv, char **envp);
|
||||
|
||||
signals:
|
||||
void resolved(unsigned addr);
|
||||
|
||||
protected slots:
|
||||
void receive_result(int);
|
||||
void send_request(int);
|
||||
|
||||
protected:
|
||||
void request(unsigned addr);
|
||||
void do_child(int fd);
|
||||
|
||||
static void setproctitle(const char *txt);
|
||||
|
||||
static char *argv0;
|
||||
static int maxtitlelen;
|
||||
|
||||
QHash<int, Hostnode *> hostdict;
|
||||
Hostnode hostlru; // head of circular list
|
||||
UintQueue addrqueue; // queue of addresses to lookup
|
||||
int outstanding; // number of outstanding requests
|
||||
int sockfd; // -1 if no helper process is running
|
||||
|
||||
QSocketNotifier *readsn, *writesn;
|
||||
|
||||
static const unsigned hostname_cache_size = 400; // max names to cache
|
||||
};
|
||||
|
||||
#endif // LOOKUP_H
|
@ -1,37 +0,0 @@
|
||||
<ui version="4.0" >
|
||||
<class>ExecWindow</class>
|
||||
<widget class="QWidget" name="ExecWindow" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>309</width>
|
||||
<height>162</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Qps</string>
|
||||
</property>
|
||||
<property name="windowIcon" >
|
||||
<iconset>
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit" />
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okButton" >
|
||||
<property name="text" >
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="qps.qrc" />
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,317 +0,0 @@
|
||||
/*
|
||||
* misc.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 2014 dae hyun, yang <daehyun.yang@gmail.com>
|
||||
* Copyright 2015 Paulo Lieuthier <paulolieuthier@gmail.com>
|
||||
*
|
||||
* 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 MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#ifndef USING_PCH
|
||||
#include <QAbstractButton>
|
||||
#include <QCheckBox>
|
||||
#include <QRadioButton>
|
||||
#include <QStatusBar>
|
||||
#include <QPainter>
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QTextEdit>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <QTimerEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QAbstractButton>
|
||||
#include <QTimerEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QFrame>
|
||||
#include <QResizeEvent>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QTimeLine>
|
||||
#endif
|
||||
|
||||
char *userName(int uid, int euid);
|
||||
char *groupName(int gid, int egid);
|
||||
|
||||
void setQpsTheme();
|
||||
|
||||
int fsize(char *fname);
|
||||
void msleep(long msec);
|
||||
void mem_string(int kbytes, char *buf);
|
||||
void mem_string_k(int kbytes, char *buf);
|
||||
|
||||
void init_xpm();
|
||||
void init_misc(QWidget *main);
|
||||
int pf_write(QPainter *p, int x, int y, const char *str);
|
||||
int pf_str_width(char *str);
|
||||
int pf_char_height();
|
||||
void check_qps_running();
|
||||
|
||||
int QPS_PROCVIEW_CPU_NUM();
|
||||
void AddLog(QString str);
|
||||
|
||||
class CrossBox : public QCheckBox
|
||||
{
|
||||
public:
|
||||
CrossBox(const char *text, QWidget *parent);
|
||||
|
||||
protected:
|
||||
virtual void drawButton(QPainter *paint);
|
||||
};
|
||||
|
||||
class CheckMenu : public QMenu
|
||||
{
|
||||
public:
|
||||
CheckMenu(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
class TFrame : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TFrame(QWidget *parent);
|
||||
void setText(QString str);
|
||||
void draw(QPainter &p);
|
||||
void showText(QPoint pos, QString str);
|
||||
void setPos(int x, int y);
|
||||
void setPos();
|
||||
|
||||
protected slots:
|
||||
// void refresh();
|
||||
// void update(int n);
|
||||
// QToolButton *button,*button2,*button3;
|
||||
// void event_cursor_moved(QMouseEvent *e);
|
||||
void setValue(int val);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
virtual void moveEvent(QMoveEvent *event);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
||||
private:
|
||||
QString text;
|
||||
QTimeLine *timeLine;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
class TBloon : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TBloon(QWidget *parent);
|
||||
// void setText(QString str);
|
||||
// void draw( QPainter &p );
|
||||
// void showText(QPoint pos,QString str);
|
||||
|
||||
virtual bool eventFilter(QObject *watched, QEvent *event);
|
||||
protected slots:
|
||||
void update(int val);
|
||||
// void refresh();
|
||||
// void update(int n);
|
||||
// QToolButton *button,*button2,*button3;
|
||||
// void event_cursor_moved(QMouseEvent *e);
|
||||
protected:
|
||||
// virtual void paintEvent( QPaintEvent * event );
|
||||
// virtual void moveEvent (QMoveEvent * event );
|
||||
private:
|
||||
QWidget *paren;
|
||||
QString text;
|
||||
QTimeLine *timeLine;
|
||||
};
|
||||
|
||||
class FaderWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QBrush fadeBrush READ fadeBrush WRITE setFadeBrush)
|
||||
Q_PROPERTY(int fadeDuration READ fadeDuration WRITE setFadeDuration)
|
||||
public:
|
||||
FaderWidget(QWidget *parent);
|
||||
|
||||
QBrush fadeBrush() const { return startBrush; }
|
||||
void setFadeBrush(const QBrush &newColor) { startBrush = newColor; }
|
||||
|
||||
int fadeDuration() const { return timeLine->duration(); }
|
||||
void setFadeDuration(int milliseconds)
|
||||
{
|
||||
timeLine->setDuration(milliseconds);
|
||||
}
|
||||
|
||||
void start();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
QTimeLine *timeLine;
|
||||
QBrush startBrush;
|
||||
};
|
||||
|
||||
class UFrame : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UFrame(QWidget *parent);
|
||||
void setTitle(QString str);
|
||||
protected slots:
|
||||
// void refresh();
|
||||
// void update(int n);
|
||||
// QToolButton *button,*button2,*button3;
|
||||
// void event_cursor_moved(QMouseEvent *e);
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
QString title;
|
||||
QString stylesheet;
|
||||
};
|
||||
|
||||
class XButton : public QAbstractButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
XButton(QWidget *parent);
|
||||
protected slots:
|
||||
// void refresh();
|
||||
// void update(int n);
|
||||
// QToolButton *button,*button2,*button3;
|
||||
// void event_cursor_moved(QMouseEvent *e);
|
||||
protected:
|
||||
// virtual void drawButton 3( QPainter * ) ;
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
void resizeEvent(QResizeEvent *p);
|
||||
};
|
||||
|
||||
class SearchBox : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SearchBox(QWidget *parent);
|
||||
void event_cursor_moved(QMouseEvent *e);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
protected slots:
|
||||
void event_xbutton_clicked();
|
||||
// void refresh();
|
||||
// void update(int n);
|
||||
// QToolButton *button,*button2,*button3;
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void timerEvent(QTimerEvent *);
|
||||
int left_time;
|
||||
// XButton *xb;
|
||||
};
|
||||
|
||||
class LogBox : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LogBox(QWidget *w);
|
||||
QTextEdit *text;
|
||||
// QLabel *label,*label2,*label3;
|
||||
};
|
||||
|
||||
class StatusBar : public QStatusBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
StatusBar(QWidget *parent);
|
||||
void refresh();
|
||||
void update(int n);
|
||||
QLabel *label, *label2, *label3;
|
||||
};
|
||||
|
||||
class ControlBar : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QComboBox *view;
|
||||
ControlBar(QWidget *parent);
|
||||
void setMode(bool treemode);
|
||||
void update_bar();
|
||||
QToolButton *pauseButton;
|
||||
|
||||
signals:
|
||||
void modeChange(bool treemode);
|
||||
void viewChange(QAction *);
|
||||
void need_refresh();
|
||||
|
||||
public slots:
|
||||
void linear_clicked();
|
||||
void view_changed(int idx);
|
||||
void tree_clicked();
|
||||
void show_thread_clicked();
|
||||
void event_search_box_changed();
|
||||
void event_command_pressed();
|
||||
void setPaused(bool);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private:
|
||||
QRadioButton *b_tree, *b_linear, *b_treeT;
|
||||
QCheckBox *check_thread;
|
||||
QBoxLayout *layout;
|
||||
};
|
||||
|
||||
#include <QTabWidget>
|
||||
|
||||
class QTabWidgetX : public QTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QTabWidgetX(QWidget *parent);
|
||||
void showTab(bool);
|
||||
};
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
// class ServerAdaptor: public QDBusAbstractAdaptor
|
||||
class ServerAdaptor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "com.trolltech.Examples.CarInterface")
|
||||
Q_CLASSINFO("D-Bus Introspection",
|
||||
""
|
||||
" <interface name=\"com.trolltech.Examples.CarInterface\" >\n"
|
||||
" <method name=\"accelerate\" />\n"
|
||||
" <method name=\"decelerate\" />\n"
|
||||
" <method name=\"turnLeft\" />\n"
|
||||
" <method name=\"turnRight\" />\n"
|
||||
" <signal name=\"crashed\" />\n"
|
||||
" </interface>\n"
|
||||
"")
|
||||
public:
|
||||
// ServerAdaptor(QObject *parent);
|
||||
ServerAdaptor(){};
|
||||
virtual ~ServerAdaptor(){};
|
||||
|
||||
public: // PROPERTIES
|
||||
public Q_SLOTS: // METHODS
|
||||
void accelerate();
|
||||
Q_SIGNALS: // SIGNALS
|
||||
void crashed();
|
||||
};
|
||||
|
||||
#endif // MISC_H
|
@ -1,420 +0,0 @@
|
||||
/*
|
||||
* prefs.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 "prefs.h"
|
||||
#include "proc.h"
|
||||
#include "qps.h"
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QGroupBox>
|
||||
#include <qstring.h>
|
||||
#include <QtGui>
|
||||
#include <QApplication>
|
||||
#include <QFontComboBox>
|
||||
|
||||
//#include <qstylefactory.h>
|
||||
#include "qps.h"
|
||||
extern Qps *qps;
|
||||
|
||||
extern QFontComboBox *font_cb;
|
||||
// class that validates input for the "swap warning limit" field
|
||||
class Swapvalid : public QValidator
|
||||
{
|
||||
public:
|
||||
Swapvalid(QWidget *parent) : QValidator(parent) {}
|
||||
virtual State validate(QString &s, int &) const;
|
||||
};
|
||||
|
||||
struct Boxvar
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Boxvar)
|
||||
public:
|
||||
const QString text;
|
||||
bool *variable;
|
||||
// CrossBox *cb;
|
||||
QCheckBox *cb;
|
||||
|
||||
Boxvar() : text( QString() ), variable( static_cast< bool * >( 0 ) ), cb( static_cast< QCheckBox *>( 0 ) ) {}
|
||||
Boxvar( const QString t, bool *v, QCheckBox *c ) : text( t ), variable( v ), cb( c ) {}
|
||||
|
||||
static QVector< Boxvar > *general_boxes()
|
||||
{
|
||||
static QVector< Boxvar > boxes( { { tr( "Exit On Close Button" ), &Qps::flag_exit, 0}
|
||||
// , { tr( "Graphic Load Display" ), &Qps::show_load_graph, 0 }
|
||||
// , { tr( "Graphic CPU Display" ), &Qps::show_cpu_bar, 0}
|
||||
// , { tr( "Minimized on Close Button" ), &Qps::flag_systray, 0}
|
||||
// TEMPO
|
||||
// , { tr( "Use Tab-View" ), &Qps::flag_useTabView, 0}
|
||||
// , { tr( "Hide qps in Linear mode" ), &Qps::flag_qps_hide, 0}
|
||||
// , { tr( "Load Graph in Icon" ), &Qps::load_in_icon, 0}
|
||||
// , { tr( "Selection: Copy PIDs to Clipboard" ), &Qps::pids_to_selection, 0}
|
||||
// , { tr( "show underdevelopment" ), &Qps::flag_devel, 0}
|
||||
// , { tr( "Vertical CPU Bar (under development)" ), &Qps::vertical_cpu_bar, 0}
|
||||
} );
|
||||
return &boxes;
|
||||
}
|
||||
|
||||
//#ifdef LINUX
|
||||
static QVector< Boxvar > *sockinfo_boxes()
|
||||
{
|
||||
static QVector< Boxvar > boxes( { { tr( "Host Name Lookup" ), &Qps::hostname_lookup, 0}
|
||||
, { tr( "Service Name Lookup" ), &Qps::service_lookup, 0} } );
|
||||
return &boxes;
|
||||
}
|
||||
//#endif
|
||||
static QVector< Boxvar > *tree_boxes()
|
||||
{
|
||||
static QVector< Boxvar > boxes( { { tr( "Disclosure Triangles" ), &Qps::tree_gadgets, 0}
|
||||
, { tr( "Branch Lines" ), &Qps::tree_lines, 0} } );
|
||||
return &boxes;
|
||||
}
|
||||
|
||||
static QVector< Boxvar > *misc_boxes()
|
||||
{
|
||||
static QVector< Boxvar > boxes( { { tr( "Auto Save Settings on Exit" ), &Qps::auto_save_options, 0}
|
||||
, { tr( "Selection: Copy PIDs to Clipboard" ), &Qps::pids_to_selection, 0}
|
||||
#ifdef SOLARIS
|
||||
, { tr( "Normalize NICE" ), &Qps::normalize_nice, 0}
|
||||
, { tr( "Use pmap for Map Names" ), &Qps::use_pmap, 0}
|
||||
#endif
|
||||
} );
|
||||
return &boxes;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Cbgroup
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Cbgroup)
|
||||
public:
|
||||
const QString caption;
|
||||
QVector< Boxvar > *boxvar;
|
||||
|
||||
Cbgroup() : caption( QString() ), boxvar( static_cast< QVector< Boxvar > * >( 0 ) ) {}
|
||||
Cbgroup( const QString c, QVector< Boxvar > *b ) : caption( c ), boxvar( b ) {}
|
||||
|
||||
static QVector< Cbgroup > &groups()
|
||||
{
|
||||
static QVector< Cbgroup > groups( { { tr( "General" ), Boxvar::general_boxes() }
|
||||
#ifdef LINUX
|
||||
// , { tr( "Socket Info Window" ), Boxvar::sockinfo_boxes() }
|
||||
#endif
|
||||
// , { tr( "Tree View" ), Boxvar::tree_boxes() }
|
||||
// , { tr( "Miscellaneous" ), Boxvar::misc_boxes() }
|
||||
} );
|
||||
return groups;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
void find_fontsets();
|
||||
// dual use function: both validate and apply changes
|
||||
QValidator::State Swapvalid::validate(QString &s, int &) const
|
||||
{
|
||||
// only accept /^[0-9]*[%kKmM]?$/
|
||||
int len = s.length();
|
||||
int i = 0;
|
||||
while (i < len && s[i] >= '0' && s[i] <= '9')
|
||||
i++;
|
||||
if ((i < len && QString("kKmM%").contains(s[i]) == 0) || i < len - 1)
|
||||
return Invalid;
|
||||
if (s[i] == 'k')
|
||||
s[i] = 'K';
|
||||
if (s[i] == 'm')
|
||||
s[i] = 'M';
|
||||
// int val = atoi((const char *)s);
|
||||
int val = s.toInt();
|
||||
bool percent;
|
||||
if (s[i] == '%')
|
||||
{
|
||||
percent = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
percent = false;
|
||||
if (s[i] == 'M')
|
||||
val <<= 10;
|
||||
}
|
||||
Qps::swaplimit = val;
|
||||
Qps::swaplim_percent = percent;
|
||||
return Acceptable;
|
||||
}
|
||||
|
||||
Preferences::Preferences() : QDialog()
|
||||
{
|
||||
int flag_test = 0;
|
||||
setWindowTitle( tr( "Preferences" ) );
|
||||
QVBoxLayout *v_layout = new QVBoxLayout;
|
||||
|
||||
if (flag_test)
|
||||
{
|
||||
QTabWidget *tbar = new QTabWidget(this);
|
||||
QWidget *w = new QWidget(this);
|
||||
tbar->addTab(w, tr( "Setting" ) );
|
||||
w->setLayout(v_layout);
|
||||
}
|
||||
else
|
||||
setLayout(v_layout);
|
||||
|
||||
v_layout->setSpacing(1);
|
||||
// v_layout->setSpacing(1);
|
||||
const int border_x = 10;
|
||||
int min_x = 0;
|
||||
|
||||
QVector< Cbgroup >::iterator endItG = Cbgroup::groups().end();
|
||||
for( QVector< Cbgroup >::iterator itG = Cbgroup::groups().begin(); itG != endItG; ++ itG )
|
||||
{
|
||||
QGroupBox *grp = new QGroupBox( itG->caption, this );
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
if ( itG->boxvar )
|
||||
{
|
||||
QVector< Boxvar >::iterator endItB = itG->boxvar->end();
|
||||
for( QVector< Boxvar >::iterator itB = itG->boxvar->begin(); itB != endItB; ++ itB )
|
||||
{
|
||||
itB->cb = new QCheckBox( itB->text, grp );
|
||||
vbox->addWidget( itB->cb );
|
||||
connect( itB->cb, SIGNAL(clicked()), SLOT(update_reality()));
|
||||
// -> EMIT prefs_change()
|
||||
}
|
||||
}
|
||||
grp->setLayout(vbox);
|
||||
v_layout->addWidget(grp);
|
||||
}
|
||||
|
||||
update_boxes();
|
||||
|
||||
/*
|
||||
QGroupBox *wgrp = new QGroupBox("Swap Warning", this);
|
||||
QHBoxLayout *hl = new QHBoxLayout;
|
||||
wgrp->setLayout(hl);
|
||||
QLabel *lbl = new QLabel("Warn when free swap below", wgrp);
|
||||
QLineEdit *swaped = new QLineEdit(wgrp);
|
||||
hl->addWidget(lbl);
|
||||
hl->addWidget(swaped);
|
||||
//swaped->setAlignment ( Qt::AlignRight );
|
||||
QString s;
|
||||
if(Qps::swaplim_percent) {
|
||||
s.sprintf("%d%%", Qps::swaplimit);
|
||||
} else {
|
||||
if(Qps::swaplimit >= 1024 && (Qps::swaplimit & 0x7ff) == 0)
|
||||
s.sprintf("%dM", Qps::swaplimit >> 10);
|
||||
else
|
||||
s.sprintf("%dK", Qps::swaplimit);
|
||||
}
|
||||
swaped->setText(s);
|
||||
swaped->setValidator(new Swapvalid(this));
|
||||
connect(swaped, SIGNAL(textChanged(const QString &)),
|
||||
SIGNAL(prefs_change()));
|
||||
v_layout->addWidget(wgrp);
|
||||
*/
|
||||
|
||||
rb_totalcpu = NULL; // tmp
|
||||
|
||||
if (QPS_PROCVIEW_CPU_NUM() > 1)
|
||||
{
|
||||
QGroupBox *grp_cpu = new QGroupBox( tr( "%CPU divided by" ), this);
|
||||
QVBoxLayout *vboxlayout = new QVBoxLayout;
|
||||
QHBoxLayout *hbox = new QHBoxLayout;
|
||||
vboxlayout->addLayout(hbox);
|
||||
|
||||
// num_cpus
|
||||
|
||||
rb_totalcpu = new QRadioButton( tr( "Total cpu: %1" ).arg( QPS_PROCVIEW_CPU_NUM() ), grp_cpu);
|
||||
QRadioButton *rb2 = new QRadioButton( tr( "Single cpu: 1" ), grp_cpu);
|
||||
if (!Procview::flag_pcpu_single)
|
||||
rb_totalcpu->setChecked(true);
|
||||
else
|
||||
rb2->setChecked(true);
|
||||
|
||||
rb_totalcpu->setToolTip( tr( "default" ) );
|
||||
rb2->setToolTip( tr( "for developer" ) );
|
||||
hbox->addWidget(rb_totalcpu);
|
||||
hbox->addWidget(rb2);
|
||||
grp_cpu->setLayout(vboxlayout);
|
||||
v_layout->addWidget(grp_cpu);
|
||||
|
||||
connect(rb_totalcpu, SIGNAL(clicked()), this, SLOT(update_config()));
|
||||
connect(rb2, SIGNAL(clicked()), this, SLOT(update_config()));
|
||||
}
|
||||
|
||||
// Appearance ====================================
|
||||
if (font_cb == NULL)
|
||||
{
|
||||
font_cb = new QFontComboBox(this); // preload
|
||||
font_cb->setWritingSystem(QFontDatabase::Latin);
|
||||
font_cb->setCurrentFont(QApplication::font());
|
||||
|
||||
// remove Some Ugly Font : hershey...
|
||||
// printf("size=%d\n",font_cb->count());
|
||||
for (int i = 0; i < font_cb->count();)
|
||||
{
|
||||
QString name = font_cb->itemText(i);
|
||||
if (name.contains("hershey", Qt::CaseInsensitive) == true)
|
||||
{
|
||||
// printf("%s\n",qPrintable(name));
|
||||
font_cb->removeItem(i);
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (font_cb)
|
||||
{
|
||||
font_cb->show();
|
||||
|
||||
QGroupBox *gbox = new QGroupBox( tr( "Appearance" ), this);
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
QHBoxLayout *hbox = new QHBoxLayout();
|
||||
|
||||
psizecombo = new QComboBox(this);
|
||||
hbox->addWidget(font_cb);
|
||||
hbox->addWidget(psizecombo);
|
||||
vbox->addLayout(hbox);
|
||||
gbox->setLayout(vbox);
|
||||
v_layout->addWidget(gbox);
|
||||
|
||||
// connect(font_cb, SIGNAL(activated( int)),this,
|
||||
// SLOT(font_changed(int)));
|
||||
connect(font_cb, SIGNAL(activated(int)), this, SLOT(font_changed(int)));
|
||||
connect(psizecombo, SIGNAL(activated(int)), SLOT(font_changed(int)));
|
||||
|
||||
// add to font size
|
||||
init_font_size();
|
||||
}
|
||||
|
||||
/*
|
||||
// Style, Themes ==================================
|
||||
QLabel *label3 = new QLabel("Themes", font_grp);
|
||||
QComboBox *theme_combo = new QComboBox(font_grp);
|
||||
|
||||
QStringList styles = QStyleFactory::keys();
|
||||
styles.sort();
|
||||
theme_combo->insertStringList(styles);
|
||||
|
||||
QString currentstyle;
|
||||
currentstyle = QApplication::style().className();
|
||||
*/
|
||||
|
||||
QPushButton *saveButton = new QPushButton("OK", this);
|
||||
// saveButton->setFocusPolicy(QWidget::NoFocus);
|
||||
saveButton->setFocus();
|
||||
saveButton->setDefault(true);
|
||||
v_layout->addWidget(saveButton);
|
||||
// v_layout->freeze();
|
||||
|
||||
connect(saveButton, SIGNAL(clicked()), SLOT(closed()));
|
||||
}
|
||||
|
||||
//
|
||||
void Preferences::init_font_size()
|
||||
{
|
||||
// QFontDatabase db;
|
||||
// QStringList families ( WritingSystem writingSystem = Any ) const
|
||||
// QStringList families = db.families(QFontDatabase::Latin);
|
||||
// QStringList extra;
|
||||
psizecombo->clear();
|
||||
int i, idx = 0;
|
||||
for (i = 5; i < 24; i++)
|
||||
psizecombo->insertItem(idx++, QString::number(i));
|
||||
|
||||
// find current font size
|
||||
i = 0;
|
||||
for (int psize = QApplication::font().pointSize(); i < psizecombo->count();
|
||||
++i)
|
||||
{
|
||||
const int sz = psizecombo->itemText(i).toInt();
|
||||
if (sz == psize)
|
||||
{
|
||||
psizecombo->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// slot: update check boxes to reflect current status
|
||||
void Preferences::update_boxes()
|
||||
{
|
||||
QVector< Cbgroup >::iterator endItG = Cbgroup::groups().end();
|
||||
for( QVector< Cbgroup >::iterator itG = Cbgroup::groups().begin(); itG != endItG; ++ itG )
|
||||
{
|
||||
if ( ! itG->boxvar )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QVector< Boxvar >::iterator endItB = itG->boxvar->end();
|
||||
for( QVector< Boxvar >::iterator itB = itG->boxvar->begin(); itB != endItB; ++ itB )
|
||||
{
|
||||
itB->cb->setChecked( *( itB->variable ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// slot: update flags and repaint to reflect state of check boxes
|
||||
void Preferences::update_reality()
|
||||
{
|
||||
QVector< Cbgroup >::iterator endItG = Cbgroup::groups().end();
|
||||
for( QVector< Cbgroup >::iterator itG = Cbgroup::groups().begin(); itG != endItG; ++ itG )
|
||||
{
|
||||
if ( ! itG->boxvar )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QVector< Boxvar >::iterator endItB = itG->boxvar->end();
|
||||
for( QVector< Boxvar >::iterator itB = itG->boxvar->begin(); itB != endItB; ++ itB )
|
||||
{
|
||||
*( itB->variable ) = itB->cb->isChecked();
|
||||
}
|
||||
}
|
||||
emit prefs_change();
|
||||
}
|
||||
|
||||
void Preferences::update_config()
|
||||
{
|
||||
if (rb_totalcpu and rb_totalcpu->isChecked() == true)
|
||||
Procview::flag_pcpu_single = false;
|
||||
else
|
||||
Procview::flag_pcpu_single = true;
|
||||
}
|
||||
|
||||
void Preferences::closed()
|
||||
{
|
||||
// delete font_cb; font_cb==NULL;
|
||||
// font_cb->clear();
|
||||
update_config();
|
||||
hide();
|
||||
emit prefs_change();
|
||||
}
|
||||
|
||||
// work
|
||||
void Preferences::font_changed(int i)
|
||||
{
|
||||
int size = psizecombo->currentText().toInt();
|
||||
QFont font = font_cb->currentFont();
|
||||
font.setPointSize(size);
|
||||
|
||||
QApplication::setFont(font);
|
||||
}
|
||||
|
||||
// DRAFT CODE:
|
||||
void Preferences::fontset_changed(int i) {}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* prefs.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 PREFS_H
|
||||
#define PREFS_H
|
||||
|
||||
#include <qdialog.h>
|
||||
#include <qradiobutton.h>
|
||||
#include <qlabel.h>
|
||||
//#include <q3buttongroup.h>
|
||||
#include <QtGui>
|
||||
#include "misc.h"
|
||||
|
||||
class Preferences : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Preferences();
|
||||
QComboBox *psizecombo;
|
||||
// QFontComboBox *font_cb;
|
||||
QRadioButton *rb_totalcpu;
|
||||
void init_font_size();
|
||||
|
||||
public slots:
|
||||
void update_boxes();
|
||||
void update_reality();
|
||||
void update_config();
|
||||
void closed();
|
||||
void font_changed(int);
|
||||
void fontset_changed(int);
|
||||
signals:
|
||||
void prefs_change();
|
||||
};
|
||||
|
||||
#endif // PREFS_H
|
@ -1,889 +0,0 @@
|
||||
/*
|
||||
* proc.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 PROC_H
|
||||
#define PROC_H
|
||||
|
||||
#include "config.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
#ifdef SOLARIS
|
||||
#include <kstat.h> // kstat_ctl_t
|
||||
#endif
|
||||
|
||||
#ifndef USING_PCH
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
#endif
|
||||
|
||||
class Procinfo;
|
||||
int read_file(char *name, char *buf, int max);
|
||||
int read_file_addNULL(char *name, void *buf, int max);
|
||||
void check_system_requirement();
|
||||
int get_kernel_version();
|
||||
|
||||
//#define F_PID 0x00000000
|
||||
enum fields
|
||||
{
|
||||
F_PID = 0,
|
||||
#ifdef LINUX
|
||||
F_TGID,
|
||||
#endif
|
||||
F_PPID,
|
||||
F_PGID,
|
||||
F_SID,
|
||||
F_TTY,
|
||||
#ifdef LINUX
|
||||
F_TPGID,
|
||||
#endif
|
||||
#ifdef MOSIX
|
||||
F_MIGR,
|
||||
F_LOCKED,
|
||||
F_NMIGS,
|
||||
F_NOMOVE,
|
||||
F_RPID,
|
||||
#endif
|
||||
F_USER,
|
||||
F_GROUP,
|
||||
F_UID,
|
||||
F_EUID,
|
||||
#ifdef LINUX
|
||||
F_SUID,
|
||||
F_FSUID,
|
||||
#endif
|
||||
F_GID,
|
||||
F_EGID,
|
||||
#ifdef LINUX
|
||||
F_SGID,
|
||||
F_FSGID,
|
||||
#endif
|
||||
F_PRI,
|
||||
F_NICE,
|
||||
F_PLCY,
|
||||
F_RPRI,
|
||||
#ifdef LINUX
|
||||
F_TMS,
|
||||
F_AFFCPU,
|
||||
F_SLPAVG,
|
||||
#endif
|
||||
F_NLWP,
|
||||
#ifdef SOLARIS
|
||||
F_ARCH,
|
||||
#endif
|
||||
F_MAJFLT,
|
||||
F_MINFLT,
|
||||
#ifdef LINUX
|
||||
F_TRS,
|
||||
F_DRS,
|
||||
F_STACK,
|
||||
#endif
|
||||
F_SIZE, // VSIZE
|
||||
F_SWAP, // Linux not correct
|
||||
F_MEM,
|
||||
F_RSS,
|
||||
#ifdef LINUX
|
||||
F_SHARE,
|
||||
F_DT,
|
||||
F_IOW,
|
||||
F_IOR,
|
||||
#endif
|
||||
F_STAT,
|
||||
F_FLAGS,
|
||||
F_WCHAN,
|
||||
F_WCPU,
|
||||
F_CPU, /* %CPU */
|
||||
F_PMEM, // F_PMEM: %MEM
|
||||
F_START,
|
||||
F_TIME,
|
||||
F_CPUNUM,
|
||||
F_CMD,
|
||||
F_PROCESSNAME, // NEW
|
||||
F_CWD,
|
||||
F_ROOT, //?
|
||||
F_CMDLINE,
|
||||
F_END = -1
|
||||
};
|
||||
|
||||
class Details;
|
||||
|
||||
#ifdef LINUX
|
||||
|
||||
class Sockinfo
|
||||
{
|
||||
public:
|
||||
enum proto_t
|
||||
{
|
||||
TCP,
|
||||
UDP
|
||||
};
|
||||
proto_t proto;
|
||||
unsigned char st;
|
||||
unsigned char tr;
|
||||
unsigned local_addr;
|
||||
unsigned rem_addr;
|
||||
unsigned short local_port;
|
||||
unsigned short rem_port;
|
||||
unsigned tx_queue;
|
||||
unsigned rx_queue;
|
||||
unsigned tm_when;
|
||||
unsigned rexmits;
|
||||
int uid; //??
|
||||
int pid;
|
||||
int timeout;
|
||||
int inode;
|
||||
};
|
||||
|
||||
class SockInode
|
||||
{
|
||||
public:
|
||||
SockInode(int descr, unsigned long ino) : fd(descr), inode(ino){};
|
||||
int fd;
|
||||
unsigned long inode;
|
||||
};
|
||||
|
||||
class UnixSocket
|
||||
{
|
||||
public:
|
||||
unsigned long inode;
|
||||
QString name;
|
||||
unsigned flags;
|
||||
unsigned char type; // SOCK_STREAM or SOCK_DGRAM
|
||||
unsigned char state; // SS_FREE, SS_UNCONNECTED, SS_CONNECTING,
|
||||
// SS_CONNECTED, SS_DISCONNECTING
|
||||
};
|
||||
|
||||
#endif // LINUX
|
||||
|
||||
// COMMON
|
||||
class Mapsinfo
|
||||
{
|
||||
public:
|
||||
unsigned long from, to;
|
||||
unsigned long offset;
|
||||
unsigned long inode;
|
||||
QString filename; // null if name unknown
|
||||
char perm[4]; // "rwx[ps]"; last is private/shared flag
|
||||
unsigned minor, major;
|
||||
};
|
||||
|
||||
#define OPEN_READ 1
|
||||
#define OPEN_WRITE 2
|
||||
|
||||
class Fileinfo
|
||||
{
|
||||
public:
|
||||
Fileinfo(int descr, QString name, int open_mode = 0)
|
||||
: fd(descr), filename(name), mode(open_mode){};
|
||||
int fd;
|
||||
QString filename; // "major:minor inode" in Linux 2.0,
|
||||
// texual description in Solaris 2.6
|
||||
unsigned mode; // bits from OPEN_* above (Linux only)
|
||||
};
|
||||
|
||||
class NameValue
|
||||
{
|
||||
public:
|
||||
NameValue(){};
|
||||
// NameValue(const NameValue &nv){ name=nv.name; value=nv.value; };
|
||||
NameValue(const char *n, const char *val) : name(n), value(val){};
|
||||
QString name;
|
||||
QString value;
|
||||
};
|
||||
|
||||
class Category
|
||||
{
|
||||
public:
|
||||
Category( const QString &heading, const QString &explain ) : name(heading), help(explain), reversed(false),flag_int_value(false){}
|
||||
virtual ~Category();
|
||||
|
||||
virtual int alignment() = 0;
|
||||
virtual QString string(Procinfo *p) = 0;
|
||||
virtual int width() = 0;
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
|
||||
QString name;
|
||||
QString help;
|
||||
int index;
|
||||
int id;
|
||||
bool reversed; // testing
|
||||
bool flag_int_value; // testing: for total sum , cat_memory , cat_int
|
||||
};
|
||||
|
||||
// COMMON
|
||||
class Cat_int : public Category
|
||||
{
|
||||
public:
|
||||
Cat_int(const QString &heading, const QString &explain, int w,
|
||||
int Procinfo::*member);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return field_width; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
|
||||
protected:
|
||||
int Procinfo::*int_member;
|
||||
int field_width;
|
||||
};
|
||||
|
||||
// COMMON for memory usage
|
||||
class Cat_memory : public Category
|
||||
{
|
||||
public:
|
||||
Cat_memory(const QString &heading, const QString &explain, int w,
|
||||
unsigned long Procinfo::*member);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return field_width; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
|
||||
protected:
|
||||
unsigned long Procinfo::*uintl_member;
|
||||
int field_width;
|
||||
};
|
||||
|
||||
class Cat_uintl : public Category
|
||||
{
|
||||
public:
|
||||
Cat_uintl(const QString &heading, const QString &explain, int w,
|
||||
unsigned long Procinfo::*member);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return field_width; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
|
||||
protected:
|
||||
unsigned long Procinfo::*uintl_member;
|
||||
int field_width;
|
||||
};
|
||||
|
||||
class Cat_hex : public Cat_uintl
|
||||
{
|
||||
public:
|
||||
Cat_hex(const QString &heading, const QString &explain, int w,
|
||||
unsigned long Procinfo::*member);
|
||||
virtual QString string(Procinfo *p);
|
||||
};
|
||||
|
||||
class Cat_swap : public Category
|
||||
{
|
||||
public:
|
||||
Cat_swap(const QString &heading, const QString &explain);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return 8; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
};
|
||||
|
||||
class Cat_string : public Category
|
||||
{
|
||||
public:
|
||||
Cat_string(const QString &heading, const QString &explain,
|
||||
QString Procinfo::*member = 0);
|
||||
virtual int alignment() { return Qt::AlignLeft; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return -9; };
|
||||
virtual int gap() { return 8; };
|
||||
|
||||
protected:
|
||||
QString Procinfo::*str_member;
|
||||
};
|
||||
|
||||
class Cat_user : public Cat_string
|
||||
{
|
||||
public:
|
||||
Cat_user(const QString &heading, const QString &explain);
|
||||
virtual QString string(Procinfo *p);
|
||||
};
|
||||
|
||||
class Cat_group : public Cat_string
|
||||
{
|
||||
public:
|
||||
Cat_group(const QString &heading, const QString &explain);
|
||||
virtual QString string(Procinfo *p);
|
||||
};
|
||||
|
||||
class Cat_wchan : public Cat_string
|
||||
{
|
||||
public:
|
||||
Cat_wchan(const QString &heading, const QString &explain);
|
||||
virtual QString string(Procinfo *p);
|
||||
};
|
||||
|
||||
class Cat_dir : public Cat_string
|
||||
{
|
||||
public:
|
||||
Cat_dir(const QString &heading, const QString &explain, const char *dirname,
|
||||
QString Procinfo::*member);
|
||||
virtual QString string(Procinfo *p);
|
||||
|
||||
protected:
|
||||
const char *dir;
|
||||
QString Procinfo::*cache;
|
||||
};
|
||||
|
||||
class Cat_cmdline : public Cat_string
|
||||
{
|
||||
public:
|
||||
Cat_cmdline(const QString &heading, const QString &explain);
|
||||
virtual QString string(Procinfo *p);
|
||||
};
|
||||
|
||||
class Cat_state : public Category
|
||||
{
|
||||
public:
|
||||
Cat_state(const QString &heading, const QString &explain);
|
||||
virtual int alignment() { return Qt::AlignLeft; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return 6; };
|
||||
virtual int gap() { return 8; };
|
||||
};
|
||||
|
||||
class Cat_policy : public Category
|
||||
{
|
||||
public:
|
||||
Cat_policy(const QString &heading, const QString &explain);
|
||||
virtual int alignment() { return Qt::AlignLeft; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return 3; };
|
||||
virtual int gap() { return 8; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
};
|
||||
|
||||
class Cat_rtprio : public Category
|
||||
{
|
||||
public:
|
||||
Cat_rtprio(const QString &heading, const QString &explain);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return 5; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
};
|
||||
|
||||
#ifdef LINUX
|
||||
class Cat_tms : public Category
|
||||
{
|
||||
public:
|
||||
Cat_tms(const QString &heading, const QString &explain);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return 5; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
};
|
||||
|
||||
class Cat_affcpu : public Category
|
||||
{
|
||||
public:
|
||||
Cat_affcpu(const QString &heading, const QString &explain);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return 8; };
|
||||
// virtual int compare(Procinfo *a, Procinfo *b);
|
||||
};
|
||||
#endif
|
||||
|
||||
class Cat_time : public Category
|
||||
{
|
||||
public:
|
||||
Cat_time(const QString &heading, const QString &explain);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return 7; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
};
|
||||
|
||||
class Cat_start : public Category
|
||||
{
|
||||
public:
|
||||
Cat_start(const QString &heading, const QString &explain);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return 8; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
};
|
||||
|
||||
class Cat_percent : public Category
|
||||
{
|
||||
public:
|
||||
Cat_percent(const QString &heading, const QString &explain, int w,
|
||||
float Procinfo::*member);
|
||||
virtual int alignment() { return Qt::AlignRight; };
|
||||
virtual QString string(Procinfo *p);
|
||||
virtual int width() { return field_width; };
|
||||
virtual int compare(Procinfo *a, Procinfo *b);
|
||||
|
||||
protected:
|
||||
float Procinfo::*float_member;
|
||||
int field_width;
|
||||
};
|
||||
|
||||
class Cat_tty : public Cat_string
|
||||
{
|
||||
public:
|
||||
Cat_tty(const QString &heading, const QString &explain);
|
||||
virtual QString string(Procinfo *p);
|
||||
};
|
||||
|
||||
#define CPU_TIMES(cpu, kind) cpu_times_vec[cpu * CPUTIMES + kind]
|
||||
class Proc;
|
||||
|
||||
class Procinfo // Process Infomation
|
||||
{
|
||||
public:
|
||||
Procinfo(Proc *system_proc, int pid, int thread_id = -1);
|
||||
#ifdef SOLARIS
|
||||
// Procinfo(int pid); //solaris !
|
||||
// Procinfo(int pid, int thread); //solaris !
|
||||
int readproc(int pid, int lwp);
|
||||
#endif
|
||||
~Procinfo();
|
||||
Procinfo *ref()
|
||||
{
|
||||
refcnt++;
|
||||
return this;
|
||||
};
|
||||
void deref()
|
||||
{
|
||||
if (!--refcnt)
|
||||
delete this;
|
||||
};
|
||||
Proc *proc;
|
||||
|
||||
inline void calculate_cpu();
|
||||
|
||||
int readproc();
|
||||
|
||||
bool isThread();
|
||||
void read_fd(int fdnum, char *path);
|
||||
bool read_fds();
|
||||
bool read_maps();
|
||||
bool read_environ();
|
||||
#ifdef SOLARIS
|
||||
void read_pmap_maps();
|
||||
#endif
|
||||
#ifdef MOSIX
|
||||
static void check_for_mosix();
|
||||
static Svec<int> mosix_nodes();
|
||||
#endif
|
||||
|
||||
int get_policy();
|
||||
int get_rtprio();
|
||||
|
||||
#ifdef LINUX
|
||||
double get_tms();
|
||||
unsigned long get_affcpu();
|
||||
|
||||
QVector<SockInode *> sock_inodes; // socket inodes or NULL if not read
|
||||
#endif
|
||||
int pid;
|
||||
bool clone;
|
||||
|
||||
bool first_run; // for optimization
|
||||
char hashstr[128 * 8]; // cache
|
||||
int hashlen;
|
||||
int hashcmp(char *str);
|
||||
|
||||
QString command; // COMMAND
|
||||
QString cmdline; // COMMAND_LINE
|
||||
QString username; //
|
||||
QString groupname; //
|
||||
QString cwd; // null if not read
|
||||
QString root; // null if not read
|
||||
|
||||
bool accepted;
|
||||
int test_stop; // for test
|
||||
int session; // ???
|
||||
|
||||
int uid, euid;
|
||||
int gid, egid;
|
||||
|
||||
char state;
|
||||
int ppid; // Parent's PID
|
||||
int pgrp;
|
||||
dev_t tty; // tty major:minor device
|
||||
int type; // TESTING X,NETWORK,FILE_OPEN,TERMINAL(tty),THREAD,
|
||||
|
||||
int nthreads; // number of threads : LWP(Solaris), task(Linux)
|
||||
int tgid; // thread leader's id
|
||||
|
||||
#ifdef LINUX
|
||||
double tms; // slice time
|
||||
int slpavg;
|
||||
unsigned long affcpu;
|
||||
|
||||
int suid, fsuid;
|
||||
int sgid, fsgid;
|
||||
int tpgid;
|
||||
|
||||
unsigned long cminflt;
|
||||
unsigned long cmajflt;
|
||||
#endif
|
||||
|
||||
unsigned long io_read; // byte, testing
|
||||
unsigned long io_write; // testing
|
||||
unsigned long io_read_KBps; // K byte/sec
|
||||
unsigned long io_write_KBps; // K byte/sec
|
||||
unsigned long io_read_prev, io_write_prev;
|
||||
|
||||
unsigned long flags; //?
|
||||
unsigned long minflt;
|
||||
unsigned long majflt;
|
||||
|
||||
long utime;
|
||||
long old_utime; // initial value = -1 ;
|
||||
long cutime;
|
||||
int priority;
|
||||
int nice;
|
||||
unsigned long starttime; // start time since run in epoch? Linux : jiffies
|
||||
// since boot , solaris
|
||||
unsigned long wchan;
|
||||
QString wchan_str;
|
||||
|
||||
// Memory
|
||||
unsigned long mem; // user Memory define
|
||||
unsigned long size; // SIZE: total memory (K)
|
||||
unsigned long resident; // RSS: pages in resident set (non-swapped) (K)
|
||||
#ifdef LINUX
|
||||
unsigned long share; // shared memory pages (mmaped) (K)
|
||||
unsigned long trs; // text resident set size (K)
|
||||
unsigned long lrs; // shared-lib resident set size (K)
|
||||
unsigned long drs; // data resident set size (K)
|
||||
unsigned long
|
||||
dt; // dirty pages (number of pages, not K), obsolute in Kernel 2.6
|
||||
unsigned long stack; // stack size (K)
|
||||
#endif
|
||||
|
||||
#ifdef SOLARIS
|
||||
int addr_bits; // address bits (32 or 64)
|
||||
|
||||
char policy_name[2]; // two first letters of scheduling class
|
||||
#endif
|
||||
struct timeval tv; // time when the snapshot was taken
|
||||
struct timeval old_tv; //
|
||||
|
||||
// Posix.1b scheduling
|
||||
int policy; // -1 = uninitialized
|
||||
int rtprio; // 0-99, higher can pre-empt lower (-1 = uninitialized)
|
||||
|
||||
// Linux: the cpu used most of the time of the process
|
||||
// Solaris: the cpu on which the process last ran
|
||||
int which_cpu;
|
||||
|
||||
// computed %cpu and %mem since last update
|
||||
float wcpu, old_wcpu; // %WCPUwheight cpu
|
||||
float pcpu; // %CPU: percent cpu after last update
|
||||
float pmem; // %MEM
|
||||
|
||||
QVector<Fileinfo *> fd_files; // file names list
|
||||
QVector<Mapsinfo *> maps; // maps list
|
||||
QVector<NameValue> environ; // environment
|
||||
char *envblock; // malloc()ed environment data block
|
||||
|
||||
#ifdef SOLARIS
|
||||
unsigned long env_ofs;
|
||||
#endif
|
||||
|
||||
Details *detail; // details window or NULL (backlink)
|
||||
|
||||
unsigned int generation; // timestamp
|
||||
|
||||
bool selected : 1; // true if selected in current view
|
||||
bool hidekids : 1; // true if children are hidden in tree view
|
||||
bool lastchild : 1; // true if last (visible) child in tree view
|
||||
|
||||
short level; // distance from process root
|
||||
QVector<Procinfo *> children; // real child processes
|
||||
static const int MAX_CMD_LEN = 512;
|
||||
|
||||
char refcnt;
|
||||
|
||||
// virtual child for Table_Tree
|
||||
QVector<Procinfo *> table_children;
|
||||
int table_child_seq;
|
||||
int clear_gen;
|
||||
int child_seq_prev;
|
||||
int parent_row; // virtual parent for tree table
|
||||
|
||||
#ifdef MOSIX
|
||||
bool isremote;
|
||||
int from;
|
||||
int where;
|
||||
int remotepid;
|
||||
QString migr; // String explaining migration "node>" or ">node"
|
||||
int nmigs;
|
||||
int locked;
|
||||
QString cantmove;
|
||||
static bool mosix_running; // true if MOSIX is running
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef QHash<int, Procinfo *> Proclist;
|
||||
|
||||
class SysHistory
|
||||
{
|
||||
public:
|
||||
int idx;
|
||||
time_t time; // saved time, epoch...
|
||||
int current_gen;
|
||||
float load_cpu; // %CPU total ; green
|
||||
float load_mem; // %mem ; yellow?
|
||||
float load_io; // %SYS_IO ; BLUE
|
||||
float load_net; // ;blue? orange?
|
||||
Proclist procs;
|
||||
~SysHistory();
|
||||
};
|
||||
|
||||
|
||||
// for A System
|
||||
// cf. Procinfo is for a Process
|
||||
//
|
||||
class Proc
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Proc)
|
||||
public:
|
||||
Proc();
|
||||
~Proc();
|
||||
void commonPostInit(); // COMMON
|
||||
void read_proc_all(); // test
|
||||
void refresh();
|
||||
|
||||
static void init_static();
|
||||
int read_system();
|
||||
int countCpu();
|
||||
void read_loadavg();
|
||||
|
||||
int read_pid_tasks(int pid);
|
||||
|
||||
Category *cat_by_name( const QString &s );
|
||||
int field_id_by_name( const QString &s );
|
||||
|
||||
#ifdef LINUX
|
||||
/* from /proc/net/{tcp,udp,unix} */
|
||||
QHash<int, Sockinfo *> socks; // tcp/udp sockets
|
||||
QHash<int, UnixSocket *> usocks; // unix domain sockets
|
||||
bool socks_current; // true if the socks list is current
|
||||
bool usocks_current; // true if the usocks list is current
|
||||
|
||||
bool read_socket_list(Sockinfo::proto_t proto, const char *pseudofile);
|
||||
void read_sockets();
|
||||
bool read_usocket_list();
|
||||
void read_usockets();
|
||||
void invalidate_sockets();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SOLARIS
|
||||
static kstat_ctl_t *kc; // NULL if kstat not opened
|
||||
#endif
|
||||
QHash<int, Category *> categories;
|
||||
|
||||
Proclist procs; // processes indexed by pid
|
||||
|
||||
// TESTING
|
||||
QString supasswd; // test
|
||||
int syshistoryMAX;
|
||||
Proclist *hprocs; // temp_hprocs list
|
||||
Proclist *mprocs; //
|
||||
QList<SysHistory *> history;
|
||||
|
||||
void setHistory(int tick);
|
||||
Proclist getHistory(int pos);
|
||||
|
||||
int qps_pid; // test
|
||||
float loadQps; // TEST
|
||||
static int update_msec;
|
||||
|
||||
// class
|
||||
int num_cpus; // current number of CPUs
|
||||
int old_num_cpus; // previous number of CPUs
|
||||
|
||||
long num_network_process; // number of network(socket) process
|
||||
long num_opened_files; // number of opened normal(not socket) files
|
||||
int num_process; // number of process
|
||||
|
||||
long dt_total; //
|
||||
long dt_used; // cpu used time in clktick
|
||||
|
||||
long read_byte; // test
|
||||
long write_byte; // test
|
||||
long io_byte; // test file_io
|
||||
|
||||
float load_cpu; // %CPU total
|
||||
float loadavg[3]; // 1,5,15 minutes load avgs
|
||||
|
||||
unsigned int clk_tick; // the number of clock ticks per second.
|
||||
unsigned int boot_time; // boot time in seconds since the Epoch
|
||||
|
||||
int mem_total, mem_free; // (Kb)
|
||||
int swap_total, swap_free; // in kB
|
||||
|
||||
int mem_shared, mem_buffers, mem_cached; // Linux
|
||||
|
||||
// the following are pointers to matrices indexed by kind (above) and
|
||||
// cpu
|
||||
unsigned *cpu_times_vec;
|
||||
unsigned *old_cpu_times_vec;
|
||||
|
||||
// accessors for (old_)cpu_times_vec
|
||||
unsigned &cpu_times(int cpu, int kind)
|
||||
{
|
||||
return cpu_times_vec[cpu * CPUTIMES + kind];
|
||||
}
|
||||
unsigned &old_cpu_times(int cpu, int kind)
|
||||
{
|
||||
return old_cpu_times_vec[cpu * CPUTIMES + kind];
|
||||
}
|
||||
|
||||
#ifdef LINUX
|
||||
// from /proc/stat
|
||||
unsigned long *per_cpu_times; // vector of num_cpus times
|
||||
unsigned long *old_per_cpu_times; // vector of num_cpus times
|
||||
#endif
|
||||
|
||||
// Solaris <sys/sysinfo.h> #defines CPU_xxx so we must avoid them
|
||||
enum
|
||||
{
|
||||
CPUTIME_USER,
|
||||
#ifdef LINUX
|
||||
CPUTIME_NICE,
|
||||
#endif
|
||||
CPUTIME_SYSTEM,
|
||||
#ifdef SOLARIS
|
||||
CPUTIME_WAIT,
|
||||
#endif
|
||||
CPUTIME_IDLE,
|
||||
CPUTIMES
|
||||
};
|
||||
|
||||
//#define CPU_TIMES(cpu, kind) cpu_times_vec[cpu * CPUTIMES + kind]
|
||||
|
||||
unsigned int current_gen;
|
||||
int maxSizeHistory;
|
||||
};
|
||||
|
||||
class Procview : public Proc
|
||||
{
|
||||
public:
|
||||
Procview();
|
||||
QString filterstr;
|
||||
|
||||
static bool flag_show_file_path;
|
||||
static bool flag_pcpu_single;
|
||||
static bool flag_cumulative;
|
||||
|
||||
static int compare(Procinfo *const *a, Procinfo *const *b);
|
||||
static int compare_backwards(Procinfo *const *a, Procinfo *const *b);
|
||||
void refresh();
|
||||
bool accept_proc(Procinfo *p); // COMMON
|
||||
void linearize_tree(QVector<Procinfo *> *ps, int level, int prow,
|
||||
bool flag_hide = false);
|
||||
void build_tree(Proclist &);
|
||||
void rebuild();
|
||||
|
||||
void set_fields();
|
||||
void set_fields_list(int fields[]);
|
||||
void addField(char *name); // interface
|
||||
void addField(int FIELD_ID, int where = -1); // base interface
|
||||
void removeField(int FIELD_ID);
|
||||
int findCol(int FIELD_ID);
|
||||
void moveColumn(int col, int place);
|
||||
void deduce_fields();
|
||||
void fieldArrange();
|
||||
void update_customfield();
|
||||
//
|
||||
void setSortColumn(int col, bool r = false);
|
||||
void setTreeMode(bool b);
|
||||
void saveCOMMANDFIELD();
|
||||
|
||||
#ifndef GTK
|
||||
Procinfo *getProcinfoByPID(int pid) { return procs.value(pid, NULL); };
|
||||
#endif
|
||||
|
||||
QVector<Procinfo *> linear_procs; // this is linear_proc_list for viewer
|
||||
|
||||
#ifdef LINUX
|
||||
QVector<Sockinfo *> linear_socks; // Linux Testing
|
||||
#endif
|
||||
|
||||
// QList<> tags_kernel;
|
||||
|
||||
// root_procs contains processes without parent; normally only init, but
|
||||
// we cannot rely on this (Solaris has several parentless processes).
|
||||
// Also, if the view is restricted, all processes whose parent isn't in
|
||||
// the table.
|
||||
QVector<Procinfo *> root_procs; // table_root_procs; for viewer
|
||||
QVector<Category *> cats; // for table
|
||||
|
||||
Category *sortcat;
|
||||
Category *sortcat_linear; // testing
|
||||
int sort_column; // index of
|
||||
bool reversed; // true if sorted backwards
|
||||
static bool treeview; // true if viewed in tree form
|
||||
bool enable; // tmp
|
||||
|
||||
enum procstates
|
||||
{
|
||||
ALL,
|
||||
OWNED,
|
||||
NROOT,
|
||||
RUNNING,
|
||||
HIDDEN,
|
||||
NETWORK
|
||||
};
|
||||
enum fieldstates
|
||||
{
|
||||
USER = HIDDEN + 1,
|
||||
JOBS,
|
||||
MEM,
|
||||
SCHED,
|
||||
CUSTOM
|
||||
};
|
||||
int viewproc;
|
||||
int viewfields;
|
||||
|
||||
int idxF_CMD; ////Test
|
||||
QStringList customfields;
|
||||
static int custom_fields[64];
|
||||
// lists of fields to be used for different views, terminated by -1:
|
||||
static int mini_fields[]; // for mobile
|
||||
static int basic_fields[];
|
||||
static int jobs_fields[];
|
||||
static int mem_fields[];
|
||||
#ifdef LINUX
|
||||
static int sched_fields[];
|
||||
#endif
|
||||
|
||||
#ifdef MOSIX
|
||||
static int user_fields_mosix[];
|
||||
static int jobs_fields_mosix[];
|
||||
static int mem_fields_mosix[];
|
||||
#endif
|
||||
static float avg_factor; // exponential factor for averaging
|
||||
static const int cpu_avg_time = 30 * 1000; // averaging time for WCPU (ms)
|
||||
|
||||
private:
|
||||
static Category *static_sortcat; // kludge: to be used by compare
|
||||
};
|
||||
|
||||
#endif // PROC_H
|
@ -1,603 +0,0 @@
|
||||
/*
|
||||
* pstable.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// ** toooo complex,so need new Design ... should be more simple.. (by
|
||||
// fasthyun@magicn.com)
|
||||
|
||||
#include "proc.h"
|
||||
#include "pstable.h"
|
||||
#include "misc.h"
|
||||
|
||||
///#include <limits.h>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QToolTip>
|
||||
|
||||
// When a subtree is folded away, selections inside it disappear to prevent
|
||||
// unexpected behaviour
|
||||
static void clear_subtree_selections(Procinfo *p)
|
||||
{
|
||||
for (int i = 0; i < p->table_children.size(); i++)
|
||||
{
|
||||
Procinfo *c = p->table_children[i];
|
||||
c->selected = false;
|
||||
clear_subtree_selections(c);
|
||||
}
|
||||
}
|
||||
|
||||
// SLOT :
|
||||
// connect(this, SIGNAL(titleClicked(int)), SLOT(setSortColumn(int)));
|
||||
void Pstable::setSortColumn(int col)
|
||||
{
|
||||
procview->setSortColumn(col, false);
|
||||
setSortedCol(col); // void HeadedTable::setSortedCol(int col)
|
||||
refresh(); // rebuild table
|
||||
}
|
||||
|
||||
// AWKWARD
|
||||
// sync Procview and HeadedTable set sorted column of table to procview->sortcol
|
||||
// called by 1. Pstable::moveCol(int col, int place)
|
||||
void Pstable::set_sortcol()
|
||||
{
|
||||
for (int i = 0; i < procview->cats.size(); i++)
|
||||
{
|
||||
if (procview->cats[i] == procview->sortcat)
|
||||
{
|
||||
HeadedTable::setSortedCol(i); // HeadedTable
|
||||
return;
|
||||
}
|
||||
}
|
||||
setSortedCol(-1);
|
||||
}
|
||||
|
||||
// for Optimization
|
||||
int Pstable::sizeHintForColumn(int col) const
|
||||
{
|
||||
// int aw=fontMetrics().averageCharWidth();
|
||||
int aw = fontMetrics().width("0");
|
||||
int cat_idx = procview->cats[col]->index;
|
||||
// if(col==0) printf("col.idx=%d
|
||||
// %s\n",cat_idx,procview->cats[col]->name);
|
||||
switch (cat_idx)
|
||||
{
|
||||
// only COMMON Field
|
||||
// case F_PID :
|
||||
case F_RSS:
|
||||
case F_SIZE:
|
||||
case F_TTY:
|
||||
return aw * 6;
|
||||
case F_MEM:
|
||||
case F_START:
|
||||
case F_CPU: // PCPU
|
||||
return aw * 6 + 2;
|
||||
case F_TIME:
|
||||
return aw * 5;
|
||||
case F_WCPU:
|
||||
case F_NICE:
|
||||
return aw * 5;
|
||||
case F_CMD:
|
||||
return -(aw * 20);
|
||||
|
||||
case F_USER:
|
||||
// case F_USER : return aw*10;
|
||||
case F_CMDLINE:
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// inner
|
||||
QString Pstable::title(int col)
|
||||
{
|
||||
if (col >= procview->cats.size())
|
||||
{
|
||||
qDebug("Qps Bug!: title() over col !! %d\n", col);
|
||||
return "";
|
||||
}
|
||||
return procview->cats[col]->name;
|
||||
}
|
||||
|
||||
// TESTING
|
||||
void Pstable::overpaintCell(QPainter *p, int row, int col, int xpos)
|
||||
{
|
||||
if (col != 0)
|
||||
return;
|
||||
if (procview->cats[col]->id != F_CMD)
|
||||
return;
|
||||
|
||||
int w;
|
||||
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
|
||||
int n = pi->nthreads;
|
||||
if (n == 1)
|
||||
return;
|
||||
#ifdef LINUX
|
||||
if (pi->pid != pi->tgid)
|
||||
return; // LINUX
|
||||
|
||||
#endif
|
||||
w = p->fontMetrics().width(text(row, col));
|
||||
|
||||
QFont font = p->font();
|
||||
int size = font.pointSize(); // point size
|
||||
|
||||
if (size <= 0)
|
||||
return; // saver!
|
||||
|
||||
int h = body->cellHeight();
|
||||
h = p->fontMetrics().height(); // return pixel
|
||||
|
||||
int msize = h * 3.0 / 8.0;
|
||||
// printf("DEBUG: height=%d, msize=%d\n",h,msize);
|
||||
|
||||
if (h <= 11)
|
||||
return; // saver!
|
||||
|
||||
if (msize < 6)
|
||||
msize = 6;
|
||||
|
||||
// font.setPointSize(msize); // not pixel!
|
||||
font.setPixelSize(msize); // not pixel!
|
||||
p->setFont(font);
|
||||
p->drawText(xpos + w + 2, msize + msize / 3, QString::number(n));
|
||||
font.setPointSize(size);
|
||||
p->setFont(font);
|
||||
}
|
||||
//
|
||||
QString Pstable::text(int row, int col)
|
||||
{
|
||||
if (col >= procview->cats.size())
|
||||
{
|
||||
qDebug("Qps Bug!: text() over col !! %d\n", col);
|
||||
return "";
|
||||
}
|
||||
return procview->cats[col]->string(procview->linear_procs[row]);
|
||||
}
|
||||
|
||||
int Pstable::totalRow() //???
|
||||
{
|
||||
return procview->linear_procs.size();
|
||||
}
|
||||
|
||||
int Pstable::colWidth(int col)
|
||||
{
|
||||
// this is -1 for variable width fields, htable keeps track of it
|
||||
if (col >= procview->cats.size())
|
||||
{
|
||||
qDebug("Qps Bug!: colWidth() over col !! %d\n", col);
|
||||
return -1;
|
||||
}
|
||||
return procview->cats[col]->width();
|
||||
}
|
||||
|
||||
int Pstable::alignment(int col)
|
||||
{
|
||||
// qDebug("debug:alignment()\n");
|
||||
Category *cat = procview->cats[col];
|
||||
return cat->alignment();
|
||||
}
|
||||
|
||||
// virtual of HeadedTable
|
||||
void Pstable::setSelected(int row, bool flag)
|
||||
{
|
||||
/// qDebug("debug:Pstable::setSelected()\n");
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
if (pi->selected != flag)
|
||||
{
|
||||
pi->selected = flag;
|
||||
// body->repaintRow(row); // TEMP trick..
|
||||
}
|
||||
}
|
||||
|
||||
// virtual
|
||||
bool Pstable::isSelected(int row)
|
||||
{
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
return pi->selected; // VALGRIND
|
||||
}
|
||||
|
||||
int Pstable::rowDepth(int row)
|
||||
{
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
if (pi)
|
||||
return pi->level; // VALGRIND segfault
|
||||
|
||||
qDebug("Qps bug: over row %d!!!\n", row);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Pstable::lastChild(int row)
|
||||
{
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
if (pi)
|
||||
return pi->lastchild;
|
||||
qDebug("Qps bug: over row %d!!!\n", row);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Segfault !!!!
|
||||
// return not PPID ! just virtual parent in tree
|
||||
int Pstable::parentRow(int row)
|
||||
{
|
||||
return procview->linear_procs[row]->parent_row;
|
||||
/* int ppid= procview->linear_procs[row]->ppid;
|
||||
Procinfo *pi= procview->getProcinfoByPID(ppid);
|
||||
if(pi) return ppid;
|
||||
else return -1; */
|
||||
}
|
||||
|
||||
// DRAFT tooltip
|
||||
QString Pstable::tipText(int col)
|
||||
{
|
||||
Category *cat = procview->cats[col];
|
||||
QString s(cat->help);
|
||||
// trick
|
||||
if (cat->index == F_STAT)
|
||||
s.append("\n(R =Running, S =Sleeping, T =sTopped, Z=Zombie)");
|
||||
if (cat->index == F_PLCY)
|
||||
s.append("\n(TS =Time Sharing)");
|
||||
// if(cat->index == F_RSS);
|
||||
// s.append("\nRSS = CODE + DATA + SHARE\n"
|
||||
// "RSS = TRS + DRS + SHARE\n");
|
||||
/// s.append("\n(RSS = TRS + DRS)");
|
||||
if (cat == procview->sortcat)
|
||||
s.append(procview->reversed ? "\n(sorted backwards)" : "\n(sorted)");
|
||||
|
||||
// printf("size=%d\n",s.capacity());
|
||||
return s;
|
||||
}
|
||||
|
||||
void Pstable::showTip(QPoint p, int idx)
|
||||
{
|
||||
QToolTip::showText(p, tipText(idx));
|
||||
}
|
||||
|
||||
extern TFrame *infobox; // testing
|
||||
|
||||
// SLOT
|
||||
void Pstable::mouseOutOfCell() { infobox->hide(); }
|
||||
|
||||
// TEST
|
||||
void Pstable::mouseOnCell(int row, int col)
|
||||
{
|
||||
// printf("cursor on (%d,%d)\n",row,col);
|
||||
|
||||
Category *cat = procview->cats[col];
|
||||
QString s = "";
|
||||
|
||||
return;
|
||||
|
||||
// below TEST code!
|
||||
if (cat->index == F_USER)
|
||||
{
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
s = pi->username;
|
||||
}
|
||||
else
|
||||
{
|
||||
infobox->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (infobox != NULL)
|
||||
{
|
||||
// p.setY(p.y() + geometry().y());
|
||||
// p.setY(QCursor::pos().y() - geometry().y());
|
||||
// p.setY(QCursor::pos().y() - frameGeometry().y());
|
||||
// p.setX(QCursor::pos().x() - frameGeometry().x());
|
||||
// QPoint p=QCursor::pos();
|
||||
// if(htable->numSelected()>=2)
|
||||
|
||||
infobox->show();
|
||||
infobox->setPos();
|
||||
if (s > 0)
|
||||
{
|
||||
infobox->setText(s);
|
||||
}
|
||||
else
|
||||
infobox->hide();
|
||||
}
|
||||
|
||||
// char *str=htable->total_selectedRow(col);
|
||||
}
|
||||
|
||||
void Pstable::leaveEvent(QEvent *) {}
|
||||
|
||||
// DRAFT who call?
|
||||
// void TableBody::mouseMoveEvent(QMouseEvent *e)
|
||||
char *Pstable::total_selectedRow(int col)
|
||||
{
|
||||
static char buff[48];
|
||||
char mem_str[48];
|
||||
std::string name;
|
||||
int index;
|
||||
|
||||
if (procview->cats.size() <= col or col < 0)
|
||||
return 0; // col == -1
|
||||
index = procview->cats[col]->index;
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case F_SIZE:
|
||||
name = "total SIZE: ";
|
||||
break;
|
||||
case F_RSS:
|
||||
name = "total RSS: ";
|
||||
break;
|
||||
#ifdef LINUX
|
||||
case F_TRS:
|
||||
name = "total Text: ";
|
||||
break;
|
||||
case F_DRS:
|
||||
name = "total Data: ";
|
||||
break;
|
||||
case F_STACK:
|
||||
name = "total STACK: ";
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
int rows = procview->linear_procs.size();
|
||||
for (int i = 0; i < rows; i++)
|
||||
if (procview->linear_procs[i]->selected)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case F_SIZE:
|
||||
total += procview->linear_procs[i]->size;
|
||||
break;
|
||||
case F_RSS:
|
||||
total += procview->linear_procs[i]->resident;
|
||||
break;
|
||||
#ifdef LINUX
|
||||
case F_TRS:
|
||||
total += procview->linear_procs[i]->trs;
|
||||
break;
|
||||
case F_DRS:
|
||||
total += procview->linear_procs[i]->drs;
|
||||
break;
|
||||
case F_STACK:
|
||||
total += procview->linear_procs[i]->stack;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
mem_string(total, mem_str); // misc.h
|
||||
strcpy(buff, name.c_str());
|
||||
strcat(buff, mem_str);
|
||||
// sqDebug(buff,"total:%s",total);
|
||||
return buff;
|
||||
}
|
||||
|
||||
// col
|
||||
// colMoved(col, place);
|
||||
Pstable::Pstable(QWidget *parent, Procview *pv) : HeadedTable(parent, 0)
|
||||
{
|
||||
procview = pv;
|
||||
// connect(this, SIGNAL(selectionChanged(const Svec<int>
|
||||
//*)),SLOT(selection_update(const Svec<int> *))); //DEL?
|
||||
// connect(this,
|
||||
// SIGNAL(selectionChanged()),SLOT(selection_update())); //
|
||||
// when procinfo clicked
|
||||
connect(this, SIGNAL(titleClicked(int)), SLOT(setSortColumn(int)));
|
||||
connect(this, SIGNAL(foldSubTree(int)), SLOT(subtree_folded(int)));
|
||||
connect(head, SIGNAL(toolTip(QPoint, int)), this,
|
||||
SLOT(showTip(QPoint, int)));
|
||||
connect(this, SIGNAL(flyOnCell(int, int)), SLOT(mouseOnCell(int, int)));
|
||||
connect(this, SIGNAL(outOfCell()), SLOT(mouseOutOfCell()));
|
||||
}
|
||||
|
||||
// who call this ? : from qps.cpp
|
||||
void Pstable::setProcview(Procview *pv) { procview = pv; }
|
||||
|
||||
HeadedTable::NodeState Pstable::folded(int row)
|
||||
{
|
||||
Procinfo *p = procview->linear_procs[row];
|
||||
return (p->table_children.size() > 0) ? (p->hidekids ? Closed : Open)
|
||||
: Leaf;
|
||||
}
|
||||
|
||||
// slot: called when selection changes
|
||||
// called by
|
||||
// 1.void HeadedTable::selectionNotify()
|
||||
/*
|
||||
void Pstable::selection_update(const Svec<int> *rows)
|
||||
{
|
||||
//CLIPBOARD
|
||||
qDebug("debug:selection_update()\n");
|
||||
for(int i = 0; i < rows->size(); i++) {
|
||||
int row = (*rows)[i];
|
||||
procview->linear_procs[row]->selected = isSelected(row); //
|
||||
WRONG !!!
|
||||
}
|
||||
|
||||
qps->update_menu_selection_status();
|
||||
|
||||
if(numSelected() > 0 && qps->pids_to_selection) {
|
||||
// set the X11 selection to "PID1 PID2 PID3 ..."
|
||||
QString s, num;
|
||||
int n = numRows();
|
||||
for(int i = 0; i < n; i++) {
|
||||
if(isSelected(i)) {
|
||||
num.setNum(procview->linear_procs[i]->pid);
|
||||
s.append(num);
|
||||
if(i < n - 1)
|
||||
s.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
// important: this mustn't be called non-interactively since Qt
|
||||
uses
|
||||
// the selection time of the last mouse or keyboard event
|
||||
//// QApplication::clipboard()->setText(s);
|
||||
}
|
||||
|
||||
} */
|
||||
|
||||
// call by
|
||||
// 1.void Qps::set_table_mode(bool treemode)
|
||||
// slot: changes table mode
|
||||
void Pstable::setTreeMode(bool treemode)
|
||||
{
|
||||
// qDebug("Pstable::setTreeMode() %d , procview.treeview
|
||||
// =%d\n",treemode,procview->treeview);
|
||||
// no more HeadedTable::setTreeMode(treemode);
|
||||
HeadedTable::setTreeMode(treemode);
|
||||
procview->treeview = treemode;
|
||||
procview->fieldArrange();
|
||||
set_sortcol();
|
||||
refresh(); //==rebuild();
|
||||
}
|
||||
|
||||
//
|
||||
bool Pstable::columnMovable(int col)
|
||||
{
|
||||
if (treemode)
|
||||
{
|
||||
if (col == 0)
|
||||
return false;
|
||||
}
|
||||
if (procview->cats[col]->index == F_CMDLINE)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// called by HeadedTable
|
||||
// Description : FIELD movement by mouse drag to place From col
|
||||
// virtual HeadedTable::moveCol(col,place);
|
||||
void Pstable::moveCol(int col, int place)
|
||||
{
|
||||
// qDebug("Pstable::moveCol\n");
|
||||
procview->moveColumn(col, place);
|
||||
set_sortcol(); //???
|
||||
procview->fieldArrange();
|
||||
// update();
|
||||
refresh(); // width size changed ,...
|
||||
return;
|
||||
// updateColWidth(place); updateColWidth(col);// TEMP
|
||||
}
|
||||
|
||||
// NEED Check !!
|
||||
// Slot: called when a subtree is opened or closed
|
||||
// row = row number of sheet
|
||||
void Pstable::subtree_folded(int row)
|
||||
{
|
||||
|
||||
Procinfo *p = procview->linear_procs[row];
|
||||
p->hidekids = !p->hidekids;
|
||||
|
||||
if (p->hidekids)
|
||||
clear_subtree_selections(p); // *** important
|
||||
|
||||
refresh(); // tree rebuild only
|
||||
return;
|
||||
// ???
|
||||
Procinfo *nextp =
|
||||
(row < numRows() - 1) ? procview->linear_procs[row + 1] : 0;
|
||||
if (!p->hidekids)
|
||||
{
|
||||
// Show as much as possible of the opened subtree
|
||||
int r = row + 1;
|
||||
while (r < numRows() && procview->linear_procs[r] != nextp)
|
||||
r++;
|
||||
// setAutoUpdate(FALSE);
|
||||
showRange(row, r - 1);
|
||||
// setAutoUpdate(TRUE);
|
||||
}
|
||||
// This is a stopgap solution; it would be better to have htable
|
||||
// take care of the hiding of subtrees and repaint only the rows under
|
||||
// the line hidden
|
||||
}
|
||||
|
||||
// DRAFT CODE:
|
||||
// 1.procview->refresh: proc.refresh, rebuild
|
||||
// 2.resetwidth
|
||||
// 3.repaint
|
||||
|
||||
// called by
|
||||
// 1.void Qps::refresh()
|
||||
void STATUSBAR_SETCOUNT(int n);
|
||||
|
||||
static int kgen = 123;
|
||||
void Pstable::checkTableModel()
|
||||
{
|
||||
// int size=procview->linear_procs.size();
|
||||
// if(size!=numRows())
|
||||
{
|
||||
// printf("Warnning: this is the bug.. wrong! %d
|
||||
//%d\n",size,numRows());
|
||||
}
|
||||
if (procview->current_gen != kgen)
|
||||
{
|
||||
// printf("Warnning: maybe this is the bug.. wrong!
|
||||
//%d
|
||||
//%d\n",kgen,procview->current_gen);
|
||||
// setAutoUpdate(false); // ********** important for
|
||||
// GUI-thread
|
||||
// HeadedTable::setTreeMode(procview->treeview);
|
||||
procview->rebuild(); // for Table
|
||||
setNumRows(procview->linear_procs.size()); // 1.
|
||||
// qDebug("Pstable setTreeMode =%d , procview.treeview
|
||||
//=%d\n",treemode,procview->treeview);
|
||||
setNumCols(procview->cats.size()); // 2. resetWidths()
|
||||
kgen = procview->current_gen;
|
||||
// setAutoUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
// paintEvent();
|
||||
|
||||
void Pstable::refresh()
|
||||
{
|
||||
// qDebug("Pstable:refresh()");
|
||||
// procview->refresh(); -> move to Qps::refresh()
|
||||
// qDebug("catsize=%d\n",procview->cats.size());
|
||||
procview->rebuild(); // for Table
|
||||
setNumRows(procview->linear_procs.size()); // 1.
|
||||
setNumCols(procview->cats.size()); // 2. resetWidths() UNINITIAL
|
||||
kgen = procview->current_gen;
|
||||
// checkTableModel();
|
||||
repaint_changed();
|
||||
|
||||
/*
|
||||
if(true)
|
||||
{
|
||||
int count=0,trow=0;
|
||||
for(int row = 0; row < nrows; row++)
|
||||
if(isSelected(row))
|
||||
{
|
||||
count++;
|
||||
trow=row;
|
||||
}
|
||||
if (count == 1)
|
||||
centerVertically(trow);
|
||||
} */
|
||||
|
||||
STATUSBAR_SETCOUNT(procview->num_process);
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* pstable.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 PSTABLE_H
|
||||
#define PSTABLE_H
|
||||
|
||||
#include "proc.h"
|
||||
#include "htable.h"
|
||||
|
||||
class Pstable : public HeadedTable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Pstable(QWidget *parent, Procview *pv);
|
||||
|
||||
void set_sortcol();
|
||||
void setProcview(Procview *pv);
|
||||
virtual void moveCol(int col, int place);
|
||||
void refresh();
|
||||
|
||||
// called by super
|
||||
bool hasSelection() { return 0; };
|
||||
|
||||
virtual bool isSelected(int row);
|
||||
virtual void setSelected(int row, bool sel);
|
||||
virtual int totalRow();
|
||||
virtual void checkTableModel();
|
||||
|
||||
public slots:
|
||||
// void selection_update(const Svec<int> *row);
|
||||
void setSortColumn(int col);
|
||||
void subtree_folded(int row);
|
||||
void showTip(QPoint p, int index);
|
||||
void setTreeMode(bool treemode);
|
||||
void mouseOnCell(int row, int col);
|
||||
void mouseOutOfCell();
|
||||
|
||||
protected:
|
||||
// implementation of the interface to HeadedTable
|
||||
virtual QString title(int col);
|
||||
virtual QString text(int row, int col);
|
||||
virtual int colWidth(int col);
|
||||
virtual int alignment(int col);
|
||||
virtual QString tipText(int col);
|
||||
virtual int rowDepth(int row);
|
||||
virtual NodeState folded(int row);
|
||||
virtual int parentRow(int row);
|
||||
virtual bool lastChild(int row);
|
||||
virtual char *total_selectedRow(int col);
|
||||
virtual int sizeHintForColumn(int col) const;
|
||||
virtual bool columnMovable(int col);
|
||||
|
||||
virtual void overpaintCell(QPainter *p, int row, int col, int xpos);
|
||||
// virtual bool hasChildren(int row);
|
||||
|
||||
virtual void leaveEvent(QEvent *);
|
||||
|
||||
private:
|
||||
Procview *procview;
|
||||
};
|
||||
|
||||
#endif // PSTABLE_H
|
@ -1,513 +0,0 @@
|
||||
/*
|
||||
* pstable2.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 2014 dae hyun, yang <daehyun.yang@gmail.com>
|
||||
* Copyright 2015 Paulo Lieuthier <paulolieuthier@gmail.com>
|
||||
*
|
||||
* 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 "pstable2.h"
|
||||
int flag_x = 0;
|
||||
PstableModel::PstableModel(QObject *parent, Procview *pv) : HtableModel(parent)
|
||||
{
|
||||
procview = pv;
|
||||
}
|
||||
|
||||
QModelIndex PstableModel::index(int row, int col,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
if (flag_x)
|
||||
printf("index(): row=%d col=%d parent(%d %d)\n", row, col,
|
||||
parent.row(), parent.column());
|
||||
// if(row<0 or column<0) // root?
|
||||
// return QModelIndex();
|
||||
Procinfo *pi;
|
||||
|
||||
if (col < 0 or col >= procview->cats.size())
|
||||
return QModelIndex();
|
||||
// qFatal("Qps::Pstable2::sizeHintForColumn() Bug!: over col !!
|
||||
// %d\n",col);
|
||||
if (parent == QModelIndex())
|
||||
{
|
||||
if (row >= 0 and row < procview->root_procs.size())
|
||||
{
|
||||
Procinfo *pi = procview->root_procs[row]; // NULL possible!!
|
||||
return createIndex(row, col, pi);
|
||||
}
|
||||
else
|
||||
printf("out of row %d", row); // ???????????????????
|
||||
}
|
||||
|
||||
if (parent.isValid())
|
||||
{
|
||||
|
||||
Procinfo *ppi = static_cast<Procinfo *>(parent.internalPointer());
|
||||
|
||||
if (ppi and row < ppi->table_children.size() and row >= 0)
|
||||
{
|
||||
Procinfo *pi = ppi->table_children[row];
|
||||
return createIndex(row, col, pi);
|
||||
}
|
||||
}
|
||||
printf(" indeX() error\n");
|
||||
// qFatal("Error : index() row=%d ",row);
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
// Pure Virtual
|
||||
QModelIndex PstableModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
// wrong parent makes segfault
|
||||
// return QModelIndex();
|
||||
// printf("parent() ! %d %d\n",child.row(),child.column());
|
||||
if (child.isValid())
|
||||
{
|
||||
Procinfo *pi = static_cast<Procinfo *>(child.internalPointer());
|
||||
// if (pi==NULL or pi->level==0 )//or pi->parent_row<0)
|
||||
if (pi->level < 1) // or pi->parent_row<0)
|
||||
{
|
||||
// printf("root , pid=%d ppid=%d
|
||||
//\n",pi->pid,pi->ppid);
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
// parent_row == -1 segfault
|
||||
Procinfo *ppi = procview->procs.value(pi->ppid, 0); ///
|
||||
if (ppi == NULL)
|
||||
printf("error xxxxxxxxxxxx\n");
|
||||
// if(pi->ppid==2608) printf("parent_row=%d
|
||||
// ppid=%d\n",pi->parent_row,pi->ppid);
|
||||
// Procinfo *ppi=procview->linear_procs[pi->parent_row];
|
||||
// if (pi->ppid==0 or ppi==NULL)// or !procview->treeview)
|
||||
////if(flag_x) printf("parent : pid=%d (row=%d
|
||||
/// ppid=%d)\n",pi->pid,ppi->table_child_seq,ppi->pid);
|
||||
return createIndex(ppi->table_child_seq, 0, ppi);
|
||||
// return createIndex(0 , 0 ,ppi);
|
||||
}
|
||||
printf("parent() Invalud\n");
|
||||
return QModelIndex(); // no parent!
|
||||
|
||||
// if(row>=0 and col>=0 and row<htable->nrows)
|
||||
// return createIndex(htable->parentRow(row),col,NULL);
|
||||
}
|
||||
|
||||
int PstableModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.column() > 0)
|
||||
return 0;
|
||||
// printf("columnCount() size=%d\n" ,procview->cats.size());
|
||||
return procview->cats.size();
|
||||
}
|
||||
|
||||
// pure virtual: return chilren count
|
||||
int PstableModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.column() > 0)
|
||||
return 0;
|
||||
|
||||
int count = 0;
|
||||
if (parent == QModelIndex())
|
||||
{
|
||||
count = procview->root_procs.size();
|
||||
// printf("rowCount() root_procs size=%d\n"
|
||||
//,count);
|
||||
}
|
||||
else
|
||||
{
|
||||
Procinfo *pi = static_cast<Procinfo *>(parent.internalPointer());
|
||||
count = pi->table_children.size();
|
||||
}
|
||||
// printf("rowCount (%d %d),
|
||||
//%d\n",parent.row(),parent.column(),count);
|
||||
// if(pi->table_children.size()>0)
|
||||
// htable->setExpanded(index,false);
|
||||
// if(count>0) htable->setExpanded(parent,false);
|
||||
// if(count>0) htable->expand(parent);
|
||||
return count;
|
||||
}
|
||||
|
||||
bool PstableModel::hasChildren(const QModelIndex &parent) const
|
||||
{
|
||||
int count;
|
||||
if (parent.column() > 0)
|
||||
return false;
|
||||
return rowCount(parent);
|
||||
}
|
||||
|
||||
QVariant PstableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
// printf("data\n");
|
||||
Procinfo *pi = static_cast<Procinfo *>(index.internalPointer());
|
||||
int col = index.column();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
// if(pi->child_seq_prev>=0 and pi->child_seq!=index.row())
|
||||
// printf("========= not equal row =====\n");
|
||||
return procview->cats[index.column()]->string(pi);
|
||||
// returhtable->text(index.row(),index.column());
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
{
|
||||
}
|
||||
else if (role == Qt::EditRole)
|
||||
{
|
||||
}
|
||||
else if (role == Qt::CheckStateRole)
|
||||
{
|
||||
// if(item->enable)
|
||||
// return Qt::Checked;
|
||||
// else
|
||||
// return Qt::Unchecked;
|
||||
}
|
||||
else if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
Category *cat = procview->cats[index.column()];
|
||||
return cat->alignment();
|
||||
}
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
}
|
||||
else if (role == Qt::BackgroundColorRole)
|
||||
{
|
||||
}
|
||||
else if (role == Qt::SizeHintRole)
|
||||
{
|
||||
// return QSize(18,18);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
// MOVE TO Procview
|
||||
// slot: called when a title is clicked
|
||||
|
||||
// void Pstable::set_sortcol()
|
||||
// setSortedCol(i);
|
||||
// connect(header(), SIGNAL(sectionPressed( int )),SLOT(setSortColumn(int )));
|
||||
void Pstable2::setSortColumn(int col)
|
||||
{
|
||||
// col=-1 no section
|
||||
if (col < 0 or col >= procview->cats.size())
|
||||
return;
|
||||
// qFatal("Qps::Pstable2::setSortColumn() Bug!: over col !! %d\n",col);
|
||||
// printf("setSortColumn()\n");
|
||||
procview->setSortColumn(col, false);
|
||||
setSortedCol(col); // void HeadedTable::setSortedCol(int col)
|
||||
refresh(); // no redraw
|
||||
model->update();
|
||||
}
|
||||
|
||||
// sync Procview and HeadedTable
|
||||
// set sorted column of table to procview->sortcol
|
||||
void Pstable2::set_sortcol()
|
||||
{
|
||||
for (int i = 0; i < procview->cats.size(); i++)
|
||||
{
|
||||
if (procview->cats[i] == procview->sortcat)
|
||||
{
|
||||
setSortedCol(i); // HeadedTable
|
||||
return;
|
||||
}
|
||||
}
|
||||
setSortedCol(-1);
|
||||
}
|
||||
|
||||
// for Speed Optimize
|
||||
int Pstable2::sizeHintForColumn(int col) const
|
||||
{
|
||||
if (col < 0 or col >= procview->cats.size())
|
||||
qFatal("Qps::Pstable2::sizeHintForColumn() Bug!: over col !! %d\n",
|
||||
col);
|
||||
// int aw=fontMetrics().averageCharWidth();
|
||||
int aw = fontMetrics().width("0");
|
||||
// int title_witdh=fontMetrics().width(procview->cats[col]->name);
|
||||
// static int z5=fontMetrics ().width("00000");
|
||||
// static int z6=fontMetrics ().width("000000");
|
||||
int cat_id = procview->cats[col]->index;
|
||||
switch (cat_id)
|
||||
{
|
||||
// only COMMON Field
|
||||
// case F_PID :
|
||||
case F_RSS:
|
||||
case F_NICE:
|
||||
case F_SIZE:
|
||||
case F_TIME:
|
||||
return aw * 6;
|
||||
case F_TTY:
|
||||
case F_MEM:
|
||||
case F_CPU:
|
||||
// return aw*7;
|
||||
return fontMetrics().width("%MEM") + 10;
|
||||
case F_WCPU:
|
||||
return fontMetrics().width("%WCPU") + 10;
|
||||
// return aw*4;
|
||||
case F_USER:
|
||||
case F_CMD:
|
||||
// case F_CMDLINE: return 300;
|
||||
default:
|
||||
return QTreeView::sizeHintForColumn(col);
|
||||
// return HeadedTable::sizeHintForColumn(col);
|
||||
// QTreeView::resizeColumnToContents (col);
|
||||
return -1;
|
||||
;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// inner
|
||||
QString Pstable2::title(int col)
|
||||
{
|
||||
if (col < 0 or col >= procview->cats.size())
|
||||
{
|
||||
qFatal("Qps::Pstable2::title(): Bug! over col !! %d\n", col);
|
||||
return "";
|
||||
}
|
||||
return procview->cats[col]->name;
|
||||
}
|
||||
|
||||
QString Pstable2::text(int row, int col) // not called
|
||||
{
|
||||
if (col < 0 or col >= procview->cats.size())
|
||||
qFatal("Qps::Pstable2::text() Bug!: over col !! %d\n", col);
|
||||
|
||||
return procview->cats[col]->string(procview->linear_procs[row]);
|
||||
}
|
||||
|
||||
int Pstable2::totalRow() //???
|
||||
{
|
||||
return procview->linear_procs.size();
|
||||
}
|
||||
|
||||
int Pstable2::colWidth(int col)
|
||||
{
|
||||
if (col < 0 or col >= procview->cats.size())
|
||||
qFatal("Qps::Pstable2::colWidth() Bug!: over col !! %d\n", col);
|
||||
/// return 30;
|
||||
// this is -1 for variable width fields, htable keeps track of it
|
||||
return procview->cats[col]->width();
|
||||
}
|
||||
|
||||
int Pstable2::alignment(int col)
|
||||
{
|
||||
if (col < 0 or col >= procview->cats.size())
|
||||
qFatal("Qps::Pstable2::alignment() Bug!: over col !! %d\n", col);
|
||||
// printf("debug:alignment()\n");
|
||||
Category *cat = procview->cats[col];
|
||||
return cat->alignment();
|
||||
}
|
||||
|
||||
// virtual of HeadedTable
|
||||
void Pstable2::setSelected(int row, bool sel)
|
||||
{
|
||||
/// printf("debug:setSelected()\n");
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
if (pi->selected != sel)
|
||||
{
|
||||
pi->selected = sel;
|
||||
// body->repaintRow(row); // TEMP trick..
|
||||
}
|
||||
}
|
||||
|
||||
// virtual
|
||||
bool Pstable2::isSelected(int row)
|
||||
{
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
return pi->selected;
|
||||
}
|
||||
|
||||
int Pstable2::rowDepth(int row)
|
||||
{
|
||||
// if(row < procview->linear_procs.size())
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
if (pi)
|
||||
return pi->level;
|
||||
|
||||
printf("Qps bug: over row %d!!!\n", row);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Pstable2::lastChild(int row)
|
||||
{
|
||||
Procinfo *pi = procview->linear_procs[row];
|
||||
if (pi)
|
||||
return pi->lastchild;
|
||||
printf("Qps bug: over row %d!!!\n", row);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
int Pstable2::childCount(int row)
|
||||
{
|
||||
return procview->linear_procs[row]->table_children.size();
|
||||
//and !p->hidekids)
|
||||
} */
|
||||
|
||||
// Segfault !!!!
|
||||
// return not PPID ! just virtual parent in tree
|
||||
int Pstable2::parentRow(int row)
|
||||
{
|
||||
return procview->linear_procs[row]->parent_row;
|
||||
/* int ppid= procview->linear_procs[row]->ppid;
|
||||
Procinfo *pi= procview->getProcinfoByPID(ppid);
|
||||
if(pi) return ppid;
|
||||
else return -1; */
|
||||
}
|
||||
|
||||
// DRAFT
|
||||
QString Pstable2::tipText(int col)
|
||||
{
|
||||
Category *cat = procview->cats[col];
|
||||
QString s(cat->help);
|
||||
|
||||
// trick
|
||||
if (cat->index == F_STAT)
|
||||
s.append("\n(R =Running, S =Sleeping, T =sTopped, Z=Zombie)");
|
||||
if (cat->index == F_PLCY)
|
||||
s.append("\n(TS =Time Sharing)");
|
||||
if (cat->index == F_RSS)
|
||||
;
|
||||
// s.append("\nRSS = CODE + DATA + SHARE\n"
|
||||
// "RSS = TRS + DRS + SHARE\n");
|
||||
/// s.append("\n(RSS = TRS + DRS)");
|
||||
if (cat == procview->sortcat)
|
||||
s.append(procview->reversed ? "\n(sorted backwards)" : "\n(sorted)");
|
||||
return s;
|
||||
}
|
||||
|
||||
// DRAFT who call?
|
||||
char *Pstable2::total_selectedRow(int col) { return 0; }
|
||||
|
||||
Pstable2::Pstable2(QWidget *parent, Procview *pv) : HeadedTable2(parent, 0)
|
||||
{
|
||||
printf("read 3-2\n");
|
||||
procview = pv;
|
||||
model = new PstableModel(this, pv);
|
||||
setModel(model);
|
||||
// activate() double click
|
||||
// pressed() one click
|
||||
// entered() drag
|
||||
// connect(this, SIGNAL(activated ( const QModelIndex &
|
||||
// )),SLOT(selection_update(const QModelIndex&)));
|
||||
connect(this, SIGNAL(pressed(const QModelIndex &)),
|
||||
SLOT(selection_update(const QModelIndex &)));
|
||||
// connect(header(), SIGNAL(sectionClicked( int
|
||||
//)),SLOT(setSortColumn(int
|
||||
//)));
|
||||
connect(header(), SIGNAL(sectionPressed(int)), SLOT(setSortColumn(int)));
|
||||
// connect(this, SIGNAL(titleClicked(int)),
|
||||
// SLOT(setSortColumn(int)));
|
||||
|
||||
printf("read 3-3\n");
|
||||
// modelIterate(rootIndex());
|
||||
// modelIterate(QModelIndex());
|
||||
// update(QModelIndex());
|
||||
// reset();
|
||||
// expandAll();
|
||||
// reset();
|
||||
printf("read 3-4\n");
|
||||
}
|
||||
|
||||
// who call this ? : from qps.cpp
|
||||
void Pstable2::setProcview(Procview *pv) { procview = pv; }
|
||||
|
||||
HeadedTable2::NodeState Pstable2::folded(int row)
|
||||
{
|
||||
Procinfo *p = procview->linear_procs[row];
|
||||
return (p->table_children.size() > 0) ? (p->hidekids ? Closed : Open)
|
||||
: Leaf;
|
||||
}
|
||||
|
||||
// slot: called when selection changes
|
||||
// called by
|
||||
void Pstable2::selection_update(const QModelIndex &idx)
|
||||
{
|
||||
QModelIndexList list = selectionModel()->selectedRows();
|
||||
printf("debug:selection_update()\n");
|
||||
// qps->update_menu_selection_status();
|
||||
}
|
||||
|
||||
// slot: changes table mode
|
||||
// call by
|
||||
// 1.void Qps::set_table_mode(bool treemode)
|
||||
void Pstable2::setTreeMode(bool treemode)
|
||||
{
|
||||
/// printf("Pstable setTreeMode\n");
|
||||
procview->treeview = treemode;
|
||||
procview->fieldArrange();
|
||||
set_sortcol();
|
||||
HeadedTable2::setTreeMode(treemode);
|
||||
Pstable2::refresh();
|
||||
if (treemode)
|
||||
setRootIsDecorated(true);
|
||||
else
|
||||
setRootIsDecorated(false);
|
||||
|
||||
reset();
|
||||
expandAll();
|
||||
// model->update(); //SEGFAULT
|
||||
// rebuild();
|
||||
}
|
||||
|
||||
bool Pstable2::columnMovable(int col)
|
||||
{
|
||||
if (treemode)
|
||||
{
|
||||
if (col == 0)
|
||||
return false;
|
||||
}
|
||||
if (procview->cats[col]->index == F_CMDLINE)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// called by HeadedTable
|
||||
// Description : FIELD movement by mouse drag
|
||||
// To place From col
|
||||
// virtual HeadedTable::moveCol(col,place);
|
||||
void Pstable2::moveCol(int col, int place)
|
||||
{
|
||||
// printf("Pstable::moveCol\n");
|
||||
procview->moveColumn(col, place);
|
||||
set_sortcol();
|
||||
// update();
|
||||
refresh(); // width size changed ,...
|
||||
}
|
||||
|
||||
// DRAFT CODE:
|
||||
// 1.procview->refresh: proc.refresh, rebuild
|
||||
// 2.resetwidth
|
||||
// 3.repaint
|
||||
|
||||
// called by
|
||||
// 1.void Qps::refresh()
|
||||
void Pstable2::refresh()
|
||||
{
|
||||
printf("Pstable2:refresh()\n");
|
||||
procview->rebuild(); // for Table
|
||||
setNumCols(procview->cats.size()); // 2. resetWidths()
|
||||
setNumRows(procview->linear_procs.size()); // 1.
|
||||
// printf("catsize=%d
|
||||
// row=%d\n",procview->cats.size(),procview->linear_procs.size());
|
||||
// update();
|
||||
// update(QModelIndex());
|
||||
// repaint();
|
||||
// repaint_changed();
|
||||
// model->revert(); //temp
|
||||
// model->submit(); //temp
|
||||
// model->update();
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* pstable2.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 2014 dae hyun, yang <daehyun.yang@gmail.com>
|
||||
* Copyright 2015 Paulo Lieuthier <paulolieuthier@gmail.com>
|
||||
*
|
||||
* 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 "proc.h"
|
||||
#include "htable2.h"
|
||||
#include <QToolTip>
|
||||
|
||||
class PstableModel : public HtableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PstableModel(QObject *parent, Procview *procview);
|
||||
~PstableModel(){};
|
||||
virtual QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
virtual QModelIndex parent(const QModelIndex &child) const; // pure virtual
|
||||
virtual int rowCount(const QModelIndex &parent) const;
|
||||
virtual int columnCount(const QModelIndex &parent) const;
|
||||
virtual QVariant data(const QModelIndex &index, int role) const;
|
||||
virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
|
||||
// int columnCount(const QModelIndex &parent) const;
|
||||
// HeadedTable2 *htable;
|
||||
Procview *procview;
|
||||
};
|
||||
|
||||
class Pstable2 : public HeadedTable2
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Pstable2(QWidget *parent, Procview *pv);
|
||||
|
||||
void set_sortcol();
|
||||
void setProcview(Procview *pv);
|
||||
void setTreeMode(bool treemode);
|
||||
virtual void moveCol(int col, int place);
|
||||
void refresh();
|
||||
|
||||
// called by super
|
||||
bool hasSelection() { return selectionModel()->hasSelection(); };
|
||||
|
||||
virtual bool isSelected(int row); // hmm
|
||||
virtual void setSelected(int row, bool sel);
|
||||
virtual int totalRow(); // DEL?
|
||||
|
||||
public slots:
|
||||
void selection_update(const QModelIndex &); // hmm
|
||||
void setSortColumn(int col);
|
||||
|
||||
signals:
|
||||
void selection_changed();
|
||||
|
||||
protected:
|
||||
// implementation of the interface to HeadedTable
|
||||
virtual QString title(int col); // ok
|
||||
virtual QString text(int row, int col); // ok
|
||||
virtual int colWidth(int col);
|
||||
virtual int alignment(int col); // ok
|
||||
virtual QString tipText(int col); // ok
|
||||
|
||||
virtual int rowDepth(int row);
|
||||
virtual NodeState folded(int row);
|
||||
virtual int parentRow(int row);
|
||||
virtual bool lastChild(int row);
|
||||
virtual char *total_selectedRow(int col);
|
||||
virtual int sizeHintForColumn(int col) const;
|
||||
virtual bool columnMovable(int col);
|
||||
|
||||
// virtual void drawCellContents(int row, int col, int w, int h,
|
||||
// QPainter *p);
|
||||
|
||||
private:
|
||||
Procview *procview;
|
||||
};
|
@ -1,338 +0,0 @@
|
||||
/*
|
||||
* qps.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 QPS_H
|
||||
#define QPS_H
|
||||
|
||||
#ifndef USING_PCH
|
||||
#include <QWidget>
|
||||
#include <QMenuBar>
|
||||
#include <QColor>
|
||||
#include <QMenu>
|
||||
#include <QCloseEvent>
|
||||
#include <QTimerEvent>
|
||||
#include <QPixmap>
|
||||
#include <QUrl>
|
||||
#include <QSystemTrayIcon>
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x040200
|
||||
#else
|
||||
//#error Qt library version 4.2 or higher is needed for this version of qps
|
||||
#endif
|
||||
|
||||
#define HTABLE1
|
||||
#include "misc.h"
|
||||
#ifdef HTABLE2
|
||||
#include "pstable2.h"
|
||||
#else
|
||||
#include "pstable.h"
|
||||
#endif
|
||||
#include "proc.h"
|
||||
#include "infobar.h"
|
||||
#include "fieldsel.h"
|
||||
#include "details.h"
|
||||
#include "prefs.h"
|
||||
#include "command.h"
|
||||
|
||||
#define DEBUG printf
|
||||
|
||||
#define FUNC_START
|
||||
#define FUNC_END
|
||||
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
class CommandDialog;
|
||||
|
||||
class Qps : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Qps();
|
||||
~Qps();
|
||||
|
||||
void set_update_period(int milliseconds);
|
||||
void setWindowGroup(QWidget *w);
|
||||
void setCommand(int argc, char **argv);
|
||||
void setIconSize(int w, int h) { icon_width = w, icon_height = h; }
|
||||
void write_settings();
|
||||
void save_settings();
|
||||
|
||||
QPixmap *get_load_icon();
|
||||
|
||||
// settings
|
||||
static bool show_file_path; // shows command/file map path
|
||||
static bool show_cmd_path; // DEL CMDLINE shows command path
|
||||
static bool show_infobar; // information bar is shown
|
||||
static bool show_ctrlbar; // control bar is shown
|
||||
static bool show_statusbar; //
|
||||
static bool show_mem_bar; // memory is shown as a bar
|
||||
static bool show_swap_bar; // swap is shown as a bar
|
||||
static bool show_cpu_bar; // cpu states are shown as a bar
|
||||
static bool show_load_graph; // load is shown as a graph
|
||||
static bool load_in_icon; // load graph in icon
|
||||
static bool auto_save_options; // settings saved on exit
|
||||
#ifdef LINUX
|
||||
static bool hostname_lookup; // do a name lookup on socket addresses
|
||||
static bool service_lookup; // map port numbers to service names
|
||||
#endif
|
||||
static bool pids_to_selection; // selected processes' PIDS to X11 sel
|
||||
static bool vertical_cpu_bar; // save space with SMP
|
||||
|
||||
static int swaplimit; // limit of swap redline, in K or %
|
||||
static bool swaplim_percent; // true if swaplimit is in %
|
||||
#ifdef SOLARIS
|
||||
static bool
|
||||
normalize_nice; // whether nice should be normalized (normal nice
|
||||
// is 0 etc)
|
||||
static bool use_pmap; // use /proc/bin/pmap for map names
|
||||
#endif
|
||||
static bool tree_gadgets; // use open/close gadgets (triangles)
|
||||
static bool tree_lines; // draw tree branch lines
|
||||
|
||||
// static bool comm_is_magic; //DEL, auto-remove COMM
|
||||
// when
|
||||
// switching
|
||||
static bool flag_systray; // trayicon , sytemtray
|
||||
static bool flag_exit;
|
||||
static bool flag_show; // last qps-main_window state
|
||||
static bool flag_useTabView;
|
||||
static bool flag_qps_hide;
|
||||
|
||||
// colors which may be set by the user
|
||||
enum
|
||||
{
|
||||
COLOR_CPU_USER,
|
||||
#ifdef LINUX
|
||||
COLOR_CPU_NICE,
|
||||
#endif
|
||||
COLOR_CPU_SYS,
|
||||
#ifdef SOLARIS
|
||||
COLOR_CPU_WAIT,
|
||||
#endif
|
||||
COLOR_CPU_IDLE,
|
||||
COLOR_MEM_USED,
|
||||
COLOR_MEM_BUFF,
|
||||
COLOR_MEM_CACHE,
|
||||
COLOR_MEM_FREE,
|
||||
COLOR_SWAP_USED,
|
||||
COLOR_SWAP_FREE,
|
||||
COLOR_SWAP_WARN,
|
||||
COLOR_LOAD_BG,
|
||||
COLOR_LOAD_FG,
|
||||
COLOR_LOAD_LINES,
|
||||
COLOR_SELECTION_BG,
|
||||
COLOR_SELECTION_FG,
|
||||
NUM_COLORS
|
||||
};
|
||||
|
||||
enum menuid
|
||||
{
|
||||
MENU_SIGQUIT,
|
||||
MENU_SIGILL,
|
||||
MENU_SIGABRT,
|
||||
MENU_SIGFPE,
|
||||
MENU_SIGSEGV,
|
||||
MENU_SIGPIPE,
|
||||
MENU_SIGALRM,
|
||||
MENU_SIGUSR1,
|
||||
MENU_SIGUSR2,
|
||||
MENU_SIGCHLD,
|
||||
MENU_SIGCONT,
|
||||
MENU_SIGSTOP,
|
||||
MENU_SIGTSTP,
|
||||
MENU_SIGTTIN,
|
||||
MENU_SIGTTOU,
|
||||
MENU_RENICE,
|
||||
MENU_SCHED,
|
||||
MENU_DETAILS,
|
||||
MENU_PARENT,
|
||||
MENU_CHILD,
|
||||
MENU_DYNASTY,
|
||||
MENU_SIGTERM,
|
||||
MENU_SIGHUP,
|
||||
MENU_SIGINT,
|
||||
MENU_SIGKILL,
|
||||
MENU_OTHERS,
|
||||
MENU_PROCS,
|
||||
MENU_FIELDS,
|
||||
MENU_CUSTOM,
|
||||
MENU_PATH,
|
||||
MENU_INFOBAR,
|
||||
MENU_CTRLBAR,
|
||||
MENU_CUMUL,
|
||||
MENU_PREFS,
|
||||
MENU_ADD_HIDDEN,
|
||||
MENU_REMOVE_HIDDEN,
|
||||
MENU_STATUS,
|
||||
#ifdef MOSIX
|
||||
POPUP_MIGRATE,
|
||||
#endif
|
||||
MENU_FIRST_COMMAND // must be last
|
||||
};
|
||||
|
||||
public slots:
|
||||
void start_screenshot();
|
||||
void clicked_trayicon(QSystemTrayIcon::ActivationReason);
|
||||
void clicked_trayicon();
|
||||
void sig_term();
|
||||
void sig_hup();
|
||||
void sig_stop();
|
||||
void sig_cont();
|
||||
void sig_kill();
|
||||
void signal_menu(QAction *);
|
||||
void run_command(QAction *);
|
||||
void about();
|
||||
void license();
|
||||
void menu_update();
|
||||
void menu_toggle_path();
|
||||
void menu_toggle_infobar();
|
||||
void menu_toggle_ctrlbar();
|
||||
void menu_toggle_statusbar();
|
||||
void menu_toggle_cumul();
|
||||
void menu_prefs();
|
||||
void menu_renice();
|
||||
void menu_sched();
|
||||
void Action_Detail();
|
||||
void menu_parent();
|
||||
void menu_children();
|
||||
void menu_dynasty();
|
||||
void menu_custom();
|
||||
void menu_remove_field();
|
||||
void menu_edit_cmd();
|
||||
void mig_menu(int id); // MOSIX only
|
||||
void make_command_menu();
|
||||
void view_menu(QAction *);
|
||||
void save_quit();
|
||||
void add_fields_menu(int id);
|
||||
void add_fields_menu(QAction *act);
|
||||
void tabChanged(int i);
|
||||
|
||||
void show_popup_menu(QPoint p);
|
||||
void context_heading_menu(QPoint p, int col);
|
||||
|
||||
void update_menu_selection_status();
|
||||
void field_added(int index);
|
||||
void field_removed(int index);
|
||||
void set_table_mode(bool treemode); // hmmm
|
||||
|
||||
void details_closed(Details *d);
|
||||
void open_details(int row);
|
||||
|
||||
void config_change();
|
||||
|
||||
void update_timer();
|
||||
void refresh();
|
||||
void refresh_details();
|
||||
void test_popup(const QUrl &link);
|
||||
void update_menu_status();
|
||||
|
||||
protected:
|
||||
// reimplementation of QWidget methods
|
||||
virtual void timerEvent(QTimerEvent *);
|
||||
virtual void closeEvent(QCloseEvent *);
|
||||
virtual void moveEvent(QMoveEvent *event);
|
||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||
virtual void hideEvent(QHideEvent *event);
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
virtual void enterEvent(QEvent *event);
|
||||
virtual void leaveEvent(QEvent *event);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
virtual void focusInEvent(QFocusEvent *event);
|
||||
virtual void focusOutEvent(QFocusEvent *event);
|
||||
virtual void keyPressEvent(QKeyEvent *event);
|
||||
// bool event(QEvent *e);
|
||||
void transfer_selection();
|
||||
void adjust_popup_menu(QMenu *m, bool cont);
|
||||
void adjust_popup_menu();
|
||||
bool all_selected_stopped();
|
||||
|
||||
void locate_relatives(int Procinfo::*a, int Procinfo::*b);
|
||||
QMenu *make_signal_popup_menu();
|
||||
#ifdef MOSIX
|
||||
QMenu *make_migrate_menu();
|
||||
void migrate_selected(int sig);
|
||||
#endif
|
||||
void send_to_selected(int sig);
|
||||
void sendsig(Procinfo *p, int sig);
|
||||
void earlier_refresh();
|
||||
bool read_settings();
|
||||
|
||||
bool load_settings();
|
||||
|
||||
void bar_visibility();
|
||||
void set_default_icon();
|
||||
void set_load_icon();
|
||||
|
||||
public:
|
||||
#ifdef HTABLE2
|
||||
Pstable2 *pstable; // test
|
||||
#else
|
||||
Pstable *pstable;
|
||||
#endif
|
||||
Procview *procview;
|
||||
StatusBar *statusBar;
|
||||
// Netable *netable;
|
||||
QTextEdit *logbox;
|
||||
void update_icon();
|
||||
|
||||
private:
|
||||
QMenuBar *menubar;
|
||||
QMenu *m_field; // Field Menu
|
||||
QMenu *m_view; // Field Menu
|
||||
QAction *am_view;
|
||||
QMenu *m_command;
|
||||
QMenu *m_options;
|
||||
QMenu *m_popup;
|
||||
QMenu *m_headpopup;
|
||||
QMenu *m_fields;
|
||||
QMenu *popupx; // testing
|
||||
|
||||
bool selection_items_enabled; // state of certain menu items (???)
|
||||
|
||||
Infobar2 *infobar; // tmp
|
||||
ControlBar *ctrlbar;
|
||||
FieldSelect *field_win;
|
||||
Preferences *prefs_win;
|
||||
CommandDialog *command_win;
|
||||
|
||||
QList<Details> details;
|
||||
|
||||
int update_period; // in mili second
|
||||
static const int eternity = 0x7fffffff; // turns off automatic update
|
||||
// the Linux kernel updates its load average counters every 5 seconds
|
||||
// (kernel 2.0.29), so there is no point in reading it too often
|
||||
static const int load_update_period = 4800; // in ms
|
||||
int update_load_time; // time left to update load
|
||||
|
||||
// size of our icon
|
||||
int icon_width;
|
||||
int icon_height;
|
||||
int timer_id;
|
||||
|
||||
QPixmap *default_icon;
|
||||
bool default_icon_set; // true if default icon is current icon
|
||||
int context_col; // where heading context menu was clicked
|
||||
};
|
||||
|
||||
#endif // QPS_H
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* qpsapp.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
* Copyright 2005-2012 fasthyun@magicn.com
|
||||
* Copyright 2015- daehyun.yang@gmail.com
|
||||
*
|
||||
* 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 "qpsapp.h"
|
||||
|
||||
void QpsApp::saveState(QSessionManager &manager)
|
||||
{
|
||||
// printf("saveState()\n");
|
||||
// manager.setRestartHint(QSessionManager::RestartIfRunning);
|
||||
// manager.release();
|
||||
}
|
||||
|
||||
// this is called when X Logout
|
||||
// closeEvent() never called !!
|
||||
void QpsApp::commitData(QSessionManager &manager)
|
||||
{
|
||||
/*
|
||||
printf("commitData()\n");
|
||||
manager.setRestartHint(QSessionManager::RestartIfRunning);
|
||||
qps->flag_exit=true; // ready to Logout
|
||||
qps->save_settings() ;
|
||||
manager.release();
|
||||
sleep(2);
|
||||
return;
|
||||
if (manager.allowsInteraction()) {
|
||||
int ret = QMessageBox::warning(
|
||||
qps,
|
||||
tr("My Application"),
|
||||
tr("Save changes to document?"),
|
||||
QMessageBox::Save | QMessageBox::Discard |
|
||||
QMessageBox::Cancel);
|
||||
|
||||
switch (ret) {
|
||||
case QMessageBox::Save:
|
||||
manager.release();
|
||||
// if (!saveDocument()) manager.cancel();
|
||||
break;
|
||||
case QMessageBox::Discard:
|
||||
break;
|
||||
case QMessageBox::Cancel:
|
||||
default:
|
||||
manager.cancel();
|
||||
}
|
||||
} else {
|
||||
|
||||
manager.release();
|
||||
|
||||
// we did not get permission to interact, then
|
||||
// do something reasonable instead
|
||||
}
|
||||
*/
|
||||
/*
|
||||
//DEL sm.release();
|
||||
qDebug("Qps: Session saved\n");
|
||||
// sm.cancel();
|
||||
//sm.setRestartHint (QSessionManager::RestartIfRunning);
|
||||
QApplication::commitData(sm);
|
||||
*/
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* qpsapp.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
* Copyright 2005-2012 fasthyun@magicn.com
|
||||
* Copyright 2015- daehyun.yang@gmail.com
|
||||
*
|
||||
* 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 QPSAPP_H
|
||||
#define QPSAPP_H
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
// MOD!!!: For systray update.
|
||||
// this trick very suck, but I can't find a better solution.
|
||||
class QpsApp : public QApplication
|
||||
{
|
||||
public:
|
||||
QpsApp(int &argc, char **argv) : QApplication(argc, argv){};
|
||||
void commitData(QSessionManager &sm);
|
||||
void saveState(QSessionManager &manager);
|
||||
|
||||
/*
|
||||
virtual bool x11EventFilter ( XEvent *xev ){
|
||||
// catch X11 event for systray_update !! which event?
|
||||
///if(trayicon!=NULL) return
|
||||
trayicon->checkNewTrayEvent(xev);
|
||||
return false; // events to qt.
|
||||
}; */
|
||||
};
|
||||
|
||||
#endif // QPSAPP_H
|
@ -1,240 +0,0 @@
|
||||
/**********************************************************************
|
||||
** $Id: qttableview.h,v 1.46 2011/08/27 00:13:41 fasthyun Exp $
|
||||
**
|
||||
** Definition of QtTableView class
|
||||
**
|
||||
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
||||
**
|
||||
** This file contains a class moved out of the Qt GUI Toolkit API.
|
||||
**
|
||||
** This file may be distributed under the terms of the Q Public License
|
||||
** as defined by Trolltech AS of Norway and appearing in the file
|
||||
** LICENSE.QPL included in the packaging of this file.
|
||||
**
|
||||
** This file may be distributed and/or modified under the terms of the
|
||||
** GNU General Public License version 2 as published by the Free Software
|
||||
** Foundation and appearing in the file COPYING included in the
|
||||
** packaging of this file.
|
||||
**
|
||||
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
||||
** licenses may use this file in accordance with the Qt Commercial License
|
||||
** Agreement provided with the Software.
|
||||
**
|
||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||
** information about Qt Commercial License Agreements.
|
||||
** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
||||
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||
**
|
||||
** Contact info@trolltech.com if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef QTTABLEVIEW_H
|
||||
#define QTTABLEVIEW_H
|
||||
|
||||
#ifndef USING_PCH
|
||||
#include <QScrollBar>
|
||||
#include <QAbstractScrollArea>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QPushButton>
|
||||
#endif
|
||||
|
||||
class QScrollBar;
|
||||
class QtTableView : public QAbstractScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWidget *view;
|
||||
int flag_view;
|
||||
int cellWidth() const;
|
||||
int cellHeight() const;
|
||||
void repaintRow(int row); // paintRow();
|
||||
void coverCornerSquare(bool);
|
||||
void clearCache() {}
|
||||
void repaintChanged();
|
||||
virtual bool isCellChanged(int r, int c) { return true; };
|
||||
virtual void eraseRight(QPainter *, QRect &r) { return; }
|
||||
virtual void checkProfile(){};
|
||||
QSize tmp_size; // testing.
|
||||
int tmp_x;
|
||||
bool test;
|
||||
QColor backColor;
|
||||
|
||||
protected:
|
||||
QtTableView(QWidget *parent = 0, const char *name = 0);
|
||||
~QtTableView();
|
||||
|
||||
int numRows() const;
|
||||
int numCols() const;
|
||||
void setNumRows(int);
|
||||
void setNumCols(int);
|
||||
|
||||
int topCell() const;
|
||||
int leftCell() const;
|
||||
void setTopCell(int row);
|
||||
void setLeftCell(int col);
|
||||
void setTopLeftCell(int row, int col);
|
||||
|
||||
int xOffset() const;
|
||||
int yOffset() const;
|
||||
virtual void setXOffset(int);
|
||||
virtual void setYOffset(int);
|
||||
virtual void setOffset(int x, int y, bool updateScrBars = true);
|
||||
virtual void scrollTrigger(int x, int y){}; // tmp
|
||||
|
||||
virtual int cellWidth(int col);
|
||||
int cellHeight(int row);
|
||||
virtual void setCellWidth(int);
|
||||
virtual void setCellHeight(int);
|
||||
|
||||
int totalWidth();
|
||||
int totalHeight();
|
||||
|
||||
uint tableFlags() const;
|
||||
// bool testTableFlags( uint f ) const;
|
||||
virtual void setTableFlags(uint f);
|
||||
void clearTableFlags(uint f = ~0);
|
||||
|
||||
void setAutoUpdate(bool);
|
||||
|
||||
void repaintCell(int row, int column, bool usecache = false);
|
||||
|
||||
QRect cellUpdateRect() const;
|
||||
QRect viewRect() const;
|
||||
|
||||
int lastRowVisible() const;
|
||||
int lastColVisible() const;
|
||||
|
||||
bool rowIsVisible(int row) const;
|
||||
bool colIsVisible(int col) const;
|
||||
|
||||
QScrollBar *verticalScrollBar() const;
|
||||
QScrollBar *horizontalScrollBar() const;
|
||||
|
||||
private slots:
|
||||
void horSbValue(int);
|
||||
void horSbSliding(int);
|
||||
void horSbSlidingDone();
|
||||
void verSbValue(int);
|
||||
void verSbSliding(int);
|
||||
void verSbSlidingDone();
|
||||
|
||||
protected:
|
||||
virtual void paintCell(QPainter *, int row, int col, bool update) = 0;
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
virtual void resizeEvent(QResizeEvent *);
|
||||
virtual void scrollContentsBy(int dx, int dy);
|
||||
|
||||
int findRow(int yPos) const;
|
||||
int findCol(int xPos) const;
|
||||
int findColNoMinus(int xPos) const;
|
||||
|
||||
bool rowYPos(int row, int *yPos) const;
|
||||
bool colXPos(int col, int *xPos) const;
|
||||
|
||||
int maxXOffset();
|
||||
int maxYOffset();
|
||||
int maxColOffset();
|
||||
int maxRowOffset();
|
||||
|
||||
int minViewX() const;
|
||||
int minViewY() const;
|
||||
int maxViewX() const;
|
||||
int maxViewY() const;
|
||||
int viewWidth() const;
|
||||
int viewHeight() const;
|
||||
|
||||
void updateScrollBars();
|
||||
void updateTableSize();
|
||||
|
||||
QRect cellUpdateR;
|
||||
|
||||
private:
|
||||
int findRawRow(int yPos, int *cellMaxY, int *cellMinY = 0,
|
||||
bool goOutsideView = false) const;
|
||||
int findRawCol(int xPos, int *cellMaxX, int *cellMinX = 0,
|
||||
bool goOutsideView = false) const;
|
||||
int maxColsVisible() const;
|
||||
|
||||
void updateScrollBars(uint);
|
||||
void showOrHideScrollBars();
|
||||
|
||||
int nRows;
|
||||
int nCols;
|
||||
int xOffs, yOffs;
|
||||
int xCellOffs, yCellOffs;
|
||||
short xCellDelta, yCellDelta;
|
||||
short cellH, cellW; //
|
||||
|
||||
uint eraseInPaint : 1;
|
||||
uint verSliding : 1;
|
||||
uint verSnappingOff : 1;
|
||||
uint horSliding : 1;
|
||||
uint horSnappingOff : 1;
|
||||
uint coveringCornerSquare : 1;
|
||||
uint sbDirty : 8;
|
||||
uint inSbUpdate : 1;
|
||||
|
||||
bool enablePaint;
|
||||
|
||||
uint tFlags;
|
||||
|
||||
QScrollBar *vScrollBar;
|
||||
QScrollBar *hScrollBar;
|
||||
};
|
||||
|
||||
const uint Tbl_vScrollBar = 0x00000001;
|
||||
const uint Tbl_hScrollBar = 0x00000002;
|
||||
const uint Tbl_autoVScrollBar = 0x00000004;
|
||||
const uint Tbl_autoHScrollBar = 0x00000008;
|
||||
const uint Tbl_autoScrollBars = 0x0000000C;
|
||||
|
||||
const uint Tbl_clipCellPainting = 0x00000100;
|
||||
const uint Tbl_cutCellsV = 0x00000200;
|
||||
const uint Tbl_cutCellsH = 0x00000400;
|
||||
const uint Tbl_cutCells = 0x00000600;
|
||||
|
||||
const uint Tbl_scrollLastHCell = 0x00000800;
|
||||
const uint Tbl_scrollLastVCell = 0x00001000;
|
||||
const uint Tbl_scrollLastCell = 0x00001800;
|
||||
|
||||
const uint Tbl_smoothHScrolling = 0x00002000;
|
||||
const uint Tbl_smoothVScrolling = 0x00004000;
|
||||
const uint Tbl_smoothScrolling = 0x00006000;
|
||||
|
||||
const uint Tbl_snapToHGrid = 0x00008000;
|
||||
const uint Tbl_snapToVGrid = 0x00010000;
|
||||
const uint Tbl_snapToGrid = 0x00018000;
|
||||
|
||||
inline int QtTableView::numRows() const { return nRows; }
|
||||
|
||||
inline int QtTableView::numCols() const { return nCols; }
|
||||
|
||||
inline int QtTableView::topCell() const { return yCellOffs; }
|
||||
|
||||
inline int QtTableView::leftCell() const { return xCellOffs; }
|
||||
|
||||
inline int QtTableView::xOffset() const { return xOffs; }
|
||||
|
||||
inline int QtTableView::yOffset() const { return yOffs; }
|
||||
|
||||
inline int QtTableView::cellHeight() const { return cellH; }
|
||||
|
||||
inline int QtTableView::cellWidth() const { return cellW; }
|
||||
|
||||
inline uint QtTableView::tableFlags() const { return tFlags; }
|
||||
|
||||
#define testTableFlags(f) ((tFlags & f) != 0)
|
||||
// inline bool QtTableView::testTableFlags( uint f ) const{ return (tFlags & f)
|
||||
// != 0; }
|
||||
|
||||
inline QRect QtTableView::cellUpdateRect() const { return cellUpdateR; }
|
||||
|
||||
inline void QtTableView::updateScrollBars() { updateScrollBars(0); }
|
||||
|
||||
#endif // QTTABLEVIEW_H
|
@ -1,448 +0,0 @@
|
||||
/*
|
||||
* screenshot.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 2014 dae hyun, yang <daehyun.yang@gmail.com>
|
||||
* Copyright 2015 Paulo Lieuthier <paulolieuthier@gmail.com>
|
||||
*
|
||||
* 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 <QtGui>
|
||||
#include <QSizeGrip>
|
||||
#include "screenshot.h"
|
||||
#include <QStatusBar>
|
||||
#include <QMouseEvent>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QStyle>
|
||||
#include <QStyleOptionFrame>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
/*
|
||||
SizeGrip::SizeGrip()
|
||||
{
|
||||
|
||||
setWindowFlags( Qt::FramelessWindowHint);
|
||||
} */
|
||||
|
||||
QSizeGrip *sg;
|
||||
int window_width = 320;
|
||||
int window_height = 240;
|
||||
|
||||
TitleBar::TitleBar(QWidget *w) : QWidget(w)
|
||||
{
|
||||
// setWindowFlags( Qt::FramelessWindowHint);
|
||||
// resize(window_width,32);
|
||||
setMinimumHeight(32);
|
||||
}
|
||||
|
||||
void TitleBar::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
// press_pos = e->pos();
|
||||
// printf("x=%d y=%d\n",press_pos.x(),press_pos.y());
|
||||
}
|
||||
|
||||
void TitleBar::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->buttons() == Qt::LeftButton) // Button state )
|
||||
{
|
||||
// move(e->globalX()-e->x(), e->globalY()-e->y());//
|
||||
// coe->x(),e->y());
|
||||
// move(e->globalX() - press_pos.x(), e->globalY()-
|
||||
// press_pos.y());//
|
||||
// coe->x(),e->y());
|
||||
// sg->move(x()-100,y()-100);
|
||||
}
|
||||
}
|
||||
|
||||
ShotArea::ShotArea()
|
||||
{
|
||||
setLineWidth(3);
|
||||
setFrameStyle(QFrame::Panel | QFrame::Raised);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
||||
|
||||
void ShotArea::resizeEvent(QResizeEvent * /* event */)
|
||||
{
|
||||
// printf("ShotArea::resizeEvent()\n");
|
||||
// QPixmap pixmap = QPixmap(screenshotLabel->size());
|
||||
}
|
||||
|
||||
void ShotArea::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
// printf("ShotArea::paintEvent\n");
|
||||
// QPainter painter(this);
|
||||
// painter.setOpacity(1.0);
|
||||
// painter.fillRect(10, 10, 100, 80, QColor(255,255,255,120));
|
||||
}
|
||||
|
||||
void ShotArea::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
press_pos = e->pos();
|
||||
/// printf("x=%d y=%d\n",press_pos.x(),press_pos.y());
|
||||
}
|
||||
|
||||
void ShotArea::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->buttons() == Qt::LeftButton) // Button state )
|
||||
{
|
||||
// move(e->globalX()-e->x(), e->globalY()-e->y());//
|
||||
// coe->x(),e->y());
|
||||
// move(e->globalX() - press_pos.x(), e->globalY()-
|
||||
// press_pos.y());//
|
||||
// coe->x(),e->y());
|
||||
// sg->move(x()-100,y()-100);
|
||||
}
|
||||
}
|
||||
|
||||
#include <QX11Info>
|
||||
Screenshot::Screenshot(QWidget *p) : QWidget(p)
|
||||
{
|
||||
// Qt::WindowTitleHint
|
||||
// Qt::CustomizeWindowHint );
|
||||
// setWindowTitle(tr("Screenshot"));
|
||||
// TitleBar *titlebar=new TitleBar(this);
|
||||
QStatusBar *statusbar = new QStatusBar(this);
|
||||
shotarea = new ShotArea();
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
// setWindowFlags(Qt::X11BypassWindowManagerHint);
|
||||
setStyleSheet( // padding: 2px
|
||||
"QWidget { background-color : rgba(20,20,20,70%); color: "
|
||||
"rgb(0,255,150);}"
|
||||
"QPushButton,QToolButton,QLineEdit { border-width: 1px; "
|
||||
"padding:3px; "
|
||||
"border-style: solid; border-color: rgb(210,50,130); "
|
||||
"border-radius: 5px "
|
||||
";}"
|
||||
"QPushButton:hover,QToolButton:hover { color:rgb(40,255,190); "
|
||||
"padding:3px; border-width: 1px; border-style: solid; "
|
||||
"border-color: "
|
||||
"rgb(230,80,170); border-radius: 5px ;}"
|
||||
"QPushButton:pressed,QToolButton:pressed { color:rgb(0,255,150); "
|
||||
"padding:3px; border-width: 2px; border-style: solid; "
|
||||
"border-color: "
|
||||
"rgb(210,50,130); border-radius: 5px ;}"
|
||||
"QComboBox { border-width: 1px; padding:3px; border-style: solid; "
|
||||
"border-color: rgb(50,200,130); border-radius: 5px ;}"
|
||||
"QLabel { border-width: 1px; padding:3px; border-style: solid; "
|
||||
"border-color: rgb(65,16,40); border-radius: 5px ;}"
|
||||
"QComboBox:drop-down { border-width: 2px; padding:0px; "
|
||||
"border-style: "
|
||||
"solid; border-color: rgb(50,200,130); border-radius: 3px ;}");
|
||||
|
||||
// sg=new QSizeGrip(NULL);
|
||||
// sg->show();
|
||||
// sg->move(100,100);
|
||||
// QStyle::PE_Frame
|
||||
// createOptionsGroupBox();
|
||||
// createButtonsLayout();
|
||||
|
||||
#if QT_VERSION > 0x040500
|
||||
|
||||
#endif
|
||||
|
||||
mainLayout = new QVBoxLayout;
|
||||
#if QT_VERSION < 0x040300
|
||||
mainLayout->setMargin(3); // qt-4.2
|
||||
#else
|
||||
mainLayout->setContentsMargins(3, 3, 3, 3); // qt-4.3
|
||||
#endif
|
||||
mainLayout->setSpacing(0);
|
||||
|
||||
// mainLayout->addWidget(titlebar);
|
||||
mainLayout->addWidget(shotarea);
|
||||
// mainLayout->addLayout(buttonsLayout);
|
||||
mainLayout->addWidget(statusbar);
|
||||
|
||||
// saveScreenshotButton = createButton(tr("Save"),this,
|
||||
// SLOT(saveScreenshot()));
|
||||
saveScreenshotButton = new QPushButton("Save");
|
||||
connect(saveScreenshotButton, SIGNAL(clicked()), this,
|
||||
SLOT(saveScreenshot()));
|
||||
|
||||
statusbar->addWidget(saveScreenshotButton);
|
||||
// statusbar->addWidget( quitScreenshotButton);
|
||||
statusbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
||||
setLayout(mainLayout);
|
||||
// delaySpinBox->setValue(5);
|
||||
|
||||
setMouseTracking(true);
|
||||
|
||||
// if (QApplication::desktop()->winId() < 0)
|
||||
// printf("Qps: Null Desktop\n");
|
||||
resize(300, 240);
|
||||
}
|
||||
|
||||
static QPoint init_pos;
|
||||
void Screenshot::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
|
||||
press_pos = e->globalPos();
|
||||
init_pos = pos();
|
||||
// printf("x=%d y=%d\n",press_pos.x(),press_pos.y());
|
||||
}
|
||||
|
||||
void Screenshot::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->buttons() == Qt::LeftButton) // Button state )
|
||||
{
|
||||
move(init_pos + e->globalPos() - press_pos);
|
||||
// move(x() + e->globalX() - press_pos.x(), y()+e->globalY()-
|
||||
// press_pos.y());// coe->x(),e->y());
|
||||
// sg->move(x()-100,y()-100);
|
||||
}
|
||||
}
|
||||
|
||||
extern bool flag_xcompmgr;
|
||||
void Screenshot::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QPainter p(this);
|
||||
// printf("Screenshot::paintEvent\n");
|
||||
// setAttribute(Qt::WA_NoSystemBackground);
|
||||
if (0) // if(flag_xcompmgr)//setWindowOpacity (0.9);
|
||||
// //_NET_WM_WINDOW_OPACITY
|
||||
{
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
// setAttribute(Qt::WA_);
|
||||
// p.setOpacity(0.1);
|
||||
p.setCompositionMode(QPainter::CompositionMode_Source); // need!
|
||||
p.fillRect(rect(), Qt::transparent); // clear!
|
||||
// QRect rectR(shotarea->x(),shotarea->y(),
|
||||
// shotarea->width(),shotarea->height());
|
||||
// p.fillRect(rectR,QColor(0,255,0,10));
|
||||
// p.fillRect(rect(),QColor(255,255,255,255));
|
||||
}
|
||||
|
||||
return;
|
||||
QStyleOptionFrame opt;
|
||||
QRect rectR(shotarea->x() - 1, shotarea->y() - 1, shotarea->width() + 2,
|
||||
shotarea->height() + 2);
|
||||
opt.rect = rectR;
|
||||
opt.lineWidth = 2;
|
||||
opt.midLineWidth = 1;
|
||||
opt.state = opt.state | QStyle::State_Sunken;
|
||||
/// style()->drawControl(QStyle::CE_Header, &opt, p, this);
|
||||
style()->drawPrimitive(QStyle::PE_Frame, &opt, &p, 0);
|
||||
}
|
||||
|
||||
void Screenshot::resizeEvent(QResizeEvent *e /* event */)
|
||||
{
|
||||
|
||||
// printf("Screenshot::resizeEvent()\n");
|
||||
// QWidget::resizeEvent(e);
|
||||
// return;
|
||||
if (flag_xcompmgr == false)
|
||||
{
|
||||
QPixmap pixmap = QPixmap(size());
|
||||
QPainter painter(&pixmap);
|
||||
// painter.eraseRect(0,0,width(),height());
|
||||
painter.fillRect(0, 0, width(), height(), QColor(0, 0, 0));
|
||||
painter.fillRect(shotarea->x() + 1, shotarea->y() + 1,
|
||||
shotarea->width() - 2, shotarea->height() - 2
|
||||
// painter.fillRect(shotarea->geometry()
|
||||
,
|
||||
QColor(255, 255, 255));
|
||||
#if QT_VERSION >= 0x040300
|
||||
setMask(
|
||||
pixmap.createMaskFromColor(QColor(255, 255, 255), Qt::MaskInColor));
|
||||
// setMask(pixmap.mask()); // with alpha channel ,notwork
|
||||
#else
|
||||
// #error Qt library version 4.2 or higher is needed for this version of
|
||||
// qps
|
||||
#endif
|
||||
}
|
||||
|
||||
// QSize scaledSize = originalPixmap.size();
|
||||
// scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio);
|
||||
// if (!screenshotLabel->pixmap()|| scaledSize !=
|
||||
// screenshotLabel->pixmap()->size())
|
||||
// updateScreenshotLabel();
|
||||
}
|
||||
|
||||
void Screenshot::newScreenshot()
|
||||
{
|
||||
// newScreenshotButton->setDisabled(true);
|
||||
// shootScreen();
|
||||
// QTimer::singleShot(delaySpinBox->value() * 1000, this,
|
||||
// SLOT(shootScreen()));
|
||||
}
|
||||
|
||||
void Screenshot::saveScreenshot()
|
||||
{
|
||||
shootScreen();
|
||||
QString format = "png";
|
||||
QString path = QDir::homePath() + "/Desktop"; // *** ooooooo
|
||||
if (QFile::exists(path))
|
||||
path = path + tr("/untitled.") + format;
|
||||
else
|
||||
path = QDir::homePath();
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(
|
||||
this, tr("Save As"), path,
|
||||
tr("%1 Files (*.%2);;All Files (*)").arg(format.toUpper()).arg(format));
|
||||
if (!fileName.isEmpty())
|
||||
originalPixmap.save(fileName, format.toLatin1());
|
||||
|
||||
// setWindowFlags(Qt::X11BypassWindowManagerHint);
|
||||
}
|
||||
|
||||
void Screenshot::shootScreen()
|
||||
{
|
||||
|
||||
// if (delaySpinBox->value() != 0) qApp->beep();
|
||||
originalPixmap = QPixmap::grabWindow(
|
||||
QApplication::desktop()->winId(), geometry().x() + shotarea->x(),
|
||||
geometry().y() + shotarea->y(), shotarea->width(), shotarea->height());
|
||||
/// updateScreenshotLabel();
|
||||
}
|
||||
|
||||
void Screenshot::updateCheckBox()
|
||||
{
|
||||
if (delaySpinBox->value() == 0)
|
||||
hideThisWindowCheckBox->setDisabled(true);
|
||||
else
|
||||
hideThisWindowCheckBox->setDisabled(false);
|
||||
}
|
||||
|
||||
void Screenshot::createOptionsGroupBox()
|
||||
{
|
||||
optionsGroupBox = new QGroupBox(tr("Options"));
|
||||
|
||||
delaySpinBox = new QSpinBox;
|
||||
delaySpinBox->setSuffix(tr(" s"));
|
||||
delaySpinBox->setMaximum(60);
|
||||
connect(delaySpinBox, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(updateCheckBox()));
|
||||
|
||||
delaySpinBoxLabel = new QLabel(tr("Screenshot Delay:"));
|
||||
|
||||
hideThisWindowCheckBox = new QCheckBox(tr("Hide This Window"));
|
||||
|
||||
optionsGroupBoxLayout = new QGridLayout;
|
||||
optionsGroupBoxLayout->addWidget(delaySpinBoxLabel, 0, 0);
|
||||
optionsGroupBoxLayout->addWidget(delaySpinBox, 0, 1);
|
||||
optionsGroupBoxLayout->addWidget(hideThisWindowCheckBox, 1, 0, 1, 2);
|
||||
optionsGroupBox->setLayout(optionsGroupBoxLayout);
|
||||
}
|
||||
|
||||
void Screenshot::createButtonsLayout()
|
||||
{
|
||||
newScreenshotButton =
|
||||
createButton(tr("New Screenshot"), this, SLOT(newScreenshot()));
|
||||
quitScreenshotButton = createButton(tr("Quit"), this, SLOT(close()));
|
||||
|
||||
buttonsLayout = new QHBoxLayout;
|
||||
buttonsLayout->addStretch();
|
||||
buttonsLayout->addWidget(newScreenshotButton);
|
||||
buttonsLayout->addWidget(saveScreenshotButton);
|
||||
buttonsLayout->addWidget(quitScreenshotButton);
|
||||
}
|
||||
|
||||
QPushButton *Screenshot::createButton(const QString &text, QWidget *receiver,
|
||||
const char *member)
|
||||
{
|
||||
QPushButton *button = new QPushButton(text);
|
||||
button->connect(button, SIGNAL(clicked()), receiver, member);
|
||||
return button;
|
||||
}
|
||||
|
||||
// preview
|
||||
void Screenshot::updateScreenshotLabel()
|
||||
{
|
||||
screenshotLabel->setPixmap(originalPixmap.scaled(screenshotLabel->size(),
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation));
|
||||
}
|
||||
|
||||
//#include "widget.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <X11/extensions/Xrender.h>
|
||||
|
||||
int screenshot_main(int argc, char **argv)
|
||||
// int screenshot_main()
|
||||
{
|
||||
// qWarning("Please make sure you're running a composition manager!");
|
||||
bool argbVisual = false;
|
||||
Display *dpy = QX11Info::display(); // open default display
|
||||
if (!dpy)
|
||||
{
|
||||
qWarning("Cannot connect to the X server");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int screen = DefaultScreen(dpy);
|
||||
Colormap colormap = 0;
|
||||
Visual *visual = 0;
|
||||
int eventBase, errorBase;
|
||||
|
||||
if (0 and XRenderQueryExtension(dpy, &eventBase, &errorBase))
|
||||
{
|
||||
int nvi;
|
||||
XVisualInfo templ;
|
||||
templ.screen = screen;
|
||||
templ.depth = 32;
|
||||
templ.c_class = TrueColor;
|
||||
XVisualInfo *xvi = XGetVisualInfo(
|
||||
dpy, VisualScreenMask | VisualDepthMask | VisualClassMask, &templ,
|
||||
&nvi);
|
||||
|
||||
printf("nvi=%d\n", nvi);
|
||||
for (int i = 0; i < nvi; ++i)
|
||||
{
|
||||
XRenderPictFormat *format =
|
||||
XRenderFindVisualFormat(dpy, xvi[i].visual);
|
||||
if (format->type == PictTypeDirect && format->direct.alphaMask > 0)
|
||||
{
|
||||
visual = xvi[i].visual;
|
||||
colormap = XCreateColormap(dpy, RootWindow(dpy, screen), visual,
|
||||
AllocNone);
|
||||
argbVisual = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (argbVisual == true)
|
||||
{
|
||||
qWarning("Found ARGB visual. Starting app...");
|
||||
// QApplication app(dpy, argc, argv, Qt::HANDLE(visual),
|
||||
// Qt::HANDLE(colormap));
|
||||
}
|
||||
else
|
||||
{
|
||||
// qWarning("Couldn't find ARGB visual... Exiting.");
|
||||
// QApplication app(dpy, argc, argv);
|
||||
}
|
||||
|
||||
// QApplication app(dpy, argc, argv, Qt::HANDLE(visual),
|
||||
// Qt::HANDLE(colormap));
|
||||
QApplication app(argc, argv);
|
||||
|
||||
Display *dsp = QX11Info::display(); // get the display(X server?)
|
||||
|
||||
Screenshot *w = new Screenshot();
|
||||
w->show();
|
||||
// Widget w;
|
||||
// w.resize(400, 300);
|
||||
// w.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
/*
|
||||
* screenshot.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 2014 dae hyun, yang <daehyun.yang@gmail.com>
|
||||
* Copyright 2015 Paulo Lieuthier <paulolieuthier@gmail.com>
|
||||
*
|
||||
* 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 SCREENSHOT_H
|
||||
#define SCREENSHOT_H
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QFrame>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFileDialog>
|
||||
|
||||
class TitleBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TitleBar(QWidget *w);
|
||||
|
||||
protected:
|
||||
// void resizeEvent(QResizeEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
private slots:
|
||||
private:
|
||||
QPoint press_pos;
|
||||
};
|
||||
|
||||
class ShotArea : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShotArea();
|
||||
|
||||
protected:
|
||||
// void resizeEvent(QResizeEvent *event);
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *e);
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
private slots:
|
||||
private:
|
||||
QPoint press_pos;
|
||||
};
|
||||
|
||||
/*
|
||||
class SizeGrip : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SizeGrip();
|
||||
protected:
|
||||
// void resizeEvent(QResizeEvent *event);
|
||||
void mouseMoveEvent ( QMouseEvent * event );
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
private slots:
|
||||
private:
|
||||
QPoint press_pos;
|
||||
};
|
||||
*/
|
||||
|
||||
class Screenshot : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Screenshot(QWidget *p = 0);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
|
||||
private slots:
|
||||
void newScreenshot();
|
||||
void saveScreenshot();
|
||||
void shootScreen();
|
||||
void updateCheckBox();
|
||||
|
||||
private:
|
||||
void createOptionsGroupBox();
|
||||
void createButtonsLayout();
|
||||
QPushButton *createButton(const QString &text, QWidget *receiver,
|
||||
const char *member);
|
||||
void updateScreenshotLabel();
|
||||
|
||||
QPoint press_pos;
|
||||
QPixmap originalPixmap;
|
||||
|
||||
QLabel *screenshotLabel;
|
||||
QGroupBox *optionsGroupBox;
|
||||
QSpinBox *delaySpinBox;
|
||||
QLabel *delaySpinBoxLabel;
|
||||
QCheckBox *hideThisWindowCheckBox;
|
||||
QPushButton *newScreenshotButton;
|
||||
QPushButton *saveScreenshotButton;
|
||||
QPushButton *quitScreenshotButton;
|
||||
|
||||
QVBoxLayout *mainLayout;
|
||||
QGridLayout *optionsGroupBoxLayout;
|
||||
QHBoxLayout *buttonsLayout;
|
||||
ShotArea *shotarea;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* stable.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 2014 dae hyun, yang <daehyun.yang@gmail.com>
|
||||
* Copyright 2015 Paulo Lieuthier <paulolieuthier@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
// for Precompiled Header !
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined __cplusplus
|
||||
|
||||
#include <QBitArray>
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QProcess>
|
||||
#include <QSettings>
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <QShortcut>
|
||||
#include <QAction>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QFrame>
|
||||
#include <QPixmap>
|
||||
#include <QDialog>
|
||||
#include <QSlider>
|
||||
#include <QSpinBox>
|
||||
#include <QTabWidget>
|
||||
|
||||
#include <QStyleOption>
|
||||
#include <QAbstractScrollArea>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QPushButton>
|
||||
#include <QCheckBox>
|
||||
#include <QRadioButton>
|
||||
#include <QStatusBar>
|
||||
#include <QToolButton>
|
||||
#include <QGroupBox>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <QToolTip>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QTextEdit>
|
||||
|
||||
#include <QTimeLine>
|
||||
#include <QDir>
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
|
||||
#include <QListView>
|
||||
#include <QHeaderView>
|
||||
#include <QTreeView>
|
||||
|
||||
#include <QTextBrowser>
|
||||
#include <QUrl>
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QApplication>
|
||||
#include <QSessionManager>
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QCloseEvent>
|
||||
#include <QTimerEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QResizeEvent>
|
||||
|
||||
#include <QFontComboBox>
|
||||
|
||||
#include "svec.h"
|
||||
#endif
|
@ -1,162 +0,0 @@
|
||||
/*
|
||||
* svec.cpp
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// implement a stretchy vector class:
|
||||
// An Svec<T> grows automatically (doubles when full), so that adding
|
||||
// elements to the end has an amortized cost of O(1).
|
||||
// For now, only use this for types not requiring a con/destructor.
|
||||
|
||||
#ifndef SVEC_C
|
||||
#define SVEC_C
|
||||
|
||||
#include "svec.h"
|
||||
////#define fatal(str) { printf("fatal error: %s\n",str); exit(0);}
|
||||
#define fatal printf
|
||||
|
||||
template <class T> Svec<T>::Svec(const Svec<T> &s)
|
||||
{
|
||||
int n = s.size();
|
||||
if (n < 8)
|
||||
n = 8;
|
||||
vect = (T *)malloc(n * sizeof(T));
|
||||
alloced = n;
|
||||
used = s.size();
|
||||
for (int i = 0; i < used; i++)
|
||||
vect[i] = s[i];
|
||||
}
|
||||
|
||||
template <class T> Svec<T> &Svec<T>::operator=(const Svec<T> &s)
|
||||
{
|
||||
if (this != &s)
|
||||
{
|
||||
if (alloced < s.size())
|
||||
{
|
||||
alloced = s.size();
|
||||
vect = (T *)realloc(vect, alloced * sizeof(T));
|
||||
}
|
||||
for (int i = 0; i < s.size(); i++)
|
||||
{
|
||||
vect[i] = s.vect[i];
|
||||
}
|
||||
used = s.size();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*
|
||||
template<class T>
|
||||
void Svec<T>::indexerr(int index) const
|
||||
{
|
||||
fatal("Svec: index out of range (%d, valid is 0..%d)", index, used - 1);
|
||||
}
|
||||
*/
|
||||
|
||||
template <class T> void Svec<T>::setSize(int newsize)
|
||||
{
|
||||
while (newsize > alloced)
|
||||
grow();
|
||||
used = newsize;
|
||||
}
|
||||
|
||||
template <class T> void Svec<T>::setextend(int index, T value)
|
||||
{
|
||||
#ifdef CHECK_INDICES
|
||||
if (index < 0)
|
||||
fatal("const Svec: negative index");
|
||||
#endif
|
||||
while (index >= alloced)
|
||||
grow();
|
||||
if (index >= used)
|
||||
used = index + 1;
|
||||
vect[index] = value;
|
||||
}
|
||||
|
||||
template <class T> void Svec<T>::insert(int index, T value)
|
||||
{
|
||||
#ifdef CHECK_INDICES
|
||||
if (index < 0 || index > used)
|
||||
fatal("Svec: index out of range");
|
||||
#endif
|
||||
if ((used + 1) > alloced)
|
||||
grow();
|
||||
|
||||
/*int i;
|
||||
T v;
|
||||
v=vect[i+1];
|
||||
for(i = index; j < =used ; i++)
|
||||
vect[i+1]=v;
|
||||
vect[i+1]=vect[i]; //vect[index+1]=vect[index];
|
||||
*/
|
||||
|
||||
// old
|
||||
for (int j = used - 1; j >= index; j--)
|
||||
vect[j + 1] = vect[j];
|
||||
|
||||
vect[index] = value;
|
||||
|
||||
used++;
|
||||
}
|
||||
|
||||
// for int,float type , no delete
|
||||
template <class T> void Svec<T>::remove(int index)
|
||||
{
|
||||
#ifdef CHECK_INDICES
|
||||
if (index < 0 || index >= used)
|
||||
fatal("Svec: index out of range");
|
||||
#endif
|
||||
for (int j = index; j < used - 1; j++)
|
||||
vect[j] = vect[j + 1];
|
||||
used--;
|
||||
}
|
||||
|
||||
// for class type
|
||||
template <class T> void Svec<T>::Delete(int index)
|
||||
{
|
||||
#ifdef CHECK_INDICES
|
||||
if (index < 0 || index >= used)
|
||||
fatal("Svec: index out of range");
|
||||
#endif
|
||||
delete vect[index];
|
||||
for (int j = index; j < used - 1; j++)
|
||||
vect[j] = vect[j + 1];
|
||||
used--;
|
||||
}
|
||||
|
||||
// Assuming T is "pointer to U", delete all contents.
|
||||
// Warning: duplicated objects will be deleted twice --- doubleplusungood
|
||||
template <class T> void Svec<T>::purge()
|
||||
{
|
||||
for (int i = 0; i < used; i++)
|
||||
delete vect[i];
|
||||
used = 0;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
typedef int (*compare_func)(const void *, const void *);
|
||||
}
|
||||
|
||||
template <class T> void Svec<T>::sort(int (*compare)(const T *a, const T *b))
|
||||
{
|
||||
qsort(vect, used, sizeof(T), (compare_func)compare);
|
||||
}
|
||||
|
||||
#endif // SVEC_C
|
@ -1,155 +0,0 @@
|
||||
/*
|
||||
* svec.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 SVEC_H
|
||||
#define SVEC_H
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
template <typename Key, typename T> class SHash : public std::map<Key, T>
|
||||
{
|
||||
public:
|
||||
T value(Key k, T r)
|
||||
{
|
||||
using namespace std;
|
||||
typename map<Key, T>::const_iterator it;
|
||||
it = map<Key, T>::find(k);
|
||||
if (it == map<Key, T>::end())
|
||||
return r;
|
||||
return (*it).second;
|
||||
}
|
||||
void insert(Key k, T r)
|
||||
{
|
||||
using namespace std;
|
||||
map<Key, T>::insert(pair<Key, T>(k, r));
|
||||
}
|
||||
bool contains(Key k)
|
||||
{
|
||||
if (value(k, NULL) == NULL)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//#ifndef NDEBUG
|
||||
//#define CHECK_INDICES // Check invalid vector indices (the default)
|
||||
//#endif
|
||||
|
||||
template <class T> class Svec
|
||||
{
|
||||
public:
|
||||
Svec(int max = 16);
|
||||
Svec(const Svec<T> &s);
|
||||
~Svec();
|
||||
|
||||
Svec<T> &operator=(const Svec<T> &s);
|
||||
int size() const;
|
||||
void setSize(int newsize);
|
||||
T &operator[](int i);
|
||||
T operator[](int i) const;
|
||||
void set(int i, T val);
|
||||
void sort(int (*compare)(const T *a, const T *b));
|
||||
void add(T x);
|
||||
void insert(int index, T val);
|
||||
void remove(int index);
|
||||
void Delete(int index);
|
||||
void clear();
|
||||
void purge(); // like clear() but deletes all contents
|
||||
|
||||
private:
|
||||
void grow();
|
||||
void setextend(int index, T value);
|
||||
void indexerr(int index) const;
|
||||
|
||||
T *vect;
|
||||
int alloced; // # of entries allocated
|
||||
int used; // # of entries actually used (size)
|
||||
};
|
||||
|
||||
template <class T> inline Svec<T>::Svec(int max) : alloced(max), used(0)
|
||||
{
|
||||
vect = (T *)malloc(max * sizeof(T));
|
||||
}
|
||||
|
||||
template <class T> inline Svec<T>::~Svec() { free(vect); }
|
||||
|
||||
template <class T> inline int Svec<T>::size() const { return used; }
|
||||
|
||||
template <class T> inline T &Svec<T>::operator[](int i)
|
||||
{
|
||||
#ifdef CHECK_INDICES
|
||||
if (i < 0 || i >= used)
|
||||
indexerr(i);
|
||||
#endif
|
||||
return vect[i];
|
||||
}
|
||||
|
||||
template <class T> inline T Svec<T>::operator[](int i) const
|
||||
{
|
||||
#ifdef CHECK_INDICES
|
||||
if (i < 0 || i >= used)
|
||||
indexerr(i);
|
||||
#endif
|
||||
return vect[i];
|
||||
}
|
||||
|
||||
template <class T> inline void Svec<T>::set(int i, T val)
|
||||
{
|
||||
if (i < 0 || i >= used)
|
||||
setextend(i, val);
|
||||
else
|
||||
vect[i] = val;
|
||||
}
|
||||
|
||||
template <class T> inline void Svec<T>::add(T x)
|
||||
{
|
||||
if (++used > alloced)
|
||||
grow();
|
||||
vect[used - 1] = x;
|
||||
}
|
||||
|
||||
/*
|
||||
template<class T>
|
||||
inline void Svec<T>::add(T x)
|
||||
{
|
||||
if(++used > alloced)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
vect[used - 1] = x;
|
||||
}
|
||||
*/
|
||||
|
||||
template <class T> inline void Svec<T>::clear() { used = 0; }
|
||||
|
||||
template <class T> inline void Svec<T>::grow()
|
||||
{
|
||||
// printf("size=%d\n",sizeof(T));
|
||||
vect = (T *)realloc(vect, (alloced *= 2) * sizeof(T));
|
||||
}
|
||||
|
||||
#endif // SVEC_H
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* tablefield.h
|
||||
* This file is part of qps -- Qt-based visual process status monitor
|
||||
*
|
||||
* Copyright 1997-1999 Mattias Engdegård
|
||||
*
|
||||
* 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 TABLEFIELD_H
|
||||
#define TABLEFIELD_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
struct TableField
|
||||
{
|
||||
QString name;
|
||||
int width;
|
||||
int gap;
|
||||
int align;
|
||||
QString tooltip;
|
||||
};
|
||||
|
||||
#endif // TABLEFIELD_H
|