mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
ksystemlog: remove it
requires changes to defaults or configuration changes from the user to function properly on any BSD, journalctl is what Linux uses (i.e. requires major rewrite) Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
988be03b11
commit
2f0f8249a5
311 changed files with 0 additions and 26551 deletions
|
@ -30,7 +30,6 @@ kde4_optional_add_subdirectory(kmix)
|
|||
kde4_optional_add_subdirectory(krdc)
|
||||
kde4_optional_add_subdirectory(krfb)
|
||||
kde4_optional_add_subdirectory(ksnapshot)
|
||||
kde4_optional_add_subdirectory(ksystemlog)
|
||||
kde4_optional_add_subdirectory(ktimer)
|
||||
kde4_optional_add_subdirectory(kuser)
|
||||
kde4_optional_add_subdirectory(kvkbd)
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
project(KSystemLog)
|
||||
|
||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include(FeatureSummary)
|
||||
|
||||
find_package(KDE4 4.23.0 REQUIRED)
|
||||
include(KDE4Defaults)
|
||||
include_directories(${KDE4_INCLUDES})
|
||||
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
include(CheckIncludeFile)
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckLibraryExists)
|
||||
include(CheckTypeSize)
|
||||
|
||||
|
||||
if(ENABLE_TESTING)
|
||||
set(CMAKE_C_VISIBILITY_PRESET "default")
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET "default")
|
||||
endif()
|
||||
|
||||
########### Subfolders ##########
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if(ENABLE_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
endif()
|
|
@ -1,339 +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 Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
|
@ -1,4 +0,0 @@
|
|||
#! /bin/sh
|
||||
$EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp
|
||||
$XGETTEXT `find . -name "*.cpp" -o -name "*.h"` -o $podir/ksystemlog.pot
|
||||
rm -f rc.cpp
|
|
@ -1,188 +0,0 @@
|
|||
|
||||
########### Build ###############
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lib
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/acpid
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/apache
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/authentication
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/base
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/cron
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/cups
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/daemon
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/kernel
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/open
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/postfix
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/samba
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/system
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/xorg
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modes/xsession
|
||||
)
|
||||
|
||||
set(ksystemlog_library_sources
|
||||
lib/analyzer.cpp
|
||||
lib/logModeFactory.cpp
|
||||
lib/logModeConfiguration.cpp
|
||||
lib/logModeConfigurationWidget.cpp
|
||||
lib/logModeItemBuilder.cpp
|
||||
lib/logManager.cpp
|
||||
lib/view.cpp
|
||||
lib/globals.cpp
|
||||
lib/logMode.cpp
|
||||
lib/logLevel.cpp
|
||||
lib/logFile.cpp
|
||||
lib/logFileReader.cpp
|
||||
lib/localLogFileReader.cpp
|
||||
lib/processOutputLogFileReader.cpp
|
||||
lib/kioLogFileReader.cpp
|
||||
lib/logLine.cpp
|
||||
lib/logViewModel.cpp
|
||||
lib/logViewColumn.cpp
|
||||
lib/logViewColumns.cpp
|
||||
lib/logViewWidgetItem.cpp
|
||||
lib/logViewWidget.cpp
|
||||
lib/logViewExport.cpp
|
||||
lib/logViewFilterWidget.cpp
|
||||
lib/logViewSearchWidget.cpp
|
||||
lib/loadingBar.cpp
|
||||
lib/logModeAction.cpp
|
||||
lib/simpleAction.cpp
|
||||
lib/multipleActions.cpp
|
||||
lib/levelPrintPage.cpp
|
||||
|
||||
modes/base/parsingHelper.cpp
|
||||
modes/base/fileList.cpp
|
||||
modes/base/logLevelFileList.cpp
|
||||
modes/base/multipleFileList.cpp
|
||||
modes/base/fileListHelper.cpp
|
||||
modes/base/logLevelSelectionDialog.cpp
|
||||
modes/base/genericConfiguration.cpp
|
||||
modes/base/syslogAnalyzer.cpp
|
||||
modes/kernel/kernelFactory.cpp
|
||||
modes/kernel/kernelAnalyzer.cpp
|
||||
modes/kernel/kernelLogMode.cpp
|
||||
modes/kernel/kernelItemBuilder.cpp
|
||||
modes/system/systemFactory.cpp
|
||||
modes/system/systemConfigurationWidget.cpp
|
||||
modes/system/systemConfiguration.cpp
|
||||
modes/system/systemAnalyzer.cpp
|
||||
modes/system/systemLogMode.cpp
|
||||
)
|
||||
|
||||
set(ksystemlog_sources
|
||||
modes/acpid/acpidConfigurationWidget.cpp
|
||||
modes/acpid/acpidConfiguration.cpp
|
||||
modes/acpid/acpidAnalyzer.cpp
|
||||
modes/acpid/acpidItemBuilder.cpp
|
||||
modes/acpid/acpidLogMode.cpp
|
||||
modes/acpid/acpidFactory.cpp
|
||||
modes/apache/apacheConfiguration.cpp
|
||||
modes/apache/apacheConfigurationWidget.cpp
|
||||
modes/apache/apacheAnalyzer.cpp
|
||||
modes/apache/apacheItemBuilder.cpp
|
||||
modes/apache/apacheAccessAnalyzer.cpp
|
||||
modes/apache/apacheAccessItemBuilder.cpp
|
||||
modes/apache/apacheFactory.cpp
|
||||
modes/apache/apacheLogMode.cpp
|
||||
modes/apache/apacheAccessLogMode.cpp
|
||||
modes/authentication/authenticationConfigurationWidget.cpp
|
||||
modes/authentication/authenticationConfiguration.cpp
|
||||
modes/authentication/authenticationAnalyzer.cpp
|
||||
modes/authentication/authenticationLogMode.cpp
|
||||
modes/authentication/authenticationFactory.cpp
|
||||
modes/cron/cronConfigurationWidget.cpp
|
||||
modes/cron/cronConfiguration.cpp
|
||||
modes/cron/cronAnalyzer.cpp
|
||||
modes/cron/cronItemBuilder.cpp
|
||||
modes/cron/cronLogMode.cpp
|
||||
modes/cron/cronFactory.cpp
|
||||
modes/cups/cupsConfiguration.cpp
|
||||
modes/cups/cupsConfigurationWidget.cpp
|
||||
modes/cups/cupsAnalyzer.cpp
|
||||
modes/cups/cupsItemBuilder.cpp
|
||||
modes/cups/cupsLogMode.cpp
|
||||
modes/cups/cupsAccessAnalyzer.cpp
|
||||
modes/cups/cupsAccessItemBuilder.cpp
|
||||
modes/cups/cupsAccessLogMode.cpp
|
||||
modes/cups/cupsPageAnalyzer.cpp
|
||||
modes/cups/cupsPageItemBuilder.cpp
|
||||
modes/cups/cupsPageLogMode.cpp
|
||||
modes/cups/cupsPdfAnalyzer.cpp
|
||||
modes/cups/cupsPdfItemBuilder.cpp
|
||||
modes/cups/cupsPdfLogMode.cpp
|
||||
modes/cups/cupsFactory.cpp
|
||||
modes/daemon/daemonConfigurationWidget.cpp
|
||||
modes/daemon/daemonConfiguration.cpp
|
||||
modes/daemon/daemonLogMode.cpp
|
||||
modes/daemon/daemonFactory.cpp
|
||||
modes/open/openAnalyzer.cpp
|
||||
modes/open/openFactory.cpp
|
||||
modes/open/openLogMode.cpp
|
||||
modes/postfix/postfixFactory.cpp
|
||||
modes/postfix/postfixConfigurationWidget.cpp
|
||||
modes/postfix/postfixConfiguration.cpp
|
||||
modes/postfix/postfixAnalyzer.cpp
|
||||
modes/postfix/postfixLogMode.cpp
|
||||
modes/samba/sambaConfiguration.cpp
|
||||
modes/samba/sambaConfigurationWidget.cpp
|
||||
modes/samba/sambaAnalyzer.cpp
|
||||
modes/samba/sambaLogMode.cpp
|
||||
modes/samba/sambaItemBuilder.cpp
|
||||
modes/samba/sambaAccessLogMode.cpp
|
||||
modes/samba/netbiosLogMode.cpp
|
||||
modes/samba/sambaFactory.cpp
|
||||
modes/xorg/xorgConfigurationWidget.cpp
|
||||
modes/xorg/xorgConfiguration.cpp
|
||||
modes/xorg/xorgAnalyzer.cpp
|
||||
modes/xorg/xorgItemBuilder.cpp
|
||||
modes/xorg/xorgLogMode.cpp
|
||||
modes/xorg/xorgFactory.cpp
|
||||
modes/xsession/xsessionConfigurationWidget.cpp
|
||||
modes/xsession/xsessionConfiguration.cpp
|
||||
modes/xsession/xsessionAnalyzer.cpp
|
||||
modes/xsession/xsessionItemBuilder.cpp
|
||||
modes/xsession/xsessionLogMode.cpp
|
||||
modes/xsession/xsessionFactory.cpp
|
||||
|
||||
main.cpp
|
||||
mainWindow.cpp
|
||||
logModePluginsLoader.cpp
|
||||
loggerDialog.cpp
|
||||
detailDialog.cpp
|
||||
generalConfigurationWidget.cpp
|
||||
configurationDialog.cpp
|
||||
tabLogViewsWidget.cpp
|
||||
tabLogManager.cpp
|
||||
statusBar.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(ksystemlog_library_sources ksystemlogConfig.kcfgc)
|
||||
|
||||
add_executable(ksystemlog ${ksystemlog_library_sources} ${ksystemlog_sources})
|
||||
|
||||
target_link_libraries(ksystemlog
|
||||
${KDE4_KIO_LIBS}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${KDE4_KFILE_LIBS}
|
||||
${KDE4_KARCHIVE_LIBS}
|
||||
)
|
||||
|
||||
if(ENABLE_TESTING)
|
||||
add_library(ksystemlog_library SHARED ${ksystemlog_library_sources})
|
||||
target_link_libraries(ksystemlog_library PUBLIC
|
||||
${KDE4_KIO_LIBS}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${KDE4_KFILE_LIBS}
|
||||
${KDE4_KARCHIVE_LIBS}
|
||||
)
|
||||
endif()
|
||||
|
||||
########### Installation ###############
|
||||
|
||||
install(TARGETS ksystemlog ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
install(PROGRAMS ksystemlog.desktop DESTINATION ${KDE4_XDG_APPS_INSTALL_DIR})
|
||||
install(FILES ksystemlogui.rc DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksystemlog)
|
|
@ -1,200 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "configurationDialog.h"
|
||||
|
||||
|
||||
#include <QList>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kiconloader.h>
|
||||
|
||||
|
||||
#include "generalConfigurationWidget.h"
|
||||
|
||||
#include "logModeConfigurationWidget.h"
|
||||
|
||||
#include "mainWindow.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
#include "logging.h"
|
||||
#include "defaults.h"
|
||||
|
||||
class ConfigurationDialogPrivate {
|
||||
public:
|
||||
|
||||
GeneralConfigurationWidget* generalConfiguration;
|
||||
|
||||
QList<LogModeConfigurationWidget*> logModeConfigurations;
|
||||
|
||||
bool changed;
|
||||
};
|
||||
|
||||
ConfigurationDialog::ConfigurationDialog(QWidget* parent) :
|
||||
KConfigDialog(parent, i18n("Settings"), KSystemLogConfig::self()),
|
||||
d(new ConfigurationDialogPrivate())
|
||||
{
|
||||
|
||||
d->changed = false;
|
||||
|
||||
setupGeneralConfiguration();
|
||||
|
||||
setupLogModeConfigurations();
|
||||
|
||||
}
|
||||
|
||||
ConfigurationDialog::~ConfigurationDialog() {
|
||||
//All configuration pages are managed by KConfigDialog
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ConfigurationDialog::setupLogModeConfigurations() {
|
||||
logDebug() << "Setup Log Mode Configurations...";
|
||||
|
||||
|
||||
foreach(LogMode* logMode, Globals::instance()->logModes()) {
|
||||
//Some Log mode does not need a configuration widget
|
||||
if (logMode->logModeConfigurationWidget() == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//The configuration widget could be shared between Log Modes
|
||||
if (d->logModeConfigurations.contains(logMode->logModeConfigurationWidget()) == true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
d->logModeConfigurations.append(logMode->logModeConfigurationWidget());
|
||||
}
|
||||
|
||||
|
||||
foreach (LogModeConfigurationWidget* logModeConfigurationWidget, d->logModeConfigurations ) {
|
||||
logDebug() << "Adding " << logModeConfigurationWidget->itemName() << " configuration...";
|
||||
|
||||
addPage(logModeConfigurationWidget, logModeConfigurationWidget->itemName(), logModeConfigurationWidget->iconName(), logModeConfigurationWidget->header(), false);
|
||||
|
||||
connect(logModeConfigurationWidget, SIGNAL(configurationChanged()), this, SLOT(updateConfiguration()));
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigurationDialog::showConfiguration() {
|
||||
logDebug() << "Showing Configuration dialog...";
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
void ConfigurationDialog::setupGeneralConfiguration() {
|
||||
d->generalConfiguration = new GeneralConfigurationWidget();
|
||||
|
||||
addPage(d->generalConfiguration, i18n("General"), QLatin1String( KSYSTEMLOG_ICON ), i18n("General"), false);
|
||||
|
||||
connect(d->generalConfiguration, SIGNAL(configurationChanged()), this, SLOT(updateConfiguration()));
|
||||
}
|
||||
|
||||
void ConfigurationDialog::updateSettings() {
|
||||
logDebug() << "Saving configuration...";
|
||||
|
||||
d->changed = false;
|
||||
|
||||
d->generalConfiguration->saveConfig();
|
||||
|
||||
foreach (LogModeConfigurationWidget* logModeConfigurationWidget, d->logModeConfigurations ) {
|
||||
logModeConfigurationWidget->saveConfig();
|
||||
}
|
||||
|
||||
KSystemLogConfig::self()->writeConfig();
|
||||
|
||||
emit configurationSaved();
|
||||
|
||||
logDebug() << "Configuration saved";
|
||||
}
|
||||
|
||||
bool ConfigurationDialog::hasChanged() {
|
||||
logDebug() << "Current change status : " << d->changed;
|
||||
return d->changed;
|
||||
}
|
||||
|
||||
void ConfigurationDialog::updateConfiguration() {
|
||||
logDebug() << "Updating configuration...";
|
||||
|
||||
bool valid = d->generalConfiguration->isValid();
|
||||
if (valid) {
|
||||
foreach (LogModeConfigurationWidget* logModeConfigurationWidget, d->logModeConfigurations ) {
|
||||
if (logModeConfigurationWidget->isValid() == false) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (valid == true) {
|
||||
enableButtonOk(true);
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
else {
|
||||
enableButtonOk(false);
|
||||
enableButtonApply(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConfigurationDialog::updateButtons() {
|
||||
logDebug() << "Updating configuration buttons...";
|
||||
|
||||
d->changed = true;
|
||||
|
||||
}
|
||||
|
||||
void ConfigurationDialog::updateWidgets() {
|
||||
logDebug() << "Reading configuration...";
|
||||
|
||||
d->generalConfiguration->readConfig();
|
||||
foreach (LogModeConfigurationWidget* logModeConfigurationWidget, d->logModeConfigurations ) {
|
||||
logModeConfigurationWidget->readConfig();
|
||||
}
|
||||
|
||||
d->changed = false;
|
||||
}
|
||||
|
||||
void ConfigurationDialog::updateWidgetsDefault() {
|
||||
logDebug() << "Loading default configuration...";
|
||||
|
||||
d->generalConfiguration->defaultConfig();
|
||||
foreach (LogModeConfigurationWidget* logModeConfigurationWidget, d->logModeConfigurations ) {
|
||||
logModeConfigurationWidget->defaultConfig();
|
||||
}
|
||||
|
||||
d->changed = false;
|
||||
}
|
||||
|
||||
bool ConfigurationDialog::isDefault() {
|
||||
/**
|
||||
* TODO Set this to true and find a way to retrieve defaults value
|
||||
* of the configuration (see defaultConfig() methods of LogModeConfigurations)
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "moc_configurationDialog.cpp"
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _CONFIGURATION_DIALOG_H_
|
||||
#define _CONFIGURATION_DIALOG_H_
|
||||
|
||||
#include <kconfigdialog.h>
|
||||
|
||||
|
||||
class ConfigurationDialogPrivate;
|
||||
|
||||
class ConfigurationDialog: public KConfigDialog {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigurationDialog(QWidget* parent);
|
||||
|
||||
~ConfigurationDialog();
|
||||
|
||||
void showConfiguration();
|
||||
|
||||
signals:
|
||||
void configurationSaved();
|
||||
|
||||
protected slots:
|
||||
|
||||
void updateWidgets();
|
||||
void updateWidgetsDefault();
|
||||
void updateSettings();
|
||||
void updateButtons();
|
||||
|
||||
private slots:
|
||||
void updateConfiguration();
|
||||
|
||||
private:
|
||||
bool hasChanged();
|
||||
bool isDefault();
|
||||
|
||||
ConfigurationDialogPrivate* const d;
|
||||
|
||||
void setupGeneralConfiguration();
|
||||
|
||||
void setupLogModeConfigurations();
|
||||
};
|
||||
|
||||
#endif //_CONFIGURATION_DIALOG_H_
|
|
@ -1,135 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "detailDialog.h"
|
||||
|
||||
//Qt includes
|
||||
|
||||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "logViewWidget.h"
|
||||
#include "logViewWidgetItem.h"
|
||||
#include "logLine.h"
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
DetailDialog::DetailDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
logViewWidget(NULL) {
|
||||
|
||||
setupUi(this);
|
||||
|
||||
previous->setText(i18n("&Previous"));
|
||||
previous->setIcon(KIcon( QLatin1String( "arrow-up" )));
|
||||
connect(previous, SIGNAL(clicked()), this, SLOT(previousItem()));
|
||||
|
||||
next->setText(i18n("&Next"));
|
||||
next->setIcon(KIcon( QLatin1String( "arrow-down" )));
|
||||
connect(next, SIGNAL(clicked()), this, SLOT(nextItem()));
|
||||
|
||||
closeButton->setText(KStandardGuiItem::close().text());
|
||||
closeButton->setIcon(KStandardGuiItem::close().icon());
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
}
|
||||
|
||||
DetailDialog::~DetailDialog() {
|
||||
|
||||
}
|
||||
|
||||
void DetailDialog::selectionChanged(LogViewWidget* logViewWidget) {
|
||||
this->logViewWidget=logViewWidget;
|
||||
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
//TODO Try to find a method that reload (an resize) correctly the content of the detail dialog
|
||||
void DetailDialog::updateDetails() {
|
||||
//logDebug() << "Updating Detail Dialog...";
|
||||
|
||||
//Get the current-last item selected
|
||||
LogViewWidgetItem* item=logViewWidget->lastSelectedItem();
|
||||
if (item==NULL) {
|
||||
logDebug() << "No item found.";
|
||||
return;
|
||||
}
|
||||
|
||||
icon->setPixmap(DesktopIcon(item->logLine()->logLevel()->icon()));
|
||||
|
||||
header->setText(item->logLine()->formattedText());
|
||||
|
||||
message->setText(item->logLine()->logItems().last());
|
||||
|
||||
if (logViewWidget->topLevelItem(logViewWidget->indexOfTopLevelItem(item) - 1)==NULL)
|
||||
previous->setEnabled(false);
|
||||
else
|
||||
previous->setEnabled(true);
|
||||
|
||||
if (logViewWidget->topLevelItem(logViewWidget->indexOfTopLevelItem(item) + 1 )==NULL)
|
||||
next->setEnabled(false);
|
||||
else
|
||||
next->setEnabled(true);
|
||||
|
||||
/*
|
||||
header->adjustSize();
|
||||
this->adjustSize();
|
||||
*/
|
||||
}
|
||||
|
||||
void DetailDialog::moveToItem(int direction) {
|
||||
if (direction < 0)
|
||||
logDebug() << "Go to previous item...";
|
||||
else
|
||||
logDebug() << "Go to next item...";
|
||||
|
||||
//Get the current-last item selected
|
||||
LogViewWidgetItem* item=logViewWidget->lastSelectedItem();
|
||||
if (item==NULL) {
|
||||
logDebug() << "No item found.";
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem* destinationItem = logViewWidget->topLevelItem( logViewWidget->indexOfTopLevelItem(item) + direction );
|
||||
if (destinationItem==NULL) {
|
||||
if (direction < 0)
|
||||
logDebug() << "No previous item found.";
|
||||
else
|
||||
logDebug() << "No next item found.";
|
||||
return;
|
||||
}
|
||||
|
||||
logViewWidget->setItemSelected(item, false);
|
||||
logViewWidget->setItemSelected(destinationItem, true);
|
||||
logViewWidget->scrollToItem(destinationItem);
|
||||
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
void DetailDialog::previousItem() {
|
||||
moveToItem(-1);
|
||||
}
|
||||
|
||||
void DetailDialog::nextItem() {
|
||||
moveToItem(1);
|
||||
}
|
||||
|
||||
#include "moc_detailDialog.cpp"
|
|
@ -1,59 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _DETAIL_DIALOG_H_
|
||||
#define _DETAIL_DIALOG_H_
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class LogViewWidget;
|
||||
|
||||
#include "ui_detailDialogBase.h"
|
||||
|
||||
class DetailDialog : public QDialog, public Ui::DetailDialogBase {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DetailDialog(QWidget *parent);
|
||||
|
||||
~DetailDialog();
|
||||
|
||||
public slots:
|
||||
void selectionChanged(LogViewWidget* logViewWidget);
|
||||
|
||||
private slots:
|
||||
void previousItem();
|
||||
void nextItem();
|
||||
|
||||
private:
|
||||
void updateDetails();
|
||||
|
||||
/**
|
||||
* Method that replaces the bugged itemAbove() and itemBelow() methods
|
||||
*/
|
||||
void moveToItem(int direction);
|
||||
|
||||
LogViewWidget* logViewWidget;
|
||||
|
||||
};
|
||||
|
||||
#endif //_DETAIL_DIALOG_H_
|
|
@ -1,189 +0,0 @@
|
|||
<ui version="4.0" >
|
||||
<class>DetailDialogBase</class>
|
||||
<widget class="QDialog" name="DetailDialogBase" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>411</width>
|
||||
<height>248</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Log Line Details</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<string>This dialog displays detailed information about the currently selected log line.</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="1" column="0" colspan="2" >
|
||||
<widget class="KTextEdit" native="1" name="message" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" stdset="0" >
|
||||
<string>Message</string>
|
||||
</property>
|
||||
<property name="readOnly" stdset="0" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="icon" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Icon</string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLabel" name="header" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Main information</string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="KPushButton" native="1" name="previous" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Move to the previous line</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<string>Moves to the previous line. This button is deactivated if there is no previous log line.</string>
|
||||
</property>
|
||||
<property name="text" stdset="0" >
|
||||
<string>&Back</string>
|
||||
</property>
|
||||
<property name="stdItem" stdset="0" >
|
||||
<number>14</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KPushButton" native="1" name="next" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Move to the next line</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<string>Moves to the next line. This button is deactivated if there is no next log line.</string>
|
||||
</property>
|
||||
<property name="text" stdset="0" >
|
||||
<string>&Forward</string>
|
||||
</property>
|
||||
<property name="stdItem" stdset="0" >
|
||||
<number>15</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KPushButton" native="1" name="closeButton" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Close the Detail dialog.</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<string>Closes this Detail dialog.</string>
|
||||
</property>
|
||||
<property name="text" stdset="0" >
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
<property name="stdItem" stdset="0" >
|
||||
<number>13</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KTextEdit</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>ktextedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KPushButton</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>kpushbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>message</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local" >ktextedit.h</include>
|
||||
<include location="local" >kpushbutton.h</include>
|
||||
<include location="local" >kpushbutton.h</include>
|
||||
<include location="local" >kpushbutton.h</include>
|
||||
</includes>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,150 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "generalConfigurationWidget.h"
|
||||
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QButtonGroup>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kicon.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "defaults.h"
|
||||
#include "globals.h"
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
class GeneralConfigurationWidgetPrivate {
|
||||
public:
|
||||
QButtonGroup* dateFormatGroup;
|
||||
};
|
||||
|
||||
GeneralConfigurationWidget::GeneralConfigurationWidget() :
|
||||
QWidget(),
|
||||
d(new GeneralConfigurationWidgetPrivate())
|
||||
{
|
||||
|
||||
setupUi(this);
|
||||
|
||||
startupLogMode->addItem(KIcon( QLatin1String( NO_MODE_ICON) ), i18n("No Log Mode"), QVariant(QLatin1String( "" ) ));
|
||||
foreach(LogMode* logMode, Globals::instance()->logModes()) {
|
||||
//Ignore this special case
|
||||
if (logMode->id() == QLatin1String( "openLogMode" ))
|
||||
continue;
|
||||
|
||||
startupLogMode->addItem(KIcon(logMode->icon()), logMode->name(), QVariant(logMode->id()));
|
||||
}
|
||||
|
||||
connect(startupLogMode, SIGNAL(currentIndexChanged(int)), this, SIGNAL(configurationChanged()));
|
||||
|
||||
connect(maxLines, SIGNAL(valueChanged(int)), this, SIGNAL(configurationChanged()));
|
||||
|
||||
connect(deleteDuplicatedLines, SIGNAL(clicked()), this, SIGNAL(configurationChanged()));
|
||||
|
||||
connect(deleteProcessId, SIGNAL(clicked()), this, SIGNAL(configurationChanged()));
|
||||
|
||||
connect(colorizeLogLines, SIGNAL(clicked()), this, SIGNAL(configurationChanged()));
|
||||
|
||||
d->dateFormatGroup = new QButtonGroup(this);
|
||||
d->dateFormatGroup->addButton(formatShortDate, KLocale::ShortDate);
|
||||
d->dateFormatGroup->addButton(formatLongDate, KLocale::LongDate);
|
||||
d->dateFormatGroup->addButton(formatFancyShortDate, KLocale::FancyShortDate);
|
||||
d->dateFormatGroup->addButton(formatFancyLongDate, KLocale::FancyLongDate);
|
||||
|
||||
connect(d->dateFormatGroup, SIGNAL(buttonClicked(int)), this, SIGNAL(configurationChanged()));
|
||||
|
||||
addDateFormatExample();
|
||||
}
|
||||
|
||||
|
||||
GeneralConfigurationWidget::~GeneralConfigurationWidget() {
|
||||
//dateFormatGroup is automatically deleted by Qt
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
void GeneralConfigurationWidget::addDateFormatExample() {
|
||||
foreach(QAbstractButton* button, d->dateFormatGroup->buttons()) {
|
||||
QDateTime currentDateTime(QDateTime::currentDateTime());
|
||||
|
||||
KLocale::DateFormat currentButtonFormat = (KLocale::DateFormat) d->dateFormatGroup->id(button);
|
||||
|
||||
QString formattedDate = KGlobal::locale()->formatDateTime(currentDateTime, currentButtonFormat, true);
|
||||
|
||||
button->setText( i18nc("Date format Option (Date example)", "%1 (%2)", button->text(), formattedDate) );
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralConfigurationWidget::readConfig() {
|
||||
for (int i=0; i<startupLogMode->count(); ++i) {
|
||||
if (KSystemLogConfig::startupLogMode() == startupLogMode->itemData(i).toString()) {
|
||||
startupLogMode->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
maxLines->setValue(KSystemLogConfig::maxLines());
|
||||
|
||||
deleteDuplicatedLines->setChecked(KSystemLogConfig::deleteDuplicatedLines());
|
||||
|
||||
deleteProcessId->setChecked(KSystemLogConfig::deleteProcessIdentifier());
|
||||
|
||||
colorizeLogLines->setChecked(KSystemLogConfig::colorizeLogLines());
|
||||
|
||||
KLocale::DateFormat dateFormat = (KLocale::DateFormat) KSystemLogConfig::dateFormat();
|
||||
QAbstractButton* selectedButton = d->dateFormatGroup->button(dateFormat);
|
||||
selectedButton->setChecked(true);
|
||||
}
|
||||
|
||||
void GeneralConfigurationWidget::saveConfig() const {
|
||||
logDebug() << "Save config from General preferences";
|
||||
|
||||
KSystemLogConfig::setStartupLogMode(startupLogMode->itemData(startupLogMode->currentIndex()).toString());
|
||||
|
||||
KSystemLogConfig::setMaxLines(maxLines->value());
|
||||
KSystemLogConfig::setDeleteDuplicatedLines(deleteDuplicatedLines->isChecked());
|
||||
KSystemLogConfig::setDeleteProcessIdentifier(deleteProcessId->isChecked());
|
||||
KSystemLogConfig::setColorizeLogLines(colorizeLogLines->isChecked());
|
||||
|
||||
KSystemLogConfig::setDateFormat(d->dateFormatGroup->checkedId());
|
||||
|
||||
}
|
||||
|
||||
void GeneralConfigurationWidget::defaultConfig() {
|
||||
//TODO Find a way to read the configuration per default
|
||||
readConfig();
|
||||
}
|
||||
|
||||
bool GeneralConfigurationWidget::isValid() const {
|
||||
if (maxLines->value()>0) {
|
||||
logDebug() << "General configuration valid";
|
||||
return true;
|
||||
}
|
||||
|
||||
logDebug() << "General configuration not valid";
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "moc_generalConfigurationWidget.cpp"
|
|
@ -1,58 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _GENERAL_CONFIGURATION_WIDGET_H_
|
||||
#define _GENERAL_CONFIGURATION_WIDGET_H_
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ui_generalConfigurationWidgetBase.h"
|
||||
|
||||
class GeneralConfigurationWidgetPrivate;
|
||||
|
||||
class GeneralConfigurationWidget : public QWidget, public Ui::GeneralConfigurationWidgetBase {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GeneralConfigurationWidget();
|
||||
|
||||
~GeneralConfigurationWidget();
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
public slots:
|
||||
void saveConfig() const;
|
||||
|
||||
void defaultConfig();
|
||||
|
||||
void readConfig();
|
||||
|
||||
signals:
|
||||
void configurationChanged();
|
||||
|
||||
private:
|
||||
void addDateFormatExample();
|
||||
|
||||
GeneralConfigurationWidgetPrivate* const d;
|
||||
};
|
||||
|
||||
#endif // _GENERAL_CONFIGURATION_WIDGET_H_
|
|
@ -1,202 +0,0 @@
|
|||
<ui version="4.0" >
|
||||
<author>Nicolas Ternisien</author>
|
||||
<class>GeneralConfigurationWidgetBase</class>
|
||||
<widget class="QWidget" name="GeneralConfigurationWidgetBase" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>368</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4" >
|
||||
<property name="title" >
|
||||
<string>Startup</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Load this log mode at startup:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>startupLogMode</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="startupLogMode" >
|
||||
<property name="toolTip" >
|
||||
<string>The log mode which is loaded by default at startup</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<string>The log mode loaded by default at startup. Choose 'No Log Mode' if you do not want this to happen.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>Log Lines List</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="maxLinesLabel" >
|
||||
<property name="text" >
|
||||
<string>Maximum lines displayed:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>maxLines</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KIntSpinBox" name="maxLines" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Choose here the maximum number of log lines displayed in the main view.</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<string>You can choose here the maximum number of log lines displayed in the main view.</string>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>30000</number>
|
||||
</property>
|
||||
<property name="singleStep" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="deleteDuplicatedLines" >
|
||||
<property name="toolTip" >
|
||||
<string>Select this option if you want to delete duplicate log lines <b>(may be slow)</b>.</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<string>Select this option if you want to delete duplicate log lines. <b>This option can slow log reading</b>.</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Remove &duplicate log lines (may be slower)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2" >
|
||||
<property name="title" >
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QCheckBox" name="deleteProcessId" >
|
||||
<property name="toolTip" >
|
||||
<string>Remove process identifier from process name.</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<string>Select this option if you want to remove the process identifier from the process name. For example, the <b>Process</b> column may contain entries such as <i>cron<b>[3433]</b></i>. If this option is activated, the bold part will be removed.</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Remove &identifier from process name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="colorizeLogLines" >
|
||||
<property name="toolTip" >
|
||||
<string>This option allows log lines to be colored depending on their log level.</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<string>This option allows log lines to be colored depending on their log level. For example, errors will be shown in red, warnings in orange, and so on. This will help you to see problems more easily.</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Colored log lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3" >
|
||||
<property name="title" >
|
||||
<string>Date Format</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QRadioButton" name="formatShortDate" >
|
||||
<property name="styleSheet" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Short date format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="formatFancyShortDate" >
|
||||
<property name="text" >
|
||||
<string>&Fancy short date format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="formatLongDate" >
|
||||
<property name="text" >
|
||||
<string>&Long date format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="formatFancyLongDate" >
|
||||
<property name="text" >
|
||||
<string>Fanc&y long date format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KIntSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>knuminput.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,174 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=KSystemLog
|
||||
Name[ast]=KSystemLog
|
||||
Name[bg]=Системни дневници
|
||||
Name[bs]=KSystemLog
|
||||
Name[ca]=KSystemLog
|
||||
Name[ca@valencia]=KSystemLog
|
||||
Name[cs]=KSystemLog
|
||||
Name[da]=KSystemLog
|
||||
Name[de]=KSystemLog
|
||||
Name[el]=KSystemLog
|
||||
Name[en_GB]=KSystemLog
|
||||
Name[es]=KSystemLog
|
||||
Name[et]=KSystemLog
|
||||
Name[eu]=KSystemLog
|
||||
Name[fi]=KSystemLog
|
||||
Name[fr]=KSystemLog
|
||||
Name[ga]=KSystemLog
|
||||
Name[gl]=KSystemLog
|
||||
Name[hne]=के-सिस्टम-लाग
|
||||
Name[hr]=KSystemLog
|
||||
Name[hu]=Rendszernapló-megjelenítő
|
||||
Name[ia]=KSystemLog
|
||||
Name[id]=KSystemLog
|
||||
Name[is]=KSystemLog
|
||||
Name[it]=KSystemLog
|
||||
Name[ja]=KSystemLog
|
||||
Name[kk]=KSystemLog
|
||||
Name[ko]=KSystemLog
|
||||
Name[lt]=KSystemLog
|
||||
Name[lv]=KSystemLog
|
||||
Name[ml]=കെസിസ്റ്റംലോഗ്
|
||||
Name[mr]=के-सिस्टीम-लॉग
|
||||
Name[nb]=KSystemLog
|
||||
Name[nds]=KSystemLog
|
||||
Name[nl]=KSystemLog
|
||||
Name[nn]=KSystemlogg
|
||||
Name[pa]=ਕੇ-ਸਿਸਟਮ-ਲਾਗ
|
||||
Name[pl]=KSystemLog
|
||||
Name[pt]=KSystemLog
|
||||
Name[pt_BR]=KSystemLog
|
||||
Name[ro]=KSystemLog
|
||||
Name[ru]=KSystemLog
|
||||
Name[sk]=KSystemLog
|
||||
Name[sl]=KSystemLog
|
||||
Name[sq]=KSystemLog
|
||||
Name[sr]=К‑системски-дневник
|
||||
Name[sr@ijekavian]=К‑системски-дневник
|
||||
Name[sr@ijekavianlatin]=K‑sistemski-dnevnik
|
||||
Name[sr@latin]=K‑sistemski-dnevnik
|
||||
Name[sv]=Ksystemlog
|
||||
Name[th]=ปูมบันทึกระบบ
|
||||
Name[tr]=KSystemLog
|
||||
Name[ug]=KSystemLog
|
||||
Name[uk]=KSystemLog
|
||||
Name[x-test]=xxKSystemLogxx
|
||||
Name[zh_CN]=KSystemLog
|
||||
Name[zh_TW]=KSystemLog
|
||||
Categories=Qt;KDE;System;Monitor;
|
||||
X-KDE-SubstituteUID=true
|
||||
Exec=ksystemlog --icon '%i' --caption '%c'
|
||||
Icon=utilities-log-viewer
|
||||
Type=Application
|
||||
X-DocPath=ksystemlog/index.html
|
||||
Comment=System log viewer tool
|
||||
Comment[ast]=Ferramienta de visor de rexistru de sistema
|
||||
Comment[bg]=Инструмент за преглеждане на системните дневници
|
||||
Comment[bs]=Alat za pregled sistemski zabilješki
|
||||
Comment[ca]=Eina de visualització dels registres del sistema
|
||||
Comment[ca@valencia]=Eina de visualització dels registres del sistema
|
||||
Comment[cs]=Nástroj na prohlížení záznamů systému
|
||||
Comment[da]=Fremviserværktøj til systemlog
|
||||
Comment[de]=Betrachter für Systemprotokolle
|
||||
Comment[el]=Εργαλείο εμφάνισης της καταγραφής του συστήματος
|
||||
Comment[en_GB]=System log viewer tool
|
||||
Comment[es]=Herramienta de visualización de registros del sistema
|
||||
Comment[et]=Süsteemilogi näitaja
|
||||
Comment[eu]=Sistema egunkariak erakusteko tresna
|
||||
Comment[fi]=Järjestelmälokien katselin
|
||||
Comment[fr]=Outil d'affichage des journaux du système
|
||||
Comment[ga]=Amharcán ar logchomhaid an chórais
|
||||
Comment[gl]=Visor dos rexistros do sistema
|
||||
Comment[hne]=तंत्र लाग प्रदर्सक औजार
|
||||
Comment[hr]=Alat za prikaz dnevnika sustava
|
||||
Comment[hu]=Rendszernapló-megjelenítő eszköz
|
||||
Comment[ia]=Instrumento pro vider registro de systema
|
||||
Comment[id]=Alat pembaca Catatan sistem
|
||||
Comment[is]=Tól til að skoða kerfisannála (system logs)
|
||||
Comment[it]=Strumento di visione dei registri di sistema
|
||||
Comment[ja]=システムログビューア
|
||||
Comment[kk]=Жүйелік журналын қарау құралы
|
||||
Comment[ko]=시스템 로그 뷰어 도구
|
||||
Comment[lt]=Sistemos žurnalų žiūryklė
|
||||
Comment[lv]=Sistēmas žurnāla skatīšanas rīks
|
||||
Comment[ml]=സിസ്റ്റം ലോഗ് കാണാന്നുള്ള ടൂള്
|
||||
Comment[mr]=प्रणाली लॉग प्रदर्शक साधन
|
||||
Comment[nb]=Verktøy for å vise systemlogger
|
||||
Comment[nds]=Kieker för Systeem-Logböker
|
||||
Comment[nl]=Systeemlogs bekijken
|
||||
Comment[nn]=Verktøy for vising av systemloggar
|
||||
Comment[pa]=ਸਿਸਟਮ ਲਾਗ ਦਰਸ਼ਕ ਟੂਲ
|
||||
Comment[pl]=Narzędzie do przeglądania dziennika systemowego
|
||||
Comment[pt]=Ferramenta de visualização de registos do sistema
|
||||
Comment[pt_BR]=Ferramenta de visualização de registros do sistema
|
||||
Comment[ro]=Unealtă de vizualizare a jurnalelor de sistem
|
||||
Comment[ru]=Программа просмотра системных журналов
|
||||
Comment[sk]=Nástroj na prehliadanie záznamov systému
|
||||
Comment[sl]=Orodje za pregledovanje sistemskih dnevnikov
|
||||
Comment[sq]=Mjeti shfaqës i hyrjeve në sistem
|
||||
Comment[sr]=Приказивач системских дневника
|
||||
Comment[sr@ijekavian]=Приказивач системских дневника
|
||||
Comment[sr@ijekavianlatin]=Prikazivač sistemskih dnevnika
|
||||
Comment[sr@latin]=Prikazivač sistemskih dnevnika
|
||||
Comment[sv]=Visningsverktyg för systemloggar
|
||||
Comment[th]=เครื่องมือแสดงปูมบันทึกของระบบ
|
||||
Comment[tr]=Sistem günlük kayıtlarını gösterme aracı
|
||||
Comment[ug]=سىستېما خاتىرىسىنى كۆرۈش قورالى
|
||||
Comment[uk]=Засіб перегляду системних журналів
|
||||
Comment[x-test]=xxSystem log viewer toolxx
|
||||
Comment[zh_CN]=系统日志查看工具
|
||||
Comment[zh_TW]=系統紀錄檢視工具
|
||||
Terminal=false
|
||||
GenericName=System Log Viewer
|
||||
GenericName[bg]=Преглед на системните дневници
|
||||
GenericName[bs]=Preglednik sistemskih bilješki
|
||||
GenericName[ca]=Visor dels registres del sistema
|
||||
GenericName[ca@valencia]=Visor dels registres del sistema
|
||||
GenericName[cs]=Prohlížeč záznamů systému
|
||||
GenericName[da]=Systemlogfremviser
|
||||
GenericName[de]=Systemprotokoll-Betrachter
|
||||
GenericName[el]=Εμφάνιση καταγραφών του συστήματος
|
||||
GenericName[en_GB]=System Log Viewer
|
||||
GenericName[es]=Visor de registros del sistema
|
||||
GenericName[et]=Süsteemi logide jälgija
|
||||
GenericName[eu]=Sistema egunkarien erakuslea
|
||||
GenericName[fi]=Järjestelmän lokitiedostojen katselin
|
||||
GenericName[fr]=Afficheur des journaux du système
|
||||
GenericName[ga]=Amharcán ar Logchomhaid an Chórais
|
||||
GenericName[gl]=Visor dos rexistros do sistema
|
||||
GenericName[hr]=Preglednik sistemskih zapisa
|
||||
GenericName[hu]=Rendszernapló-megjelenítő
|
||||
GenericName[ia]=Visor de registro de systema
|
||||
GenericName[id]=Penampil Catatan Sistem
|
||||
GenericName[is]=Kerfisannálabirtir
|
||||
GenericName[it]=Visore dei registri di sistema
|
||||
GenericName[ja]=システムログビューア
|
||||
GenericName[kk]=Жүйелік журналын қарау
|
||||
GenericName[ko]=시스템 로그 뷰어
|
||||
GenericName[lt]=Sistemos žurnalų žiūryklė
|
||||
GenericName[mr]=प्रणाली लॉग प्रदर्शक
|
||||
GenericName[nb]=Systemloggviser
|
||||
GenericName[nds]=Kieker för't Systeemlogbook
|
||||
GenericName[nl]=Systeemlog-weergaveprogramma
|
||||
GenericName[nn]=Systemloggvisar
|
||||
GenericName[pa]=ਸਿਸਟਮ ਲਾਗ ਦਰਸ਼ਕ
|
||||
GenericName[pl]=Przeglądarka dziennika systemowego
|
||||
GenericName[pt]=Visualizador de Registos do Sistema
|
||||
GenericName[pt_BR]=Visualizador do registros do sistema
|
||||
GenericName[ro]=Vizualizator jurnale de sistem
|
||||
GenericName[ru]=Просмотр системных журналов
|
||||
GenericName[sk]=Prehliadač záznamov systému
|
||||
GenericName[sl]=Pregledovalnik sistemskih dnevnikov
|
||||
GenericName[sr]=Приказивач системског дневника
|
||||
GenericName[sr@ijekavian]=Приказивач системског дневника
|
||||
GenericName[sr@ijekavianlatin]=Prikazivač sistemskog dnevnika
|
||||
GenericName[sr@latin]=Prikazivač sistemskog dnevnika
|
||||
GenericName[sv]=Visning av systemloggar
|
||||
GenericName[th]=แสดงปูมบันทึกของระบบ
|
||||
GenericName[tr]=Sistem Günlüğü İzleyici
|
||||
GenericName[ug]=سىستېما خاتىرىسى كۆرگۈچ
|
||||
GenericName[uk]=Переглядач системних журналів
|
||||
GenericName[x-test]=xxSystem Log Viewerxx
|
||||
GenericName[zh_CN]=系统日志查看器
|
||||
GenericName[zh_TW]=系統紀錄檔檢視器
|
|
@ -1,78 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
|
||||
<kcfgfile name="ksystemlogrc" />
|
||||
|
||||
<include>klocale.h</include>
|
||||
|
||||
<group name="KSystemLogGeneral">
|
||||
<entry name="StartupLogMode" type="String">
|
||||
<label>Load this log mode at startup.</label>
|
||||
<default>systemLogMode</default>
|
||||
</entry>
|
||||
|
||||
<entry name="MaxLines" type="Int">
|
||||
<label>The log view line count limit.</label>
|
||||
<default>1000</default>
|
||||
</entry>
|
||||
|
||||
<entry name="DeleteDuplicatedLines" type="Bool">
|
||||
<label>Option is true if the user wants to delete repeated log lines.</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
|
||||
<entry name="DeleteProcessIdentifier" type="Bool">
|
||||
<label>Option is true if the PID in the process column of the SystemLog is to be omitted.</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
|
||||
<entry name="ColorizeLogLines" type="Bool">
|
||||
<label>Option is true if the log lines are to be colored depending on their log level.</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
||||
|
||||
<entry name="TooltipEnabled" type="Bool">
|
||||
<label>Whether the tooltips are enabled.</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
||||
<entry name="NewLinesDisplayed" type="Bool">
|
||||
<label>Whether new lines are displayed.</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
||||
<entry name="ToggleFilterBar" type="Bool">
|
||||
<label>Whether the filter bar is shown.</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
||||
<entry name="DateFormat" type="Enum">
|
||||
<label>The date format of log lines.</label>
|
||||
<default>KLocale::ShortDate</default>
|
||||
<!--
|
||||
<choices>
|
||||
<choice name="KLocale::ShortDate"/>
|
||||
<choice name="KLocale::LongDate"/>
|
||||
<choice name="KLocale::FancyShortDate"/>
|
||||
<choice name="KLocale::FancyLongDate"/>
|
||||
</choices>
|
||||
-->
|
||||
</entry>
|
||||
|
||||
<!--
|
||||
|
||||
Samba config entries
|
||||
<entry name="SambaPaths" type="StringList">
|
||||
<label>The Samba log file paths.</label>
|
||||
<default>/var/log/samba/log.nmbd,/var/log/samba/log.smbd</default>
|
||||
</entry>
|
||||
|
||||
-->
|
||||
|
||||
</group>
|
||||
|
||||
</kcfg>
|
|
@ -1,16 +0,0 @@
|
|||
Begin3
|
||||
Title: KSystemLog -- System Log Viewer Tool
|
||||
Version: 0.1.1
|
||||
Entered-date:
|
||||
Description: System Log Viewer Tool for KDE
|
||||
Keywords: KDE Qt System Log
|
||||
Author: Nicolas Ternisien <nicolas.ternisien@gmail.com>
|
||||
Maintained-by: Nicolas Ternisien <nicolas.ternisien@gmail.com>
|
||||
Home-page: http://www.kde-apps.org/content/show.php?content=23761
|
||||
Alternate-site:
|
||||
Primary-site: http://annivernet.free.fr/images/divers/ksystemlog/
|
||||
0.1.1 ksystemlog-0.1.1.tar.gz
|
||||
0.1.1 ksystemlog-0.1.1.lsm
|
||||
Platform: Linux. Needs KDE
|
||||
Copying-policy: GPL
|
||||
End
|
|
@ -1,4 +0,0 @@
|
|||
File=ksystemlog.kcfg
|
||||
ClassName=KSystemLogConfig
|
||||
Singleton=true
|
||||
Mutators=true
|
|
@ -1,70 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||
<kpartgui name="ksystemlog" version="5">
|
||||
|
||||
<MenuBar>
|
||||
|
||||
<Menu name="file">
|
||||
<Action name="send_mail" />
|
||||
<Action name="log_message" />
|
||||
</Menu>
|
||||
|
||||
<Menu name="edit">
|
||||
<text>&Edit</text>
|
||||
<Action name="reload" />
|
||||
<!--
|
||||
<Separator/>
|
||||
<Action name="expand_all" />
|
||||
<Action name="collapse_all" />
|
||||
-->
|
||||
<Separator/>
|
||||
<Action name="copy" />
|
||||
<Separator/>
|
||||
<Action name="find" />
|
||||
<Action name="find_next" />
|
||||
<Separator/>
|
||||
<Action name="group_by" />
|
||||
<Action name="details" />
|
||||
</Menu>
|
||||
|
||||
<Menu name="logs">
|
||||
<text>Logs</text>
|
||||
<ActionList name="log_mode_list" />
|
||||
</Menu>
|
||||
|
||||
<Menu name="window">
|
||||
<text>&Window</text>
|
||||
<Action name="new_tab" />
|
||||
<Action name="duplicate_tab" />
|
||||
<Action name="close_tab" />
|
||||
<Separator/>
|
||||
<Action name="move_tab_left" />
|
||||
<Action name="move_tab_right" />
|
||||
</Menu>
|
||||
|
||||
<Menu name="settings">
|
||||
<Action name="show_quick_filter" />
|
||||
<Separator />
|
||||
</Menu>
|
||||
|
||||
|
||||
</MenuBar>
|
||||
|
||||
|
||||
<ToolBar name="logToolBar" position="top" iconText="textundericon" noMerge="1" >
|
||||
<text>Logs Toolbar</text>
|
||||
<ActionList name="tool_bar_log_mode_list" />
|
||||
</ToolBar>
|
||||
|
||||
<ToolBar name="mainToolBar" position="top" iconText="textundericon" noMerge="1" >
|
||||
<text>Main Toolbar</text>
|
||||
<Action name="resume_pause_parsing" />
|
||||
<Action name="reload" />
|
||||
<Action name="abort" />
|
||||
<Separator/>
|
||||
<Action name="details" />
|
||||
<Separator/>
|
||||
<Action name="group_by" />
|
||||
</ToolBar>
|
||||
|
||||
</kpartgui>
|
|
@ -1,47 +0,0 @@
|
|||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../config
|
||||
)
|
||||
|
||||
set(ksystemlog_lib_sources
|
||||
analyzer.cpp
|
||||
logModeFactory.cpp
|
||||
logModeConfiguration.cpp
|
||||
logModeConfigurationWidget.cpp
|
||||
logModeItemBuilder.cpp
|
||||
logManager.cpp
|
||||
view.cpp
|
||||
globals.cpp
|
||||
logMode.cpp
|
||||
logLevel.cpp
|
||||
logFile.cpp
|
||||
logFileReader.cpp
|
||||
localLogFileReader.cpp
|
||||
processOutputLogFileReader.cpp
|
||||
kioLogFileReader.cpp
|
||||
logLine.cpp
|
||||
logViewModel.cpp
|
||||
logViewColumn.cpp
|
||||
logViewColumns.cpp
|
||||
logViewWidgetItem.cpp
|
||||
logViewWidget.cpp
|
||||
logViewExport.cpp
|
||||
logViewFilterWidget.cpp
|
||||
logViewSearchWidget.cpp
|
||||
loadingBar.cpp
|
||||
logModeAction.cpp
|
||||
simpleAction.cpp
|
||||
multipleActions.cpp
|
||||
|
||||
levelPrintPage.cpp
|
||||
)
|
||||
|
||||
add_library(ksystemlog_lib STATIC ${ksystemlog_lib_sources})
|
||||
|
||||
target_link_libraries(ksystemlog_lib
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${KDE4_KIO_LIBS}
|
||||
${KDE4_KFILE_LIBS}
|
||||
)
|
|
@ -1,254 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "analyzer.h"
|
||||
|
||||
#include <klocale.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
#include "logViewModel.h"
|
||||
|
||||
#include "logMode.h"
|
||||
#include "logFileReader.h"
|
||||
|
||||
#include "logFile.h"
|
||||
|
||||
Analyzer::Analyzer(LogMode* logMode) :
|
||||
QObject(NULL),
|
||||
logViewModel(NULL),
|
||||
logMode(logMode),
|
||||
logLineInternalIdGenerator(0) {
|
||||
|
||||
parsingPaused = false;
|
||||
|
||||
insertionLocking = new QMutex();
|
||||
}
|
||||
|
||||
Analyzer::~Analyzer() {
|
||||
deleteLogFiles();
|
||||
|
||||
//logMode is managed by Globals
|
||||
//logViewModel is managed by LogViewWidget
|
||||
}
|
||||
|
||||
void Analyzer::watchLogFiles(bool enabled) {
|
||||
//Enable the log file watching, by revert order to read the most top file at last, and be sure its line will be kept
|
||||
|
||||
QListIterator<LogFileReader*> it(logFileReaders);
|
||||
it.toBack();
|
||||
while (it.hasPrevious()) {
|
||||
LogFileReader* logFileReader = it.previous();
|
||||
logFileReader->watchFile(enabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Analyzer::deleteLogFiles() {
|
||||
watchLogFiles(false);
|
||||
|
||||
// Remove the watching on the monitored files
|
||||
foreach (LogFileReader* logFileReader, logFileReaders) {
|
||||
logDebug() << "Remove file : " << logFileReader->logFile().url().path();
|
||||
delete logFileReader;
|
||||
}
|
||||
|
||||
logFileReaders.clear();
|
||||
}
|
||||
|
||||
bool Analyzer::isParsingPaused() const {
|
||||
return parsingPaused;
|
||||
}
|
||||
|
||||
void Analyzer::setParsingPaused(bool paused) {
|
||||
parsingPaused = paused;
|
||||
|
||||
bool watching;
|
||||
//If we resume the parsing, then parse files to know if new lines have been appended
|
||||
if (parsingPaused==true) {
|
||||
logDebug() << "Pausing reading";
|
||||
watching=false;
|
||||
}
|
||||
else {
|
||||
logDebug() << "Relaunch reading";
|
||||
watching=true;
|
||||
}
|
||||
|
||||
watchLogFiles(watching);
|
||||
|
||||
}
|
||||
|
||||
void Analyzer::setLogViewModel(LogViewModel* logViewModel) {
|
||||
this->logViewModel = logViewModel;
|
||||
}
|
||||
|
||||
void Analyzer::setLogFiles(const QList<LogFile>& logFiles) {
|
||||
//Remove previous files
|
||||
deleteLogFiles();
|
||||
|
||||
foreach(const LogFile &logFile, logFiles) {
|
||||
LogFileReader* logFileReader = createLogFileReader(logFile);
|
||||
logFileReaders.append(logFileReader);
|
||||
|
||||
connect(logFileReader, SIGNAL(contentChanged(LogFileReader*,Analyzer::ReadingMode,QStringList)), this, SLOT(logFileChanged(LogFileReader*,Analyzer::ReadingMode,QStringList)));
|
||||
connect(logFileReader, SIGNAL(statusBarChanged(QString)), this, SIGNAL(statusBarChanged(QString)));
|
||||
connect(logFileReader, SIGNAL(errorOccured(QString,QString)), this, SIGNAL(errorOccured(QString,QString)));
|
||||
}
|
||||
}
|
||||
|
||||
void Analyzer::logFileChanged(LogFileReader* logFileReader, ReadingMode readingMode, const QStringList& content) {
|
||||
if (readingMode == Analyzer::FullRead)
|
||||
logDebug() << "File " << logFileReader->logFile().url().path() << " has been modified on full read.";
|
||||
else
|
||||
logDebug() << "File " << logFileReader->logFile().url().path() << " has been modified on partial read";
|
||||
|
||||
if (parsingPaused == true) {
|
||||
logDebug() << "Pause enabled. Nothing read.";
|
||||
return;
|
||||
}
|
||||
|
||||
logDebug() << "Locking file modifications of " << logFileReader->logFile().url().path();
|
||||
QMutexLocker locker(insertionLocking);
|
||||
logDebug() << "Unlocking file modifications of " << logFileReader->logFile().url().path();
|
||||
|
||||
QTime benchmark;
|
||||
benchmark.start();
|
||||
|
||||
int insertedLogLineCount;
|
||||
|
||||
logViewModel->startingMultipleInsertions(readingMode);
|
||||
|
||||
if (readingMode == Analyzer::UpdatingRead) {
|
||||
insertedLogLineCount = insertLines(content, logFileReader->logFile(), Analyzer::UpdatingRead);
|
||||
}
|
||||
else {
|
||||
logDebug() << "Reading file "<< logFileReader->logFile().url().path();
|
||||
|
||||
emit statusBarChanged( i18n("Opening '%1'...", logFileReader->logFile().url().path()) );
|
||||
|
||||
//Inform that we are now reading the "index" file
|
||||
emit readFileStarted(*logMode, logFileReader->logFile(), logFileReaders.count() - logFileReaders.indexOf(logFileReader), logFileReaders.count());
|
||||
|
||||
insertedLogLineCount = insertLines(content, logFileReader->logFile(), Analyzer::FullRead);
|
||||
|
||||
emit statusBarChanged( i18n("Log file '%1' loaded successfully.", logFileReader->logFile().url().path()) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
logViewModel->endingMultipleInsertions(readingMode, insertedLogLineCount);
|
||||
|
||||
//Inform connected LoadingBar that the reading is now finished
|
||||
emit readEnded();
|
||||
|
||||
//Inform LogManager that new lines have been added
|
||||
emit logUpdated(insertedLogLineCount);
|
||||
|
||||
//Inform MainWindow status bar
|
||||
emit statusBarChanged( i18n("Log file '%1' has changed.", logFileReader->logFile().url().path()) );
|
||||
|
||||
logDebug() << "Updating log files in " << benchmark.elapsed() << " ms";
|
||||
}
|
||||
|
||||
int Analyzer::insertLines(const QStringList& bufferedLines, const LogFile& logFile, ReadingMode readingMode) {
|
||||
logDebug() << "Inserting lines...";
|
||||
|
||||
//If there is no line
|
||||
if (bufferedLines.size()==0) {
|
||||
logWarning() << "File is empty : " << logFile.url().path();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int stop = 0;
|
||||
int currentPosition = 0;
|
||||
|
||||
QListIterator<QString> it(bufferedLines);
|
||||
/**
|
||||
* If the log file is sorted, then we can ignore the first lines
|
||||
* if there are more lines in the log file than the max lines
|
||||
*
|
||||
* TODO Read revertly the file and ignore last lines if we are in Descending mode
|
||||
*/
|
||||
logDebug() << "Log file Sort mode is " << logFileSortMode();
|
||||
if (logFileSortMode() == Analyzer::AscendingSortedLogFile) {
|
||||
//Calculate how many lines we will ignore
|
||||
if (bufferedLines.size() > KSystemLogConfig::maxLines()) {
|
||||
stop=bufferedLines.size() - KSystemLogConfig::maxLines();
|
||||
}
|
||||
|
||||
//Ignore those lines
|
||||
while (currentPosition < stop) {
|
||||
it.next();
|
||||
++currentPosition;
|
||||
}
|
||||
}
|
||||
|
||||
int insertedLogLineCount = 0;
|
||||
while (currentPosition < bufferedLines.size()) {
|
||||
QString buffer(it.next());
|
||||
|
||||
bool inserted = insertLine(buffer, logFile, readingMode);
|
||||
if (inserted) {
|
||||
insertedLogLineCount++;
|
||||
}
|
||||
|
||||
if (readingMode == Analyzer::FullRead) {
|
||||
informOpeningProgress(currentPosition, (bufferedLines.size()-1) - stop);
|
||||
}
|
||||
|
||||
++currentPosition;
|
||||
}
|
||||
|
||||
logDebug() << "Total read lines :"<< (bufferedLines.size() - stop) << "(" << logFile.url().path() << ")";
|
||||
|
||||
return insertedLogLineCount;
|
||||
}
|
||||
|
||||
bool Analyzer::insertLine(const QString& buffer, const LogFile& originalFile, ReadingMode readingMode) {
|
||||
LogLine* line=parseMessage(buffer, originalFile);
|
||||
|
||||
//Invalid log line
|
||||
if (line==NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//On full reading, it is not needed to display the recent status
|
||||
if (readingMode == Analyzer::FullRead) {
|
||||
line->setRecent(false);
|
||||
}
|
||||
|
||||
return logViewModel->insertNewLogLine(line);
|
||||
}
|
||||
|
||||
inline void Analyzer::informOpeningProgress(int currentPosition, int total) {
|
||||
int each=total / 100;
|
||||
if (each==0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentPosition%each==0) {
|
||||
emit openingProgressed();
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_analyzer.cpp"
|
|
@ -1,133 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _ANALYZER_H_
|
||||
#define _ANALYZER_H_
|
||||
|
||||
#include <QList>
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <kurl.h>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "logLine.h"
|
||||
|
||||
#include "logFile.h"
|
||||
#include "logViewColumn.h"
|
||||
#include "logViewColumns.h"
|
||||
|
||||
class LogViewModel;
|
||||
class LogFileReader;
|
||||
class LogMode;
|
||||
|
||||
class Analyzer : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ReadingMode {
|
||||
UpdatingRead,
|
||||
FullRead
|
||||
};
|
||||
Q_DECLARE_FLAGS(ReadingModes, ReadingMode)
|
||||
|
||||
enum LogFileSortMode {
|
||||
AscendingSortedLogFile,
|
||||
FilteredLogFile,
|
||||
UnsortedLogFile
|
||||
};
|
||||
Q_DECLARE_FLAGS(LogFileSortModes, LogFileSortMode)
|
||||
|
||||
explicit Analyzer(LogMode* logMode);
|
||||
|
||||
~Analyzer();
|
||||
|
||||
void watchLogFiles(bool enabled);
|
||||
|
||||
|
||||
void setLogFiles(const QList<LogFile>& logFiles);
|
||||
void setLogViewModel(LogViewModel* logViewModel);
|
||||
|
||||
bool isParsingPaused() const;
|
||||
|
||||
virtual LogViewColumns initColumns() = 0;
|
||||
|
||||
public slots:
|
||||
void setParsingPaused(bool paused);
|
||||
|
||||
protected:
|
||||
virtual LogFileReader* createLogFileReader(const LogFile& logFile) = 0;
|
||||
virtual Analyzer::LogFileSortMode logFileSortMode() = 0;
|
||||
|
||||
virtual LogLine* parseMessage(const QString& logLine, const LogFile& originalFile) = 0;
|
||||
|
||||
private:
|
||||
|
||||
inline void informOpeningProgress(int currentPosition, int total);
|
||||
|
||||
void deleteLogFiles();
|
||||
|
||||
/**
|
||||
* Parse and insert the buffered lines in the model
|
||||
* Returns the count of inserted lines
|
||||
*/
|
||||
int insertLines(const QStringList& bufferedLines, const LogFile& logFile, ReadingMode readingMode);
|
||||
|
||||
/**
|
||||
* Parse and insert a line in the model
|
||||
* Returns false if it was not inserted, true if it was
|
||||
*/
|
||||
bool insertLine(const QString& buffer, const LogFile& originalFile, ReadingMode readingMode);
|
||||
|
||||
private slots:
|
||||
void logFileChanged(LogFileReader* logFileReader, Analyzer::ReadingMode readingMode, const QStringList& content);
|
||||
|
||||
signals:
|
||||
void statusBarChanged(const QString& message);
|
||||
void errorOccured(const QString& title, const QString& message);
|
||||
|
||||
void openingProgressed();
|
||||
|
||||
void logUpdated(int lineTotal);
|
||||
|
||||
void readFileStarted(const LogMode& logMode, const LogFile& logFile, int fileIndex, int fileCount);
|
||||
void readEnded();
|
||||
|
||||
protected:
|
||||
//TODO Move those members to a D-pointer (and think about subclasses accesses)
|
||||
bool parsingPaused;
|
||||
|
||||
LogViewModel* logViewModel;
|
||||
|
||||
LogMode* logMode;
|
||||
|
||||
QList<LogFileReader*> logFileReaders;
|
||||
|
||||
QMutex* insertionLocking;
|
||||
|
||||
long logLineInternalIdGenerator;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,77 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _DEFAULTS_H_
|
||||
#define _DEFAULTS_H_
|
||||
|
||||
#define DEFAULT_LOG_FOLDER "/var/log"
|
||||
|
||||
/**
|
||||
* Icon name of KSystemLog
|
||||
*/
|
||||
#define KSYSTEMLOG_ICON "utilities-log-viewer"
|
||||
|
||||
enum LogLevelIds {
|
||||
NONE_LOG_LEVEL_ID=0,
|
||||
DEBUG_LOG_LEVEL_ID,
|
||||
INFORMATION_LOG_LEVEL_ID,
|
||||
NOTICE_LOG_LEVEL_ID,
|
||||
WARNING_LOG_LEVEL_ID,
|
||||
ERROR_LOG_LEVEL_ID,
|
||||
CRITICAL_LOG_LEVEL_ID,
|
||||
ALERT_LOG_LEVEL_ID,
|
||||
EMERGENCY_LOG_LEVEL_ID
|
||||
};
|
||||
|
||||
//TODO Need a rewriting
|
||||
/*
|
||||
enum GroupByType {
|
||||
NO_GROUP_BY=0,
|
||||
GROUP_BY_LOG_LEVEL,
|
||||
GROUP_BY_DAY,
|
||||
GROUP_BY_HOUR,
|
||||
GROUP_BY_LOG_FILE,
|
||||
GROUP_BY_COLUMN
|
||||
};
|
||||
|
||||
//This variable only counts GROUP_BY methods != than GROUP_BY_COLUMN
|
||||
#define DEFAULT_GROUP_BY_COUNT 5
|
||||
|
||||
#define NO_GROUP_BY_ICON "process-stop"
|
||||
#define GROUP_BY_LOG_LEVEL_ICON INFORMATION_LOG_LEVEL_ICON
|
||||
#define GROUP_BY_DAY_ICON "go-jump-today"
|
||||
#define GROUP_BY_HOUR_ICON "chronometer"
|
||||
#define GROUP_BY_LOG_FILE_ICON "utilities-log-viewer"
|
||||
|
||||
#define GROUP_BY_COLUMN_ICON "view-list-text"
|
||||
|
||||
|
||||
//Icon of the Group By action
|
||||
#define GROUP_BY_ICON "view-list-tree"
|
||||
*/
|
||||
|
||||
/**
|
||||
* Icon name of No Mode icon
|
||||
*/
|
||||
#define NO_MODE_ICON "text-x-generic"
|
||||
|
||||
|
||||
#endif // _DEFAULTS_H_
|
|
@ -1,225 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "globals.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
||||
#include <klocale.h>
|
||||
|
||||
#include "defaults.h"
|
||||
#include "logLevel.h"
|
||||
#include "logMode.h"
|
||||
#include "logFile.h"
|
||||
|
||||
#include "analyzer.h"
|
||||
#include "logModeAction.h"
|
||||
#include "logModeFactory.h"
|
||||
#include "logModeConfiguration.h"
|
||||
#include "logModeConfigurationWidget.h"
|
||||
|
||||
Globals* Globals::self = NULL;
|
||||
|
||||
Globals* Globals::instance() {
|
||||
if (Globals::self == NULL) {
|
||||
Globals::self = new Globals();
|
||||
}
|
||||
|
||||
return Globals::self;
|
||||
}
|
||||
|
||||
class GlobalsPrivate {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Existing Log modes.
|
||||
*/
|
||||
QMap<QString, LogMode*> logModes;
|
||||
|
||||
QList<LogModeAction*> logModeActions;
|
||||
|
||||
/*
|
||||
LogMode* noMode;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Existing Log levels. The id value corresponds to the index in the vector
|
||||
*/
|
||||
QList<LogLevel*> logLevels;
|
||||
|
||||
/**
|
||||
* These value are only pointers to item of the previous vector,
|
||||
* they are provided for convenience
|
||||
*/
|
||||
LogLevel* noLogLevel;
|
||||
LogLevel* debugLogLevel;
|
||||
LogLevel* informationLogLevel;
|
||||
LogLevel* noticeLogLevel;
|
||||
LogLevel* warningLogLevel;
|
||||
LogLevel* errorLogLevel;
|
||||
LogLevel* criticalLogLevel;
|
||||
LogLevel* alertLogLevel;
|
||||
LogLevel* emergencyLogLevel;
|
||||
|
||||
};
|
||||
|
||||
Globals::Globals() :
|
||||
d(new GlobalsPrivate()) {
|
||||
|
||||
setupLogLevels();
|
||||
|
||||
}
|
||||
|
||||
Globals::~Globals() {
|
||||
|
||||
foreach(LogMode* logMode, d->logModes) {
|
||||
delete logMode;
|
||||
}
|
||||
d->logModes.clear();
|
||||
|
||||
foreach(LogModeAction* logModeAction, d->logModeActions) {
|
||||
delete logModeAction;
|
||||
}
|
||||
d->logModeActions.clear();
|
||||
|
||||
foreach(LogLevel* logLevel, d->logLevels) {
|
||||
delete logLevel;
|
||||
}
|
||||
d->logLevels.clear();
|
||||
|
||||
delete d;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void Globals::setupLogModes() {
|
||||
d->noMode=new LogMode("noLogMode", i18n("No Log"), NO_MODE_ICON);
|
||||
d->logModes.append(d->noMode);
|
||||
|
||||
d->sambaMode=new LogMode("sambaLogMode", i18n("Samba Log"), SAMBA_MODE_ICON);
|
||||
d->logModes.append(d->sambaMode);
|
||||
|
||||
d->cupsMode=new LogMode("cupsLogMode", i18n("CUPS Log"), CUPS_MODE_ICON);
|
||||
d->logModes.append(d->cupsMode);
|
||||
|
||||
d->cupsAccessMode=new LogMode("cupsAccessLogMode", i18n("CUPS Access Log"), CUPS_ACCESS_MODE_ICON);
|
||||
d->logModes.append(d->cupsAccessMode);
|
||||
|
||||
d->postfixMode=new LogMode("postfixLogMode", i18n("Postfix Log"), POSTFIX_MODE_ICON);
|
||||
d->logModes.append(d->postfixMode);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void Globals::setupLogLevels() {
|
||||
d->noLogLevel=new LogLevel(NONE_LOG_LEVEL_ID, i18n("None"), QLatin1String( "help-contents" ), QColor(208, 210, 220));
|
||||
d->logLevels.append(d->noLogLevel);
|
||||
|
||||
d->debugLogLevel=new LogLevel(DEBUG_LOG_LEVEL_ID, i18n("Debug"), QLatin1String( "attach" ), QColor(156, 157, 165));
|
||||
d->logLevels.append(d->debugLogLevel);
|
||||
|
||||
d->informationLogLevel=new LogLevel(INFORMATION_LOG_LEVEL_ID, i18n("Information"), QLatin1String( "dialog-information" ), QColor(36, 49, 103) /*QColor(0, 0, 0)*/);
|
||||
d->logLevels.append(d->informationLogLevel);
|
||||
|
||||
d->noticeLogLevel=new LogLevel(NOTICE_LOG_LEVEL_ID, i18n("Notice"), QLatin1String( "book2" ), QColor(36, 138, 22));
|
||||
d->logLevels.append(d->noticeLogLevel);
|
||||
|
||||
d->warningLogLevel=new LogLevel(WARNING_LOG_LEVEL_ID, i18n("Warning"), QLatin1String( "dialog-warning" ), QColor(238, 144, 21));
|
||||
d->logLevels.append(d->warningLogLevel);
|
||||
|
||||
d->errorLogLevel=new LogLevel(ERROR_LOG_LEVEL_ID, i18n("Error"), QLatin1String( "dialog-close" ), QColor(173, 28, 28));
|
||||
d->logLevels.append(d->errorLogLevel);
|
||||
|
||||
d->criticalLogLevel=new LogLevel(CRITICAL_LOG_LEVEL_ID, i18n("Critical"), QLatin1String( "exec" ), QColor(214, 26, 26));
|
||||
d->logLevels.append(d->criticalLogLevel);
|
||||
|
||||
d->alertLogLevel=new LogLevel(ALERT_LOG_LEVEL_ID, i18n("Alert"), QLatin1String( "bell" ), QColor(214, 0, 0));
|
||||
d->logLevels.append(d->alertLogLevel);
|
||||
|
||||
d->emergencyLogLevel=new LogLevel(EMERGENCY_LOG_LEVEL_ID, i18n("Emergency"), QLatin1String( "application-exit" ), QColor(255, 0, 0));
|
||||
d->logLevels.append(d->emergencyLogLevel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
QList<LogMode*> Globals::logModes() {
|
||||
return d->logModes.values();
|
||||
}
|
||||
|
||||
QList<LogLevel*> Globals::logLevels() {
|
||||
return d->logLevels;
|
||||
}
|
||||
|
||||
|
||||
LogLevel* Globals::noLogLevel() {
|
||||
return d->noLogLevel;
|
||||
}
|
||||
LogLevel* Globals::debugLogLevel() {
|
||||
return d->debugLogLevel;
|
||||
}
|
||||
LogLevel* Globals::informationLogLevel() {
|
||||
return d->informationLogLevel;
|
||||
}
|
||||
LogLevel* Globals::noticeLogLevel() {
|
||||
return d->noticeLogLevel;
|
||||
}
|
||||
LogLevel* Globals::warningLogLevel() {
|
||||
return d->warningLogLevel;
|
||||
}
|
||||
LogLevel* Globals::errorLogLevel() {
|
||||
return d->errorLogLevel;
|
||||
}
|
||||
LogLevel* Globals::criticalLogLevel() {
|
||||
return d->criticalLogLevel;
|
||||
}
|
||||
LogLevel* Globals::alertLogLevel() {
|
||||
return d->alertLogLevel;
|
||||
}
|
||||
LogLevel* Globals::emergencyLogLevel() {
|
||||
return d->emergencyLogLevel;
|
||||
}
|
||||
|
||||
void Globals::registerLogModeFactory(LogModeFactory* logModeFactory) {
|
||||
QList<LogMode*> logModes = logModeFactory->createLogModes();
|
||||
|
||||
foreach (LogMode* logMode, logModes) {
|
||||
//Log mode
|
||||
d->logModes.insert(logMode->id(), logMode);
|
||||
}
|
||||
|
||||
//Log mode Actions
|
||||
LogModeAction* logModeAction = logModeFactory->createLogModeAction();
|
||||
if (logModeAction != NULL) {
|
||||
d->logModeActions.append(logModeAction);
|
||||
}
|
||||
|
||||
delete logModeFactory;
|
||||
}
|
||||
|
||||
LogMode* Globals::findLogMode(const QString& logModeName) {
|
||||
return d->logModes.value(logModeName);
|
||||
}
|
||||
|
||||
QList<LogModeAction*> Globals::logModeActions() {
|
||||
return d->logModeActions;
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _GLOBALS_H_
|
||||
#define _GLOBALS_H_
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "logMode.h"
|
||||
#include "logModeFactory.h"
|
||||
|
||||
|
||||
|
||||
class LogModeFactory;
|
||||
|
||||
class LogMode;
|
||||
class LogModeAction;
|
||||
class LogLevel;
|
||||
|
||||
class Reader;
|
||||
|
||||
class GlobalsPrivate;
|
||||
|
||||
class Globals {
|
||||
public:
|
||||
static Globals* instance();
|
||||
|
||||
~Globals();
|
||||
|
||||
QList<LogLevel*> logLevels();
|
||||
|
||||
LogLevel* noLogLevel();
|
||||
LogLevel* debugLogLevel();
|
||||
LogLevel* informationLogLevel();
|
||||
LogLevel* noticeLogLevel();
|
||||
LogLevel* warningLogLevel();
|
||||
LogLevel* errorLogLevel();
|
||||
LogLevel* criticalLogLevel();
|
||||
LogLevel* alertLogLevel();
|
||||
LogLevel* emergencyLogLevel();
|
||||
|
||||
/**
|
||||
* Allow to add a new Reader for a new log mode
|
||||
*/
|
||||
void registerLogModeFactory(LogModeFactory* logModeFactory);
|
||||
|
||||
QList<LogMode*> logModes();
|
||||
|
||||
QList<LogModeAction*> logModeActions();
|
||||
|
||||
LogMode* findLogMode(const QString& logModeName);
|
||||
|
||||
private:
|
||||
explicit Globals();
|
||||
|
||||
static Globals* self;
|
||||
|
||||
void setupLogLevels();
|
||||
|
||||
GlobalsPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,166 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "kioLogFileReader.h"
|
||||
|
||||
#include <QIODevice>
|
||||
|
||||
#include <kio/filejob.h>
|
||||
#include <kio/job.h>
|
||||
|
||||
#include <kdirwatch.h>
|
||||
|
||||
#include "logFile.h"
|
||||
#include "logging.h"
|
||||
|
||||
#define READ_SIZE 10
|
||||
|
||||
class KioLogFileReaderPrivate {
|
||||
|
||||
public:
|
||||
|
||||
KioLogFileReaderPrivate(const LogFile& file) :
|
||||
logFile(file) {
|
||||
|
||||
}
|
||||
|
||||
LogFile logFile;
|
||||
|
||||
KIO::FileJob* fileJob;
|
||||
|
||||
QString buffer;
|
||||
qulonglong totalRead;
|
||||
|
||||
KDirWatch* fileWatch;
|
||||
|
||||
};
|
||||
|
||||
KioLogFileReader::KioLogFileReader(const LogFile& logFile) :
|
||||
d(new KioLogFileReaderPrivate(logFile)) {
|
||||
|
||||
d->fileJob = NULL;
|
||||
d->totalRead = 0;
|
||||
|
||||
d->fileWatch = new KDirWatch(this);
|
||||
|
||||
connect(d->fileWatch, SIGNAL(dirty(QString)), this, SLOT(watchFile(QString)));
|
||||
d->fileWatch->addFile(logFile.url().path());
|
||||
/*
|
||||
d->fileWatch.setInterval(1000);
|
||||
connect(& (d->fileWatch), SIGNAL(timeout()), this, SLOT(watchFile()));
|
||||
*/
|
||||
|
||||
logDebug() << "Starting " << logFile.url().path();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
KioLogFileReader::~KioLogFileReader() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
void KioLogFileReader::open() {
|
||||
logDebug() << "Opening...";
|
||||
d->fileJob = KIO::open(d->logFile.url(), QIODevice::ReadOnly | QIODevice::Text);
|
||||
|
||||
connect(d->fileJob, SIGNAL(open(KIO::Job*)), this, SLOT(openDone(KIO::Job*)));
|
||||
connect(d->fileJob, SIGNAL(close(KIO::Job*)), this, SLOT(closeDone(KIO::Job*)));
|
||||
|
||||
connect(d->fileJob, SIGNAL(data(KIO::Job*,QByteArray)), this, SLOT(dataReceived(KIO::Job*,QByteArray)));
|
||||
connect(d->fileJob, SIGNAL(mimetype(KIO::Job*,QString)), this, SLOT(mimetypeReceived(KIO::Job*,QString)));
|
||||
|
||||
logDebug() << "File opened.";
|
||||
}
|
||||
|
||||
void KioLogFileReader::close() {
|
||||
d->fileJob->close();
|
||||
}
|
||||
|
||||
void KioLogFileReader::openDone(KIO::Job* job) {
|
||||
logDebug() << "Opening done...";
|
||||
|
||||
d->fileJob->read(READ_SIZE);
|
||||
|
||||
}
|
||||
void KioLogFileReader::closeDone(KIO::Job* job) {
|
||||
logDebug() << "Closing done...";
|
||||
}
|
||||
|
||||
void KioLogFileReader::dataReceived(KIO::Job* job, const QByteArray& data) {
|
||||
if (job != d->fileJob) {
|
||||
logDebug() << "Not the good job";
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//logDebug() << "Receiving data... (" << d->totalRead << ")";
|
||||
d->buffer.append(QLatin1String( data ));
|
||||
d->totalRead += data.size();
|
||||
|
||||
emitCompleteLines();
|
||||
|
||||
logDebug() << "Total read : " << d->totalRead << " of " << d->fileJob->size();
|
||||
if (d->totalRead < d->fileJob->size()) {
|
||||
d->fileJob->read(READ_SIZE);
|
||||
}
|
||||
|
||||
//logDebug() << "Data received : " << d->buffer;
|
||||
|
||||
//d->totalRead++;
|
||||
}
|
||||
|
||||
void KioLogFileReader::emitCompleteLines() {
|
||||
|
||||
int endLinePos = d->buffer.indexOf(QLatin1String( "\n" ));
|
||||
forever {
|
||||
if (endLinePos==-1)
|
||||
break;
|
||||
|
||||
emit lineRead(d->buffer.left(endLinePos));
|
||||
|
||||
//Remove the emitted line and the end line character
|
||||
d->buffer.remove(0, endLinePos+1);
|
||||
|
||||
endLinePos = d->buffer.indexOf(QLatin1String( "\n" ));
|
||||
}
|
||||
|
||||
//If this is the end line and it does not terminate by a \n, we return it
|
||||
if (d->totalRead == d->fileJob->size()) {
|
||||
emit lineRead(d->buffer);
|
||||
d->buffer.clear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void KioLogFileReader::mimetypeReceived(KIO::Job* job, const QString& type) {
|
||||
logDebug() << "Mimetype received " << type;
|
||||
}
|
||||
|
||||
void KioLogFileReader::watchFile(const QString& path) {
|
||||
logDebug() << "Watch file : size : " << path;
|
||||
}
|
||||
|
||||
#include "moc_kioLogFileReader.cpp"
|
|
@ -1,69 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _KIO_LOG_FILE_READER_H_
|
||||
#define _KIO_LOG_FILE_READER_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
#include "logFile.h"
|
||||
|
||||
namespace KIO {
|
||||
class Job;
|
||||
}
|
||||
|
||||
class KioLogFileReaderPrivate;
|
||||
|
||||
/**
|
||||
* TODO Inherits from LogFileReader
|
||||
*/
|
||||
class KioLogFileReader : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
KioLogFileReader(const LogFile& logFile);
|
||||
|
||||
virtual ~KioLogFileReader();
|
||||
|
||||
void open();
|
||||
void close();
|
||||
|
||||
signals:
|
||||
void lineRead(const QString&);
|
||||
|
||||
private slots:
|
||||
void openDone(KIO::Job* job);
|
||||
void closeDone(KIO::Job* job);
|
||||
void dataReceived(KIO::Job* job, const QByteArray& data);
|
||||
void mimetypeReceived(KIO::Job* job, const QString& type);
|
||||
|
||||
void watchFile(const QString& path);
|
||||
private:
|
||||
void emitCompleteLines();
|
||||
|
||||
KioLogFileReaderPrivate* const d;
|
||||
};
|
||||
|
||||
#endif // _KIO_LOG_FILE_READER_H_
|
|
@ -1,131 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "levelPrintPage.h"
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kglobal.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QButtonGroup>
|
||||
|
||||
#include "logLevel.h"
|
||||
#include "logViewWidgetItem.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
LevelPrintPage::LevelPrintPage(QWidget* parent)
|
||||
: QWidget( parent)
|
||||
{
|
||||
setWindowTitle(i18n("Log Level Printing"));
|
||||
|
||||
//m_pageLayout = new QVBoxLayout(this, 3, 3);
|
||||
m_pageLayout = new QVBoxLayout(this);
|
||||
|
||||
m_lblChoose = new QLabel(this);
|
||||
//m_lblChoose->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, m_lblChoose->sizePolicy().hasHeightForWidth() ) );
|
||||
m_lblChoose->setText( i18n( "Choose which log levels you wish to print in color." ) );
|
||||
m_pageLayout->addWidget( m_lblChoose );
|
||||
|
||||
m_btnGroup = new QButtonGroup(this);
|
||||
/*
|
||||
i18n("Log Levels"),
|
||||
m_btnGroup->setColumnLayout(0, Qt::Vertical );
|
||||
m_btnGroup->layout()->setSpacing( 6 );
|
||||
m_btnGroup->layout()->setMargin( 11 );
|
||||
m_btnGroupLayout = new QGridLayout( m_btnGroup->layout() );
|
||||
m_btnGroupLayout->setAlignment( Qt::AlignTop );
|
||||
*/
|
||||
|
||||
int row = 0, col = 0;
|
||||
|
||||
foreach(LogLevel* level, Globals::instance()->logLevels()) {
|
||||
|
||||
QCheckBox* button = new QCheckBox(level->name());//, m_btnGroup, 0
|
||||
|
||||
levelCheckBoxes.append(button);
|
||||
m_btnGroup->addButton(button, level->id());
|
||||
m_btnGroupLayout->addWidget(button, row, col);
|
||||
|
||||
logDebug() << "name: " << level->name() << " id: " << level->id();
|
||||
|
||||
row++;
|
||||
if(row >= 4) {
|
||||
row = 0;
|
||||
col++;
|
||||
}
|
||||
}
|
||||
|
||||
//m_pageLayout->addWidget(m_btnGroup);
|
||||
}
|
||||
|
||||
LevelPrintPage::~LevelPrintPage() {
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
/* QPrinter Port: comment out as dialog page is not currently being used, so not ported
|
||||
|
||||
void LevelPrintPage::getOptions( QMap<QString,QString>& opts, bool incldef ) {
|
||||
foreach(LogLevel* level, Globals::instance()->logLevels()) {
|
||||
QString key = "kde-ksystemlog-print_" + level->name();
|
||||
|
||||
|
||||
QCheckBox* checkBox = static_cast<QCheckBox*>(m_btnGroup->find(level->id()));
|
||||
if(checkBox) {
|
||||
if (checkBox->isChecked())
|
||||
opts[ key ] = "1";
|
||||
else
|
||||
opts[ key ] = "0";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void LevelPrintPage::setOptions( const QMap<QString,QString>& opts ) {
|
||||
foreach(LogLevel* level, Globals::instance()->logLevels()) {
|
||||
QString key = "kde-ksystemlog-print_" + level->name();
|
||||
QString use = opts[ key ];
|
||||
|
||||
int chk = use.toInt();
|
||||
|
||||
|
||||
QCheckBox* checkBox = static_cast<QCheckBox*>(m_btnGroup->find(level->id()));
|
||||
if(checkBox) {
|
||||
if(chk)
|
||||
checkBox->setChecked(true);
|
||||
else
|
||||
checkBox->setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
bool LevelPrintPage::isValid( QString& msg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 LEVELPRINTPAGE_H
|
||||
#define LEVELPRINTPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QVBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
|
||||
/**
|
||||
@author Bojan Djurkovic
|
||||
*/
|
||||
class LevelPrintPage : public QWidget {
|
||||
public:
|
||||
explicit LevelPrintPage(QWidget *parent = 0);
|
||||
~LevelPrintPage();
|
||||
|
||||
bool isValid(QString& msg);
|
||||
|
||||
private:
|
||||
QButtonGroup* m_btnGroup;
|
||||
QGridLayout* m_btnGroupLayout;
|
||||
QVBoxLayout* m_pageLayout;
|
||||
QLabel* m_lblChoose;
|
||||
QList<QCheckBox*> levelCheckBoxes;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,128 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "loadingBar.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QProgressBar>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kapplication.h>
|
||||
#include <kiconloader.h>
|
||||
|
||||
class LoadingBarPrivate {
|
||||
public:
|
||||
//Attributes managing the position in the files loading of each log
|
||||
int fileCount;
|
||||
int currentFileIndex;
|
||||
|
||||
bool firstLoading;
|
||||
|
||||
QLabel* label;
|
||||
|
||||
QProgressBar* progressBar;
|
||||
|
||||
};
|
||||
|
||||
LoadingBar::LoadingBar(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
d(new LoadingBarPrivate())
|
||||
{
|
||||
|
||||
d->firstLoading = true;
|
||||
|
||||
QHBoxLayout* widgetLayout = new QHBoxLayout();
|
||||
setLayout(widgetLayout);
|
||||
|
||||
widgetLayout->addStretch();
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
widgetLayout->addLayout(layout);
|
||||
|
||||
widgetLayout->addStretch();
|
||||
|
||||
d->label = new QLabel(i18n("Loading Progress..."));
|
||||
d->label->setMinimumWidth(250);
|
||||
layout->addWidget(d->label, 1, Qt::AlignBottom);
|
||||
|
||||
d->progressBar = new QProgressBar();
|
||||
d->progressBar->setRange(0, 100);
|
||||
d->progressBar->setMinimumWidth(250);
|
||||
layout->addWidget(d->progressBar, 1, Qt::AlignCenter | Qt::AlignTop);
|
||||
|
||||
}
|
||||
|
||||
LoadingBar::~LoadingBar() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
QProgressBar* LoadingBar::progressBar() {
|
||||
return d->progressBar;
|
||||
}
|
||||
|
||||
void LoadingBar::startLoading(const LogMode& logMode, const LogFile& logFile, int fileIndex, int fileCount) {
|
||||
emit displayed(true);
|
||||
|
||||
d->progressBar->setValue(0);
|
||||
|
||||
//Several files to load
|
||||
if (fileCount>1 && fileIndex>=1) {
|
||||
if (d->firstLoading)
|
||||
d->label->setText(i18np("Loading <b>%2</b>...<br /><i>%3</i> - (<b>%4</b>)",
|
||||
"Loading <b>%2</b>...<br /><i>%3</i> - (<b>%4</b>/%1 files)",
|
||||
fileCount, logMode.name(), logFile.url().path(), fileIndex));
|
||||
else
|
||||
d->label->setText(i18np("Reloading <b>%2</b>...<br /><i>%3</i> - (<b>%4</b>)",
|
||||
"Reloading <b>%2</b>...<br /><i>%3</i> - (<b>%4</b>/%1 files)",
|
||||
fileCount, logMode.name(), logFile.url().path(), fileIndex));
|
||||
}
|
||||
//Only one file
|
||||
else {
|
||||
if (d->firstLoading)
|
||||
d->label->setText(i18n("Loading <b>%1</b>...<br /><i>%2</i>", logMode.name(), logFile.url().path()));
|
||||
else
|
||||
d->label->setText(i18n("Reloading <b>%1</b>...<br /><i>%2</i>", logMode.name(), logFile.url().path()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LoadingBar::endLoading() {
|
||||
emit displayed(false);
|
||||
|
||||
d->progressBar->setValue(100);
|
||||
|
||||
//If the endLoading has been called one time, it means it has already been loaded
|
||||
d->firstLoading=false;
|
||||
|
||||
}
|
||||
|
||||
void LoadingBar::progressLoading() {
|
||||
d->progressBar->setValue( d->progressBar->value() + 1 );
|
||||
|
||||
kapp->processEvents();
|
||||
}
|
||||
|
||||
#include "moc_loadingBar.cpp"
|
|
@ -1,63 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOADING_BAR_H_
|
||||
#define _LOADING_BAR_H_
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "logMode.h"
|
||||
#include "logFile.h"
|
||||
|
||||
#include <QProgressBar>
|
||||
class LoadingBarPrivate;
|
||||
|
||||
/**
|
||||
* TODO Try to have a working Cancel button (for the moment, it only hide the Loading Dialog)
|
||||
*/
|
||||
class LoadingBar : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LoadingBar(QWidget* parent=NULL);
|
||||
|
||||
~LoadingBar();
|
||||
|
||||
QProgressBar* progressBar();
|
||||
|
||||
public slots:
|
||||
|
||||
void startLoading(const LogMode& logMode, const LogFile& logFile, int fileIndex, int fileCount);
|
||||
void endLoading();
|
||||
|
||||
void progressLoading();
|
||||
|
||||
signals:
|
||||
void displayed(bool displayed);
|
||||
|
||||
private:
|
||||
LoadingBarPrivate* const d;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // _LOADING_BAR_H_
|
|
@ -1,259 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "localLogFileReader.h"
|
||||
|
||||
#include <QMutex>
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <kdirwatch.h>
|
||||
#include <klocale.h>
|
||||
#include <kdecompressor.h>
|
||||
#include <kmimetype.h>
|
||||
#include <kurl.h>
|
||||
|
||||
#include "logFileReader.h"
|
||||
#include "logFileReaderPrivate.h"
|
||||
#include "logging.h"
|
||||
|
||||
|
||||
class LocalLogFileReaderPrivate : public LogFileReaderPrivate {
|
||||
|
||||
public:
|
||||
|
||||
KDirWatch* watch;
|
||||
|
||||
long previousFilePosition;
|
||||
|
||||
/**
|
||||
* Mutex avoiding multiple logFileModified() calls
|
||||
*/
|
||||
QMutex insertionLocking;
|
||||
|
||||
};
|
||||
|
||||
|
||||
LocalLogFileReader::LocalLogFileReader(const LogFile& logFile) :
|
||||
LogFileReader(*new LocalLogFileReaderPrivate(), logFile) {
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
LocalLogFileReader::LocalLogFileReader(LocalLogFileReaderPrivate& dd, const LogFile& logFile) :
|
||||
LogFileReader(dd, logFile) {
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
LocalLogFileReader::~LocalLogFileReader() {
|
||||
Q_D(LocalLogFileReader);
|
||||
|
||||
//Delete the watching object
|
||||
delete d->watch;
|
||||
|
||||
//d pointer is deleted by the parent class
|
||||
}
|
||||
|
||||
void LocalLogFileReader::init() {
|
||||
Q_D(LocalLogFileReader);
|
||||
|
||||
d->watch=new KDirWatch();
|
||||
connect(d->watch, SIGNAL(dirty(QString)), this, SLOT(logFileModified()));
|
||||
|
||||
//Init current file position
|
||||
d->previousFilePosition = 0;
|
||||
|
||||
logDebug() << "Reading local file " << d->logFile.url().path();
|
||||
|
||||
}
|
||||
|
||||
void LocalLogFileReader::watchFile(bool enable) {
|
||||
Q_D(LocalLogFileReader);
|
||||
|
||||
if (enable == true) {
|
||||
logDebug() << "Monitoring file : " << d->logFile.url().path();
|
||||
|
||||
if (d->watch->contains(d->logFile.url().path()) == false) {
|
||||
d->watch->addFile(d->logFile.url().path());
|
||||
}
|
||||
|
||||
//Reinit current file position
|
||||
d->previousFilePosition = 0;
|
||||
|
||||
//If we enable the watching, then we first try to see if new lines have appeared
|
||||
logFileModified();
|
||||
}
|
||||
else {
|
||||
d->watch->removeFile(d->logFile.url().path());
|
||||
}
|
||||
}
|
||||
|
||||
QIODevice* LocalLogFileReader::open() {
|
||||
Q_D(LocalLogFileReader);
|
||||
|
||||
if (d->logFile.url().isValid()==false) {
|
||||
QString message(i18n("This file is not valid. Please adjust it in the settings of KSystemLog."));
|
||||
emit errorOccured(i18n("File Does Not Exist"), message);
|
||||
emit statusBarChanged(message);
|
||||
}
|
||||
|
||||
QString mimeType = KMimeType::findByFileContent( d->logFile.url().path() )->name();
|
||||
|
||||
logDebug() << d->logFile.url().path() << " : " << mimeType;
|
||||
QIODevice* inputDevice;
|
||||
|
||||
//Try to see if this file exists
|
||||
QFile* file = new QFile(d->logFile.url().path());
|
||||
//If the file does not exist
|
||||
if (! file->exists()) {
|
||||
QString message(i18n("The file '%1' does not exist.", d->logFile.url().path()));
|
||||
emit errorOccured(i18n("File Does Not Exist"), message);
|
||||
emit statusBarChanged(message);
|
||||
delete file;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Plain text file : we use a QFile object
|
||||
if (mimeType == QLatin1String( "text/plain" ) || mimeType == QLatin1String( "application/octet-stream" )) {
|
||||
logDebug() << "Using QFile input device";
|
||||
|
||||
inputDevice = file;
|
||||
}
|
||||
//Compressed file : we use the KFilterDev helper
|
||||
else {
|
||||
logDebug() << "Using KFilterDev input device";
|
||||
|
||||
const QString logFilePath = d->logFile.url().path();
|
||||
KDecompressor kdecompressor;
|
||||
if (!kdecompressor.setType(KDecompressor::typeForMime(mimeType))
|
||||
&& !kdecompressor.setType(KDecompressor::typeForFile(logFilePath))) {
|
||||
QString message(i18n("Compressed file format is not supported '%1'.", logFilePath));
|
||||
emit errorOccured(i18n("Unable to open Compressed File"), message);
|
||||
emit statusBarChanged(message);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QFile logFileDevice(logFilePath);
|
||||
if (!logFileDevice.open(QFile::ReadOnly)) {
|
||||
QString message(i18n("Unable to open compressed file '%1': %2.", logFilePath, logFileDevice.errorString()));
|
||||
emit errorOccured(i18n("Unable to open Compressed File"), message);
|
||||
emit statusBarChanged(message);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (kdecompressor.process(logFileDevice.readAll())) {
|
||||
QString message(i18n("Unable to uncompress '%1': '%2'.", logFilePath, kdecompressor.errorString()));
|
||||
emit errorOccured(i18n("Unable to Uncompress File"), message);
|
||||
emit statusBarChanged(message);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inputDevice = new QBuffer();
|
||||
qobject_cast<QBuffer*>(inputDevice)->setData(kdecompressor.result());
|
||||
}
|
||||
|
||||
if ( ! inputDevice->open( QIODevice::ReadOnly ) ) {
|
||||
QString message(i18n("You do not have sufficient permissions to read '%1'.", d->logFile.url().path()));
|
||||
emit errorOccured(i18n("Insufficient Permissions"), message);
|
||||
emit statusBarChanged(message);
|
||||
delete inputDevice;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return inputDevice;
|
||||
}
|
||||
|
||||
void LocalLogFileReader::close(QIODevice* inputDevice) {
|
||||
inputDevice->close();
|
||||
delete inputDevice;
|
||||
}
|
||||
|
||||
QStringList LocalLogFileReader::readContent(QIODevice* inputDevice) {
|
||||
logDebug() << "Retrieving raw buffer...";
|
||||
|
||||
Q_D(LocalLogFileReader);
|
||||
|
||||
QStringList rawBuffer;
|
||||
|
||||
QTextStream inputStream(inputDevice);
|
||||
while (inputStream.atEnd() == false) {
|
||||
rawBuffer.append(inputStream.readLine());
|
||||
}
|
||||
|
||||
logDebug() << "Raw buffer retrieved.";
|
||||
|
||||
//Get the size file for the next calculation
|
||||
d->previousFilePosition = inputDevice->size();
|
||||
logDebug() << "New file position : " << d->previousFilePosition << " (" << d->logFile.url().path() << ")";
|
||||
|
||||
return rawBuffer;
|
||||
}
|
||||
|
||||
void LocalLogFileReader::logFileModified() {
|
||||
Q_D(LocalLogFileReader);
|
||||
|
||||
logDebug() << "Locking log file modification...";
|
||||
if (d->insertionLocking.tryLock() == false) {
|
||||
logDebug() << "Log file modification already detected.";
|
||||
return;
|
||||
}
|
||||
|
||||
QIODevice* inputDevice = open();
|
||||
if (inputDevice == NULL) {
|
||||
logError() << "Could not open file " << d->logFile.url().path();
|
||||
return;
|
||||
}
|
||||
|
||||
//If there are new lines in the file, insert only them or this is the first time we read this file
|
||||
if (d->previousFilePosition!=0 && d->previousFilePosition <= inputDevice->size()) {
|
||||
logDebug() << "Reading from position " << d->previousFilePosition << " (" << d->logFile.url().path() << ")";
|
||||
|
||||
if (inputDevice->isSequential()) {
|
||||
logError() << "The file current position could not be modified";
|
||||
}
|
||||
else {
|
||||
//Place the cursor to the last line opened
|
||||
inputDevice->seek(d->previousFilePosition);
|
||||
}
|
||||
|
||||
logDebug() << "Retrieving a part of the file...";
|
||||
|
||||
emit contentChanged(this, Analyzer::UpdatingRead, readContent(inputDevice));
|
||||
|
||||
}
|
||||
//Else reread all lines, clear log list
|
||||
else {
|
||||
logDebug() << "New file or file truncated. (Re-)Loading log file";
|
||||
|
||||
emit contentChanged(this, Analyzer::FullRead, readContent(inputDevice));
|
||||
|
||||
}
|
||||
|
||||
close(inputDevice);
|
||||
|
||||
logDebug() << "Unlocking log file modification...";
|
||||
d->insertionLocking.unlock();
|
||||
}
|
||||
|
||||
#include "moc_localLogFileReader.cpp"
|
|
@ -1,68 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOCAL_LOG_FILE_READER_H_
|
||||
#define _LOCAL_LOG_FILE_READER_H_
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "logFile.h"
|
||||
|
||||
#include "logFileReader.h"
|
||||
|
||||
|
||||
class LocalLogFileReaderPrivate;
|
||||
|
||||
class LocalLogFileReader : public LogFileReader {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
LocalLogFileReader(const LogFile& logFile);
|
||||
|
||||
virtual ~LocalLogFileReader();
|
||||
|
||||
void watchFile(bool enable);
|
||||
|
||||
void setPreviousFilePosition(long previousFilePosition);
|
||||
|
||||
private slots:
|
||||
void logFileModified();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
QIODevice* open();
|
||||
void close(QIODevice* inputDevice);
|
||||
|
||||
QStringList readContent(QIODevice* inputDevice);
|
||||
|
||||
protected:
|
||||
LocalLogFileReader(LocalLogFileReaderPrivate& dd, const LogFile& logFile);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(LocalLogFileReader)
|
||||
|
||||
};
|
||||
|
||||
#endif // _LOCAL_LOG_FILE_READER_H_
|
|
@ -1,94 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logFile.h"
|
||||
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
class LogFilePrivate {
|
||||
|
||||
public:
|
||||
KUrl url;
|
||||
|
||||
LogLevel* defaultLogLevel;
|
||||
|
||||
};
|
||||
|
||||
LogFile::LogFile() :
|
||||
d(new LogFilePrivate()) {
|
||||
//Nothing to do
|
||||
}
|
||||
|
||||
LogFile::LogFile(const LogFile& logFile) :
|
||||
QObject(),
|
||||
d(new LogFilePrivate()) {
|
||||
|
||||
d->url = logFile.url();
|
||||
d->defaultLogLevel = logFile.defaultLogLevel();
|
||||
}
|
||||
|
||||
LogFile::LogFile(const KUrl& url, LogLevel* defaultLogLevel) :
|
||||
d(new LogFilePrivate()) {
|
||||
|
||||
d->url = url;
|
||||
d->defaultLogLevel = defaultLogLevel;
|
||||
}
|
||||
|
||||
LogFile::~LogFile() {
|
||||
//defaultLogLevel is managed by Globals
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool LogFile::operator==(const LogFile& other) {
|
||||
if (d->url == other.url() && d->defaultLogLevel == other.defaultLogLevel())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
LogFile& LogFile::operator=(const LogFile& logFile) {
|
||||
d->url = logFile.url();
|
||||
d->defaultLogLevel = logFile.defaultLogLevel();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
KUrl LogFile::url() const {
|
||||
return d->url;
|
||||
}
|
||||
|
||||
LogLevel* LogFile::defaultLogLevel() const {
|
||||
return d->defaultLogLevel;
|
||||
}
|
||||
|
||||
QDataStream& operator<< (QDataStream& out, const LogFile& logFile) {
|
||||
out << logFile.url().path();
|
||||
return out;
|
||||
}
|
||||
|
||||
QDebug& operator<< (QDebug& out, const LogFile& logFile) {
|
||||
out << logFile.url().path();
|
||||
return out;
|
||||
}
|
||||
|
||||
#include "moc_logFile.cpp"
|
|
@ -1,62 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_FILE_H_
|
||||
#define _LOG_FILE_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
#include <kurl.h>
|
||||
|
||||
class LogLevel;
|
||||
|
||||
class LogFilePrivate;
|
||||
|
||||
class LogFile : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogFile();
|
||||
|
||||
LogFile(const LogFile& logFile);
|
||||
LogFile(const KUrl& url, LogLevel* defaultLogLevel);
|
||||
|
||||
virtual ~LogFile();
|
||||
|
||||
bool operator==(const LogFile& other);
|
||||
|
||||
LogFile& operator=(const LogFile& column);
|
||||
|
||||
KUrl url() const;
|
||||
|
||||
LogLevel* defaultLogLevel() const;
|
||||
|
||||
private:
|
||||
LogFilePrivate* const d;
|
||||
};
|
||||
|
||||
QDataStream & operator<< (QDataStream& out, const LogFile& column);
|
||||
QDebug & operator<< (QDebug& out, const LogFile& column);
|
||||
|
||||
#endif // _LOG_FILE_H_
|
|
@ -1,54 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logFileReader.h"
|
||||
|
||||
#include "logFileReaderPrivate.h"
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
LogFileReader::LogFileReader(const LogFile& logFile) :
|
||||
d_ptr(new LogFileReaderPrivate) {
|
||||
|
||||
Q_D(LogFileReader);
|
||||
d->logFile = logFile;
|
||||
|
||||
}
|
||||
|
||||
LogFileReader::LogFileReader(LogFileReaderPrivate& dd, const LogFile& logFile) :
|
||||
d_ptr(&dd) {
|
||||
|
||||
Q_D(LogFileReader);
|
||||
d->logFile = logFile;
|
||||
|
||||
}
|
||||
|
||||
LogFileReader::~LogFileReader() {
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
LogFile LogFileReader::logFile() const {
|
||||
//const LogFileReaderPrivate * const d = d_func();
|
||||
Q_D(const LogFileReader);
|
||||
return d->logFile;
|
||||
}
|
||||
|
||||
#include "moc_logFileReader.cpp"
|
|
@ -1,63 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_FILE_READER_H_
|
||||
#define _LOG_FILE_READER_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "analyzer.h"
|
||||
#include "logFile.h"
|
||||
|
||||
class LogFileReaderPrivate;
|
||||
|
||||
class LogFileReader : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
LogFileReader(const LogFile& logFile);
|
||||
|
||||
virtual ~LogFileReader();
|
||||
|
||||
virtual void watchFile(bool enable) = 0;
|
||||
|
||||
LogFile logFile() const;
|
||||
|
||||
signals:
|
||||
void contentChanged(LogFileReader* origin, Analyzer::ReadingMode readingMode, const QStringList& newLines);
|
||||
|
||||
void statusBarChanged(const QString& message);
|
||||
void errorOccured(const QString& title, const QString& message);
|
||||
|
||||
protected:
|
||||
LogFileReaderPrivate* const d_ptr;
|
||||
LogFileReader(LogFileReaderPrivate& dd, const LogFile& logFile);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(LogFileReader)
|
||||
|
||||
};
|
||||
|
||||
#endif // _LOG_FILE_READER_H_
|
|
@ -1,37 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_FILE_READER_PRIVATE_H_
|
||||
#define _LOG_FILE_READER_PRIVATE_H_
|
||||
|
||||
#include "logFile.h"
|
||||
|
||||
class LogFileReaderPrivate {
|
||||
|
||||
public:
|
||||
virtual ~LogFileReaderPrivate() {
|
||||
|
||||
}
|
||||
|
||||
LogFile logFile;
|
||||
};
|
||||
|
||||
#endif // _LOG_FILE_READER_PRIVATE_H_
|
|
@ -1,74 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logLevel.h"
|
||||
|
||||
#include <kiconloader.h>
|
||||
|
||||
class LogLevelPrivate {
|
||||
public:
|
||||
int id;
|
||||
QString name;
|
||||
|
||||
QString icon;
|
||||
|
||||
QColor color;
|
||||
|
||||
QPixmap pixmap;
|
||||
|
||||
};
|
||||
|
||||
|
||||
LogLevel::LogLevel(int id, const QString& nm, const QString& ic, const QColor& col) :
|
||||
d(new LogLevelPrivate()) {
|
||||
|
||||
d->id = id;
|
||||
d->name = nm;
|
||||
d->icon = ic;
|
||||
d->color = col;
|
||||
d->pixmap = SmallIcon(ic);
|
||||
|
||||
}
|
||||
|
||||
|
||||
LogLevel::~LogLevel() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
int LogLevel::id() {
|
||||
return d->id;
|
||||
}
|
||||
|
||||
QString LogLevel::name() {
|
||||
return d->name;
|
||||
}
|
||||
|
||||
QString LogLevel::icon() {
|
||||
return d->icon;
|
||||
}
|
||||
|
||||
QColor LogLevel::color() {
|
||||
return d->color;
|
||||
}
|
||||
|
||||
QPixmap LogLevel::pixmap() {
|
||||
return d->pixmap;
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_LEVEL_H_
|
||||
#define _LOG_LEVEL_H_
|
||||
|
||||
#include <QColor>
|
||||
#include <QString>
|
||||
#include <QPixmap>
|
||||
|
||||
class LogLevelPrivate;
|
||||
|
||||
class LogLevel {
|
||||
|
||||
public:
|
||||
explicit LogLevel(int id, const QString& name, const QString& icon, const QColor& color);
|
||||
|
||||
virtual ~LogLevel();
|
||||
|
||||
int id();
|
||||
QString name();
|
||||
|
||||
QString icon();
|
||||
|
||||
QColor color();
|
||||
|
||||
QPixmap pixmap();
|
||||
|
||||
private:
|
||||
LogLevelPrivate* const d;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,218 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logLine.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "logMode.h"
|
||||
#include "logModeItemBuilder.h"
|
||||
#include "logViewWidgetItem.h"
|
||||
|
||||
#include "logging.h"
|
||||
#include "globals.h"
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
class LogLinePrivate {
|
||||
public:
|
||||
|
||||
long internalId;
|
||||
|
||||
QDateTime time;
|
||||
|
||||
QStringList logItems;
|
||||
|
||||
QString originalFile;
|
||||
|
||||
LogLevel* logLevel;
|
||||
|
||||
LogMode* logMode;
|
||||
|
||||
bool recent;
|
||||
|
||||
LogViewWidgetItem* item;
|
||||
|
||||
};
|
||||
|
||||
LogLine::LogLine(
|
||||
long internalId,
|
||||
const QDateTime& dateTime,
|
||||
const QStringList& logItems,
|
||||
const QString& file,
|
||||
LogLevel* logLevel,
|
||||
LogMode* logMode) :
|
||||
|
||||
d(new LogLinePrivate()) {
|
||||
|
||||
d->internalId = internalId;
|
||||
d->time=dateTime;
|
||||
d->logItems = logItems;
|
||||
d->originalFile = file;
|
||||
d->logLevel = logLevel;
|
||||
d->logMode = logMode;
|
||||
|
||||
//No linked item when constructs this LogLine
|
||||
d->item = NULL;
|
||||
|
||||
//By default in newly created item has the recent state
|
||||
setRecent(true);
|
||||
|
||||
}
|
||||
|
||||
LogLine::~LogLine() {
|
||||
//logLevel is managed by Globals
|
||||
|
||||
//item is managed by LogMode
|
||||
//itemBuilder is managed by LogMode
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
LogMode* LogLine::logMode() const {
|
||||
return d->logMode;
|
||||
}
|
||||
|
||||
void LogLine::setLogMode(LogMode* logMode) {
|
||||
d->logMode = logMode;
|
||||
}
|
||||
|
||||
bool LogLine::equals(const LogLine& other) const {
|
||||
if (logMode()->id() != other.logMode()->id())
|
||||
return false;
|
||||
|
||||
if (time() != other.time())
|
||||
return false;
|
||||
|
||||
if (logLevel()->id() != other.logLevel()->id())
|
||||
return false;
|
||||
|
||||
if (d->logItems != other.d->logItems)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LogLevel* LogLine::logLevel() const {
|
||||
return d->logLevel;
|
||||
}
|
||||
|
||||
void LogLine::setLogLevel(LogLevel* level) {
|
||||
d->logLevel=level;
|
||||
}
|
||||
|
||||
QDateTime LogLine::time() const {
|
||||
return d->time;
|
||||
}
|
||||
|
||||
void LogLine::setLogItems(const QStringList& logItems) {
|
||||
d->logItems = logItems;
|
||||
}
|
||||
|
||||
QStringList LogLine::logItems() const {
|
||||
return d->logItems;
|
||||
}
|
||||
|
||||
QString LogLine::sourceFileName() const {
|
||||
return d->originalFile;
|
||||
}
|
||||
|
||||
bool LogLine::isOlderThan(const LogLine& other) const {
|
||||
if (d->time == other.time())
|
||||
return d->internalId < other.internalId();
|
||||
|
||||
return d->time < other.time();
|
||||
}
|
||||
|
||||
bool LogLine::isNewerThan(const LogLine& other) const {
|
||||
if (d->time == other.time())
|
||||
return d->internalId > other.internalId();
|
||||
|
||||
return d->time > other.time();
|
||||
}
|
||||
|
||||
bool LogLine::isSameTime(const LogLine& other) const {
|
||||
return d->time==other.time();
|
||||
}
|
||||
|
||||
long LogLine::internalId() const {
|
||||
return d->internalId;
|
||||
}
|
||||
|
||||
void LogLine::setRecent(bool recent) {
|
||||
d->recent = recent;
|
||||
|
||||
if (d->item!=NULL) {
|
||||
QFont currentFont = d->item->font(d->item->columnCount()-1);
|
||||
|
||||
//We avoid doing the same process
|
||||
if (d->recent != currentFont.bold()) {
|
||||
currentFont.setBold(recent);
|
||||
d->item->setFont(d->item->columnCount()-1, currentFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString LogLine::exportToText() const {
|
||||
|
||||
QString exporting;
|
||||
|
||||
if (d->item == NULL) {
|
||||
logError() << "Trying to export text from NULL item";
|
||||
return exporting;
|
||||
}
|
||||
|
||||
for (int i=0; i < d->item->columnCount(); ++i) {
|
||||
if (i>0)
|
||||
exporting.append(QLatin1Char( '\t' ));
|
||||
|
||||
exporting.append(d->item->text(i));
|
||||
}
|
||||
|
||||
return exporting;
|
||||
}
|
||||
|
||||
QString LogLine::formattedText() {
|
||||
return d->logMode->itemBuilder()->createFormattedText(this);
|
||||
}
|
||||
|
||||
void LogLine::setItem(LogViewWidgetItem* item) {
|
||||
d->item = item;
|
||||
|
||||
initializeItem();
|
||||
}
|
||||
|
||||
void LogLine::initializeItem() {
|
||||
d->logMode->itemBuilder()->prepareItem(d->item);
|
||||
|
||||
//Call methods that change the look of the item
|
||||
setRecent(d->recent);
|
||||
|
||||
if (KSystemLogConfig::colorizeLogLines()) {
|
||||
//Last column index = d->logItems.count() = (d->logItems.count() -1) +1 (the date column)
|
||||
d->item->setForeground(d->logItems.count(), QBrush(d->logLevel->color()));
|
||||
}
|
||||
|
||||
d->item->toggleToolTip(KSystemLogConfig::tooltipEnabled());
|
||||
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 LOG_LINE_H
|
||||
#define LOG_LINE_H
|
||||
|
||||
#include <QStringList>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <kurl.h>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "logLevel.h"
|
||||
|
||||
class LogViewWidget;
|
||||
#include <QDateTime>
|
||||
#include <QStringList>
|
||||
class LogViewWidgetItem;
|
||||
|
||||
class LogLinePrivate;
|
||||
|
||||
class LogLine {
|
||||
|
||||
public:
|
||||
LogLine(
|
||||
long internalId,
|
||||
const QDateTime& dateTime,
|
||||
const QStringList& logItems,
|
||||
const QString& originalFile,
|
||||
LogLevel* level,
|
||||
LogMode* logMode
|
||||
);
|
||||
|
||||
virtual ~LogLine();
|
||||
|
||||
bool isOlderThan(const LogLine& other) const;
|
||||
bool isNewerThan(const LogLine& other) const;
|
||||
|
||||
bool equals(const LogLine& other) const;
|
||||
|
||||
bool isSameTime(const LogLine& other) const;
|
||||
|
||||
LogLevel* logLevel() const;
|
||||
|
||||
long internalId() const;
|
||||
QDateTime time() const;
|
||||
QStringList logItems() const;
|
||||
QString sourceFileName() const;
|
||||
|
||||
LogMode* logMode() const;
|
||||
|
||||
bool itemExists() const;
|
||||
|
||||
void setLogItems(const QStringList& logItems);
|
||||
void setLogLevel(LogLevel* level);
|
||||
void setLogMode(LogMode* logMode);
|
||||
|
||||
void setRecent(bool recent);
|
||||
void setItem(LogViewWidgetItem* item);
|
||||
|
||||
QString formattedText();
|
||||
|
||||
QString exportToText() const;
|
||||
|
||||
protected:
|
||||
LogLinePrivate* const d;
|
||||
|
||||
private:
|
||||
void initializeItem();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,218 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logManager.h"
|
||||
|
||||
#include <klocale.h>
|
||||
|
||||
#include <kmessagebox.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "analyzer.h"
|
||||
#include "view.h"
|
||||
|
||||
#include "logViewWidget.h"
|
||||
|
||||
#include "loadingBar.h"
|
||||
|
||||
class LogManagerPrivate {
|
||||
friend class LogManager;
|
||||
|
||||
QTime lastUpdate;
|
||||
|
||||
LogMode* logMode;
|
||||
|
||||
Analyzer* analyzer;
|
||||
View* usedView;
|
||||
|
||||
};
|
||||
|
||||
LogManager::LogManager(View* view) :
|
||||
d(new LogManagerPrivate())
|
||||
{
|
||||
|
||||
d->lastUpdate = QTime::currentTime();
|
||||
|
||||
d->logMode = NULL;
|
||||
d->analyzer = NULL;
|
||||
|
||||
d->usedView = view;
|
||||
connect(d->usedView, SIGNAL(droppedUrls(KUrl::List)), this, SLOT(loadDroppedUrls(KUrl::List)));
|
||||
}
|
||||
|
||||
LogManager::~LogManager() {
|
||||
cleanPreviousLogMode();
|
||||
|
||||
//usedView is managed by MainWindow
|
||||
//logMode is managed by Globals
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
View* LogManager::usedView() const {
|
||||
return d->usedView;
|
||||
}
|
||||
|
||||
void LogManager::reload() {
|
||||
if (d->logMode == NULL) {
|
||||
logWarning() << "Log manager is not yet initialized";
|
||||
return;
|
||||
}
|
||||
|
||||
logDebug() << "Reloading with log mode " << d->logMode->name() << "...";
|
||||
|
||||
emit statusBarChanged(i18n("Loading log..."));
|
||||
|
||||
// Change part of the main interface
|
||||
emit tabTitleChanged(d->usedView, d->logMode->icon(), d->logMode->name());
|
||||
emit windowTitleChanged(d->logMode->name());
|
||||
|
||||
logDebug() << "Emptying view...";
|
||||
|
||||
// Empty the current list, to better fill it
|
||||
d->usedView->logViewWidget()->model()->clear();
|
||||
|
||||
logDebug() << "Initializing view...";
|
||||
|
||||
// Init the Log View
|
||||
logDebug() << "Initializing columns view...";
|
||||
|
||||
d->usedView->logViewWidget()->setColumns(d->analyzer->initColumns());
|
||||
|
||||
logDebug() << "Reading log...";
|
||||
|
||||
// Read the log files
|
||||
d->analyzer->watchLogFiles(true);
|
||||
|
||||
emit statusBarChanged(i18n("Log successfully loaded."));
|
||||
|
||||
// Log List has been totally reloaded
|
||||
emit reloaded();
|
||||
|
||||
logDebug() << "Log mode " << d->logMode->name() << " reloaded";
|
||||
|
||||
}
|
||||
|
||||
LogMode* LogManager::logMode() {
|
||||
return d->logMode;
|
||||
}
|
||||
|
||||
const QTime& LogManager::lastUpdate() const {
|
||||
return d->lastUpdate;
|
||||
}
|
||||
|
||||
void LogManager::updateLog(int lineCount) {
|
||||
logDebug() << "Updating log " << lineCount << " new lines";
|
||||
|
||||
if (lineCount==0)
|
||||
return;
|
||||
|
||||
d->lastUpdate = QTime::currentTime();
|
||||
|
||||
emit logUpdated(d->usedView, lineCount);
|
||||
}
|
||||
|
||||
void LogManager::cleanPreviousLogMode() {
|
||||
logDebug() << "Cleaning previous LogMode...";
|
||||
|
||||
d->logMode = NULL;
|
||||
|
||||
delete d->analyzer;
|
||||
d->analyzer = NULL;
|
||||
}
|
||||
|
||||
void LogManager::initialize(LogMode* mode) {
|
||||
internalInitialize(mode, mode->createLogFiles());
|
||||
}
|
||||
|
||||
void LogManager::internalInitialize(LogMode* mode, const QList<LogFile>& logFiles) {
|
||||
logDebug() << "Initializing LogManager...";
|
||||
|
||||
logDebug() << "Using files" << logFiles;
|
||||
|
||||
cleanPreviousLogMode();
|
||||
|
||||
//Use the new mode
|
||||
d->logMode=mode;
|
||||
|
||||
//Find the Analyzer instance used for this new mode
|
||||
d->analyzer=mode->createAnalyzer();
|
||||
d->analyzer->setLogViewModel(d->usedView->logViewWidget()->model());
|
||||
|
||||
connect(d->analyzer, SIGNAL(statusBarChanged(QString)), this, SIGNAL(statusBarChanged(QString)));
|
||||
connect(d->analyzer, SIGNAL(errorOccured(QString,QString)), this, SLOT(showErrorMessage(QString,QString)));
|
||||
connect(d->analyzer, SIGNAL(logUpdated(int)), this, SLOT(updateLog(int)));
|
||||
|
||||
connect(d->analyzer, SIGNAL(readFileStarted(LogMode,LogFile,int,int)), d->usedView->loadingBar(), SLOT(startLoading(LogMode,LogFile,int,int)));
|
||||
connect(d->analyzer, SIGNAL(openingProgressed()), d->usedView->loadingBar(), SLOT(progressLoading()));
|
||||
connect(d->analyzer, SIGNAL(readEnded()), d->usedView->loadingBar(), SLOT(endLoading()));
|
||||
|
||||
//Find the log files used for this kind of mode, and set them to our log manager
|
||||
d->analyzer->setLogFiles(logFiles);
|
||||
|
||||
logDebug() << "LogManager initialized";
|
||||
|
||||
}
|
||||
|
||||
void LogManager::showErrorMessage(const QString& title, const QString& message) {
|
||||
KMessageBox::error(
|
||||
d->usedView,
|
||||
message,
|
||||
title,
|
||||
KMessageBox::Notify
|
||||
);
|
||||
}
|
||||
|
||||
void LogManager::setParsingPaused(bool paused) {
|
||||
if (d->logMode == NULL) {
|
||||
logWarning() << "Log manager is not yet initialized";
|
||||
return;
|
||||
}
|
||||
|
||||
d->analyzer->setParsingPaused(paused);
|
||||
}
|
||||
|
||||
bool LogManager::isParsingPaused() const {
|
||||
if (d->logMode == NULL) {
|
||||
logWarning() << "Log manager is not yet initialized";
|
||||
return false;
|
||||
}
|
||||
|
||||
return d->analyzer->isParsingPaused();
|
||||
}
|
||||
|
||||
void LogManager::loadDroppedUrls(const KUrl::List& urls) {
|
||||
logDebug() << "Drop " << urls;
|
||||
|
||||
QList<LogFile> logFiles;
|
||||
|
||||
foreach (const KUrl &url, urls) {
|
||||
logFiles.append(LogFile(url, Globals::instance()->informationLogLevel()));
|
||||
}
|
||||
|
||||
if (logFiles.isEmpty() == false) {
|
||||
internalInitialize(Globals::instance()->findLogMode(QLatin1String( "openLogMode" )), logFiles);
|
||||
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_logManager.cpp"
|
|
@ -1,91 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 LOG_MANAGER_H
|
||||
#define LOG_MANAGER_H
|
||||
|
||||
#include <QList>
|
||||
|
||||
#include <kurl.h>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "logMode.h"
|
||||
#include "logFile.h"
|
||||
|
||||
#include "logViewModel.h"
|
||||
#include "logViewColumns.h"
|
||||
|
||||
class View;
|
||||
|
||||
|
||||
class LogManagerPrivate;
|
||||
|
||||
class LogManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit LogManager(View* view);
|
||||
|
||||
~LogManager();
|
||||
|
||||
View* usedView() const;
|
||||
|
||||
const QTime& lastUpdate() const;
|
||||
|
||||
LogMode* logMode();
|
||||
|
||||
void initialize(LogMode* mode);
|
||||
|
||||
void setParsingPaused(bool paused);
|
||||
bool isParsingPaused() const;
|
||||
|
||||
void reload();
|
||||
|
||||
protected slots:
|
||||
|
||||
void updateLog(int lineCount);
|
||||
|
||||
void showErrorMessage(const QString& title, const QString& message);
|
||||
|
||||
signals:
|
||||
void tabTitleChanged(View* view, const QIcon& icon, const QString& label);
|
||||
|
||||
void windowTitleChanged(const QString& caption);
|
||||
void statusBarChanged(const QString& message);
|
||||
|
||||
void reloaded();
|
||||
void logUpdated(View* view, int addedLines);
|
||||
|
||||
private slots:
|
||||
void loadDroppedUrls(const KUrl::List& urls);
|
||||
|
||||
private:
|
||||
void internalInitialize(LogMode* mode, const QList<LogFile>& logFiles);
|
||||
|
||||
void cleanPreviousLogMode();
|
||||
|
||||
LogManagerPrivate* d;
|
||||
|
||||
};
|
||||
|
||||
#endif //LOG_MANAGER_H
|
|
@ -1,82 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logMode.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include <kiconloader.h>
|
||||
|
||||
#include "multipleActions.h"
|
||||
#include "logModeItemBuilder.h"
|
||||
|
||||
LogMode::LogMode(const QString& id, const QString& name, const QString& iconName) :
|
||||
d(new LogModePrivate()) {
|
||||
|
||||
d->id = id;
|
||||
d->name = name;
|
||||
d->icon = SmallIcon(iconName);
|
||||
}
|
||||
|
||||
LogMode::~LogMode() {
|
||||
delete d->action;
|
||||
|
||||
delete d->itemBuilder;
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
QString LogMode::id() const {
|
||||
return d->id;
|
||||
}
|
||||
|
||||
QString LogMode::name() const {
|
||||
return d->name;
|
||||
}
|
||||
|
||||
QPixmap LogMode::icon() const {
|
||||
return d->icon;
|
||||
}
|
||||
|
||||
QAction* LogMode::action() const {
|
||||
return d->action;
|
||||
}
|
||||
|
||||
LogModeItemBuilder* LogMode::itemBuilder() const {
|
||||
return d->itemBuilder;
|
||||
}
|
||||
|
||||
LogModeConfigurationWidget* LogMode::logModeConfigurationWidget() const {
|
||||
return d->logModeConfigurationWidget;
|
||||
}
|
||||
|
||||
LogModeConfiguration* LogMode::innerConfiguration() const {
|
||||
return d->logModeConfiguration;
|
||||
}
|
||||
|
||||
QAction* LogMode::createDefaultAction() {
|
||||
QAction* action = new QAction(d->icon, d->name, this);
|
||||
action->setData(QVariant(d->id));
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
#include "moc_logMode.cpp"
|
|
@ -1,112 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 LOG_MODE_H
|
||||
#define LOG_MODE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
#include "logFile.h"
|
||||
|
||||
class Analyzer;
|
||||
class LogModeItemBuilder;
|
||||
class LogModeConfiguration;
|
||||
class LogModeConfigurationWidget;
|
||||
|
||||
#include <QAction>
|
||||
|
||||
|
||||
//TODO Do not let this class visible to other classes (except sub-classes)
|
||||
class LogModePrivate {
|
||||
public:
|
||||
QString id;
|
||||
|
||||
QString name;
|
||||
|
||||
QString iconName;
|
||||
|
||||
QPixmap icon;
|
||||
|
||||
QAction* action;
|
||||
|
||||
LogModeItemBuilder* itemBuilder;
|
||||
|
||||
LogModeConfigurationWidget* logModeConfigurationWidget;
|
||||
|
||||
LogModeConfiguration* logModeConfiguration;
|
||||
};
|
||||
|
||||
class LogMode : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogMode(const QString& id, const QString& name, const QString& iconName);
|
||||
|
||||
virtual ~LogMode();
|
||||
|
||||
QString id() const;
|
||||
|
||||
QString name() const;
|
||||
|
||||
QPixmap icon() const;
|
||||
|
||||
QAction* action() const;
|
||||
|
||||
LogModeItemBuilder* itemBuilder() const;
|
||||
|
||||
/**
|
||||
* Log mode configuration widget
|
||||
*/
|
||||
LogModeConfigurationWidget* logModeConfigurationWidget() const;
|
||||
|
||||
template <typename T>
|
||||
T logModeConfiguration() {
|
||||
return static_cast<T>( innerConfiguration() );
|
||||
}
|
||||
/**
|
||||
* Create the Analyzer used to parse the log file
|
||||
*/
|
||||
virtual Analyzer* createAnalyzer() = 0;
|
||||
|
||||
/**
|
||||
* Create the log file list which will be read
|
||||
*/
|
||||
virtual QList<LogFile> createLogFiles() = 0;
|
||||
|
||||
protected:
|
||||
QAction* createDefaultAction();
|
||||
|
||||
LogModePrivate* const d;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Log Mode Configuration
|
||||
*/
|
||||
LogModeConfiguration* innerConfiguration() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //LOG_MODE_H
|
|
@ -1,56 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logModeAction.h"
|
||||
|
||||
class LogModeActionPrivate {
|
||||
public:
|
||||
bool inToolBar;
|
||||
|
||||
LogModeAction::Category category;
|
||||
};
|
||||
|
||||
LogModeAction::LogModeAction() :
|
||||
d(new LogModeActionPrivate()) {
|
||||
|
||||
d->inToolBar = true;
|
||||
d->category = LogModeAction::RootCategory;
|
||||
}
|
||||
|
||||
LogModeAction::~LogModeAction() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
void LogModeAction::setInToolBar(bool inToolBar) {
|
||||
d->inToolBar = inToolBar;
|
||||
}
|
||||
|
||||
bool LogModeAction::isInToolBar() {
|
||||
return d->inToolBar;
|
||||
}
|
||||
|
||||
void LogModeAction::setCategory(LogModeAction::Category category) {
|
||||
d->category = category;
|
||||
}
|
||||
|
||||
LogModeAction::Category LogModeAction::category() {
|
||||
return d->category;
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_MODE_ACTION_H_
|
||||
#define _LOG_MODE_ACTION_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QAction>
|
||||
|
||||
class LogModeActionPrivate;
|
||||
|
||||
class LogModeAction : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum Category {
|
||||
RootCategory,
|
||||
ServicesCategory,
|
||||
OthersCategory
|
||||
};
|
||||
Q_DECLARE_FLAGS(Categories, Category)
|
||||
|
||||
LogModeAction();
|
||||
|
||||
virtual ~LogModeAction();
|
||||
|
||||
virtual QList<QAction*> innerActions() = 0;
|
||||
|
||||
virtual QAction* actionMenu() = 0;
|
||||
|
||||
void setInToolBar(bool inToolBar);
|
||||
|
||||
bool isInToolBar();
|
||||
|
||||
void setCategory(Category category);
|
||||
|
||||
Category category();
|
||||
|
||||
private:
|
||||
LogModeActionPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
#endif // _LOG_MODE_ACTION_H_
|
|
@ -1,256 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logModeConfiguration.h"
|
||||
|
||||
#include "logging.h"
|
||||
#include "defaults.h"
|
||||
|
||||
#include <kurl.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "logFile.h"
|
||||
#include "logLevel.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
LogModeConfiguration::LogModeConfiguration() {
|
||||
configuration = KSystemLogConfig::self();
|
||||
}
|
||||
|
||||
LogModeConfiguration::~LogModeConfiguration() {
|
||||
//configuration is managed by KDE
|
||||
}
|
||||
|
||||
//TODO Need a rewritting
|
||||
/*
|
||||
Reader* ReaderFactory::createReader(LogMode* logMode) {
|
||||
|
||||
//Using Boot Mode in the current view
|
||||
else if (logMode==Globals::bootMode) {
|
||||
Reader* reader=new SystemReader(NULL, "boot_reader");
|
||||
return(reader);
|
||||
}
|
||||
|
||||
//Using Authentication Mode in the current view
|
||||
else if (logMode==Globals::authenticationMode) {
|
||||
Reader* reader=new SystemReader(NULL, "authentication_reader");
|
||||
return(reader);
|
||||
}
|
||||
|
||||
//Using Daemon Mode in the current view
|
||||
else if (logMode==Globals::daemonMode) {
|
||||
Reader* reader=new SystemReader(NULL, "daemon_reader");
|
||||
return(reader);
|
||||
}
|
||||
|
||||
//Using Cups Mode in the current view
|
||||
else if (logMode==Globals::cupsMode) {
|
||||
Reader* reader=new CupsReader(NULL, "cups_reader");
|
||||
return(reader);
|
||||
}
|
||||
|
||||
//Using Cups Access Mode in the current view
|
||||
else if (logMode==Globals::cupsAccessMode) {
|
||||
Reader* reader=new CupsAccessReader(NULL, "cups_access_reader");
|
||||
return(reader);
|
||||
}
|
||||
|
||||
//Using Postfix Mode in the current view
|
||||
else if (logMode==Globals::postfixMode) {
|
||||
Reader* reader=new SystemReader(NULL, "postfix_reader");
|
||||
return(reader);
|
||||
}
|
||||
|
||||
//Using Samba Mode in the current view
|
||||
else if (logMode==Globals::sambaMode) {
|
||||
Reader* reader=new SambaReader(NULL, "samba_reader");
|
||||
return(reader);
|
||||
}
|
||||
|
||||
//Using SSH Mode in the current view
|
||||
else if (logMode==Globals::sshMode) {
|
||||
Reader* reader=new SSHReader(NULL, "ssh_reader");
|
||||
return(reader);
|
||||
}
|
||||
|
||||
//Using X Session Mode in the current view
|
||||
else if (logMode==Globals::xsessionMode) {
|
||||
Reader* reader=new XSessionReader(NULL, "xsession_reader");
|
||||
return reader;
|
||||
}
|
||||
|
||||
logError() << "LogMode not found : returns NULL Reader";
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
//TODO Move this method in LogModeFactory subclasses
|
||||
/*
|
||||
QList<LogFile> LogFilesFactory::createLogFiles(LogMode* logMode) {
|
||||
|
||||
else if (logMode==Globals::instance()->bootMode()) {
|
||||
QList<LogFile> list;
|
||||
list.append(LogFilesFactory::instance()->getBootLogFile());
|
||||
return list;
|
||||
}
|
||||
|
||||
else if (logMode==Globals::instance()->authenticationMode()) {
|
||||
QList<LogFile> list;
|
||||
list.append(LogFilesFactory::instance()->getAuthenticationLogFile());
|
||||
return list;
|
||||
}
|
||||
|
||||
else if (logMode==Globals::instance()->daemonMode()) {
|
||||
return LogFilesFactory::getDaemonLogFiles();
|
||||
}
|
||||
|
||||
else if (logMode==Globals::instance()->cupsMode()) {
|
||||
return LogFilesFactory::getCupsLogFiles();
|
||||
}
|
||||
|
||||
else if (logMode==Globals::instance()->cupsAccessMode()) {
|
||||
return LogFilesFactory::getCupsAccessLogFiles();
|
||||
|
||||
}
|
||||
|
||||
else if (logMode==Globals::instance()->postfixMode()) {
|
||||
return LogFilesFactory::getPostfixLogFiles();
|
||||
}
|
||||
|
||||
else if (logMode==Globals::instance()->sambaMode()) {
|
||||
return LogFilesFactory::getSambaLogFiles();
|
||||
}
|
||||
|
||||
else if (logMode==Globals::instance()->sshMode()) {
|
||||
return LogFilesFactory::getSSHLogFiles();
|
||||
}
|
||||
|
||||
|
||||
else if (logMode==Globals::instance()->xsessionMode()) {
|
||||
return LogFilesFactory::getXSessionLogFiles();
|
||||
}
|
||||
|
||||
logError() << "LogFiles not found : returns NULL Reader";
|
||||
|
||||
return QList<LogFile>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
LogFile LogFilesFactory::getBootLogFile() {
|
||||
QString file=KSystemLogConfig::bootPath();
|
||||
return getGenericLogFile(file);
|
||||
}
|
||||
|
||||
LogFile LogFilesFactory::getAuthenticationLogFile() {
|
||||
QString file=KSystemLogConfig::authenticationPath();
|
||||
return getGenericLogFile(file);
|
||||
}
|
||||
|
||||
QList<LogFile> LogFilesFactory::getDaemonLogFiles() {
|
||||
QStringList files=KSystemLogConfig::daemonPaths();
|
||||
QList<int> levels=KSystemLogConfig::daemonLevels();
|
||||
return LogFilesFactory::getGenericLogFiles(files, levels);
|
||||
}
|
||||
|
||||
QList<LogFile> LogFilesFactory::getCupsLogFiles() {
|
||||
QStringList stringList=KSystemLogConfig::cupsPaths();
|
||||
return getNoModeLogFiles(stringList);
|
||||
}
|
||||
|
||||
QList<LogFile> LogFilesFactory::getCupsAccessLogFiles() {
|
||||
QStringList stringList=KSystemLogConfig::cupsAccessPaths();
|
||||
return getNoModeLogFiles(stringList);
|
||||
}
|
||||
|
||||
QList<LogFile> LogFilesFactory::getPostfixLogFiles() {
|
||||
QStringList files=KSystemLogConfig::postfixPaths();
|
||||
QList<int> levels=KSystemLogConfig::postfixLevels();
|
||||
return LogFilesFactory::getGenericLogFiles(files, levels);
|
||||
}
|
||||
|
||||
QList<LogFile> LogFilesFactory::getSambaLogFiles() {
|
||||
QStringList stringList=KSystemLogConfig::sambaPaths();
|
||||
return getNoModeLogFiles(stringList);
|
||||
}
|
||||
|
||||
QList<LogFile> LogFilesFactory::getSSHLogFiles() {
|
||||
QStringList stringList=KSystemLogConfig::sshPaths();
|
||||
return getNoModeLogFiles(stringList);
|
||||
}
|
||||
|
||||
QList<LogFile> LogFilesFactory::getXSessionLogFiles() {
|
||||
QStringList stringList=KSystemLogConfig::xSessionPaths();
|
||||
return getNoModeLogFiles(stringList);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
LogFile LogModeConfiguration::findGenericLogFile(const QString& file) {
|
||||
|
||||
LogLevel* level=Globals::instance()->informationLogLevel();
|
||||
|
||||
KUrl url(file);
|
||||
if (!url.isValid()) {
|
||||
logWarning() << i18n("URL '%1' is not valid, skipping this URL.", url.path());
|
||||
return LogFile(KUrl(), Globals::instance()->noLogLevel());
|
||||
}
|
||||
|
||||
return LogFile(url, level);
|
||||
}
|
||||
|
||||
QList<LogFile> LogModeConfiguration::findGenericLogFiles(const QStringList& files) {
|
||||
QList<LogFile> logFiles;
|
||||
|
||||
foreach(const QString &file, files) {
|
||||
logFiles.append(findGenericLogFile(file));
|
||||
}
|
||||
|
||||
return logFiles;
|
||||
}
|
||||
|
||||
QList<LogFile> LogModeConfiguration::findNoModeLogFiles(const QStringList& stringList) {
|
||||
|
||||
QList<LogFile> logFiles;
|
||||
|
||||
//Default level used for No Mode logs
|
||||
LogLevel* level=Globals::instance()->noLogLevel();
|
||||
|
||||
foreach (const QString &string, stringList) {
|
||||
|
||||
KUrl url(string);
|
||||
if (!url.isValid()) {
|
||||
logWarning() << i18n("URL '%1' is not valid, skipping this URL.", url.path());
|
||||
continue;
|
||||
}
|
||||
|
||||
logFiles.append(LogFile(url, level));
|
||||
|
||||
}
|
||||
|
||||
return logFiles;
|
||||
}
|
||||
|
||||
#include "moc_logModeConfiguration.cpp"
|
|
@ -1,52 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_MODE_CONFIGURATION_H_
|
||||
#define _LOG_MODE_CONFIGURATION_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
|
||||
#include "logFile.h"
|
||||
|
||||
|
||||
class KSystemLogConfig;
|
||||
|
||||
class LogModeConfiguration : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogModeConfiguration();
|
||||
|
||||
virtual ~LogModeConfiguration();
|
||||
|
||||
LogFile findGenericLogFile(const QString& file);
|
||||
QList<LogFile> findGenericLogFiles(const QStringList& files);
|
||||
|
||||
QList<LogFile> findNoModeLogFiles(const QStringList& stringList);
|
||||
|
||||
protected:
|
||||
KSystemLogConfig* configuration;
|
||||
};
|
||||
|
||||
#endif // _LOG_MODE_CONFIGURATION_H_
|
|
@ -1,63 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logModeConfigurationWidget.h"
|
||||
|
||||
class LogModeConfigurationWidgetPrivate {
|
||||
public:
|
||||
QString itemName;
|
||||
QString iconName;
|
||||
QString header;
|
||||
};
|
||||
|
||||
LogModeConfigurationWidget::LogModeConfigurationWidget(const QString& itemName, const QString& iconName, const QString& header) :
|
||||
QWidget(),
|
||||
d(new LogModeConfigurationWidgetPrivate())
|
||||
{
|
||||
|
||||
d->itemName = itemName;
|
||||
d->iconName = iconName;
|
||||
d->header = header;
|
||||
}
|
||||
|
||||
|
||||
LogModeConfigurationWidget::~LogModeConfigurationWidget() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
QString LogModeConfigurationWidget::itemName() const {
|
||||
return d->itemName;
|
||||
}
|
||||
QString LogModeConfigurationWidget::iconName() const {
|
||||
return d->iconName;
|
||||
}
|
||||
QString LogModeConfigurationWidget::header() const {
|
||||
return d->header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation
|
||||
*/
|
||||
bool LogModeConfigurationWidget::isValid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "moc_logModeConfigurationWidget.cpp"
|
|
@ -1,58 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_MODE_CONFIGURATION_WIDGET_H_
|
||||
#define _LOG_MODE_CONFIGURATION_WIDGET_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
|
||||
class LogModeConfigurationWidgetPrivate;
|
||||
|
||||
class LogModeConfigurationWidget : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogModeConfigurationWidget(const QString& itemName, const QString& iconName, const QString& header);
|
||||
|
||||
virtual ~LogModeConfigurationWidget();
|
||||
|
||||
virtual bool isValid() const;
|
||||
|
||||
virtual void saveConfig() = 0;
|
||||
virtual void defaultConfig() = 0;
|
||||
virtual void readConfig() = 0;
|
||||
|
||||
signals:
|
||||
void configurationChanged();
|
||||
|
||||
public:
|
||||
QString itemName() const;
|
||||
QString iconName() const;
|
||||
QString header() const;
|
||||
|
||||
private:
|
||||
|
||||
LogModeConfigurationWidgetPrivate* const d;
|
||||
};
|
||||
|
||||
#endif // _LOG_MODE_CONFIGURATION_WIDGET_H_
|
|
@ -1,36 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logModeFactory.h"
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
LogModeFactory::LogModeFactory() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
LogModeFactory::~LogModeFactory() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "moc_logModeFactory.cpp"
|
|
@ -1,51 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_MODE_FACTORY_H_
|
||||
#define _LOG_MODE_FACTORY_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
|
||||
class LogModeAction;
|
||||
class LogMode;
|
||||
|
||||
class LogModeFactory : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LogModeFactory();
|
||||
|
||||
virtual ~LogModeFactory();
|
||||
|
||||
virtual LogModeAction* createLogModeAction() const = 0;
|
||||
|
||||
/**
|
||||
* Create the log mode
|
||||
*/
|
||||
virtual QList<LogMode*> createLogModes() const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // _LOG_MODE_FACTORY_H_
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logModeItemBuilder.h"
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kglobal.h>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include "logLine.h"
|
||||
#include "logViewWidgetItem.h"
|
||||
#include "logMode.h"
|
||||
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
LogModeItemBuilder::LogModeItemBuilder() {
|
||||
|
||||
}
|
||||
|
||||
LogModeItemBuilder::~LogModeItemBuilder() {
|
||||
|
||||
}
|
||||
|
||||
QString LogModeItemBuilder::formatDate(const QDateTime& dateTime) const {
|
||||
return KGlobal::locale()->formatDateTime(dateTime, (KLocale::DateFormat) KSystemLogConfig::dateFormat(), true);
|
||||
}
|
||||
|
||||
void LogModeItemBuilder::prepareItem(LogViewWidgetItem* item) const {
|
||||
LogLine* line=item->logLine();
|
||||
|
||||
item->setText(0, formatDate(line->time()));
|
||||
|
||||
int i=1;
|
||||
foreach(const QString &label, line->logItems()) {
|
||||
item->setText(i, label);
|
||||
i++;
|
||||
}
|
||||
|
||||
item->setIcon(0, line->logLevel()->pixmap());
|
||||
}
|
||||
|
||||
QString LogModeItemBuilder::createFormattedText(LogLine* line) const {
|
||||
QString result;
|
||||
|
||||
QListIterator<QString> it(line->logItems());
|
||||
|
||||
result.append(QLatin1String( "<table>" ));
|
||||
|
||||
result.append(labelMessageFormat(i18n("Date:"), formatDate(line->time())));
|
||||
result.append(labelMessageFormat(i18n("Hostname:"), it.next() ));
|
||||
result.append(labelMessageFormat(i18n("Process:"), it.next() ));
|
||||
result.append(labelMessageFormat(i18n("Level:"), line->logLevel()->name()));
|
||||
result.append(labelMessageFormat(i18n("Original file:"), line->sourceFileName()));
|
||||
|
||||
result.append(QLatin1String( "</table>" ));
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
QString LogModeItemBuilder::createToolTipText(LogLine* line) const {
|
||||
QString result;
|
||||
|
||||
result.append(QLatin1String( "<table>" ));
|
||||
|
||||
result.append(labelMessageFormat(i18n("Date:"), formatDate(line->time())));
|
||||
result.append(labelMessageFormat(i18n("Level:"), line->logLevel()->name()));
|
||||
result.append(labelMessageFormat(i18n("Original file:"), line->sourceFileName()));
|
||||
|
||||
result.append(QLatin1String( "</table>" ));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QString LogModeItemBuilder::labelMessageFormat(const QString& label, const QString& value) const {
|
||||
return (QLatin1String( "<tr><td align='right'><b><nobr>" ) + label + QLatin1String( "</nobr></b></td><td>" ) + messageFormat(value) + QLatin1String( "</td></tr>" ));
|
||||
}
|
||||
|
||||
QString LogModeItemBuilder::messageFormat(const QString& message) const {
|
||||
QString transformation(message);
|
||||
transformation.replace(QRegExp(QLatin1String( "&" )), QLatin1String( "&" ));
|
||||
transformation.replace(QRegExp(QLatin1String( "<" )), QLatin1String( "<" ));
|
||||
transformation.replace(QRegExp(QLatin1String( ">" )), QLatin1String( ">" ));
|
||||
return transformation;
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_MODE_ITEM_BUILDER_H_
|
||||
#define _LOG_MODE_ITEM_BUILDER_H_
|
||||
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
class LogViewWidgetItem;
|
||||
class LogLine;
|
||||
|
||||
class LogModeItemBuilder {
|
||||
|
||||
public:
|
||||
LogModeItemBuilder();
|
||||
|
||||
virtual ~LogModeItemBuilder();
|
||||
|
||||
virtual void prepareItem(LogViewWidgetItem* item) const;
|
||||
|
||||
virtual QString createFormattedText(LogLine* line) const;
|
||||
virtual QString createToolTipText(LogLine* line) const;
|
||||
|
||||
protected:
|
||||
QString labelMessageFormat(const QString& label, const QString& value) const;
|
||||
QString messageFormat(const QString& message) const;
|
||||
|
||||
QString formatDate(const QDateTime& dateTime) const;
|
||||
|
||||
};
|
||||
|
||||
#endif // _LOG_MODE_ITEM_BUILDER_H_
|
|
@ -1,90 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logViewColumn.h"
|
||||
|
||||
|
||||
#include <QString>
|
||||
#include <QDataStream>
|
||||
|
||||
|
||||
#include <kurl.h>
|
||||
#include <kvbox.h>
|
||||
#include <kiconloader.h>
|
||||
|
||||
class LogViewColumnPrivate {
|
||||
public:
|
||||
QString columnName;
|
||||
|
||||
bool filtered;
|
||||
bool grouped;
|
||||
|
||||
};
|
||||
|
||||
LogViewColumn::LogViewColumn(const QString& name, bool filtered, bool grouped) :
|
||||
d(new LogViewColumnPrivate()) {
|
||||
|
||||
d->columnName = name;
|
||||
d->filtered = filtered;
|
||||
d->grouped = grouped;
|
||||
}
|
||||
|
||||
LogViewColumn::LogViewColumn(const LogViewColumn& column) :
|
||||
d(new LogViewColumnPrivate()) {
|
||||
|
||||
d->columnName = column.columnName();
|
||||
d->filtered = column.isFiltered();
|
||||
d->grouped = column.isGrouped();
|
||||
}
|
||||
|
||||
LogViewColumn::~LogViewColumn() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
QString LogViewColumn::columnName() const {
|
||||
return d->columnName;
|
||||
}
|
||||
|
||||
bool LogViewColumn::isGrouped() const {
|
||||
return d->grouped;
|
||||
}
|
||||
bool LogViewColumn::isFiltered() const {
|
||||
return d->filtered;
|
||||
}
|
||||
|
||||
LogViewColumn& LogViewColumn::operator=(const LogViewColumn& column) {
|
||||
d->columnName = column.columnName();
|
||||
d->grouped = column.isGrouped();
|
||||
d->filtered = column.isFiltered();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDataStream& operator<< (QDataStream& out, const LogViewColumn& column) {
|
||||
out << column.columnName();
|
||||
return out;
|
||||
}
|
||||
|
||||
QDebug& operator<< (QDebug& out, const LogViewColumn& column) {
|
||||
out << column.columnName();
|
||||
return out;
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 LOG_VIEW_COLUMN_H
|
||||
#define LOG_VIEW_COLUMN_H
|
||||
|
||||
#include <QString>
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
class LogViewColumnPrivate;
|
||||
|
||||
class LogViewColumn {
|
||||
|
||||
public:
|
||||
LogViewColumn(const LogViewColumn& column);
|
||||
|
||||
/*
|
||||
* TODO For the moment, filtered and grouped parameters are useless : Use them or remove them
|
||||
*/
|
||||
explicit LogViewColumn(const QString& name, bool filtered=true, bool grouped=true);
|
||||
|
||||
virtual ~LogViewColumn();
|
||||
|
||||
QString columnName() const;
|
||||
bool isGrouped() const;
|
||||
bool isFiltered() const;
|
||||
|
||||
LogViewColumn& operator=(const LogViewColumn& column);
|
||||
|
||||
private:
|
||||
LogViewColumnPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
QDataStream & operator<< (QDataStream& out, const LogViewColumn& column);
|
||||
QDebug & operator<< (QDebug& out, const LogViewColumn& column);
|
||||
|
||||
#endif //LOG_VIEW_COLUMN_H
|
|
@ -1,127 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logViewColumns.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
|
||||
#include "logging.h"
|
||||
#include <kurl.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "logViewColumn.h"
|
||||
|
||||
class LogViewColumnsPrivate {
|
||||
public:
|
||||
|
||||
QList<LogViewColumn> columns;
|
||||
bool groupByLogLevel;
|
||||
bool groupByDay;
|
||||
bool groupByHour;
|
||||
bool groupByLogFile;
|
||||
|
||||
};
|
||||
|
||||
LogViewColumns::LogViewColumns() :
|
||||
d(new LogViewColumnsPrivate()) {
|
||||
|
||||
d->groupByLogLevel = true;
|
||||
d->groupByDay = true;
|
||||
d->groupByHour = true;
|
||||
d->groupByLogFile = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
LogViewColumns::~LogViewColumns() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
void LogViewColumns::setGroupByLogLevel(bool value) {
|
||||
d->groupByLogLevel=value;
|
||||
}
|
||||
|
||||
void LogViewColumns::setGroupByDay(bool value) {
|
||||
d->groupByDay=value;
|
||||
}
|
||||
|
||||
void LogViewColumns::setGroupByHour(bool value) {
|
||||
d->groupByHour=value;
|
||||
}
|
||||
|
||||
void LogViewColumns::setGroupByLogFile(bool value) {
|
||||
d->groupByLogFile=value;
|
||||
}
|
||||
|
||||
|
||||
bool LogViewColumns::isGroupByLogLevel() const {
|
||||
return d->groupByLogLevel;
|
||||
}
|
||||
|
||||
bool LogViewColumns::isGroupByDay() const {
|
||||
return d->groupByDay;
|
||||
}
|
||||
|
||||
bool LogViewColumns::isGroupByHour() const {
|
||||
return d->groupByHour;
|
||||
}
|
||||
|
||||
bool LogViewColumns::isGroupByLogFile() const {
|
||||
return d->groupByLogFile;
|
||||
}
|
||||
|
||||
QStringList LogViewColumns::toStringList() const {
|
||||
QStringList columnNames;
|
||||
|
||||
foreach (const LogViewColumn& column, d->columns) {
|
||||
columnNames.append(column.columnName());
|
||||
}
|
||||
|
||||
return columnNames;
|
||||
}
|
||||
|
||||
void LogViewColumns::addColumn(const LogViewColumn& column) {
|
||||
d->columns.append(column);
|
||||
}
|
||||
|
||||
QList<LogViewColumn> LogViewColumns::columns() const {
|
||||
return d->columns;
|
||||
}
|
||||
|
||||
LogViewColumns& LogViewColumns::operator=(const LogViewColumns& columns) {
|
||||
d->columns = columns.columns();
|
||||
d->groupByLogLevel = columns.isGroupByLogLevel();
|
||||
d->groupByDay = columns.isGroupByDay();
|
||||
d->groupByHour = columns.isGroupByHour();
|
||||
d->groupByLogFile = columns.isGroupByLogFile();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDataStream & operator<< (QDataStream& out, const LogViewColumns& columns) {
|
||||
out << columns.columns();
|
||||
return out;
|
||||
}
|
||||
QDebug & operator<< (QDebug& out, const LogViewColumns& columns) {
|
||||
out << columns.columns();
|
||||
return out;
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_VIEW_COLUMNS_H_
|
||||
#define _LOG_VIEW_COLUMNS_H_
|
||||
|
||||
#include <QList>
|
||||
#include <QDataStream>
|
||||
|
||||
class LogViewColumn;
|
||||
#include <QStringList>
|
||||
class LogViewColumnsPrivate;
|
||||
|
||||
class LogViewColumns {
|
||||
|
||||
public:
|
||||
LogViewColumns();
|
||||
|
||||
~LogViewColumns();
|
||||
|
||||
bool isGroupByLogLevel() const;
|
||||
bool isGroupByDay() const;
|
||||
bool isGroupByHour() const;
|
||||
bool isGroupByLogFile() const;
|
||||
|
||||
void setGroupByLogLevel(bool value);
|
||||
void setGroupByDay(bool value);
|
||||
void setGroupByHour(bool value);
|
||||
void setGroupByLogFile(bool value);
|
||||
|
||||
QList<LogViewColumn> columns() const;
|
||||
|
||||
void addColumn(const LogViewColumn& column);
|
||||
QStringList toStringList() const;
|
||||
|
||||
LogViewColumns& operator=(const LogViewColumns& columns);
|
||||
|
||||
private:
|
||||
LogViewColumnsPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
|
||||
QDataStream & operator<< (QDataStream& out, const LogViewColumns& columns);
|
||||
QDebug & operator<< (QDebug& out, const LogViewColumns& columns);
|
||||
|
||||
#endif
|
|
@ -1,274 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logViewExport.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QClipboard>
|
||||
#include <QPrinter>
|
||||
#include <QPrintDialog>
|
||||
#include <QPen>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <kapplication.h>
|
||||
#include <klocale.h>
|
||||
#include <ktoolinvocation.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kfiledialog.h>
|
||||
#include <kdeprintdialog.h>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include "logViewWidgetItem.h"
|
||||
#include "logViewWidget.h"
|
||||
#include "logLine.h"
|
||||
|
||||
#include "levelPrintPage.h"
|
||||
|
||||
LogViewExport::LogViewExport(QWidget* parent, LogViewWidget* logViewWidget) :
|
||||
parent(parent), logViewWidget(logViewWidget) {
|
||||
|
||||
}
|
||||
|
||||
LogViewExport::~LogViewExport() {
|
||||
|
||||
}
|
||||
|
||||
void LogViewExport::sendMail() {
|
||||
logDebug() << "Exporting to mail...";
|
||||
|
||||
QString body(i18n("Here are my logs:\n"));
|
||||
|
||||
body+=i18n("---------------------------------------\n");
|
||||
|
||||
int i=0;
|
||||
QTreeWidgetItemIterator it(logViewWidget, QTreeWidgetItemIterator::Selected);
|
||||
while ( *it != NULL) {
|
||||
LogViewWidgetItem* item=static_cast<LogViewWidgetItem*> (*it);
|
||||
|
||||
body+= item->logLine()->exportToText();
|
||||
body+=QLatin1Char( '\n' );
|
||||
|
||||
++it;
|
||||
++i;
|
||||
}
|
||||
|
||||
body+=i18n("---------------------------------------\n");
|
||||
|
||||
//Too much lines selected
|
||||
if (i>1000) {
|
||||
KMessageBox::sorry(parent, i18n("You have selected too many lines. Please only select important log lines."), i18n("Too Many Lines Selected"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Parameters list of this method
|
||||
//const QString & to,
|
||||
//const QString & cc,
|
||||
//const QString & subject,
|
||||
//const QString & body,
|
||||
//const QStringList & attachURLs,
|
||||
//const QCString & startup_id
|
||||
KToolInvocation::invokeMailer(QLatin1String( "" ), QLatin1String( "" ), i18n("Log Lines of my problem"), body, QStringList(), kapp->startupId());
|
||||
}
|
||||
|
||||
void LogViewExport::printSelection() {
|
||||
logDebug() << "Printing selection...";
|
||||
|
||||
QPrinter printer;
|
||||
|
||||
// do some printer initialization
|
||||
printer.setFullPage( true);
|
||||
|
||||
/*
|
||||
LevelPrintPage* dialogPage = new LevelPrintPage(parent);
|
||||
printer.addDialogPage(dialogPage);
|
||||
*/
|
||||
|
||||
// initialize the printer using the print dialog
|
||||
QPrintDialog *printDialog = KdePrint::createPrintDialog(&printer, parent);
|
||||
if (printDialog->exec() == false) {
|
||||
delete printDialog;
|
||||
return;
|
||||
}
|
||||
delete printDialog;
|
||||
|
||||
// create a painter to paint on the printer object
|
||||
QPainter painter;
|
||||
|
||||
// start painting
|
||||
painter.begin( &printer );
|
||||
|
||||
QPen originalPen(painter.pen());
|
||||
|
||||
int dpiy = painter.device()->logicalDpiY();
|
||||
int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
|
||||
QRect printView(margin, margin, painter.device()->width() - 2*margin, painter.device()->height() - 2*margin );
|
||||
|
||||
int page = 1;
|
||||
|
||||
int i = 0;
|
||||
int movement = 0;
|
||||
|
||||
QTreeWidgetItemIterator it(logViewWidget, QTreeWidgetItemIterator::Selected);
|
||||
while ( *it != NULL) {
|
||||
LogViewWidgetItem* item=static_cast<LogViewWidgetItem*> (*it);
|
||||
|
||||
/*
|
||||
if(qtItem==NULL)
|
||||
{
|
||||
painter.setPen(originalPen);
|
||||
printPageNumber(painter, printView, movement, page);
|
||||
break;
|
||||
}*/
|
||||
|
||||
QString body = item->logLine()->exportToText();
|
||||
//body+= "\n";
|
||||
|
||||
/* QPrinter Port: comment out as dialog page is not currently being used, so not ported
|
||||
QString strUseColor = printer.option("kde-ksystemlog-print_"+ item->logLine()->logLevel()->name());
|
||||
int use = strUseColor.toInt();
|
||||
if (use) {
|
||||
QPen pen(originalPen);
|
||||
pen.setColor(item->logLine()->logLevel()->color());
|
||||
painter.setPen(pen);
|
||||
} else {*/
|
||||
painter.setPen(originalPen);
|
||||
//}
|
||||
|
||||
painter.drawText(printView, Qt::AlignLeft | Qt::TextWordWrap, body);
|
||||
|
||||
int fontHeight = painter.fontMetrics().height();
|
||||
int lines = painter.fontMetrics().width(body) / printView.width() + 1;
|
||||
int moveBy = (fontHeight + 2) * lines;
|
||||
painter.translate(0, moveBy);
|
||||
|
||||
movement = movement + moveBy;
|
||||
if (movement + margin >= printView.height()) {
|
||||
painter.setPen(originalPen);
|
||||
printPageNumber(painter, printView, movement, page);
|
||||
printer.newPage();
|
||||
page++;
|
||||
movement = 0;
|
||||
}
|
||||
|
||||
++it;
|
||||
++i;
|
||||
}
|
||||
|
||||
// stop painting, this will automatically send the print data to the printer
|
||||
painter.end();
|
||||
|
||||
}
|
||||
|
||||
void LogViewExport::printPageNumber(QPainter& painter, QRect& printView, int movement, int page) {
|
||||
logDebug() << "Printing page number...";
|
||||
|
||||
painter.translate(0, -movement);
|
||||
printView.moveTo(QPoint(0, printView.height()) );
|
||||
painter.translate( 0, -printView.height() );
|
||||
painter.drawText(printView.right() - painter.fontMetrics().width(QString::number(page) ), printView.bottom()+ painter.fontMetrics().ascent() + 5, QString::number(page) );
|
||||
|
||||
}
|
||||
|
||||
void LogViewExport::copyToClipboard() {
|
||||
logDebug() << "Copying to clipboard...";
|
||||
|
||||
int nbCopied=0;
|
||||
QString text;
|
||||
|
||||
QTreeWidgetItemIterator it(logViewWidget, QTreeWidgetItemIterator::Selected);
|
||||
while ( *it != NULL) {
|
||||
LogViewWidgetItem* item=static_cast<LogViewWidgetItem*> (*it);
|
||||
|
||||
//Copy the item content to the text string
|
||||
text.append(item->logLine()->exportToText());
|
||||
text.append(QLatin1Char( '\n' ));
|
||||
|
||||
it++;
|
||||
nbCopied++;
|
||||
|
||||
}
|
||||
|
||||
//Copy text value only if it is not empty
|
||||
if (nbCopied==0) {
|
||||
emit statusBarChanged(i18n("No items selected. Nothing copied to clipboard."));
|
||||
} else {
|
||||
//Copy both to clipboard and X11-selection
|
||||
QApplication::clipboard()->setText(text, QClipboard::Clipboard);
|
||||
QApplication::clipboard()->setText(text, QClipboard::Selection);
|
||||
|
||||
emit statusBarChanged(i18np("1 log line copied to clipboard.", "%1 log lines copied to clipboard.", nbCopied));
|
||||
}
|
||||
|
||||
logDebug() << "Copied " << nbCopied << " log lines";
|
||||
|
||||
}
|
||||
|
||||
void LogViewExport::fileSave() {
|
||||
logDebug() << "Saving to a file...";
|
||||
|
||||
QTreeWidgetItemIterator it(logViewWidget, QTreeWidgetItemIterator::Selected);
|
||||
|
||||
//No item selected
|
||||
if ( *it == NULL) {
|
||||
emit statusBarChanged(i18n("No items selected. Please select items to be able to save them."));
|
||||
return;
|
||||
}
|
||||
|
||||
QString filename = KFileDialog::getSaveFileName(KUrl(), QString(), parent);
|
||||
if (filename.isEmpty() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFile* ioDev = new QFile(filename);
|
||||
if (ioDev->open(QIODevice::WriteOnly)) {
|
||||
QTextStream stream(ioDev);
|
||||
|
||||
int nbCopied=0;
|
||||
|
||||
while ( *it != NULL) {
|
||||
LogViewWidgetItem* item=static_cast<LogViewWidgetItem*> (*it);
|
||||
|
||||
//Copy the item content to the stream
|
||||
stream << item->logLine()->exportToText() << '\n';
|
||||
|
||||
//Retrieve the next item
|
||||
it++;
|
||||
nbCopied++;
|
||||
|
||||
}
|
||||
|
||||
ioDev->close();
|
||||
|
||||
delete ioDev;
|
||||
|
||||
emit statusBarChanged(i18np("1 log line saved to '%2'.", "%1 log lines saved to '%2'.", nbCopied, filename));
|
||||
}
|
||||
else {
|
||||
QString message(i18n("Unable to save file '%1': Permission Denied.", filename));
|
||||
KMessageBox::error(parent, message, i18n("Unable to save file."));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#include "moc_logViewExport.cpp"
|
|
@ -1,61 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_VIEW_EXPORT_H_
|
||||
#define _LOG_VIEW_EXPORT_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
|
||||
class LogViewWidget;
|
||||
|
||||
class LogViewExport : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogViewExport(QWidget* parent, LogViewWidget* logViewWidget);
|
||||
|
||||
virtual ~LogViewExport();
|
||||
|
||||
void copyToClipboard();
|
||||
|
||||
void fileSave();
|
||||
|
||||
void sendMail();
|
||||
|
||||
void printSelection();
|
||||
|
||||
signals:
|
||||
void statusBarChanged(const QString& message);
|
||||
|
||||
private:
|
||||
|
||||
void printPageNumber(QPainter& painter, QRect& printView, int movement, int page);
|
||||
|
||||
QWidget* parent;
|
||||
|
||||
LogViewWidget* logViewWidget;
|
||||
};
|
||||
|
||||
|
||||
#endif //_LOG_VIEW_EXPORT_H_
|
|
@ -1,167 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logViewFilterWidget.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <kcombobox.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kicon.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "logViewWidget.h"
|
||||
|
||||
#include "logViewColumn.h"
|
||||
#include "logging.h"
|
||||
|
||||
|
||||
class LogViewFilterWidgetPrivate {
|
||||
public:
|
||||
|
||||
LogViewWidgetSearchLine* filterLine;
|
||||
|
||||
/**
|
||||
* Filter of the column list
|
||||
*/
|
||||
KComboBox* filterList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
LogViewWidgetSearchLine::LogViewWidgetSearchLine() :
|
||||
KTreeWidgetSearchLine() {
|
||||
|
||||
}
|
||||
|
||||
LogViewWidgetSearchLine::~LogViewWidgetSearchLine() {
|
||||
|
||||
}
|
||||
|
||||
void LogViewWidgetSearchLine::updateSearch(const QString& pattern) {
|
||||
KTreeWidgetSearchLine::updateSearch(pattern);
|
||||
|
||||
emit treeWidgetUpdated();
|
||||
}
|
||||
|
||||
|
||||
LogViewFilterWidget::LogViewFilterWidget() :
|
||||
d(new LogViewFilterWidgetPrivate()) {
|
||||
|
||||
|
||||
QHBoxLayout* filterBarLayout = new QHBoxLayout();
|
||||
filterBarLayout->setMargin(0);
|
||||
//filterBarLayout->setSpacing(-1);
|
||||
setLayout(filterBarLayout);
|
||||
|
||||
d->filterLine = new LogViewWidgetSearchLine();
|
||||
|
||||
d->filterLine->setToolTip(i18n("Type your filter here"));
|
||||
d->filterLine->setWhatsThis(i18n("Allows you to only list items that match the content of this text."));
|
||||
d->filterLine->setClickMessage(i18n("Enter your search here..."));
|
||||
|
||||
QLabel* filterIcon = new QLabel();
|
||||
filterIcon->setPixmap(SmallIcon(QLatin1String( "view-filter" )));
|
||||
filterIcon->setBuddy(d->filterLine);
|
||||
filterBarLayout->addWidget(filterIcon);
|
||||
|
||||
QLabel* filterLabel = new QLabel(i18n("Filter:"));
|
||||
filterLabel->setBuddy(d->filterLine);
|
||||
filterBarLayout->addWidget(filterLabel);
|
||||
|
||||
filterBarLayout->addWidget(d->filterLine);
|
||||
|
||||
initSearchListFilter();
|
||||
|
||||
filterBarLayout->addWidget(d->filterList);
|
||||
|
||||
}
|
||||
|
||||
LogViewFilterWidget::~LogViewFilterWidget() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
void LogViewFilterWidget::initSearchListFilter() {
|
||||
d->filterList=new KComboBox();
|
||||
|
||||
d->filterList->setToolTip(i18n("Choose the filtered column here"));
|
||||
d->filterList->setWhatsThis(i18n("Allows you to apply the item filter only on the specified column here. \"<i>All</i>\" column means no specific filter."));
|
||||
|
||||
d->filterList->addItem(i18n("All"));
|
||||
|
||||
d->filterList->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
|
||||
connect(d->filterList, SIGNAL(activated(int)), d->filterLine, SLOT(setFocus()));
|
||||
connect(d->filterList, SIGNAL(activated(int)), this, SLOT(changeColumnFilter(int)));
|
||||
connect(d->filterList, SIGNAL(activated(int)), d->filterLine, SLOT(updateSearch()));
|
||||
|
||||
}
|
||||
|
||||
void LogViewFilterWidget::updateFilterColumns(const LogViewColumns& columns) {
|
||||
logDebug() << "Changing columns...";
|
||||
|
||||
//We first delete all items
|
||||
d->filterList->clear();
|
||||
|
||||
//Then we insert the default items
|
||||
d->filterList->addItem(i18n("All"));
|
||||
|
||||
foreach(const LogViewColumn& column, columns.columns()) {
|
||||
if (column.isFiltered()==true) {
|
||||
d->filterList->addItem(column.columnName());
|
||||
}
|
||||
}
|
||||
|
||||
d->filterList->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void LogViewFilterWidget::changeColumnFilter(int column) {
|
||||
//The user select all columns
|
||||
if (column==0) {
|
||||
logDebug() << "Searching on all columns";
|
||||
|
||||
d->filterLine->setSearchColumns(QList<int>());
|
||||
return;
|
||||
}
|
||||
|
||||
logDebug() << "Searching on " << d->filterList->currentIndex() << " column";
|
||||
|
||||
QList<int> filterColumns;
|
||||
//currentIndex() - 1 to do not count the "All" columns item
|
||||
filterColumns.append(d->filterList->currentIndex() - 1);
|
||||
|
||||
d->filterLine->setSearchColumns(filterColumns);
|
||||
|
||||
}
|
||||
|
||||
KComboBox* LogViewFilterWidget::filterList() {
|
||||
return d->filterList;
|
||||
}
|
||||
|
||||
LogViewWidgetSearchLine* LogViewFilterWidget::filterLine() {
|
||||
return d->filterLine;
|
||||
}
|
||||
|
||||
#include "moc_logViewFilterWidget.cpp"
|
|
@ -1,87 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 LOG_VIEW_FILTER_WIDGET_H
|
||||
#define LOG_VIEW_FILTER_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <ktreewidgetsearchline.h>
|
||||
|
||||
#include "logViewColumns.h"
|
||||
|
||||
class LogViewWidget;
|
||||
class LogViewWidgetSearchLine;
|
||||
class KComboBox;
|
||||
|
||||
class LogViewFilterWidgetPrivate;
|
||||
|
||||
class LogViewFilterWidget : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogViewFilterWidget();
|
||||
|
||||
~LogViewFilterWidget();
|
||||
|
||||
KComboBox* filterList();
|
||||
LogViewWidgetSearchLine* filterLine();
|
||||
|
||||
public slots:
|
||||
void updateFilterColumns(const LogViewColumns& list);
|
||||
|
||||
private slots:
|
||||
void changeColumnFilter(int column);
|
||||
|
||||
signals:
|
||||
void treeWidgetUpdated();
|
||||
|
||||
private:
|
||||
void initSearchListFilter();
|
||||
|
||||
LogViewFilterWidgetPrivate* const d;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class LogViewWidgetSearchLine : public KTreeWidgetSearchLine {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogViewWidgetSearchLine();
|
||||
|
||||
~LogViewWidgetSearchLine();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Reimplemented just to send a signal _AFTER_ the tree updating
|
||||
*/
|
||||
void updateSearch(const QString& pattern = QString());
|
||||
|
||||
signals:
|
||||
void treeWidgetUpdated();
|
||||
|
||||
};
|
||||
|
||||
#endif //LOG_VIEW_FILTER_WIDGET_H
|
|
@ -1,255 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logViewModel.h"
|
||||
|
||||
|
||||
#include "view.h"
|
||||
#include "logLine.h"
|
||||
|
||||
#include "logViewWidgetItem.h"
|
||||
#include "logViewWidget.h"
|
||||
#include "logModeItemBuilder.h"
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
class LogViewModelPrivate {
|
||||
public:
|
||||
|
||||
LogViewWidget* logViewWidget;
|
||||
|
||||
LogViewWidgetItem* oldestItem;
|
||||
|
||||
int concurrentMultipleInsertions;
|
||||
|
||||
};
|
||||
|
||||
LogViewModel::LogViewModel(LogViewWidget* logViewWidget) :
|
||||
QObject(logViewWidget),
|
||||
d(new LogViewModelPrivate())
|
||||
{
|
||||
|
||||
d->logViewWidget = logViewWidget;
|
||||
d->oldestItem = NULL;
|
||||
|
||||
d->concurrentMultipleInsertions = 0;
|
||||
|
||||
}
|
||||
|
||||
LogViewModel::~LogViewModel() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
bool LogViewModel::logLineAlreadyExists(LogLine* line) const {
|
||||
LogViewWidgetItem* item = d->logViewWidget->findItem(line);
|
||||
if (item!=NULL)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<LogLine*> LogViewModel::logLines() {
|
||||
return d->logViewWidget->logLines();
|
||||
}
|
||||
|
||||
int LogViewModel::itemCount() const {
|
||||
return d->logViewWidget->itemCount();
|
||||
}
|
||||
|
||||
bool LogViewModel::isEmpty() const {
|
||||
if (d->logViewWidget->itemCount() == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void LogViewModel::removeRecentStatusOfLogLines() {
|
||||
//The older lines are no longer recent
|
||||
foreach(LogViewWidgetItem* item, d->logViewWidget->items()) {
|
||||
item->logLine()->setRecent(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LogViewModel::startingMultipleInsertions(Analyzer::ReadingMode /*readingMode*/) {
|
||||
bool hasLocked = false;
|
||||
|
||||
//Check the lock before adding this as locker
|
||||
if (lockMultipleInsertions() == true) {
|
||||
hasLocked = true;
|
||||
}
|
||||
|
||||
//Add a lock
|
||||
d->concurrentMultipleInsertions++;
|
||||
|
||||
if (hasLocked == true) {
|
||||
logDebug() << "Starting multiple insertions...";
|
||||
|
||||
emit( processingMultipleInsertions(true) );
|
||||
|
||||
d->logViewWidget->setUpdatesEnabled(false);
|
||||
|
||||
//Remove all recent states of previous log lines
|
||||
removeRecentStatusOfLogLines();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LogViewModel::endingMultipleInsertions(Analyzer::ReadingMode readingMode, int insertedLogLineCount) {
|
||||
//Remove a lock
|
||||
d->concurrentMultipleInsertions--;
|
||||
|
||||
if (lockMultipleInsertions() == true) {
|
||||
logDebug() << "Ending multiple insertions...";
|
||||
|
||||
//Scroll to the newest item if some lines have been added
|
||||
if (insertedLogLineCount>0) {
|
||||
d->logViewWidget->scrollToNewestItem();
|
||||
}
|
||||
|
||||
if (readingMode == Analyzer::FullRead) {
|
||||
d->logViewWidget->resizeColumns();
|
||||
}
|
||||
|
||||
logDebug() << "Enabling log view widget refresh...";
|
||||
d->logViewWidget->setUpdatesEnabled(true);
|
||||
|
||||
emit( processingMultipleInsertions(false) );
|
||||
}
|
||||
}
|
||||
|
||||
bool LogViewModel::lockMultipleInsertions() {
|
||||
if (d->concurrentMultipleInsertions == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//Debug messages
|
||||
if (d->concurrentMultipleInsertions > 0) {
|
||||
logDebug() << "Existing multiple insertions request is still active";
|
||||
}
|
||||
else if (d->concurrentMultipleInsertions < 0) {
|
||||
logError() << "Existing multiple insertions forgot to call this method";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LogViewModel::isProcessingMultipleInsertions() const {
|
||||
if (d->concurrentMultipleInsertions == 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
void LogViewModel::clear() {
|
||||
d->logViewWidget->clear();
|
||||
|
||||
//Reinit Oldest item
|
||||
d->oldestItem = NULL;
|
||||
}
|
||||
|
||||
bool LogViewModel::isNewer(LogLine* newLine) const {
|
||||
//No element in the list in this case
|
||||
if (d->oldestItem==NULL)
|
||||
return true;
|
||||
|
||||
if (newLine->isNewerThan( *(d->oldestItem->logLine()) ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void LogViewModel::removeOldestLogLine() {
|
||||
//logDebug() << "Removing oldest log line";
|
||||
|
||||
if (isEmpty()==true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (d->oldestItem==NULL) {
|
||||
logWarning() << "Oldest item is null";
|
||||
return;
|
||||
}
|
||||
|
||||
//Remove the oldest item from the list
|
||||
d->logViewWidget->takeTopLevelItem(d->logViewWidget->indexOfTopLevelItem(d->oldestItem));
|
||||
|
||||
delete d->oldestItem;
|
||||
d->oldestItem = NULL;
|
||||
|
||||
//Find the next oldest item
|
||||
foreach(LogViewWidgetItem* item, d->logViewWidget->items()) {
|
||||
if (d->oldestItem==NULL) {
|
||||
d->oldestItem = item;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (d->oldestItem->logLine()->isNewerThan( *(item->logLine()) )) {
|
||||
d->oldestItem = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LogViewModel::insert(LogLine* line) {
|
||||
//The item is automatically added to the LogViewWidget
|
||||
LogViewWidgetItem* item = new LogViewWidgetItem(d->logViewWidget, line);
|
||||
|
||||
//Update the oldest item
|
||||
if (d->oldestItem==NULL) {
|
||||
d->oldestItem = item;
|
||||
}
|
||||
else if (d->oldestItem->logLine()->isNewerThan(*line)) {
|
||||
d->oldestItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
bool LogViewModel::insertNewLogLine(LogLine* line) {
|
||||
//If the Delete Duplicated Line option is checked
|
||||
if (KSystemLogConfig::deleteDuplicatedLines()==true) {
|
||||
if (logLineAlreadyExists(line)==true) {
|
||||
delete line;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//If there is still space in the buffer
|
||||
if (itemCount()<KSystemLogConfig::maxLines()) {
|
||||
insert(line);
|
||||
|
||||
return true;
|
||||
}
|
||||
//If the line is newer, it can be inserted
|
||||
else if (isNewer(line)==true) {
|
||||
removeOldestLogLine();
|
||||
insert(line);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//logDebug() << "Do not insert an old line : " << line->logItems();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "moc_logViewModel.cpp"
|
|
@ -1,95 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_VIEW_MODEL_H_
|
||||
#define _LOG_VIEW_MODEL_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "globals.h"
|
||||
#include "analyzer.h"
|
||||
|
||||
class LogLine;
|
||||
class LogViewWidget;
|
||||
|
||||
class LogViewModelPrivate;
|
||||
|
||||
class LogViewModel : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogViewModel(LogViewWidget* logViewWidget);
|
||||
|
||||
virtual ~LogViewModel();
|
||||
|
||||
/**
|
||||
* Clear the model
|
||||
*/
|
||||
void clear();
|
||||
|
||||
bool insertNewLogLine(LogLine* line);
|
||||
|
||||
int itemCount() const;
|
||||
bool isEmpty() const;
|
||||
|
||||
bool isProcessingMultipleInsertions() const;
|
||||
|
||||
void startingMultipleInsertions(Analyzer::ReadingMode readingMode);
|
||||
void endingMultipleInsertions(Analyzer::ReadingMode readingMode, int insertedLogLineCount);
|
||||
|
||||
QList<LogLine*> logLines();
|
||||
|
||||
signals:
|
||||
void processingMultipleInsertions(bool currentlyInserting);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Prevent crossed multiple insertions between each LogFileReaders
|
||||
*/
|
||||
bool lockMultipleInsertions();
|
||||
|
||||
void setFirstReadProcessed();
|
||||
|
||||
bool logLineAlreadyExists(LogLine* line) const;
|
||||
|
||||
bool isNewer(LogLine* line) const;
|
||||
|
||||
/**
|
||||
* Remove the oldest line
|
||||
*/
|
||||
void removeOldestLogLine();
|
||||
|
||||
/**
|
||||
* Insert this line
|
||||
*/
|
||||
void insert(LogLine* line);
|
||||
|
||||
/**
|
||||
* Remove recent status on previously new log lines
|
||||
*/
|
||||
void removeRecentStatusOfLogLines();
|
||||
|
||||
LogViewModelPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
#endif //_LOG_VIEW_MODEL_H_
|
|
@ -1,336 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logViewSearchWidget.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QCheckBox>
|
||||
#include <QPalette>
|
||||
#include <QColor>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
#include <kiconloader.h>
|
||||
#include <kicon.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "logViewWidget.h"
|
||||
#include "logViewWidgetItem.h"
|
||||
|
||||
class LogViewSearchWidgetPrivate {
|
||||
public:
|
||||
|
||||
LogViewWidget* logViewWidget;
|
||||
|
||||
QColor searchLineBaseColor;
|
||||
QColor searchLineTextColor;
|
||||
|
||||
QTimer* messageHidingTimer;
|
||||
};
|
||||
|
||||
LogViewSearchWidget::LogViewSearchWidget() :
|
||||
d(new LogViewSearchWidgetPrivate()) {
|
||||
|
||||
d->logViewWidget = NULL;
|
||||
|
||||
setupUi(this);
|
||||
|
||||
//Get the searchLine base color to be able to restore it later
|
||||
d->searchLineBaseColor = searchLine->palette().color(QPalette::Base);
|
||||
d->searchLineTextColor = searchLine->palette().color(QPalette::Text);
|
||||
|
||||
//Default configuration of the hiding message timer
|
||||
d->messageHidingTimer = new QTimer(this);
|
||||
d->messageHidingTimer->setSingleShot(true);
|
||||
d->messageHidingTimer->setInterval(2000);
|
||||
connect(d->messageHidingTimer, SIGNAL(timeout()), this, SLOT(hideMessage()));
|
||||
|
||||
//The message widget is hidden by default
|
||||
hideMessage();
|
||||
|
||||
closeButton->setIcon(KIcon( QLatin1String( "dialog-close" )));
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(hide()));
|
||||
|
||||
next->setIcon(KIcon( QLatin1String( "arrow-down" )));
|
||||
connect(next, SIGNAL(clicked()), this, SLOT(findNext()));
|
||||
|
||||
previous->setIcon(KIcon( QLatin1String( "arrow-up" )));
|
||||
connect(previous, SIGNAL(clicked()), this, SLOT(findPrevious()));
|
||||
|
||||
searchLabel->setBuddy(searchLine);
|
||||
|
||||
connect(searchLine, SIGNAL(textEdited(QString)), this, SLOT(findFirst(QString)));
|
||||
connect(searchLine, SIGNAL(textEdited(QString)), this, SLOT(highlightAll()));
|
||||
|
||||
connect(searchLine, SIGNAL(returnPressed()), this, SLOT(findNext()));
|
||||
|
||||
connect(caseSensitive, SIGNAL(clicked()), this, SLOT(findFirst()));
|
||||
|
||||
connect(caseSensitive, SIGNAL(clicked()), this, SLOT(highlightAll()));
|
||||
connect(highlightAllButton, SIGNAL(clicked()), this, SLOT(highlightAll()));
|
||||
|
||||
findFirst(searchLine->text());
|
||||
|
||||
}
|
||||
|
||||
LogViewSearchWidget::~LogViewSearchWidget() {
|
||||
//widgets and timer are automatically deleted by Qt
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
void LogViewSearchWidget::displaySearch() {
|
||||
searchLine->setFocus();
|
||||
searchLine->setSelection(0, searchLine->text().length());
|
||||
show();
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::setTreeWidget(LogViewWidget* logViewWidget) {
|
||||
d->logViewWidget = logViewWidget;
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::findFirst(const QString & text) {
|
||||
bool textIsNotEmpty = !text.isEmpty();
|
||||
next->setEnabled(textIsNotEmpty);
|
||||
previous->setEnabled(textIsNotEmpty);
|
||||
if(textIsNotEmpty)
|
||||
findFirst();
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::findFirst() {
|
||||
internalFind(NULL, LogViewSearchWidget::Next);
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::findNext() {
|
||||
logDebug() << "Finding next";
|
||||
|
||||
LogViewWidgetItem* lastSelectedItem = d->logViewWidget->lastSelectedItem();
|
||||
internalFind(lastSelectedItem, LogViewSearchWidget::Next);
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::findPrevious() {
|
||||
logDebug() << "Finding previous";
|
||||
|
||||
LogViewWidgetItem* firstSelectedItem = d->logViewWidget->firstSelectedItem();
|
||||
internalFind(firstSelectedItem, LogViewSearchWidget::Previous);
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::internalFind(LogViewWidgetItem* fromItem, Direction direction) {
|
||||
if (searchLine->text().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItemIterator it(d->logViewWidget, QTreeWidgetItemIterator::NotHidden);
|
||||
initIterator(it, direction);
|
||||
|
||||
//Go to the selected position + 1 (if we already found an item)
|
||||
if (fromItem != NULL) {
|
||||
|
||||
while ( *it != NULL) {
|
||||
LogViewWidgetItem* item=static_cast<LogViewWidgetItem*> (*it);
|
||||
|
||||
if (item == fromItem) {
|
||||
iteratorJump(it, direction);
|
||||
break;
|
||||
}
|
||||
|
||||
iteratorJump(it, direction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Iterates to fromItem +1 to the last item of the list
|
||||
while ( *it != NULL) {
|
||||
LogViewWidgetItem* item=static_cast<LogViewWidgetItem*> (*it);
|
||||
|
||||
bool found = findItem(item);
|
||||
if (found == true)
|
||||
return;
|
||||
|
||||
iteratorJump(it, direction);
|
||||
}
|
||||
|
||||
//If we do not begin the search from the beginning, we do it now
|
||||
if (fromItem != NULL) {
|
||||
it = QTreeWidgetItemIterator(d->logViewWidget, QTreeWidgetItemIterator::NotHidden);
|
||||
initIterator(it, direction);
|
||||
|
||||
LogViewWidgetItem* item = NULL;
|
||||
while ( *it != NULL && item != fromItem) {
|
||||
item=static_cast<LogViewWidgetItem*> (*it);
|
||||
|
||||
bool found = findItem(item);
|
||||
if (found == true) {
|
||||
showMessage(i18n("Reached end of list."), QLatin1String( "dialog-information" ));
|
||||
return;
|
||||
}
|
||||
|
||||
iteratorJump(it, direction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setSearchLineNotFound(true);
|
||||
|
||||
}
|
||||
|
||||
inline void LogViewSearchWidget::initIterator(QTreeWidgetItemIterator& it, Direction direction) {
|
||||
//Previous direction : Go to the last item
|
||||
if (direction == LogViewSearchWidget::Previous) {
|
||||
QTreeWidgetItemIterator testedIterator(it);
|
||||
while (true) {
|
||||
++testedIterator;
|
||||
if ( *testedIterator == NULL ) {
|
||||
break;
|
||||
}
|
||||
|
||||
++it;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void LogViewSearchWidget::iteratorJump(QTreeWidgetItemIterator& it, Direction direction) {
|
||||
if (direction == LogViewSearchWidget::Next) {
|
||||
++it;
|
||||
}
|
||||
else {
|
||||
--it;
|
||||
}
|
||||
}
|
||||
|
||||
bool LogViewSearchWidget::compareItem(LogViewWidgetItem* item) {
|
||||
Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive;
|
||||
if (caseSensitive->isChecked()) {
|
||||
caseSensitivity = Qt::CaseSensitive;
|
||||
}
|
||||
|
||||
if (searchLine->text().isEmpty())
|
||||
return false;
|
||||
|
||||
if (item->logLine()->exportToText().contains(searchLine->text(), caseSensitivity)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LogViewSearchWidget::findItem(LogViewWidgetItem* item) {
|
||||
if (compareItem(item) == true) {
|
||||
unselectAll();
|
||||
|
||||
setSearchLineNotFound(false);
|
||||
item->setSelected(true);
|
||||
d->logViewWidget->setCurrentItem(item);
|
||||
d->logViewWidget->scrollToItem(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::setSearchLineNotFound(bool notFound) {
|
||||
QPalette palette = searchLine->palette();
|
||||
if (notFound == true) {
|
||||
palette.setColor(QPalette::Base, QColor(255, 102, 102)); //or Qt::red or QColor(235, 0, 0)
|
||||
palette.setColor(QPalette::Text, QColor(255, 255, 255));
|
||||
}
|
||||
else {
|
||||
palette.setColor(QPalette::Base, d->searchLineBaseColor);
|
||||
palette.setColor(QPalette::Text, d->searchLineTextColor);
|
||||
}
|
||||
|
||||
searchLine->setPalette(palette);
|
||||
|
||||
if (notFound==true)
|
||||
showMessage(i18n("Phrase not found."), QLatin1String( "dialog-error" ));
|
||||
else
|
||||
hideMessage();
|
||||
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::unselectAll() {
|
||||
QList<QTreeWidgetItem*> selectedItems = d->logViewWidget->selectedItems();
|
||||
foreach(QTreeWidgetItem* item, selectedItems) {
|
||||
item->setSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::showMessage(const QString& text, const QString& iconText) {
|
||||
message->setText(text);
|
||||
message->show();
|
||||
|
||||
messageIcon->setPixmap(SmallIcon(iconText));
|
||||
messageIcon->show();
|
||||
|
||||
d->messageHidingTimer->start();
|
||||
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::hideMessage() {
|
||||
message->hide();
|
||||
messageIcon->hide();
|
||||
|
||||
d->messageHidingTimer->stop();
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::highlightAll() {
|
||||
if (highlightAllButton->isChecked()) {
|
||||
unlightAll();
|
||||
|
||||
logDebug() << "Highlighting all";
|
||||
QTreeWidgetItemIterator it(d->logViewWidget, QTreeWidgetItemIterator::All);
|
||||
while ( *it != NULL ) {
|
||||
LogViewWidgetItem* item=static_cast<LogViewWidgetItem*> (*it);
|
||||
|
||||
if (compareItem(item) == true) {
|
||||
item->setBackground(item->columnCount()-1, QColor(255, 255, 16*8+11));
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
unlightAll();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LogViewSearchWidget::unlightAll() {
|
||||
logDebug() << "Unlighting all";
|
||||
|
||||
QTreeWidgetItemIterator it(d->logViewWidget, QTreeWidgetItemIterator::All);
|
||||
while ( *it != NULL ) {
|
||||
LogViewWidgetItem* item=static_cast<LogViewWidgetItem*> (*it);
|
||||
|
||||
//We retrieve the default column background using the first column data, where the background never changes
|
||||
item->setBackground(item->columnCount()-1, qvariant_cast<QBrush>(item->data(0, Qt::BackgroundRole)));
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_logViewSearchWidget.cpp"
|
|
@ -1,86 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_VIEW_SEARCH_WIDGET_H_
|
||||
#define _LOG_VIEW_SEARCH_WIDGET_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTreeWidgetItemIterator>
|
||||
|
||||
#include "ui_logViewSearchWidgetBase.h"
|
||||
|
||||
class LogViewWidget;
|
||||
class LogViewWidgetItem;
|
||||
|
||||
class LogViewSearchWidgetPrivate;
|
||||
|
||||
class LogViewSearchWidget : public QWidget, public Ui::LogViewSearchWidgetBase {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogViewSearchWidget();
|
||||
|
||||
~LogViewSearchWidget();
|
||||
|
||||
void setTreeWidget(LogViewWidget* logViewWidget);
|
||||
|
||||
public slots:
|
||||
void displaySearch();
|
||||
|
||||
void findFirst();
|
||||
|
||||
void findFirst(const QString &);
|
||||
void findNext();
|
||||
void findPrevious();
|
||||
|
||||
private slots:
|
||||
void hideMessage();
|
||||
|
||||
void highlightAll();
|
||||
|
||||
private:
|
||||
enum Direction {
|
||||
Next,
|
||||
Previous
|
||||
};
|
||||
Q_DECLARE_FLAGS(Directions, Direction)
|
||||
|
||||
void showMessage(const QString& text, const QString& iconText);
|
||||
|
||||
void internalFind(LogViewWidgetItem* fromItem, Direction direction);
|
||||
|
||||
void setSearchLineNotFound(bool notFound);
|
||||
void unselectAll();
|
||||
bool findItem(LogViewWidgetItem* item);
|
||||
|
||||
bool compareItem(LogViewWidgetItem* item);
|
||||
|
||||
void unlightAll();
|
||||
|
||||
inline void initIterator(QTreeWidgetItemIterator& it, Direction direction);
|
||||
inline void iteratorJump(QTreeWidgetItemIterator& it, Direction direction);
|
||||
|
||||
LogViewSearchWidgetPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
#endif //_LOG_VIEW_SEARCH_WIDGET_H_
|
|
@ -1,128 +0,0 @@
|
|||
<ui version="4.0" >
|
||||
<class>LogViewSearchWidgetBase</class>
|
||||
<widget class="QWidget" name="LogViewSearchWidgetBase" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>705</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeButton" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="searchLabel" >
|
||||
<property name="text" >
|
||||
<string>Find:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="searchLine" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="next" >
|
||||
<property name="text" >
|
||||
<string>&Next</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="previous" >
|
||||
<property name="text" >
|
||||
<string>&Previous</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="caseSensitive" >
|
||||
<property name="text" >
|
||||
<string>Match &case</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="highlightAllButton" >
|
||||
<property name="text" >
|
||||
<string>&Highlight all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="messageIcon" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="message" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,306 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logViewWidget.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QHeaderView>
|
||||
|
||||
#include <kicon.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include "logViewColumn.h"
|
||||
|
||||
#include "logViewWidgetItem.h"
|
||||
#include "logLine.h"
|
||||
#include "logViewModel.h"
|
||||
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
class LogViewWidgetPrivate {
|
||||
public:
|
||||
LogViewModel* logViewModel;
|
||||
|
||||
QActionGroup* headersTogglingActions;
|
||||
|
||||
};
|
||||
|
||||
LogViewWidget::LogViewWidget(QWidget* parent) :
|
||||
QTreeWidget(parent),
|
||||
d(new LogViewWidgetPrivate()) {
|
||||
|
||||
//TODO Add this setWhatsThis() to all columns each time they change
|
||||
//setWhatThis(i18n("<p>This is the main view of KSystemLog. It displays the last lines of the selected log. Please see the documentation to discovers the meaning of each icons and existing log.</p><p>Log lines in <b>bold</b> are the last added to the list.</p>"));
|
||||
|
||||
QStringList headerLabels;
|
||||
headerLabels.append(QLatin1String( "Date" ));
|
||||
headerLabels.append(QLatin1String( "Message" ));
|
||||
|
||||
d->logViewModel = new LogViewModel(this);
|
||||
d->headersTogglingActions = new QActionGroup(this);
|
||||
d->headersTogglingActions->setExclusive(false);
|
||||
connect(d->headersTogglingActions, SIGNAL(triggered(QAction*)), this, SLOT(toggleHeader(QAction*)));
|
||||
|
||||
setHeaderLabels(headerLabels);
|
||||
|
||||
//Header
|
||||
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
header()->setMovable(true);
|
||||
|
||||
setSortingEnabled(true);
|
||||
sortItems(0, Qt::AscendingOrder);
|
||||
|
||||
setAnimated(true);
|
||||
|
||||
setRootIsDecorated(false);
|
||||
|
||||
setAllColumnsShowFocus(true);
|
||||
|
||||
setAlternatingRowColors(true);
|
||||
|
||||
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
}
|
||||
|
||||
LogViewWidget::~LogViewWidget() {
|
||||
delete d->logViewModel;
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
void LogViewWidget::setColumns(const LogViewColumns& columns) {
|
||||
logDebug() << "Updating columns using " << columns << "...";
|
||||
|
||||
//First, delete all current columns
|
||||
setColumnCount(0);
|
||||
|
||||
setHeaderLabels(columns.toStringList());
|
||||
|
||||
sortItems(0, Qt::AscendingOrder);
|
||||
|
||||
//Remove previous header actions
|
||||
QListIterator<QAction*> it(d->headersTogglingActions->actions());
|
||||
it.toBack();
|
||||
while (it.hasPrevious()) {
|
||||
QAction* action = it.previous();
|
||||
|
||||
header()->removeAction( action );
|
||||
d->headersTogglingActions->removeAction( action );
|
||||
|
||||
delete action;
|
||||
}
|
||||
|
||||
//Add new actions
|
||||
int columnIndex = 0;
|
||||
|
||||
foreach(const LogViewColumn &column, columns.columns()) {
|
||||
QAction* action = new QAction(this);
|
||||
action->setText(column.columnName());
|
||||
//helloAction->setIcon(KIcon( QLatin1String( "media-playback-start" )));
|
||||
//helloAction->setShortcut(Qt::CTRL + Qt::Key_M);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(true);
|
||||
action->setToolTip(i18n("Display/Hide the '%1' column", column.columnName()));
|
||||
action->setData(QVariant(columnIndex));
|
||||
|
||||
d->headersTogglingActions->addAction(action);
|
||||
|
||||
++columnIndex;
|
||||
}
|
||||
|
||||
header()->addActions(d->headersTogglingActions->actions());
|
||||
|
||||
|
||||
emit columnsChanged(columns);
|
||||
|
||||
logDebug() << "Log View Widget updated...";
|
||||
|
||||
}
|
||||
|
||||
void LogViewWidget::resizeColumns() {
|
||||
//Resize all columns except the last one (which always take the last available space)
|
||||
for (int i=0; i<columnCount()-1; ++i) {
|
||||
resizeColumnToContents(i);
|
||||
}
|
||||
}
|
||||
|
||||
void LogViewWidget::selectAll() {
|
||||
if ( notHiddenItemCount()>0 )
|
||||
QTreeWidget::selectAll();
|
||||
}
|
||||
|
||||
int LogViewWidget::itemCount() const {
|
||||
return topLevelItemCount();
|
||||
}
|
||||
|
||||
QList<LogLine*> LogViewWidget::logLines() {
|
||||
QList<LogLine*> logLines;
|
||||
|
||||
QTreeWidgetItemIterator it(this);
|
||||
while (*it != NULL) {
|
||||
LogViewWidgetItem* item = static_cast<LogViewWidgetItem*>(*it);
|
||||
logLines.append(item->logLine());
|
||||
++it;
|
||||
}
|
||||
|
||||
return logLines;
|
||||
}
|
||||
|
||||
LogViewWidgetItem* LogViewWidget::findNewestItem() {
|
||||
LogViewWidgetItem* newestItem = NULL;
|
||||
|
||||
QTreeWidgetItemIterator it(this);
|
||||
while (*it != NULL) {
|
||||
LogViewWidgetItem* item = static_cast<LogViewWidgetItem*>(*it);
|
||||
if (newestItem==NULL || newestItem->logLine()->isOlderThan( *(item->logLine()) )) {
|
||||
newestItem = item;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
return newestItem;
|
||||
|
||||
}
|
||||
|
||||
LogViewWidgetItem* LogViewWidget::findItem(LogLine* searchedLogLine) {
|
||||
QTreeWidgetItemIterator it(this);
|
||||
while (*it != NULL) {
|
||||
LogViewWidgetItem* item = static_cast<LogViewWidgetItem*>(*it);
|
||||
if (item->logLine()->equals(*searchedLogLine))
|
||||
return item;
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QList<LogViewWidgetItem*> LogViewWidget::items() {
|
||||
QList<LogViewWidgetItem*> items;
|
||||
|
||||
QTreeWidgetItemIterator it(this);
|
||||
while (*it != NULL) {
|
||||
items.append(static_cast<LogViewWidgetItem*>(*it));
|
||||
++it;
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
LogViewModel* LogViewWidget::model() const {
|
||||
return d->logViewModel;
|
||||
}
|
||||
|
||||
bool LogViewWidget::hasItemsSelected() {
|
||||
return ( !selectedItems ().isEmpty() );
|
||||
}
|
||||
|
||||
LogViewWidgetItem* LogViewWidget::firstSelectedItem() {
|
||||
QTreeWidgetItemIterator it(this, QTreeWidgetItemIterator::Selected);
|
||||
|
||||
//Returns the first selected item or NULL is there is no item selected
|
||||
return static_cast<LogViewWidgetItem*> (*it);
|
||||
}
|
||||
|
||||
LogViewWidgetItem* LogViewWidget::lastSelectedItem() {
|
||||
QTreeWidgetItemIterator it(this, QTreeWidgetItemIterator::Selected);
|
||||
|
||||
QTreeWidgetItem* item=NULL;
|
||||
while (*it) {
|
||||
item=(*it);
|
||||
|
||||
it++;
|
||||
}
|
||||
|
||||
//Returns the last selected item or NULL is there is no item selected
|
||||
return static_cast<LogViewWidgetItem*>(item);
|
||||
}
|
||||
|
||||
|
||||
void LogViewWidget::expandAll() {
|
||||
QTreeWidgetItemIterator it(this);
|
||||
while (*it != NULL) {
|
||||
expandItem(*it);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void LogViewWidget::collapseAll() {
|
||||
QTreeWidgetItemIterator it(this);
|
||||
while (*it != NULL) {
|
||||
collapseItem(*it);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void LogViewWidget::toggleToolTip(bool enabled) {
|
||||
logDebug() << "Toggle tool tip ";
|
||||
|
||||
QTreeWidgetItemIterator it(this);
|
||||
while (*it != NULL) {
|
||||
LogViewWidgetItem* item = static_cast<LogViewWidgetItem*>(*it);
|
||||
item->toggleToolTip(enabled);
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LogViewWidget::scrollToNewestItem() {
|
||||
logDebug() << "Scrolling to the newest item...";
|
||||
|
||||
//Scroll to last item if requested
|
||||
if (KSystemLogConfig::newLinesDisplayed() == true) {
|
||||
LogViewWidgetItem* newestItem = findNewestItem();
|
||||
if (newestItem!=NULL) {
|
||||
scrollToItem(newestItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int LogViewWidget::notHiddenItemCount() {
|
||||
int count = 0;
|
||||
|
||||
QTreeWidgetItemIterator it(this, QTreeWidgetItemIterator::NotHidden);
|
||||
while (*it != NULL) {
|
||||
count++;
|
||||
++it;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
void LogViewWidget::toggleHeader(QAction* action) {
|
||||
logDebug() << "Toggling header";
|
||||
|
||||
int columnIndex = action->data().toInt();
|
||||
if (header()->isSectionHidden(columnIndex) == true)
|
||||
header()->setSectionHidden(columnIndex, false);
|
||||
else
|
||||
header()->setSectionHidden(columnIndex, true);
|
||||
}
|
||||
|
||||
|
||||
#include "moc_logViewWidget.cpp"
|
|
@ -1,87 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 LOG_VIEW_WIDGET_H
|
||||
#define LOG_VIEW_WIDGET_H
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QList>
|
||||
|
||||
#include "logViewColumns.h"
|
||||
|
||||
class LogViewWidgetItem;
|
||||
class LogViewModel;
|
||||
class LogLine;
|
||||
|
||||
class LogViewWidgetPrivate;
|
||||
|
||||
class LogViewWidget : public QTreeWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogViewWidget(QWidget* parent = NULL);
|
||||
|
||||
virtual ~LogViewWidget();
|
||||
virtual void selectAll();
|
||||
void setColumns(const LogViewColumns& columns);
|
||||
|
||||
int itemCount() const;
|
||||
int notHiddenItemCount();
|
||||
|
||||
QList<LogViewWidgetItem*> items();
|
||||
QList<LogLine*> logLines();
|
||||
|
||||
/**
|
||||
* Return the related widget item of this logLine or NULL if it has not been found
|
||||
*/
|
||||
LogViewWidgetItem* findItem(LogLine* logLine);
|
||||
|
||||
LogViewWidgetItem* findNewestItem();
|
||||
|
||||
LogViewModel* model() const;
|
||||
|
||||
bool hasItemsSelected();
|
||||
LogViewWidgetItem* firstSelectedItem();
|
||||
LogViewWidgetItem* lastSelectedItem();
|
||||
|
||||
void scrollToNewestItem();
|
||||
|
||||
void expandAll();
|
||||
void collapseAll();
|
||||
|
||||
void resizeColumns();
|
||||
|
||||
public slots:
|
||||
void toggleToolTip(bool enabled);
|
||||
|
||||
signals:
|
||||
void columnsChanged(const LogViewColumns& columns);
|
||||
|
||||
private slots:
|
||||
void toggleHeader(QAction* action);
|
||||
|
||||
private:
|
||||
LogViewWidgetPrivate* const d;
|
||||
};
|
||||
|
||||
|
||||
#endif //LOG_VIEW_WIDGET_H
|
|
@ -1,78 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logViewWidgetItem.h"
|
||||
|
||||
//Qt includes
|
||||
|
||||
#include <QtGui/qtreewidget.h>
|
||||
|
||||
|
||||
#include <QBrush>
|
||||
|
||||
//KDE includes
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
#include "logging.h"
|
||||
|
||||
#include "logModeItemBuilder.h"
|
||||
#include "logViewWidget.h"
|
||||
#include "logViewWidgetItem.h"
|
||||
|
||||
#include "logMode.h"
|
||||
|
||||
LogViewWidgetItem::LogViewWidgetItem(LogViewWidget* list, LogLine* l) :
|
||||
QTreeWidgetItem(list),
|
||||
line(l)
|
||||
{
|
||||
|
||||
//Add this item to the LogLine, to let the LogLine initialize it
|
||||
line->setItem(this);
|
||||
}
|
||||
|
||||
LogViewWidgetItem::~LogViewWidgetItem() {
|
||||
delete line;
|
||||
}
|
||||
|
||||
LogLine* LogViewWidgetItem::logLine() const {
|
||||
return line;
|
||||
}
|
||||
|
||||
void LogViewWidgetItem::toggleToolTip(bool displayed) {
|
||||
if (displayed == true)
|
||||
setToolTip(columnCount()-1, line->logMode()->itemBuilder()->createToolTipText(line));
|
||||
else
|
||||
setToolTip(columnCount()-1, QLatin1String( "" ));
|
||||
}
|
||||
|
||||
bool LogViewWidgetItem::operator<(const QTreeWidgetItem & other) const {
|
||||
int sortedColumn = treeWidget()->sortColumn();
|
||||
|
||||
//If we sort items by date (always the first column)
|
||||
if (sortedColumn == 0) {
|
||||
const LogViewWidgetItem& otherItem=static_cast<const LogViewWidgetItem&> (other);
|
||||
return line->isOlderThan( *(otherItem.logLine()) );
|
||||
}
|
||||
//Default sorting
|
||||
else {
|
||||
return text(sortedColumn) < other.text(sortedColumn);
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 LOG_VIEW_WIDGET_ITEM_H
|
||||
#define LOG_VIEW_WIDGET_ITEM_H
|
||||
|
||||
|
||||
#include <QtGui/qtreewidget.h>
|
||||
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "logLine.h"
|
||||
|
||||
class LogViewWidget;
|
||||
|
||||
class LogLine;
|
||||
|
||||
class LogViewWidgetItem: public QTreeWidgetItem {
|
||||
|
||||
public:
|
||||
LogViewWidgetItem(LogViewWidget* logViewWidget, LogLine* line);
|
||||
|
||||
~LogViewWidgetItem();
|
||||
|
||||
bool operator<(const QTreeWidgetItem & other) const;
|
||||
|
||||
LogLine* logLine() const;
|
||||
|
||||
void toggleToolTip(bool displayed);
|
||||
|
||||
|
||||
private:
|
||||
//TODO Move this log line to QTreeWidgetItem::data() method
|
||||
LogLine* line;
|
||||
|
||||
};
|
||||
|
||||
#endif // LOG_VIEW_WIDGET_ITEM_H
|
|
@ -1,79 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _KSYSTEMLOG_LOGGING_H_
|
||||
#define _KSYSTEMLOG_LOGGING_H_
|
||||
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
/**
|
||||
* Existing logging functions are :
|
||||
* - logDebug()
|
||||
* - logWarning()
|
||||
* - logError()
|
||||
* - logFatal()
|
||||
*
|
||||
* Use it like kDebug() function :
|
||||
* logDebug() << "Debug message" << list.size();
|
||||
*/
|
||||
|
||||
/*
|
||||
* Log prefix of any log message
|
||||
* The regexp removes the parameters and return type of the method prototype
|
||||
*
|
||||
* Example :
|
||||
* [LogManager::synchronizeLogView(547)] Synchronizing the model...
|
||||
*
|
||||
*/
|
||||
|
||||
#define KSYSTEM_LOG_KDEBUG_ID 87500
|
||||
|
||||
/**
|
||||
* Colored logging
|
||||
|
||||
#define LOG_DEFAULT_COLOR "\033[m"
|
||||
|
||||
#define LOG_DEBUG_COLOR "\033[37m"
|
||||
#define LOG_ERROR_COLOR "\033[31m"
|
||||
#define LOG_FATAL_COLOR "\033[31m"
|
||||
#define LOG_WARNING_COLOR "\033[33m"
|
||||
|
||||
#define LOG_PREFIX(logColor) logColor << "[" << __LINE__ << "]" << LOG_DEFAULT_COLOR
|
||||
|
||||
*/
|
||||
|
||||
#define LOG_DEFAULT_COLOR ""
|
||||
|
||||
#define LOG_DEBUG_COLOR ""
|
||||
#define LOG_ERROR_COLOR ""
|
||||
#define LOG_FATAL_COLOR ""
|
||||
#define LOG_WARNING_COLOR ""
|
||||
|
||||
#define LOG_PREFIX(logColor) ""
|
||||
|
||||
#define logDebug() kDebug(KSYSTEM_LOG_KDEBUG_ID) << LOG_PREFIX(LOG_DEBUG_COLOR)
|
||||
#define logWarning() kWarning(KSYSTEM_LOG_KDEBUG_ID) << LOG_PREFIX(LOG_WARNING_COLOR)
|
||||
#define logError() kError(KSYSTEM_LOG_KDEBUG_ID) << LOG_PREFIX(LOG_ERROR_COLOR)
|
||||
#define logFatal() kFatal(KSYSTEM_LOG_KDEBUG_ID) << LOG_PREFIX(LOG_FATAL_COLOR)
|
||||
|
||||
#endif // _KSYSTEMLOG_LOGGING_H_
|
|
@ -1,51 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "multipleActions.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
MultipleActions::MultipleActions(const KIcon& icon, const QString& text, QObject* parent) {
|
||||
action = new KActionMenu(icon, text, parent);
|
||||
|
||||
}
|
||||
|
||||
MultipleActions::~MultipleActions() {
|
||||
delete action;
|
||||
}
|
||||
|
||||
QList<QAction*> MultipleActions::innerActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
QAction* MultipleActions::actionMenu() {
|
||||
return action;
|
||||
}
|
||||
|
||||
void MultipleActions::addInnerAction(QAction* innerAction) {
|
||||
action->addAction(innerAction);
|
||||
actions.append(innerAction);
|
||||
|
||||
}
|
||||
|
||||
#include "moc_multipleActions.cpp"
|
|
@ -1,68 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _MULTIPLE_ACTIONS_H_
|
||||
#define _MULTIPLE_ACTIONS_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
#include <kicon.h>
|
||||
#include <kactionmenu.h>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "logModeAction.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
/**
|
||||
* This class is used by LogModeFactory to provide multiple actions
|
||||
* and be able to retrieve them when necessary, using actions().
|
||||
* This method will return QAction added using addInnerAction().
|
||||
*/
|
||||
class MultipleActions : public LogModeAction {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MultipleActions(const KIcon& icon, const QString& text, QObject* parent);
|
||||
|
||||
virtual ~MultipleActions();
|
||||
|
||||
QList<QAction*> innerActions();
|
||||
|
||||
QAction* actionMenu();
|
||||
|
||||
/**
|
||||
* This method is not called addAction() to avoid name collision with
|
||||
* parent class
|
||||
*/
|
||||
void addInnerAction(QAction* action);
|
||||
|
||||
private:
|
||||
QList<QAction*> actions;
|
||||
|
||||
KActionMenu* action;
|
||||
};
|
||||
|
||||
#endif // _MULTIPLE_ACTIONS_H_
|
|
@ -1,238 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "processOutputLogFileReader.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kurl.h>
|
||||
|
||||
#include "logFileReader.h"
|
||||
#include "logFileReaderPrivate.h"
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
|
||||
class ProcessOutputLogFileReaderPrivate : public LogFileReaderPrivate {
|
||||
|
||||
public:
|
||||
long previousLinesCount;
|
||||
|
||||
QTimer processUpdater;
|
||||
|
||||
QProcess* process;
|
||||
|
||||
QString buffer;
|
||||
QStringList availableStandardOutput;
|
||||
};
|
||||
|
||||
|
||||
ProcessOutputLogFileReader::ProcessOutputLogFileReader(const LogFile& logFile) :
|
||||
LogFileReader(*new ProcessOutputLogFileReaderPrivate(), logFile) {
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
ProcessOutputLogFileReader::ProcessOutputLogFileReader(ProcessOutputLogFileReaderPrivate& dd, const LogFile& logFile) :
|
||||
LogFileReader(dd, logFile) {
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
ProcessOutputLogFileReader::~ProcessOutputLogFileReader() {
|
||||
//d pointer is deleted by the parent class
|
||||
}
|
||||
|
||||
void ProcessOutputLogFileReader::init() {
|
||||
Q_D(ProcessOutputLogFileReader);
|
||||
|
||||
//Init current file position
|
||||
d->previousLinesCount = 0;
|
||||
d->availableStandardOutput.clear();
|
||||
d->process = NULL;
|
||||
|
||||
d->processUpdater.setInterval(PROCESS_OUTPUT_UPDATER_INTERVAL);
|
||||
connect(&(d->processUpdater), SIGNAL(timeout()), this, SLOT(startProcess()));
|
||||
|
||||
logDebug() << "Using process name " << d->logFile.url().path();
|
||||
}
|
||||
|
||||
void ProcessOutputLogFileReader::watchFile(bool enable) {
|
||||
Q_D(ProcessOutputLogFileReader);
|
||||
|
||||
if (enable == true) {
|
||||
logDebug() << "Monitoring process : " << d->logFile.url().path();
|
||||
|
||||
//Reinit current file position
|
||||
d->previousLinesCount = 0;
|
||||
|
||||
//Launch the timer
|
||||
d->processUpdater.start();
|
||||
|
||||
//Launch immediately the process updater
|
||||
startProcess();
|
||||
}
|
||||
else {
|
||||
//Stop regularly start process
|
||||
d->processUpdater.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessOutputLogFileReader::startProcess() {
|
||||
logDebug() << "Starting process...";
|
||||
|
||||
Q_D(ProcessOutputLogFileReader);
|
||||
|
||||
if (d->logFile.url().isValid()==false) {
|
||||
QString message(i18n("This file is not valid. Please adjust it in the settings of KSystemLog."));
|
||||
emit errorOccured(i18n("File Does Not Exist"), message);
|
||||
emit statusBarChanged(message);
|
||||
}
|
||||
|
||||
logDebug() << "Starting process...";
|
||||
|
||||
d->process = new QProcess();
|
||||
connect(d->process, SIGNAL(readyReadStandardOutput()), this, SLOT(logFileModified()));
|
||||
connect(d->process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(emitProcessOutput(int,QProcess::ExitStatus)));
|
||||
|
||||
d->process->start(d->logFile.url().path(), QIODevice::ReadOnly | QIODevice::Text);
|
||||
|
||||
d->process->waitForStarted();
|
||||
|
||||
logDebug() << "Process started";
|
||||
}
|
||||
|
||||
void ProcessOutputLogFileReader::closeProcess() {
|
||||
logDebug() << "Closing process...";
|
||||
|
||||
Q_D(ProcessOutputLogFileReader);
|
||||
|
||||
//Get the size file for the next calculation
|
||||
d->previousLinesCount = d->availableStandardOutput.count();
|
||||
logDebug() << "New lines count : " << d->previousLinesCount << " (" << d->logFile.url().path() << ")";
|
||||
|
||||
d->availableStandardOutput.clear();
|
||||
|
||||
if(d->process) {
|
||||
d->process->close();
|
||||
delete d->process;
|
||||
d->process = NULL;
|
||||
}
|
||||
|
||||
logDebug() << "Process closed";
|
||||
}
|
||||
|
||||
void ProcessOutputLogFileReader::emitProcessOutput(int /*exitCode*/, QProcess::ExitStatus exitStatus) {
|
||||
Q_D(ProcessOutputLogFileReader);
|
||||
|
||||
//First commit last lines of the buffer to the line list
|
||||
emptyBuffer();
|
||||
|
||||
logDebug() << "Process terminated" << d->previousLinesCount << "previously /" << d->availableStandardOutput.count() << "currently";
|
||||
|
||||
if (exitStatus==QProcess::CrashExit) {
|
||||
QString message(i18n("The process '%1' crashed.", d->logFile.url().path()));
|
||||
emit errorOccured(i18n("Process Crashed"), message);
|
||||
emit statusBarChanged(message);
|
||||
}
|
||||
|
||||
// If there is no new lines
|
||||
if (d->previousLinesCount == d->availableStandardOutput.count()) {
|
||||
/*
|
||||
//Emit an empty log lines list
|
||||
emit contentChanged(this, false, QStringList());
|
||||
*/
|
||||
}
|
||||
// If there are new lines in the file, insert only them or this is the first time we read this file
|
||||
else if (d->previousLinesCount!=0 && d->previousLinesCount <= d->availableStandardOutput.count()) {
|
||||
logDebug() << "Reading from line " << d->previousLinesCount << " (" << d->logFile.url().path() << ")";
|
||||
|
||||
QStringList newOutputs;
|
||||
|
||||
int index = d->previousLinesCount - 1;
|
||||
while (index < d->availableStandardOutput.count()) {
|
||||
newOutputs.append(d->availableStandardOutput.at(index));
|
||||
|
||||
++index;
|
||||
}
|
||||
|
||||
logDebug() << "Retrieving a part of the file...";
|
||||
|
||||
emit contentChanged(this, Analyzer::UpdatingRead, newOutputs);
|
||||
|
||||
}
|
||||
// Else reread all lines, clear log list
|
||||
else {
|
||||
logDebug() << "New process or process already read. Reading entire content";
|
||||
|
||||
emit contentChanged(this, Analyzer::FullRead, d->availableStandardOutput);
|
||||
|
||||
}
|
||||
|
||||
closeProcess();
|
||||
|
||||
}
|
||||
|
||||
void ProcessOutputLogFileReader::logFileModified() {
|
||||
Q_D(ProcessOutputLogFileReader);
|
||||
|
||||
logDebug() << "Content available on process output...";
|
||||
|
||||
//New added lines
|
||||
QByteArray bytesOutput = d->process->readAllStandardOutput();
|
||||
d->buffer.append(QLatin1String(bytesOutput));
|
||||
|
||||
//Parse buffer
|
||||
int endLinePos = d->buffer.indexOf(QLatin1String( "\n" ));
|
||||
forever {
|
||||
if (endLinePos==-1)
|
||||
break;
|
||||
|
||||
//Add the new found lines and
|
||||
d->availableStandardOutput.append(d->buffer.left(endLinePos));
|
||||
d->buffer.remove(0, endLinePos+1);
|
||||
|
||||
endLinePos = d->buffer.indexOf(QLatin1String( "\n" ));
|
||||
}
|
||||
|
||||
logDebug() << "Received a total of" << d->availableStandardOutput.count() << "new lines";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The buffer could contains some last characters that are added at last
|
||||
* (Normally useless)
|
||||
*/
|
||||
void ProcessOutputLogFileReader::emptyBuffer() {
|
||||
Q_D(ProcessOutputLogFileReader);
|
||||
|
||||
if (d->buffer.isEmpty() == false) {
|
||||
logWarning() << "Buffer was not empty !!";
|
||||
d->availableStandardOutput.append(d->buffer);
|
||||
d->buffer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_processOutputLogFileReader.cpp"
|
|
@ -1,73 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _PROCESS_OUTPUT_LOG_FILE_READER_H_
|
||||
#define _PROCESS_OUTPUT_LOG_FILE_READER_H_
|
||||
|
||||
#define PROCESS_OUTPUT_UPDATER_INTERVAL 10000
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
#include "logFile.h"
|
||||
|
||||
#include "logFileReader.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
class ProcessOutputLogFileReaderPrivate;
|
||||
|
||||
class ProcessOutputLogFileReader : public LogFileReader {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
ProcessOutputLogFileReader(const LogFile& logFile);
|
||||
|
||||
virtual ~ProcessOutputLogFileReader();
|
||||
|
||||
void watchFile(bool enable);
|
||||
|
||||
void setPreviousFilePosition(long previousFilePosition);
|
||||
|
||||
private slots:
|
||||
void startProcess();
|
||||
|
||||
void logFileModified();
|
||||
|
||||
void emitProcessOutput(int, QProcess::ExitStatus);
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
void closeProcess();
|
||||
|
||||
void emptyBuffer();
|
||||
|
||||
protected:
|
||||
ProcessOutputLogFileReader(ProcessOutputLogFileReaderPrivate& dd, const LogFile& logFile);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(ProcessOutputLogFileReader)
|
||||
|
||||
};
|
||||
|
||||
#endif // _PROCESS_OUTPUT_LOG_FILE_READER_H_
|
|
@ -1,57 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "simpleAction.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
SimpleAction::SimpleAction(const QIcon& icon, const QString& text, QObject* parent) {
|
||||
action = new QAction(icon, text, parent);
|
||||
}
|
||||
|
||||
SimpleAction::SimpleAction(QAction* originAction, QObject* parent) {
|
||||
|
||||
action = new QAction(parent);
|
||||
action->setIcon(originAction->icon());
|
||||
action->setText(originAction->text());
|
||||
action->setData(originAction->data());
|
||||
action->setToolTip(originAction->toolTip());
|
||||
action->setWhatsThis(originAction->whatsThis());
|
||||
}
|
||||
|
||||
SimpleAction::~SimpleAction() {
|
||||
delete action;
|
||||
}
|
||||
|
||||
QList<QAction*> SimpleAction::innerActions() {
|
||||
QList<QAction*> actions;
|
||||
actions.append(action);
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
QAction* SimpleAction::actionMenu() {
|
||||
return action;
|
||||
}
|
||||
|
||||
#include "moc_simpleAction.cpp"
|
|
@ -1,54 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _SIMPLE_ACTIONS_H_
|
||||
#define _SIMPLE_ACTIONS_H_
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QIcon>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "logModeAction.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
class SimpleAction : public LogModeAction {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SimpleAction(const QIcon& icon, const QString& text, QObject* parent);
|
||||
|
||||
SimpleAction(QAction* action, QObject* parent);
|
||||
|
||||
virtual ~SimpleAction();
|
||||
|
||||
QList<QAction*> innerActions();
|
||||
|
||||
QAction* actionMenu();
|
||||
|
||||
private:
|
||||
QAction* action;
|
||||
};
|
||||
|
||||
#endif // _SIMPLE_ACTIONS_H_
|
|
@ -1,230 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "view.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
#include <QtGui/qevent.h>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <kiconloader.h>
|
||||
#include <kicon.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include "logViewWidget.h"
|
||||
|
||||
#include "logViewFilterWidget.h"
|
||||
#include "logViewSearchWidget.h"
|
||||
|
||||
#include "logLine.h"
|
||||
#include "logViewColumn.h"
|
||||
#include "logViewColumns.h"
|
||||
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
#include "loadingBar.h"
|
||||
|
||||
class ViewPrivate {
|
||||
|
||||
public:
|
||||
/*
|
||||
* Log view
|
||||
*/
|
||||
LogViewWidget* logViewWidget;
|
||||
|
||||
/**
|
||||
* Filter widget
|
||||
*/
|
||||
LogViewFilterWidget* logViewFilterWidget;
|
||||
|
||||
/**
|
||||
* Search widget
|
||||
*/
|
||||
LogViewSearchWidget* logViewSearchWidget;
|
||||
|
||||
LoadingBar* loadingBar;
|
||||
};
|
||||
|
||||
View::View(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
d(new ViewPrivate()) {
|
||||
|
||||
d->logViewWidget = NULL;
|
||||
|
||||
QVBoxLayout* topLayout = new QVBoxLayout();
|
||||
topLayout->setMargin(2);
|
||||
topLayout->setSpacing(2);
|
||||
this->setLayout(topLayout);
|
||||
|
||||
d->logViewFilterWidget = new LogViewFilterWidget();
|
||||
connect(d->logViewFilterWidget->filterLine(), SIGNAL(treeWidgetUpdated()), this, SIGNAL(searchFilterChanged()));
|
||||
connect(d->logViewFilterWidget->filterLine(), SIGNAL(treeWidgetUpdated()), this, SLOT(unselectHiddenItems()));
|
||||
|
||||
d->logViewFilterWidget->setVisible(KSystemLogConfig::toggleFilterBar());
|
||||
|
||||
topLayout->addWidget(d->logViewFilterWidget);
|
||||
|
||||
d->logViewWidget=new LogViewWidget(this);
|
||||
connect(d->logViewWidget, SIGNAL(columnsChanged(LogViewColumns)), d->logViewFilterWidget, SLOT(updateFilterColumns(LogViewColumns)));
|
||||
|
||||
d->logViewFilterWidget->filterLine()->setTreeWidget(d->logViewWidget);
|
||||
topLayout->addWidget(d->logViewWidget);
|
||||
|
||||
|
||||
d->logViewSearchWidget = new LogViewSearchWidget();
|
||||
d->logViewSearchWidget->setTreeWidget(d->logViewWidget);
|
||||
|
||||
//The search line is hidden by default
|
||||
d->logViewSearchWidget->hide();
|
||||
|
||||
topLayout->addWidget(d->logViewSearchWidget);
|
||||
|
||||
d->loadingBar = new LoadingBar();
|
||||
connect(d->loadingBar, SIGNAL(displayed(bool)), this, SLOT(displayLoadingBar(bool)));
|
||||
|
||||
topLayout->addWidget(d->loadingBar);
|
||||
d->loadingBar->hide();
|
||||
|
||||
//Accept Drag and Drop
|
||||
setAcceptDrops(true);
|
||||
|
||||
}
|
||||
|
||||
View::~View() {
|
||||
//All widgets are deleted automatically by Qt
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
LogViewWidget* View::logViewWidget() const {
|
||||
return d->logViewWidget;
|
||||
}
|
||||
|
||||
LoadingBar* View::loadingBar() const {
|
||||
return d->loadingBar;
|
||||
}
|
||||
|
||||
void View::displayLoadingBar(bool display) {
|
||||
if (display == true) {
|
||||
d->logViewWidget->hide();
|
||||
d->logViewSearchWidget->hide();
|
||||
d->logViewFilterWidget->hide();
|
||||
|
||||
d->loadingBar->show();
|
||||
}
|
||||
else {
|
||||
d->logViewWidget->show();
|
||||
d->logViewFilterWidget->setVisible(KSystemLogConfig::toggleFilterBar());
|
||||
d->logViewFilterWidget->filterLine()->updateSearch();
|
||||
//No need to redisplay the search bar
|
||||
|
||||
d->loadingBar->hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void View::toggleLogViewFilter(bool display) {
|
||||
if (display == true) {
|
||||
d->logViewFilterWidget->show();
|
||||
} else {
|
||||
d->logViewFilterWidget->filterLine()->clear();
|
||||
d->logViewFilterWidget->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void View::toggleLogViewSearch(bool display) {
|
||||
if (display == true)
|
||||
d->logViewSearchWidget->displaySearch();
|
||||
else
|
||||
d->logViewSearchWidget->hide();
|
||||
}
|
||||
|
||||
LogViewSearchWidget* View::logViewSearch() const {
|
||||
return d->logViewSearchWidget;
|
||||
}
|
||||
|
||||
void View::unselectHiddenItems() {
|
||||
QTreeWidgetItemIterator it(d->logViewWidget, QTreeWidgetItemIterator::Selected);
|
||||
|
||||
while ( *it != NULL) {
|
||||
QTreeWidgetItem* item = *it;
|
||||
|
||||
if (item->isHidden()) {
|
||||
item->setSelected(false);
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
QSize View::sizeHint() const {
|
||||
return QSize(500, 500);
|
||||
}
|
||||
|
||||
void View::dropEvent(QDropEvent* event) {
|
||||
KUrl::List urls = KUrl::List::fromMimeData( event->mimeData() );
|
||||
|
||||
//If URLs have been dropped
|
||||
if ( ! urls.isEmpty() ) {
|
||||
|
||||
emit droppedUrls(urls);
|
||||
}
|
||||
}
|
||||
|
||||
void View::dragEnterEvent(QDragEnterEvent* event) {
|
||||
KUrl::List urls = KUrl::List::fromMimeData( event->mimeData() );
|
||||
|
||||
//If URLs have been dropped
|
||||
if (urls.isEmpty() ) {
|
||||
logWarning() << "Empty drag and drop";
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (const KUrl &url, urls) {
|
||||
QFileInfo fileInfo(url.path());
|
||||
|
||||
//TODO Add a recognition of binary files (using the Url mimetype) and refuse them
|
||||
|
||||
if (fileInfo.isReadable() == false) {
|
||||
logWarning() << "The drag and dropped file is not readable " << url.path();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fileInfo.isDir()) {
|
||||
logWarning() << "Tried to drag and drop a directory " << url.path();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Accept those urls
|
||||
event->acceptProposedAction();
|
||||
|
||||
}
|
||||
|
||||
#include "moc_view.cpp"
|
|
@ -1,92 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 VIEW_H
|
||||
#define VIEW_H
|
||||
|
||||
//Qt includes
|
||||
#include <QWidget>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "logViewColumn.h"
|
||||
#include "logViewColumns.h"
|
||||
|
||||
#include <QDropEvent>
|
||||
#include <QDragEnterEvent>
|
||||
|
||||
|
||||
class LoadingBar;
|
||||
|
||||
class LogViewWidget;
|
||||
class LogViewSearchWidget;
|
||||
|
||||
class ViewPrivate;
|
||||
|
||||
class View : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit View(QWidget *parent);
|
||||
|
||||
virtual ~View();
|
||||
|
||||
LogViewWidget* logViewWidget() const;
|
||||
|
||||
LoadingBar* loadingBar() const;
|
||||
|
||||
LogViewSearchWidget* logViewSearch() const;
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
public slots:
|
||||
void displayLoadingBar(bool display);
|
||||
|
||||
void toggleLogViewFilter(bool display);
|
||||
void toggleLogViewSearch(bool display);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Method which contains the action to do when receiving a drag and drop event
|
||||
*/
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
|
||||
/**
|
||||
* Method which accepts
|
||||
*/
|
||||
void dropEvent(QDropEvent *event);
|
||||
|
||||
private slots:
|
||||
void unselectHiddenItems();
|
||||
|
||||
signals:
|
||||
void searchFilterChanged();
|
||||
|
||||
void droppedUrls(const KUrl::List& urls);
|
||||
|
||||
private:
|
||||
ViewPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
#endif // VIEW_H
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "logModePluginsLoader.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "logging.h"
|
||||
#include "defaults.h"
|
||||
|
||||
//Includes existing log modes
|
||||
#include "openFactory.h"
|
||||
|
||||
#include "systemFactory.h"
|
||||
|
||||
#include "kernelFactory.h"
|
||||
#include "xorgFactory.h"
|
||||
#include "cronFactory.h"
|
||||
#include "daemonFactory.h"
|
||||
#include "authenticationFactory.h"
|
||||
#include "apacheFactory.h"
|
||||
#include "cupsFactory.h"
|
||||
#include "postfixFactory.h"
|
||||
#include "acpidFactory.h"
|
||||
#include "xsessionFactory.h"
|
||||
#include "sambaFactory.h"
|
||||
|
||||
|
||||
LogModePluginsLoader::LogModePluginsLoader(QWidget* parent) :
|
||||
parent(parent) {
|
||||
|
||||
}
|
||||
|
||||
LogModePluginsLoader::~LogModePluginsLoader() {
|
||||
|
||||
}
|
||||
|
||||
void LogModePluginsLoader::loadPlugins() {
|
||||
//Open Log mode needs the current window to display error messages and open dialogs
|
||||
Globals::instance()->registerLogModeFactory(new OpenLogModeFactory(parent));
|
||||
|
||||
//System
|
||||
Globals::instance()->registerLogModeFactory(new SystemLogModeFactory());
|
||||
|
||||
//Kernel
|
||||
Globals::instance()->registerLogModeFactory(new KernelLogModeFactory());
|
||||
|
||||
//Authentication
|
||||
Globals::instance()->registerLogModeFactory(new AuthenticationLogModeFactory());
|
||||
|
||||
//Daemon
|
||||
Globals::instance()->registerLogModeFactory(new DaemonLogModeFactory());
|
||||
|
||||
//Xorg
|
||||
Globals::instance()->registerLogModeFactory(new XorgLogModeFactory());
|
||||
|
||||
//Cron
|
||||
Globals::instance()->registerLogModeFactory(new CronLogModeFactory());
|
||||
|
||||
//Apache
|
||||
Globals::instance()->registerLogModeFactory(new ApacheLogModeFactory());
|
||||
|
||||
//Postfix
|
||||
Globals::instance()->registerLogModeFactory(new PostfixLogModeFactory());
|
||||
|
||||
//Cups
|
||||
Globals::instance()->registerLogModeFactory(new CupsLogModeFactory());
|
||||
|
||||
//Samba
|
||||
Globals::instance()->registerLogModeFactory(new SambaLogModeFactory());
|
||||
|
||||
//Acpid
|
||||
Globals::instance()->registerLogModeFactory(new AcpidLogModeFactory());
|
||||
|
||||
//XSession
|
||||
Globals::instance()->registerLogModeFactory(new XSessionLogModeFactory());
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOG_MODE_PLUGINS_LOADER_H_
|
||||
#define _LOG_MODE_PLUGINS_LOADER_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class LogModePluginsLoader: public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogModePluginsLoader(QWidget* parent);
|
||||
|
||||
~LogModePluginsLoader();
|
||||
|
||||
void loadPlugins();
|
||||
|
||||
private:
|
||||
QWidget* parent;
|
||||
};
|
||||
|
||||
#endif //_LOG_MODE_PLUGINS_LOADER_H_
|
|
@ -1,262 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "loggerDialog.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
|
||||
//Project includes
|
||||
#include "logging.h"
|
||||
|
||||
#include "logLevel.h"
|
||||
#include "globals.h"
|
||||
|
||||
class LoggerDialogPrivate {
|
||||
public:
|
||||
QMap<QString, QString> facilities;
|
||||
|
||||
QMap<QString, QString> priorities;
|
||||
QMap<QString, QPixmap> priorityIcons;
|
||||
|
||||
};
|
||||
|
||||
LoggerDialog::LoggerDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
d(new LoggerDialogPrivate()) {
|
||||
|
||||
setupUi(this);
|
||||
|
||||
connect(buttonOK, SIGNAL(clicked()), this, SLOT(sendMessage()));
|
||||
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(hide()));
|
||||
|
||||
connect(tagActivation, SIGNAL(toggled(bool)), this, SLOT(changeTagActivation(bool)));
|
||||
connect(fileActivation, SIGNAL(toggled(bool)), this, SLOT(changeFileActivation(bool)));
|
||||
connect(messageActivation, SIGNAL(toggled(bool)), this, SLOT(changeMessageActivation(bool)));
|
||||
|
||||
|
||||
connect(file, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
|
||||
connect(message, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
|
||||
connect(tag, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
|
||||
|
||||
buildMaps();
|
||||
|
||||
//Fill the priority ComboBox
|
||||
QList<QString> prioKeys(d->priorities.keys());
|
||||
|
||||
QList<QString>::Iterator itPriority;
|
||||
for (itPriority=prioKeys.begin(); itPriority!=prioKeys.end(); ++itPriority) {
|
||||
priority->addItem(d->priorityIcons[*itPriority], *itPriority);
|
||||
}
|
||||
|
||||
|
||||
//Select the right priority
|
||||
for (int i=0; i<priority->count(); ++i) {
|
||||
if (priority->itemText(i)==Globals::instance()->noticeLogLevel()->name()) {
|
||||
priority->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Fill the priority ComboBox
|
||||
QList<QString> keys(d->facilities.keys());
|
||||
|
||||
QList<QString>::Iterator itFacility;
|
||||
for (itFacility=keys.begin(); itFacility!=keys.end(); ++itFacility) {
|
||||
facility->addItem(*itFacility);
|
||||
}
|
||||
|
||||
//Select the right facility
|
||||
for (int i=0; i<facility->count(); ++i) {
|
||||
if (facility->itemText(i)==i18n("User")) {
|
||||
facility->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
tag->setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
LoggerDialog::~LoggerDialog() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
void LoggerDialog::initialize() {
|
||||
logDebug() << "Initializing Logger dialog...";
|
||||
|
||||
message->clear();
|
||||
message->setFocus();
|
||||
}
|
||||
|
||||
void LoggerDialog::buildMaps() {
|
||||
|
||||
//Fill the facility map
|
||||
d->facilities[i18n("Authentication")]=QLatin1String( "auth" );
|
||||
d->facilities[i18n("Private Authentication")]=QLatin1String( "authpriv" );
|
||||
d->facilities[i18n("Cron")]=QLatin1String( "cron" );
|
||||
d->facilities[i18n("Daemon")]=QLatin1String( "daemon" );
|
||||
d->facilities[i18n("FTP")]=QLatin1String( "ftp" );
|
||||
d->facilities[i18n("Kernel")]=QLatin1String( "kern" );
|
||||
d->facilities[i18n("LPR")]=QLatin1String( "lpr" );
|
||||
d->facilities[i18n("Mail")]=QLatin1String( "mail" );
|
||||
d->facilities[i18n("News")]=QLatin1String( "news" );
|
||||
d->facilities[i18n("Syslog")]=QLatin1String( "syslog" );
|
||||
d->facilities[i18n("User")]=QLatin1String( "user" );
|
||||
d->facilities[i18n("UUCP")]=QLatin1String( "uucp" );
|
||||
|
||||
d->facilities[i18n("Local 0")]=QLatin1String( "local0" );
|
||||
d->facilities[i18n("Local 1")]=QLatin1String( "local1" );
|
||||
d->facilities[i18n("Local 2")]=QLatin1String( "local2" );
|
||||
d->facilities[i18n("Local 3")]=QLatin1String( "local3" );
|
||||
d->facilities[i18n("Local 4")]=QLatin1String( "local4" );
|
||||
d->facilities[i18n("Local 5")]=QLatin1String( "local5" );
|
||||
d->facilities[i18n("Local 6")]=QLatin1String( "local6" );
|
||||
d->facilities[i18n("Local 7")]=QLatin1String( "local7" );
|
||||
|
||||
//Fill the priority map
|
||||
d->priorities[Globals::instance()->debugLogLevel()->name()]=QLatin1String( "debug" );
|
||||
d->priorities[Globals::instance()->informationLogLevel()->name()]=QLatin1String( "info" );
|
||||
d->priorities[Globals::instance()->noticeLogLevel()->name()]=QLatin1String( "notice" );
|
||||
d->priorities[Globals::instance()->warningLogLevel()->name()]=QLatin1String( "warning" );
|
||||
d->priorities[Globals::instance()->errorLogLevel()->name()]=QLatin1String( "err" );
|
||||
d->priorities[Globals::instance()->criticalLogLevel()->name()]=QLatin1String( "crit" );
|
||||
d->priorities[Globals::instance()->alertLogLevel()->name()]=QLatin1String( "alert" );
|
||||
d->priorities[Globals::instance()->emergencyLogLevel()->name()]=QLatin1String( "emerg" );
|
||||
|
||||
//Fill the priority icon map
|
||||
d->priorityIcons[Globals::instance()->debugLogLevel()->name()]=Globals::instance()->debugLogLevel()->icon();
|
||||
d->priorityIcons[Globals::instance()->informationLogLevel()->name()]=Globals::instance()->informationLogLevel()->icon();
|
||||
d->priorityIcons[Globals::instance()->noticeLogLevel()->name()]=Globals::instance()->noticeLogLevel()->icon();
|
||||
d->priorityIcons[Globals::instance()->warningLogLevel()->name()]=Globals::instance()->warningLogLevel()->icon();
|
||||
d->priorityIcons[Globals::instance()->errorLogLevel()->name()]=Globals::instance()->errorLogLevel()->icon();
|
||||
d->priorityIcons[Globals::instance()->criticalLogLevel()->name()]=Globals::instance()->criticalLogLevel()->icon();
|
||||
d->priorityIcons[Globals::instance()->alertLogLevel()->name()]=Globals::instance()->alertLogLevel()->icon();
|
||||
d->priorityIcons[Globals::instance()->emergencyLogLevel()->name()]=Globals::instance()->emergencyLogLevel()->icon();
|
||||
|
||||
}
|
||||
|
||||
void LoggerDialog::textChanged() {
|
||||
if (fileActivation->isChecked() && file->url().isEmpty()) {
|
||||
buttonOK->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tagActivation->isChecked() && tag->text().isEmpty()) {
|
||||
buttonOK->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (messageActivation->isChecked() && message->text().isEmpty()) {
|
||||
buttonOK->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
buttonOK->setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
void LoggerDialog::changeTagActivation(bool activation) {
|
||||
tag->setEnabled(activation);
|
||||
|
||||
textChanged();
|
||||
}
|
||||
|
||||
void LoggerDialog::changeFileActivation(bool activation) {
|
||||
file->setEnabled(activation);
|
||||
|
||||
textChanged();
|
||||
}
|
||||
|
||||
void LoggerDialog::changeMessageActivation(bool activation) {
|
||||
message->setEnabled(activation);
|
||||
|
||||
textChanged();
|
||||
}
|
||||
|
||||
|
||||
void LoggerDialog::sendMessage() {
|
||||
|
||||
QProcess process;
|
||||
|
||||
QStringList arguments;
|
||||
|
||||
if (useProcessIdentifier->isChecked()) {
|
||||
arguments << QLatin1String( "-i" );
|
||||
}
|
||||
|
||||
if (tagActivation->isChecked()) {
|
||||
arguments << QLatin1String( "-t" );
|
||||
|
||||
arguments << tag->text();
|
||||
}
|
||||
|
||||
QString prioritySelected=priority->currentText();
|
||||
|
||||
if (prioritySelected!=Globals::instance()->noLogLevel()->name()) {
|
||||
arguments << QLatin1String( "-p" );
|
||||
|
||||
QString p(d->facilities[facility->currentText()]);
|
||||
p+=QLatin1Char( '.' );
|
||||
p+=d->priorities[priority->currentText()];
|
||||
|
||||
arguments << p;
|
||||
}
|
||||
|
||||
//If we read the content of a file
|
||||
if (fileActivation->isChecked()) {
|
||||
arguments << QLatin1String( "-f" );
|
||||
|
||||
arguments << file->url().path();
|
||||
}
|
||||
//Else, the user types the content of its message
|
||||
else {
|
||||
//Remove bad "\n" characters
|
||||
arguments << message->text().replace(QLatin1String( "\n" ), QLatin1String( " " ));
|
||||
}
|
||||
|
||||
// QProcess::Block, QProcess::Stdout
|
||||
process.start(QLatin1String( "logger" ), arguments);
|
||||
|
||||
//If the launching of the command failed
|
||||
if (process.error() == QProcess::FailedToStart) {
|
||||
KMessageBox::error(this, i18n("Unable to find the 'logger' command on your system. Please type 'logger' in a Konsole to determine whether this command is installed."), i18n("Command not found"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (process.exitStatus() == QProcess::CrashExit) {
|
||||
KMessageBox::error(this, i18n("The 'logger' command has not been properly exited."), i18n("Execution problem"));
|
||||
return;
|
||||
}
|
||||
|
||||
//No such file or directory
|
||||
if (process.exitCode()==1) {
|
||||
KMessageBox::error(this, i18n("This file does not exist, please choose another."), i18n("File not valid"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Hide the Logger Dialog
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
#include "moc_loggerDialog.cpp"
|
|
@ -1,57 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _LOGGER_DIALOG_H_
|
||||
#define _LOGGER_DIALOG_H_
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
#include "ui_loggerDialogBase.h"
|
||||
|
||||
class LoggerDialogPrivate;
|
||||
|
||||
class LoggerDialog: public QDialog, public Ui::LoggerDialogBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoggerDialog(QWidget* parent = NULL);
|
||||
|
||||
virtual ~LoggerDialog();
|
||||
|
||||
void initialize();
|
||||
|
||||
protected slots:
|
||||
void sendMessage();
|
||||
|
||||
void textChanged();
|
||||
|
||||
void changeTagActivation(bool activation);
|
||||
void changeFileActivation(bool activation);
|
||||
void changeMessageActivation(bool activation);
|
||||
|
||||
private:
|
||||
void buildMaps();
|
||||
|
||||
LoggerDialogPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
#endif // _LOGGER_DIALOG_H_
|
|
@ -1,348 +0,0 @@
|
|||
<?xml version="1.0" encoding="System"?>
|
||||
<ui version="4.0">
|
||||
<author>Nicolas Ternisien</author>
|
||||
<comment>Dialog that allows the user to send a message with the logger command</comment>
|
||||
<class>LoggerDialogBase</class>
|
||||
<widget class="QDialog" name="LoggerDialogBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>440</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Log Message</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Message</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="messageActivation">
|
||||
<property name="text">
|
||||
<string>&Message:</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="message"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="fileActivation">
|
||||
<property name="text">
|
||||
<string>&File content:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="KUrlRequester" name="file">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Properties</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Priority:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>priority</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>84</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KComboBox" name="priority">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel2_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Facility:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>facility</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>84</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KComboBox" name="facility">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="tagActivation">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Tag:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="tag"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useProcessIdentifier">
|
||||
<property name="text">
|
||||
<string>Log process &identifier</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>31</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="loggerManual">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open the 'logger' command manual.</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>This link opens the 'logger' command manual.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><a href="https://linux.die.net/man/1/logger">Logger Manual</a></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>155</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonOK">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonCancel">
|
||||
<property name="text">
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KUrlRequester</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>kurlrequester.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>buttonOK</tabstop>
|
||||
<tabstop>buttonCancel</tabstop>
|
||||
<tabstop>loggerManual</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local">klineedit.h</include>
|
||||
<include location="local">kurlrequester.h</include>
|
||||
<include location="local">klineedit.h</include>
|
||||
<include location="local">kpushbutton.h</include>
|
||||
<include location="local">kcombobox.h</include>
|
||||
<include location="local">kcombobox.h</include>
|
||||
<include location="local">klineedit.h</include>
|
||||
<include location="local">QLabel</include>
|
||||
</includes>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,92 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 <kapplication.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <kcmdlineargs.h>
|
||||
#include <klocale.h>
|
||||
#include <kurl.h>
|
||||
|
||||
#include "mainWindow.h"
|
||||
#include "logging.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
KAboutData about(
|
||||
"ksystemlog",
|
||||
0,
|
||||
ki18n("KSystemlog"),
|
||||
"0.4",
|
||||
ki18n("System Logs Viewer for KDE"),
|
||||
KAboutData::License_GPL_V2,
|
||||
ki18n("(C) 2007, Nicolas Ternisien"),
|
||||
ki18n("Do not hesitate to report bugs and problems to Nicolas Ternisien <a href='mailto:nicolas.ternisien@gmail.com'>nicolas.ternisien@gmail.com</a>"),
|
||||
"http://ksystemlog.forum-software.org",
|
||||
"nicolas.ternisien@gmail.com"
|
||||
);
|
||||
|
||||
about.addAuthor(
|
||||
ki18n("Nicolas Ternisien"),
|
||||
ki18n("Main developer"),
|
||||
"nicolas.ternisien@gmail.com",
|
||||
"http://www.forum-software.org"
|
||||
);
|
||||
|
||||
about.setProgramIconName(QLatin1String( "utilities-log-viewer" ));
|
||||
about.addCredit(ki18n("Bojan Djurkovic"), ki18n("Log Printing"), "dbojan@gmail.com");
|
||||
|
||||
KCmdLineArgs::init(argc, argv, &about);
|
||||
|
||||
KCmdLineOptions options;
|
||||
options.add("+[URL]", ki18n("Document to open"));
|
||||
|
||||
KCmdLineArgs::addCmdLineOptions( options );
|
||||
|
||||
KApplication app;
|
||||
|
||||
//See if we are starting with session management
|
||||
if (app.isSessionRestored()) {
|
||||
RESTORE(KSystemLog::MainWindow);
|
||||
}
|
||||
else {
|
||||
//No session... Just start up normally
|
||||
KCmdLineArgs* args=KCmdLineArgs::parsedArgs();
|
||||
if (args->count()==0) {
|
||||
new KSystemLog::MainWindow();
|
||||
}
|
||||
else {
|
||||
/*KSystemLog::MainWindow* mainWindow;*/
|
||||
new KSystemLog::MainWindow();
|
||||
for (int i = 0; i < args->count(); i++) {
|
||||
logDebug() << "Loading file " << args->url(i);
|
||||
//TODO Implement this kind of loading
|
||||
//LogManager* firstLogManager = d->tabs->createTab();
|
||||
//d->tabs->load(Globals::instance()->findLogMode("openLogMode"), firstLogManager);
|
||||
//Open log mode need to automatically find the passed url : args->url(i)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
args->clear();
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
|
@ -1,802 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "mainWindow.h"
|
||||
|
||||
//Qt includes
|
||||
|
||||
#include <QActionGroup>
|
||||
#include <QAction>
|
||||
#include <QList>
|
||||
#include <QtGui/QPrinter>
|
||||
|
||||
//KDE includes
|
||||
#include <kmainwindow.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <ktabwidget.h>
|
||||
#include <kactionmenu.h>
|
||||
#include <kglobal.h>
|
||||
#include <klocale.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kservice.h>
|
||||
#include <kservicetypetrader.h>
|
||||
#include <ktoggleaction.h>
|
||||
#include <kfiledialog.h>
|
||||
#include <kconfig.h>
|
||||
#include <kurl.h>
|
||||
#include <kurlrequesterdialog.h>
|
||||
#include <kedittoolbar.h>
|
||||
#include <kstandardshortcut.h>
|
||||
#include <kaction.h>
|
||||
#include <kstandardaction.h>
|
||||
#include <kactioncollection.h>
|
||||
|
||||
//Project includes
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
#include "statusBar.h"
|
||||
|
||||
#include "logViewWidget.h"
|
||||
#include "tabLogViewsWidget.h"
|
||||
#include "configurationDialog.h"
|
||||
|
||||
#include "loggerDialog.h"
|
||||
|
||||
#include "detailDialog.h"
|
||||
|
||||
#include "logModeConfiguration.h"
|
||||
#include "logManager.h"
|
||||
|
||||
#include "logMode.h"
|
||||
#include "logLevel.h"
|
||||
#include "logFile.h"
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include "view.h"
|
||||
#include "logViewSearchWidget.h"
|
||||
#include "logModePluginsLoader.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "logModeAction.h"
|
||||
|
||||
namespace KSystemLog {
|
||||
|
||||
class MainWindowPrivate {
|
||||
|
||||
public:
|
||||
|
||||
KAction* saveAction;
|
||||
KAction* copyAction;
|
||||
|
||||
KAction* reloadAction;
|
||||
|
||||
KAction* sendMailAction;
|
||||
KAction* logMessageAction;
|
||||
|
||||
KAction* filterBarAction;
|
||||
|
||||
KAction* selectAllAction;
|
||||
|
||||
KAction* expandAllAction;
|
||||
KAction* collapseAllAction;
|
||||
|
||||
KAction* resumePauseAction;
|
||||
KAction* detailAction;
|
||||
KAction* printAction;
|
||||
|
||||
KAction* findAction;
|
||||
KAction* findNextAction;
|
||||
KAction* findPreviousAction;
|
||||
|
||||
KAction* tooltipEnabledAction;
|
||||
KAction* newLinesDisplayedAction;
|
||||
|
||||
/**
|
||||
* Action groups which stores all Log Mode Actions
|
||||
*/
|
||||
QActionGroup* logModesActionGroup;
|
||||
|
||||
|
||||
QPrinter* printer;
|
||||
|
||||
/**
|
||||
* Detail dialog
|
||||
*/
|
||||
DetailDialog* detailDialog;
|
||||
|
||||
/**
|
||||
* Logged Dialog
|
||||
*/
|
||||
LoggerDialog* loggedDialog;
|
||||
|
||||
ConfigurationDialog* configurationDialog;
|
||||
|
||||
/**
|
||||
* Tab widget managing different views
|
||||
*/
|
||||
TabLogViewsWidget* tabs;
|
||||
|
||||
KSystemLog::StatusBar* statusBar;
|
||||
|
||||
};
|
||||
|
||||
MainWindow::MainWindow() :
|
||||
KXmlGuiWindow(0),
|
||||
d(new MainWindowPrivate())
|
||||
{
|
||||
|
||||
d->printer = NULL;
|
||||
d->detailDialog = NULL;
|
||||
d->configurationDialog = NULL;
|
||||
d->tabs = NULL;
|
||||
d->statusBar = NULL;
|
||||
|
||||
logDebug() << "Starting KSystemLog...";
|
||||
|
||||
//Load log modes plugins
|
||||
loadLogModePlugins();
|
||||
|
||||
//Create the GUI from XML configuration
|
||||
logDebug() << "Creating Gui...";
|
||||
createGUI();
|
||||
|
||||
//TODO Improve the status bar to add a custom widget which shows an history of latest message, and add a LogLevel for each ones
|
||||
//Initialize the Status Bar
|
||||
setupStatusBar();
|
||||
|
||||
//Setup the main tab bar
|
||||
setupTabLogViews();
|
||||
|
||||
//Setup the Actions
|
||||
setupActions();
|
||||
|
||||
// Apply the create the main window and ask the mainwindow to
|
||||
// automatically save settings if changed: window size, toolbar
|
||||
// position, icon size, etc. Also to add actions for the statusbar
|
||||
// toolbar, and keybindings if necessary.
|
||||
logDebug() << "Setup Gui...";
|
||||
setupGUI();
|
||||
|
||||
setupLogActions();
|
||||
|
||||
//Apply the saved mainwindow settings, if any, and ask the main window
|
||||
//to automatically save settings if changed: window size, tool bar
|
||||
//position, icon size, etc.
|
||||
setAutoSaveSettings();
|
||||
|
||||
//TODO Try to find an improvement of this _big_ hack to set its default size, the first time KSystemLog is loaded
|
||||
|
||||
//Show KSystemLog before loading the first log file
|
||||
show();
|
||||
|
||||
LogManager* firstLogManager = d->tabs->createTab();
|
||||
|
||||
if (KSystemLogConfig::startupLogMode().isEmpty() == false) {
|
||||
d->tabs->load(Globals::instance()->findLogMode(KSystemLogConfig::startupLogMode()), firstLogManager);
|
||||
}
|
||||
|
||||
//Set focus to the list
|
||||
firstLogManager->usedView()->logViewWidget()->setFocus();
|
||||
}
|
||||
|
||||
void MainWindow::loadLogModePlugins() {
|
||||
LogModePluginsLoader pluginsLoader(this);
|
||||
pluginsLoader.loadPlugins();
|
||||
}
|
||||
|
||||
void MainWindow::setupTabLogViews() {
|
||||
logDebug() << "Creating tab widget...";
|
||||
|
||||
d->tabs=new TabLogViewsWidget();
|
||||
|
||||
connect(d->tabs, SIGNAL(statusBarChanged(QString)), this, SLOT(changeStatusBar(QString)));
|
||||
connect(d->tabs, SIGNAL(logManagerCreated(LogManager*)), this, SLOT(prepareCreatedLogManager(LogManager*)));
|
||||
connect(d->tabs, SIGNAL(currentChanged(int)), this, SLOT(changeCurrentTab()));
|
||||
|
||||
setCentralWidget(d->tabs);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete d->loggedDialog;
|
||||
|
||||
delete d->detailDialog;
|
||||
|
||||
delete d->configurationDialog;
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setupStatusBar() {
|
||||
d->statusBar = new KSystemLog::StatusBar(this);
|
||||
|
||||
setStatusBar(d->statusBar);
|
||||
}
|
||||
|
||||
void MainWindow::prepareCreatedLogManager(LogManager* manager) {
|
||||
logDebug() << "Connecting to actions the new log manager and view...";
|
||||
|
||||
//Contextual menu Log Manager signals
|
||||
QAction* separator;
|
||||
|
||||
manager->usedView()->logViewWidget()->addAction(d->reloadAction);
|
||||
manager->usedView()->logViewWidget()->addAction(d->selectAllAction);
|
||||
|
||||
separator = new QAction(this);
|
||||
separator->setSeparator(true);
|
||||
manager->usedView()->logViewWidget()->addAction(separator);
|
||||
|
||||
manager->usedView()->logViewWidget()->addAction(d->copyAction);
|
||||
manager->usedView()->logViewWidget()->addAction(d->saveAction);
|
||||
|
||||
separator = new QAction(this);
|
||||
separator->setSeparator(true);
|
||||
manager->usedView()->logViewWidget()->addAction(separator);
|
||||
|
||||
manager->usedView()->logViewWidget()->addAction(d->tooltipEnabledAction);
|
||||
manager->usedView()->logViewWidget()->addAction(d->newLinesDisplayedAction);
|
||||
|
||||
separator = new QAction(this);
|
||||
separator->setSeparator(true);
|
||||
manager->usedView()->logViewWidget()->addAction(separator);
|
||||
|
||||
manager->usedView()->logViewWidget()->addAction(d->detailAction);
|
||||
|
||||
//Log Manager and View signals
|
||||
connect(manager, SIGNAL(windowTitleChanged(QString)), this, SLOT(changeWindowTitle(QString)));
|
||||
connect(manager, SIGNAL(statusBarChanged(QString)), this, SLOT(changeStatusBar(QString)));
|
||||
connect(manager, SIGNAL(logUpdated(View*,int)), this, SLOT(updateStatusBar()));
|
||||
connect(manager, SIGNAL(reloaded()), this, SLOT(changeCurrentTab()));
|
||||
|
||||
connect(manager->usedView(), SIGNAL(searchFilterChanged()), this, SLOT(updateStatusBar()));
|
||||
connect(manager->usedView()->logViewWidget(), SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(showDetailsDialog()));
|
||||
connect(manager->usedView()->logViewWidget(), SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection()));
|
||||
connect(manager->usedView()->logViewWidget()->model(), SIGNAL(processingMultipleInsertions(bool)), this, SLOT(updateReloading()));
|
||||
|
||||
//Correctly initialize the Status Bar
|
||||
updateStatusBar();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::updateDetailDialog() {
|
||||
LogManager* currentManager=d->tabs->activeLogManager();
|
||||
if (d->detailDialog!=NULL) {
|
||||
d->detailDialog->selectionChanged(currentManager->usedView()->logViewWidget());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateSelection() {
|
||||
//logDebug() << "Updating selection...";
|
||||
|
||||
LogManager* currentLogManager = d->tabs->activeLogManager();
|
||||
|
||||
updateDetailDialog();
|
||||
|
||||
bool selection=currentLogManager->usedView()->logViewWidget()->hasItemsSelected();
|
||||
|
||||
d->copyAction->setEnabled(selection);
|
||||
d->saveAction->setEnabled(selection);
|
||||
d->detailAction->setEnabled(selection);
|
||||
d->sendMailAction->setEnabled(selection);
|
||||
d->printAction->setEnabled(selection);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::updateReloading() {
|
||||
View* currentView = d->tabs->activeLogManager()->usedView();
|
||||
|
||||
bool enabled = ! currentView->logViewWidget()->model()->isProcessingMultipleInsertions();
|
||||
|
||||
d->reloadAction->setEnabled(enabled);
|
||||
d->resumePauseAction->setEnabled(enabled);
|
||||
d->findAction->setEnabled(enabled);
|
||||
d->findNextAction->setEnabled(enabled);
|
||||
d->findPreviousAction->setEnabled(enabled);
|
||||
|
||||
//Enables/Disables all Log Mode actions
|
||||
d->logModesActionGroup->setEnabled(enabled);
|
||||
|
||||
d->tabs->changeReloadingTab(currentView, !enabled);
|
||||
|
||||
//Enables/Disables all Log Mode menus (useful for multiple actions menus)
|
||||
foreach(LogModeAction* logModeAction, Globals::instance()->logModeActions()) {
|
||||
logModeAction->actionMenu()->setEnabled(enabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||
logDebug() << "Saving configuration before exit...";
|
||||
//Write the config to the file
|
||||
KSystemLogConfig::self()->writeConfig();
|
||||
KXmlGuiWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
TabLogViewsWidget* MainWindow::tabs() {
|
||||
return d->tabs;
|
||||
}
|
||||
|
||||
void MainWindow::showDetailsDialog() {
|
||||
//Create the Detail dialog if it was not created
|
||||
if (d->detailDialog==NULL) {
|
||||
d->detailDialog=new DetailDialog(this);
|
||||
updateDetailDialog();
|
||||
}
|
||||
|
||||
d->detailDialog->show();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::toggleItemTooltip(bool enabled) {
|
||||
KSystemLogConfig::setTooltipEnabled(enabled);
|
||||
|
||||
foreach (LogManager* manager, d->tabs->logManagers()) {
|
||||
manager->usedView()->logViewWidget()->toggleToolTip(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggleNewLinesDisplaying(bool displayed) {
|
||||
KSystemLogConfig::setNewLinesDisplayed(displayed);
|
||||
}
|
||||
|
||||
void MainWindow::updateStatusBar() {
|
||||
logDebug() << "Updating status bar...";
|
||||
|
||||
LogManager* currentManager=d->tabs->activeLogManager();
|
||||
|
||||
int itemCount = currentManager->usedView()->logViewWidget()->itemCount();
|
||||
int notHiddenItemCount = currentManager->usedView()->logViewWidget()->notHiddenItemCount();
|
||||
|
||||
if (itemCount == notHiddenItemCount) {
|
||||
d->statusBar->changeLineCountMessage(i18ncp("Total displayed lines", "1 line.", "%1 lines.", currentManager->usedView()->logViewWidget()->itemCount()));
|
||||
}
|
||||
else {
|
||||
d->statusBar->changeLineCountMessage(i18ncp("Line not hidden by search / Total displayed lines", "1 line / %2 total.", "%1 lines / %2 total.", notHiddenItemCount, itemCount));
|
||||
}
|
||||
|
||||
d->statusBar->changeLastModification(currentManager->lastUpdate());
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::toggleResumePauseParsing(bool paused) {
|
||||
logDebug() << "Pausing parsing : " << paused;
|
||||
|
||||
LogManager* currentLogManager = d->tabs->activeLogManager();
|
||||
if (currentLogManager != NULL) {
|
||||
currentLogManager->setParsingPaused(paused);
|
||||
}
|
||||
|
||||
logDebug() << "Parsing paused : " << paused;
|
||||
}
|
||||
|
||||
void MainWindow::changeResumePauseAction(bool paused) {
|
||||
|
||||
if (paused == true) {
|
||||
d->resumePauseAction->setText(i18n("Resu&me"));
|
||||
d->resumePauseAction->setIcon(KIcon( QLatin1String( "media-playback-start" )));
|
||||
d->resumePauseAction->setShortcut(Qt::CTRL + Qt::Key_M);
|
||||
d->resumePauseAction->setToolTip(i18n("Resume the watching of the current log"));
|
||||
d->resumePauseAction->setWhatsThis(i18n("Resumes the watching of the current log. This action is only available when the user has already paused the reading."));
|
||||
d->resumePauseAction->setChecked(true);
|
||||
}
|
||||
else {
|
||||
d->resumePauseAction->setText(i18n("S&top"));
|
||||
d->resumePauseAction->setIcon(KIcon( QLatin1String( "media-playback-stop" )));
|
||||
d->resumePauseAction->setShortcut(Qt::CTRL + Qt::Key_P);
|
||||
d->resumePauseAction->setToolTip(i18n("Pause the watching of the current log"));
|
||||
d->resumePauseAction->setWhatsThis(i18n("Pauses the watching of the current log. This action is particularly useful when the system is writing too many lines to log files, causing KSystemLog to reload too frequently."));
|
||||
d->resumePauseAction->setChecked(false);
|
||||
}
|
||||
|
||||
//Be sur that the button will always have a good size
|
||||
foreach (QWidget* widget, d->resumePauseAction->associatedWidgets()) {
|
||||
if (widget->sizeHint().width() > widget->size().width()) {
|
||||
widget->setMinimumSize(widget->sizeHint());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::fileOpen() {
|
||||
//Launch the actualizing
|
||||
d->tabs->load(Globals::instance()->findLogMode(QLatin1String( "openLogMode" )), d->tabs->activeLogManager());
|
||||
}
|
||||
|
||||
void MainWindow::showConfigurationDialog() {
|
||||
logDebug() << "Showing configuration dialog...";
|
||||
|
||||
if (d->configurationDialog == NULL) {
|
||||
d->configurationDialog = new ConfigurationDialog(this);
|
||||
connect(d->configurationDialog, SIGNAL(configurationSaved()), d->tabs, SLOT(reloadAll()));
|
||||
}
|
||||
|
||||
d->configurationDialog->showConfiguration();
|
||||
}
|
||||
|
||||
void MainWindow::showLogMessageDialog() {
|
||||
logDebug() << "Launching the Send message dialog box...";
|
||||
|
||||
if (d->loggedDialog == NULL) {
|
||||
d->loggedDialog = new LoggerDialog(this);
|
||||
}
|
||||
|
||||
d->loggedDialog->initialize();
|
||||
d->loggedDialog->exec();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::changeStatusBar(const QString& text) {
|
||||
d->statusBar->changeMessage(text);
|
||||
}
|
||||
|
||||
void MainWindow::changeWindowTitle(const QString& text) {
|
||||
//Display this text on the caption
|
||||
setCaption(text);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::changeCurrentTab() {
|
||||
logDebug() << "Tab has changed";
|
||||
|
||||
LogManager* currentManager=d->tabs->activeLogManager();
|
||||
|
||||
//If the tab changed, the selection changes too
|
||||
updateSelection();
|
||||
|
||||
//Update the status bar
|
||||
updateStatusBar();
|
||||
|
||||
//Updating the current reloading status
|
||||
updateReloading();
|
||||
|
||||
bool enabledReloading = ! currentManager->usedView()->logViewWidget()->model()->isProcessingMultipleInsertions();
|
||||
|
||||
bool enabledAction;
|
||||
//Change the title of the window
|
||||
if (currentManager->logMode() == NULL) {
|
||||
changeWindowTitle(i18nc("Newly created tab", "Empty Log"));
|
||||
enabledAction = false;
|
||||
}
|
||||
else {
|
||||
changeWindowTitle(currentManager->logMode()->name());
|
||||
enabledAction = true;
|
||||
}
|
||||
|
||||
if (enabledReloading==true && enabledAction==true) {
|
||||
d->reloadAction->setEnabled(true);
|
||||
d->resumePauseAction->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
d->reloadAction->setEnabled(false);
|
||||
d->resumePauseAction->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
//Update Resume/Pause action state
|
||||
if (currentManager->isParsingPaused())
|
||||
changeResumePauseAction(true);
|
||||
else
|
||||
changeResumePauseAction(false);
|
||||
|
||||
//Updating Detail dialog
|
||||
updateDetailDialog();
|
||||
|
||||
logDebug() << "Tab changing done";
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Implements the session restoring
|
||||
*
|
||||
* The 'config' object points to the session managed
|
||||
* config file. anything you write here will be available
|
||||
* later when this app is restored
|
||||
*/
|
||||
void MainWindow::saveProperties(KConfigGroup & /*configuration*/) {
|
||||
logDebug() << "Saving properties...";
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Implements the session restoring
|
||||
*
|
||||
* The 'config' object points to the session managed
|
||||
* config file. this function is automatically called whenever
|
||||
* the app is being restored. read in here whatever you wrote
|
||||
* in 'saveProperties'
|
||||
*/
|
||||
void MainWindow::readProperties( const KConfigGroup& /*configuration*/) {
|
||||
logDebug() << "Reading properties...";
|
||||
}
|
||||
|
||||
void MainWindow::toggleFilterBar() {
|
||||
logDebug() << "Toggling filter bar..." << d->filterBarAction->isChecked();
|
||||
|
||||
foreach (LogManager* manager, d->tabs->logManagers()) {
|
||||
manager->usedView()->toggleLogViewFilter(d->filterBarAction->isChecked());
|
||||
}
|
||||
|
||||
KSystemLogConfig::setToggleFilterBar(d->filterBarAction->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::findNext() {
|
||||
showSearchBar();
|
||||
d->tabs->activeLogManager()->usedView()->logViewSearch()->findNext();
|
||||
}
|
||||
|
||||
void MainWindow::findPrevious() {
|
||||
showSearchBar();
|
||||
d->tabs->activeLogManager()->usedView()->logViewSearch()->findPrevious();
|
||||
}
|
||||
|
||||
void MainWindow::showSearchBar() {
|
||||
logDebug() << "Showing search bar...";
|
||||
|
||||
LogManager* activeLogManager = d->tabs->activeLogManager();
|
||||
|
||||
foreach (LogManager* manager, d->tabs->logManagers()) {
|
||||
if (manager != activeLogManager) {
|
||||
manager->usedView()->toggleLogViewSearch(true);
|
||||
}
|
||||
}
|
||||
|
||||
//Be sure to display the view search of the active LogManager at last, and focus to it
|
||||
d->tabs->activeLogManager()->usedView()->toggleLogViewSearch(true);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::setupActions() {
|
||||
logDebug() << "Creating actions...";
|
||||
|
||||
QAction* fileOpenAction = actionCollection()->addAction(KStandardAction::Open, this, SLOT(fileOpen()));
|
||||
fileOpenAction->setToolTip(i18n("Open a file in KSystemLog"));
|
||||
fileOpenAction->setWhatsThis(i18n("Opens a file in KSystemLog and displays its content in the current tab."));
|
||||
|
||||
d->printAction = actionCollection()->addAction(KStandardAction::Print);
|
||||
d->printAction->setText(i18n("&Print Selection..."));
|
||||
d->printAction->setToolTip(i18n("Print the selection"));
|
||||
d->printAction->setWhatsThis(i18n("Prints the selection. Simply select the important lines and click on this menu entry to print the selection."));
|
||||
d->printAction->setEnabled(false);
|
||||
|
||||
d->saveAction = actionCollection()->addAction(KStandardAction::SaveAs);
|
||||
//TODO Retrieve the system's shortcut of the save action (and not Save as...)
|
||||
d->saveAction->setShortcut(Qt::CTRL + Qt::Key_S);
|
||||
d->saveAction->setToolTip(i18n("Save the selection to a file"));
|
||||
d->saveAction->setWhatsThis(i18n("Saves the selection to a file. This action is useful if you want to create an attachment or a backup of a particular log."));
|
||||
d->saveAction->setEnabled(false);
|
||||
|
||||
QAction* fileQuitAction = actionCollection()->addAction(KStandardAction::Quit, kapp, SLOT(quit()));
|
||||
fileQuitAction->setToolTip(i18n("Quit KSystemLog"));
|
||||
fileQuitAction->setWhatsThis(i18n("Quits KSystemLog."));
|
||||
|
||||
d->copyAction = actionCollection()->addAction(KStandardAction::Copy);
|
||||
d->copyAction->setToolTip(i18n("Copy the selection to the clipboard"));
|
||||
d->copyAction->setWhatsThis(i18n("Copies the selection to the clipboard. This action is useful if you want to paste the selection in a chat or an email."));
|
||||
d->copyAction->setEnabled(false);
|
||||
|
||||
d->expandAllAction = actionCollection()->addAction( QLatin1String( "expand_all" ));
|
||||
d->expandAllAction->setText(i18n("Ex&pand All"));
|
||||
d->expandAllAction->setShortcut(Qt::CTRL + Qt::Key_X);
|
||||
d->expandAllAction->setToolTip(i18n("Expand all categories"));
|
||||
d->expandAllAction->setWhatsThis(i18n("This action opens all main categories. This is enabled only if an option has been selected in the <b>Group By</b> menu."));
|
||||
d->expandAllAction->setEnabled(false);
|
||||
|
||||
d->collapseAllAction = actionCollection()->addAction( QLatin1String( "collapse_all" ));
|
||||
d->collapseAllAction->setText(i18n("Col&lapse All"));
|
||||
d->collapseAllAction->setShortcut(Qt::CTRL + Qt::Key_L);
|
||||
d->collapseAllAction->setToolTip(i18n("Collapse all categories"));
|
||||
d->collapseAllAction->setWhatsThis(i18n("This action closes all main categories. This is enabled only if an option has been selected in the <b>Group By</b> menu."));
|
||||
d->collapseAllAction->setEnabled(false);
|
||||
|
||||
d->sendMailAction = actionCollection()->addAction( QLatin1String( "send_mail" ));
|
||||
d->sendMailAction->setText(i18n("&Email Selection..."));
|
||||
d->sendMailAction->setIcon(KIcon( QLatin1String( "mail-message-new" )));
|
||||
d->sendMailAction->setShortcut(Qt::CTRL + Qt::Key_M);
|
||||
d->sendMailAction->setToolTip(i18n("Send the selection by mail"));
|
||||
d->sendMailAction->setWhatsThis(i18n("Sends the selection by mail. Simply select the important lines and click on this menu entry to send the selection to a friend or a mailing list."));
|
||||
d->sendMailAction->setEnabled(false);
|
||||
|
||||
d->logMessageAction = actionCollection()->addAction( QLatin1String( "log_message" ), this, SLOT(showLogMessageDialog()));
|
||||
d->logMessageAction->setText(i18n("&Add Log Entry..."));
|
||||
d->logMessageAction->setIcon(KIcon( QLatin1String( "document-new" )));
|
||||
d->logMessageAction->setShortcut(Qt::CTRL + Qt::Key_L);
|
||||
d->logMessageAction->setToolTip(i18n("Add a log entry to the log system"));
|
||||
d->logMessageAction->setWhatsThis(i18n("This action will open a dialog which lets you send a message to the log system."));
|
||||
|
||||
d->selectAllAction = actionCollection()->addAction(KStandardAction::SelectAll);
|
||||
d->selectAllAction->setToolTip(i18n("Select all lines of the current log"));
|
||||
d->selectAllAction->setWhatsThis(i18n("Selects all lines of the current log. This action is useful if you want, for example, to save all the content of the current log in a file."));
|
||||
|
||||
d->findAction = actionCollection()->addAction(KStandardAction::Find, this, SLOT(showSearchBar()));
|
||||
d->findNextAction = actionCollection()->addAction(KStandardAction::FindNext, this, SLOT(findNext()));
|
||||
d->findPreviousAction = actionCollection()->addAction(KStandardAction::FindPrev, this, SLOT(findPrevious()));
|
||||
|
||||
|
||||
actionCollection()->addAction(KStandardAction::Preferences, this, SLOT(showConfigurationDialog()));
|
||||
|
||||
//TODO Find a solution to display at the right place this action (see Akregator interface)
|
||||
d->filterBarAction = actionCollection()->addAction( QLatin1String( "show_quick_filter" ), this, SLOT(toggleFilterBar()));
|
||||
d->filterBarAction->setText(i18n("Show &Filter Bar"));
|
||||
d->filterBarAction->setEnabled(true);
|
||||
d->filterBarAction->setCheckable(true);
|
||||
d->filterBarAction->setChecked(KSystemLogConfig::toggleFilterBar());
|
||||
|
||||
KAction* newTabAction = actionCollection()->addAction( QLatin1String( "new_tab" ), d->tabs, SLOT(createTab()));
|
||||
newTabAction->setText(i18n("&New Tab"));
|
||||
newTabAction->setIcon(KIcon( QLatin1String( "tab-new" )));
|
||||
newTabAction->setShortcut(Qt::CTRL + Qt::Key_T);
|
||||
newTabAction->setToolTip(i18n("Create a new tab"));
|
||||
newTabAction->setWhatsThis(i18n("Creates a new tab which can display another log."));
|
||||
d->tabs->addAction(newTabAction);
|
||||
|
||||
KAction* closeTabAction = actionCollection()->addAction( QLatin1String( "close_tab" ), d->tabs, SLOT(closeTab()));
|
||||
closeTabAction->setText(i18n("&Close Tab"));
|
||||
closeTabAction->setIcon(KIcon( QLatin1String( "tab-close" )));
|
||||
closeTabAction->setShortcut(Qt::CTRL+Qt::Key_W);
|
||||
closeTabAction->setToolTip(i18n("Close the current tab"));
|
||||
closeTabAction->setWhatsThis(i18n("Closes the current tab."));
|
||||
d->tabs->addAction(closeTabAction);
|
||||
|
||||
KAction* duplicateTabAction = actionCollection()->addAction( QLatin1String( "duplicate_tab" ), d->tabs, SLOT(duplicateTab()));
|
||||
duplicateTabAction->setText(i18n("&Duplicate Tab"));
|
||||
duplicateTabAction->setIcon(KIcon( QLatin1String( "tab-duplicate" )));
|
||||
duplicateTabAction->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_N);
|
||||
duplicateTabAction->setToolTip(i18n("Duplicate the current tab"));
|
||||
duplicateTabAction->setWhatsThis(i18n("Duplicates the current tab."));
|
||||
d->tabs->addAction(duplicateTabAction);
|
||||
|
||||
QAction* separatorAction = new QAction(this);
|
||||
separatorAction->setSeparator(true);
|
||||
d->tabs->addAction(separatorAction);
|
||||
|
||||
KAction* moveTabLeftAction = actionCollection()->addAction( QLatin1String( "move_tab_left" ), d->tabs, SLOT(moveTabLeft()));
|
||||
moveTabLeftAction->setText(i18n("Move Tab &Left"));
|
||||
moveTabLeftAction->setIcon(KIcon( QLatin1String( "arrow-left" )));
|
||||
moveTabLeftAction->setShortcut(Qt::SHIFT+Qt::CTRL+Qt::Key_Left);
|
||||
moveTabLeftAction->setToolTip(i18n("Move the current tab to the left"));
|
||||
moveTabLeftAction->setWhatsThis(i18n("Moves the current tab to the left."));
|
||||
d->tabs->addAction(moveTabLeftAction);
|
||||
|
||||
KAction* moveTabRightAction = actionCollection()->addAction( QLatin1String( "move_tab_right" ), d->tabs, SLOT(moveTabRight()));
|
||||
moveTabRightAction->setText(i18n("Move Tab &Right"));
|
||||
moveTabRightAction->setIcon(KIcon( QLatin1String( "arrow-right" )));
|
||||
moveTabRightAction->setShortcut(Qt::SHIFT+Qt::CTRL+Qt::Key_Right);
|
||||
moveTabRightAction->setToolTip(i18n("Move the current tab to the right"));
|
||||
moveTabRightAction->setWhatsThis(i18n("Moves the current tab to the right."));
|
||||
d->tabs->addAction(moveTabRightAction);
|
||||
|
||||
d->reloadAction = actionCollection()->addAction( QLatin1String( "reload" ), d->tabs, SLOT(reloadCurrent()));
|
||||
d->reloadAction->setText(i18n("&Reload"));
|
||||
d->reloadAction->setIcon(KIcon( QLatin1String( "view-refresh" )));
|
||||
d->reloadAction->setShortcut(Qt::Key_F5);
|
||||
d->reloadAction->setToolTip(i18n("Reload the current log"));
|
||||
d->reloadAction->setWhatsThis(i18n("Reloads the current log, if you want to be sure that the view is correctly updated."));
|
||||
|
||||
d->resumePauseAction = actionCollection()->addAction( QLatin1String( "resume_pause_parsing" ));
|
||||
d->resumePauseAction->setCheckable(true);
|
||||
connect(d->resumePauseAction, SIGNAL(toggled(bool)), this, SLOT(changeResumePauseAction(bool)));
|
||||
connect(d->resumePauseAction, SIGNAL(toggled(bool)), this, SLOT(toggleResumePauseParsing(bool)));
|
||||
changeResumePauseAction(false);
|
||||
|
||||
d->detailAction = actionCollection()->addAction( QLatin1String( "details" ), this, SLOT(showDetailsDialog()));
|
||||
d->detailAction->setText(i18n("&Details"));
|
||||
d->detailAction->setIcon(KIcon( QLatin1String( "document-preview" )));
|
||||
d->detailAction->setShortcut(Qt::ALT + Qt::Key_Return);
|
||||
d->detailAction->setToolTip(i18n("Display details on the selected line"));
|
||||
d->detailAction->setWhatsThis(i18n("Displays a dialog box which contains details on the selected line. You are able to navigate through the logs from this dialog box with the <b>Previous</b> and <b>Next</b> buttons."));
|
||||
d->detailAction->setEnabled(false);
|
||||
|
||||
d->tooltipEnabledAction = actionCollection()->addAction( QLatin1String( "tooltipEnabled" ));
|
||||
d->tooltipEnabledAction->setText(i18n("&Enable Detailed Tooltips"));
|
||||
d->tooltipEnabledAction->setToolTip(i18n("Disable/Enable the tooltip on the current view"));
|
||||
d->tooltipEnabledAction->setWhatsThis(i18n("Disables/Enables the tooltip displayed when the cursor hovers a log line."));
|
||||
d->tooltipEnabledAction->setCheckable(true);
|
||||
d->tooltipEnabledAction->setChecked(KSystemLogConfig::tooltipEnabled());
|
||||
connect(d->tooltipEnabledAction, SIGNAL(toggled(bool)), this, SLOT(toggleItemTooltip(bool)));
|
||||
|
||||
d->newLinesDisplayedAction = actionCollection()->addAction( QLatin1String( "newLinesDisplayed" ));
|
||||
d->newLinesDisplayedAction->setText(i18n("&Scroll to New Lines"));
|
||||
d->newLinesDisplayedAction->setToolTip(i18n("Scrolls or not to the new lines when the log changes"));
|
||||
d->newLinesDisplayedAction->setWhatsThis(i18n("Scrolls or not to the new lines when the log changes. Check this option if you do not want the application to scroll automatically at the bottom of the log each time it is refreshed."));
|
||||
d->newLinesDisplayedAction->setCheckable(true);
|
||||
d->newLinesDisplayedAction->setChecked(KSystemLogConfig::newLinesDisplayed());
|
||||
connect(d->newLinesDisplayedAction, SIGNAL(toggled(bool)), this, SLOT(toggleNewLinesDisplaying(bool)));
|
||||
|
||||
//Toolbar and Menu signals
|
||||
connect(d->expandAllAction, SIGNAL(triggered()), d->tabs, SLOT(expandAllCurrentView()));
|
||||
connect(d->collapseAllAction, SIGNAL(triggered()), d->tabs, SLOT(collapseAllCurrentView()));
|
||||
connect(d->saveAction, SIGNAL(triggered()), d->tabs, SLOT(fileSaveCurrentView()));
|
||||
connect(d->copyAction, SIGNAL(triggered()), d->tabs, SLOT(copyToClipboardCurrentView()));
|
||||
connect(d->sendMailAction, SIGNAL(triggered()), d->tabs, SLOT(sendMailCurrentView()));
|
||||
connect(d->printAction, SIGNAL(triggered()), d->tabs, SLOT(printSelectionCurrentView()));
|
||||
connect(d->selectAllAction, SIGNAL(triggered()), d->tabs, SLOT(selectAllCurrentView()));
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::selectLogModeAction(QAction* action) {
|
||||
QString selectedModeId = action->data().toString();
|
||||
|
||||
LogMode* currentMode = NULL;
|
||||
foreach(LogMode* logMode, Globals::instance()->logModes()) {
|
||||
if (logMode->id() == selectedModeId) {
|
||||
currentMode = logMode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMode==NULL) {
|
||||
logError() << "The selected mode does not exist";
|
||||
return;
|
||||
}
|
||||
|
||||
logDebug() << "Selecting " << currentMode->name() << " (" << currentMode->id() << ")";
|
||||
|
||||
/*
|
||||
//If the user uses the middle button OR left button + shift OR left button + control : = it opens the log in a new tab
|
||||
if (state==Qt::MiddleButton || (state==Qt::ControlModifier+Qt::LeftButton) || (state==Qt::ShiftModifier+Qt::LeftButton))
|
||||
createTab();
|
||||
*/
|
||||
|
||||
d->tabs->load(currentMode, d->tabs->activeLogManager());
|
||||
}
|
||||
|
||||
void MainWindow::setupLogActions() {
|
||||
QList<QAction*> menuLogModeActions;
|
||||
QList<QAction*> toolBarLogModeActions;
|
||||
|
||||
KActionMenu* servicesAction = new KActionMenu(KIcon( QLatin1String( "preferences-system-session-services") ), i18n("Services"), this);
|
||||
KActionMenu* othersAction = new KActionMenu(KIcon( QLatin1String( "preferences-other")), i18n("Others"), this);
|
||||
|
||||
d->logModesActionGroup=new QActionGroup(actionCollection());
|
||||
|
||||
connect(d->logModesActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(selectLogModeAction(QAction*)));
|
||||
|
||||
foreach(LogModeAction* logModeAction, Globals::instance()->logModeActions()) {
|
||||
foreach(QAction* action, logModeAction->innerActions()) {
|
||||
d->logModesActionGroup->addAction(action);
|
||||
}
|
||||
|
||||
if (logModeAction->category() == LogModeAction::RootCategory)
|
||||
menuLogModeActions.append( logModeAction->actionMenu() );
|
||||
else if (logModeAction->category() == LogModeAction::ServicesCategory)
|
||||
servicesAction->addAction( logModeAction->actionMenu() );
|
||||
else if (logModeAction->category() == LogModeAction::OthersCategory)
|
||||
othersAction->addAction( logModeAction->actionMenu() );
|
||||
|
||||
if (logModeAction->isInToolBar() == true) {
|
||||
toolBarLogModeActions.append( logModeAction->actionMenu() );
|
||||
}
|
||||
}
|
||||
|
||||
menuLogModeActions.append( servicesAction );
|
||||
menuLogModeActions.append( othersAction );
|
||||
|
||||
//Menu dynamic action list
|
||||
unplugActionList(QLatin1String( "log_mode_list" ));
|
||||
plugActionList(QLatin1String( "log_mode_list" ), menuLogModeActions);
|
||||
|
||||
//ToolBar dynamic action list
|
||||
unplugActionList(QLatin1String( "tool_bar_log_mode_list" ));
|
||||
plugActionList(QLatin1String( "tool_bar_log_mode_list" ), toolBarLogModeActions);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "moc_mainWindow.cpp"
|
|
@ -1,142 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 MAIN_WINDOW_H
|
||||
#define MAIN_WINDOW_H
|
||||
|
||||
#include <QList>
|
||||
|
||||
//KDE includes
|
||||
#include <kapplication.h>
|
||||
#include <kxmlguiwindow.h>
|
||||
#include <kconfig.h>
|
||||
#include <kmenu.h>
|
||||
|
||||
#include <ktoggleaction.h>
|
||||
|
||||
#include <QAction>
|
||||
|
||||
class LogManager;
|
||||
class LogMode;
|
||||
|
||||
class View;
|
||||
|
||||
class TabLogViewsWidget;
|
||||
|
||||
namespace KSystemLog {
|
||||
|
||||
class MainWindowPrivate;
|
||||
|
||||
/**
|
||||
* This class serves as the main window for ksystemlog. It handles the
|
||||
* menus, toolbars, and status bars.
|
||||
*/
|
||||
class MainWindow : public KXmlGuiWindow {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
MainWindow();
|
||||
|
||||
/**
|
||||
* Default Destructor
|
||||
*/
|
||||
virtual ~MainWindow();
|
||||
|
||||
TabLogViewsWidget* tabs();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This function is called when it is time for the app to save its
|
||||
* properties for session management purposes.
|
||||
*/
|
||||
void saveProperties(KConfigGroup& configuration);
|
||||
|
||||
/**
|
||||
* This function is called when this app is restored. The KConfig
|
||||
* object points to the session management config file that was saved
|
||||
* with @ref saveProperties
|
||||
*/
|
||||
void readProperties(const KConfigGroup& configuration);
|
||||
|
||||
/**
|
||||
* Reimplemented to save configuration when closing.
|
||||
*/
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
public slots:
|
||||
void changeStatusBar(const QString& text);
|
||||
void changeWindowTitle(const QString& text);
|
||||
|
||||
void updateStatusBar();
|
||||
|
||||
void prepareCreatedLogManager(LogManager* logManager);
|
||||
|
||||
private slots:
|
||||
void fileOpen();
|
||||
|
||||
void showConfigurationDialog();
|
||||
void showDetailsDialog();
|
||||
void showLogMessageDialog();
|
||||
|
||||
//Transmits signals to active LogManager
|
||||
void showSearchBar();
|
||||
void findNext();
|
||||
void findPrevious();
|
||||
|
||||
void updateSelection();
|
||||
void updateReloading();
|
||||
|
||||
void toggleFilterBar();
|
||||
|
||||
void toggleItemTooltip(bool enabled);
|
||||
void toggleNewLinesDisplaying(bool displayed);
|
||||
void toggleResumePauseParsing(bool paused);
|
||||
|
||||
void changeCurrentTab();
|
||||
|
||||
void changeResumePauseAction(bool paused);
|
||||
void selectLogModeAction(QAction* action);
|
||||
|
||||
private:
|
||||
|
||||
void loadLogModePlugins();
|
||||
|
||||
void setupStatusBar();
|
||||
|
||||
void setupTabLogViews();
|
||||
|
||||
void setupActions();
|
||||
void setupLogActions();
|
||||
|
||||
void updateDetailDialog();
|
||||
|
||||
MainWindowPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //MAIN_WINDOW_H
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "acpidAnalyzer.h"
|
|
@ -1,140 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _ACPID_ANALYZER_H_
|
||||
#define _ACPID_ANALYZER_H_
|
||||
|
||||
#include <klocale.h>
|
||||
|
||||
#include "analyzer.h"
|
||||
|
||||
#include "localLogFileReader.h"
|
||||
#include "parsingHelper.h"
|
||||
#include "acpidLogMode.h"
|
||||
|
||||
|
||||
class AcpidAnalyzer : public Analyzer {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AcpidAnalyzer(LogMode* logMode) :
|
||||
Analyzer(logMode) {
|
||||
|
||||
}
|
||||
|
||||
virtual ~AcpidAnalyzer() {
|
||||
|
||||
}
|
||||
|
||||
LogViewColumns initColumns() {
|
||||
LogViewColumns columns;
|
||||
columns.addColumn(LogViewColumn(i18n("Date"), true, false));
|
||||
columns.addColumn(LogViewColumn(i18n("Type"), true, true));
|
||||
columns.addColumn(LogViewColumn(i18n("Message"), true, false));
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
LogFileReader* createLogFileReader(const LogFile& logFile) {
|
||||
return new LocalLogFileReader(logFile);
|
||||
}
|
||||
|
||||
Analyzer::LogFileSortMode logFileSortMode() {
|
||||
return Analyzer::AscendingSortedLogFile;
|
||||
}
|
||||
|
||||
LogLine* parseMessage(const QString& logLine, const LogFile& originalFile) {
|
||||
QString line(logLine);
|
||||
|
||||
int dateBegin=line.indexOf(QLatin1String( "[" ));
|
||||
int dateEnd=line.indexOf(QLatin1String( "]" ));
|
||||
|
||||
QString type;
|
||||
QString message;
|
||||
QDate date;
|
||||
QTime time;
|
||||
|
||||
//If there is a format problem in the line
|
||||
if (dateBegin==-1 || dateEnd==-1) {
|
||||
type=QLatin1String( "" ); //No type
|
||||
message=line;
|
||||
date=QDate::currentDate();
|
||||
time=QTime::currentTime();
|
||||
}
|
||||
else {
|
||||
|
||||
QString strDate=line.mid(dateBegin+1, dateEnd-dateBegin-1);
|
||||
|
||||
QString month=strDate.mid(4, 3);
|
||||
|
||||
QString day=strDate.mid(8, 2);
|
||||
|
||||
QString hour=strDate.mid(11, 2);
|
||||
QString min=strDate.mid(14, 2);
|
||||
QString sec=strDate.mid(17, 2);
|
||||
|
||||
QString year=strDate.mid(20, 4);
|
||||
|
||||
date=QDate(year.toInt(), ParsingHelper::instance()->parseSyslogMonth(month), day.toInt());
|
||||
time=QTime(hour.toInt(), min.toInt(), sec.toInt());
|
||||
|
||||
//logDebug() << "Date=" << date.toString();
|
||||
//logDebug() << "Time=" << time.toString();
|
||||
|
||||
line=line.remove(0, dateEnd+2);
|
||||
|
||||
int endType=line.indexOf(QLatin1String( "\"" ));
|
||||
|
||||
//If the " character does not exist, it means that there is no Type category
|
||||
if (endType==-1) {
|
||||
type=QLatin1String( "" ); //No type
|
||||
message=line;
|
||||
}
|
||||
else {
|
||||
type=line.left(endType-1);
|
||||
line=line.remove(0, endType+1);
|
||||
|
||||
message=line.left(line.length()-2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
QStringList list;
|
||||
|
||||
list.append(type);
|
||||
list.append(message);
|
||||
|
||||
return new LogLine(
|
||||
logLineInternalIdGenerator++,
|
||||
QDateTime(date, time),
|
||||
list,
|
||||
originalFile.url().path(),
|
||||
Globals::instance()->informationLogLevel(),
|
||||
logMode
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // _ACPID_ANALYZER_H_
|
|
@ -1,22 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "acpidConfiguration.h"
|
|
@ -1,74 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _ACPID_CONFIGURATION_H_
|
||||
#define _ACPID_CONFIGURATION_H_
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include "logModeConfiguration.h"
|
||||
|
||||
#include "logging.h"
|
||||
#include "defaults.h"
|
||||
|
||||
#include "acpidLogMode.h"
|
||||
|
||||
#include "ksystemlogConfig.h"
|
||||
|
||||
class AcpidConfigurationPrivate {
|
||||
public:
|
||||
QStringList acpidPaths;
|
||||
};
|
||||
|
||||
class AcpidConfiguration : public LogModeConfiguration {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AcpidConfiguration() :
|
||||
d(new AcpidConfigurationPrivate()) {
|
||||
|
||||
configuration->setCurrentGroup(QLatin1String( "AcpidLogMode" ));
|
||||
|
||||
QStringList defaultAcpidPaths;
|
||||
defaultAcpidPaths << QLatin1String( "/var/log/acpid" );
|
||||
configuration->addItemStringList(QLatin1String( "LogFilesPaths" ), d->acpidPaths, defaultAcpidPaths, QLatin1String( "LogFilesPaths" ));
|
||||
|
||||
}
|
||||
|
||||
virtual ~AcpidConfiguration() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
QStringList acpidPaths() const {
|
||||
return d->acpidPaths;
|
||||
}
|
||||
|
||||
void setAcpidPaths(const QStringList& acpidPaths) {
|
||||
d->acpidPaths = acpidPaths;
|
||||
}
|
||||
|
||||
private:
|
||||
AcpidConfigurationPrivate* const d;
|
||||
|
||||
};
|
||||
|
||||
#endif // _ACPID_CONFIGURATION_H_
|
|
@ -1,22 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KApacheLog, a apache log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "acpidConfigurationWidget.h"
|
|
@ -1,101 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _ACPID_CONFIGURATION_WIDGET_H_
|
||||
#define _ACPID_CONFIGURATION_WIDGET_H_
|
||||
|
||||
|
||||
#include <klocale.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "logging.h"
|
||||
#include "fileList.h"
|
||||
|
||||
#include "logLevel.h"
|
||||
|
||||
#include "acpidConfiguration.h"
|
||||
#include "acpidLogMode.h"
|
||||
|
||||
#include "logModeConfigurationWidget.h"
|
||||
|
||||
class FileList;
|
||||
|
||||
class AcpidConfigurationWidget : public LogModeConfigurationWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AcpidConfigurationWidget() :
|
||||
LogModeConfigurationWidget(i18n("Acpid Log"), QLatin1String( ACPID_MODE_ICON ), i18n("Acpid Log"))
|
||||
{
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
this->setLayout(layout);
|
||||
|
||||
fileList=new FileList(this, i18n("<p>These files will be analyzed to show the <b>Acpid log</b>.</p>")
|
||||
);
|
||||
connect(fileList, SIGNAL(fileListChanged()), this, SIGNAL(configurationChanged()));
|
||||
layout->addWidget(fileList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
~AcpidConfigurationWidget() {
|
||||
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
void saveConfig() {
|
||||
AcpidConfiguration* acpidConfiguration = Globals::instance()->findLogMode(QLatin1String(ACPID_LOG_MODE_ID ))->logModeConfiguration<AcpidConfiguration*>();
|
||||
|
||||
acpidConfiguration->setAcpidPaths(fileList->paths());
|
||||
}
|
||||
|
||||
void readConfig() {
|
||||
AcpidConfiguration* acpidConfiguration = Globals::instance()->findLogMode(QLatin1String( ACPID_LOG_MODE_ID ))->logModeConfiguration<AcpidConfiguration*>();
|
||||
|
||||
fileList->removeAllItems();
|
||||
|
||||
fileList->addPaths(acpidConfiguration->acpidPaths());
|
||||
}
|
||||
|
||||
void defaultConfig() {
|
||||
//TODO Find a way to read the configuration per default
|
||||
readConfig();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool isValid() const {
|
||||
if (fileList->isEmpty()==false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
FileList* fileList;
|
||||
|
||||
};
|
||||
|
||||
#endif // _ACPID_CONFIGURATION_WIDGET_H_
|
|
@ -1,48 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "acpidFactory.h"
|
||||
|
||||
#include <QList>
|
||||
|
||||
|
||||
#include "logMode.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include "simpleAction.h"
|
||||
#include "acpidLogMode.h"
|
||||
|
||||
#include "logModeFactory.h"
|
||||
|
||||
QList<LogMode*> AcpidLogModeFactory::createLogModes() const {
|
||||
QList<LogMode*> logModes;
|
||||
logModes.append(new AcpidLogMode());
|
||||
return logModes;
|
||||
}
|
||||
|
||||
LogModeAction* AcpidLogModeFactory::createLogModeAction() const {
|
||||
LogMode* logMode = Globals::instance()->findLogMode(QLatin1String( ACPID_LOG_MODE_ID ));
|
||||
SimpleAction* logModeAction = new SimpleAction(logMode->action(), logMode);
|
||||
logModeAction->setInToolBar(false);
|
||||
logModeAction->setCategory(LogModeAction::OthersCategory);
|
||||
|
||||
return logModeAction;
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _ACPID_FACTORY_H_
|
||||
#define _ACPID_FACTORY_H_
|
||||
|
||||
#include <QList>
|
||||
|
||||
#include "logModeFactory.h"
|
||||
|
||||
class LogModeAction;
|
||||
class LogMode;
|
||||
|
||||
class AcpidLogModeFactory : public LogModeFactory {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QList<LogMode*> createLogModes() const;
|
||||
|
||||
LogModeAction* createLogModeAction() const;
|
||||
|
||||
};
|
||||
|
||||
#endif // _ACPID_FACTORY_H_
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "acpidItemBuilder.h"
|
|
@ -1,68 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 _ACPID_ITEM_BUILDER_H_
|
||||
#define _ACPID_ITEM_BUILDER_H_
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <klocale.h>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include "logLine.h"
|
||||
#include "logViewWidgetItem.h"
|
||||
#include "logMode.h"
|
||||
|
||||
#include "logModeItemBuilder.h"
|
||||
|
||||
class LogLine;
|
||||
|
||||
class AcpidItemBuilder : public LogModeItemBuilder {
|
||||
|
||||
public:
|
||||
AcpidItemBuilder() {
|
||||
|
||||
}
|
||||
|
||||
virtual ~AcpidItemBuilder() {
|
||||
|
||||
}
|
||||
|
||||
QString createFormattedText(LogLine* line) const {
|
||||
QString result;
|
||||
|
||||
QListIterator<QString> it(line->logItems());
|
||||
|
||||
result.append(QLatin1String( "<table>" ));
|
||||
|
||||
result.append(labelMessageFormat(i18n("Date:"), formatDate(line->time())));
|
||||
result.append(labelMessageFormat(i18n("Level:"), line->logLevel()->name()));
|
||||
result.append(labelMessageFormat(i18n("Type:"), it.next()));
|
||||
|
||||
result.append(QLatin1String( "</table>" ));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // _ACPID_ITEM_BUILDER_H_
|
|
@ -1,63 +0,0 @@
|
|||
/***************************************************************************
|
||||
* KSystemLog, a system log viewer tool *
|
||||
* Copyright (C) 2007 by Nicolas Ternisien *
|
||||
* nicolas.ternisien@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 "acpidLogMode.h"
|
||||
|
||||
#include <QList>
|
||||
|
||||
#include <kicon.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "logMode.h"
|
||||
|
||||
#include "acpidAnalyzer.h"
|
||||
#include "acpidItemBuilder.h"
|
||||
#include "acpidConfigurationWidget.h"
|
||||
#include "acpidConfiguration.h"
|
||||
|
||||
AcpidLogMode::AcpidLogMode() :
|
||||
LogMode(QLatin1String( ACPID_LOG_MODE_ID ), i18n("ACPI Log"),QLatin1String( ACPID_MODE_ICON )) {
|
||||
|
||||
d->logModeConfiguration = new AcpidConfiguration();
|
||||
|
||||
d->logModeConfigurationWidget = new AcpidConfigurationWidget();
|
||||
|
||||
d->itemBuilder = new AcpidItemBuilder();
|
||||
|
||||
d->action = createDefaultAction();
|
||||
d->action->setToolTip(i18n("Display the ACPI log."));
|
||||
d->action->setWhatsThis(i18n("Displays the ACPI log in the current tab. ACPI is used to manage the hardware components of your computer, like notebook batteries, reset buttons..."));
|
||||
|
||||
}
|
||||
|
||||
AcpidLogMode::~AcpidLogMode() {
|
||||
|
||||
}
|
||||
|
||||
Analyzer* AcpidLogMode::createAnalyzer() {
|
||||
return new AcpidAnalyzer(this);
|
||||
}
|
||||
|
||||
QList<LogFile> AcpidLogMode::createLogFiles() {
|
||||
AcpidConfiguration* configuration = logModeConfiguration<AcpidConfiguration*>();
|
||||
return configuration->findNoModeLogFiles(configuration->acpidPaths());
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue