generic: move kamera and kfilereplace from kde-extraapps

This commit is contained in:
Ivailo Monev 2015-03-02 02:53:29 +00:00
parent af40a5ee4f
commit a9f5546ca2
71 changed files with 12418 additions and 0 deletions

View file

@ -22,3 +22,5 @@ macro_optional_add_subdirectory (kdbg)
macro_optional_add_subdirectory (pykde4) macro_optional_add_subdirectory (pykde4)
macro_optional_add_subdirectory (libkdcraw) macro_optional_add_subdirectory (libkdcraw)
macro_optional_add_subdirectory (libkexiv2) macro_optional_add_subdirectory (libkexiv2)
macro_optional_add_subdirectory (kamera)
macro_optional_add_subdirectory (kfilereplace)

4
kamera/AUTHORS Normal file
View file

@ -0,0 +1,4 @@
Copyright (C) 2001 The Kompany
2001-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
2001-2007 Marcus Meissner <marcus@jet.franken.de>
2003 Nadeem Hasan <nhasan@nadmm.com>

40
kamera/CMakeLists.txt Normal file
View file

@ -0,0 +1,40 @@
project(kamera)
find_package(KDE4 4.14.3 REQUIRED)
include(CMakePushCheckState)
include(CheckSymbolExists)
include(KDE4Defaults)
include(MacroLibrary)
include(MacroOptionalAddSubdirectory)
find_package(Gphoto2)
macro_log_feature(GPHOTO2_FOUND "gphoto2" "Required to build kamera" "http://heanet.dl.sourceforge.net/sourceforge/gphoto" TRUE "" "")
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES "${GPHOTO2_INCLUDE_DIR}")
set(CMAKE_REQUIRED_LIBRARIES "${GPHOTO2_LIBRARIES}")
check_symbol_exists(gp_port_info_get_name "gphoto2.h" HAVE_GPHOTO2_5)
cmake_pop_check_state()
if(HAVE_GPHOTO2_5)
message(STATUS "Detected libgphoto2 2.5.0 or newer")
else()
message(STATUS "Detected libgphoto2 2.4 or older")
endif()
include(ConfigureChecks.cmake)
configure_file(config-kamera.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kamera.h)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
add_definitions (-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
include_directories (${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} ${GPHOTO2_INCLUDE_DIRS})
add_subdirectory( kcontrol )
add_subdirectory( kioslave )
install(FILES
solid_camera.desktop
DESTINATION ${DATA_INSTALL_DIR}/solid/actions)
macro_display_feature_log()

339
kamera/COPYING Normal file
View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
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) <year> <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) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<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 Lesser General
Public License instead of this License.

397
kamera/COPYING.DOC Normal file
View file

@ -0,0 +1,397 @@
GNU Free Documentation License
Version 1.2, November 2002
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
1. APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The "Document", below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as "you". You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall subject
(or to related matters) and contains nothing that could fall directly
within that overall subject. (Thus, if the Document is in part a
textbook of mathematics, a Secondary Section may not explain any
mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The "Invariant Sections" are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML, PostScript or PDF designed for human modification. Examples of
transparent image formats include PNG, XCF and JPG. Opaque formats
include proprietary formats that can be read and edited only by
proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, "Title Page" means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
A section "Entitled XYZ" means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
of such a section when you modify the Document means that it remains a
section "Entitled XYZ" according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled "History", Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled "History" in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the "History" section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the section all
the substance and tone of each of the contributor acknowledgements
and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
M. Delete any section Entitled "Endorsements". Such a section
may not be included in the Modified Version.
N. Do not retitle any existing section to be Entitled "Endorsements"
or to conflict in title with any Invariant Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled "History"
in the various original documents, forming one section Entitled
"History"; likewise combine any sections Entitled "Acknowledgements",
and any sections Entitled "Dedications". You must delete all sections
Entitled "Endorsements".
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an "aggregate" if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document 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.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation 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. See
http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
Copyright (c) YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the "with...Texts." line with this:
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.

View file

@ -0,0 +1,49 @@
include(CheckCXXSourceCompiles)
set(VA_COPY_TEST_SOURCE
"
#include <stdarg.h>
#include <stdlib.h>
void f (int i, ...) {
va_list args1, args2;
va_start (args1, i);
va_copy (args2, args1);
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1); va_end (args2);
}
int main() {
f (0, 42);
return 0;
}
")
set(__VA_COPY_TEST_SOURCE
"
#include <stdarg.h>
#include <stdlib.h>
void f (int i, ...) {
va_list args1, args2;
va_start (args1, i);
__va_copy (args2, args1);
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1); va_end (args2);
}
int main() {
f (0, 42);
return 0;
}
")
check_cxx_source_compiles("${VA_COPY_TEST_SOURCE}" HAVE_VA_COPY)
if(HAVE_VA_COPY)
set(VA_COPY va_copy CACHE STRING "va_copy function")
else(HAVE_VA_COPY)
check_cxx_source_compiles("${__VA_COPY_TEST_SOURCE}" HAVE___VA_COPY)
if(HAVE___VA_COPY)
set(VA_COPY __va_copy CACHE STRING "__va_copy function")
else(HAVE___VA_COPY)
message(FATAL_ERROR "Either va_copy or __va_copy must be present. Please check your libc.")
endif(HAVE___VA_COPY)
endif(HAVE_VA_COPY)

7
kamera/README Normal file
View file

@ -0,0 +1,7 @@
Dependencies:
libgphoto2 which you currently need to get from gphoto's CVS using
cvs -d:pserver:anonymous@cvs.gphoto.sourceforge.net:/cvsroot/gphoto login
cvs -d:pserver:anonymous@cvs.gphoto.sourceforge.net:/cvsroot/gphoto co libgphoto2
You need libgphoto 2.0 final (or later).

View file

@ -0,0 +1,8 @@
/* Define if we have va_copy */
#cmakedefine HAVE_VA_COPY 1
/* Define if we have __va_copy */
#cmakedefine HAVE___VA_COPY 1
/* Define if we have gp_port_info_get_name (trigger for 2.5) */
#cmakedefine HAVE_GPHOTO2_5 1

View file

@ -0,0 +1,18 @@
########### next target ###############
set(kcm_kamera_PART_SRCS kamera.cpp kameradevice.cpp kameraconfigdialog.cpp )
kde4_add_plugin(kcm_kamera ${kcm_kamera_PART_SRCS})
target_link_libraries(kcm_kamera ${KDE4_KDEUI_LIBS} ${QT_QT3SUPPORT_LIBRARY} ${GPHOTO2_LIBRARIES})
install(TARGETS kcm_kamera DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES kamera.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -0,0 +1,2 @@
#! /bin/sh
$XGETTEXT *.cpp -o $podir/kcmkamera.pot

448
kamera/kcontrol/kamera.cpp Normal file
View file

@ -0,0 +1,448 @@
/*
Copyright (C) 2001 The Kompany
2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
2002-2003 Marcus Meissner <marcus@jet.franken.de>
2003 Nadeem Hasan <nhasan@nadmm.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 "kamera.h"
#include <QtGui/QLabel>
#include <QtGui/QListView>
#include <QtGui/QVBoxLayout>
#include <QApplication>
#include <QStandardItemModel>
#include <KGenericFactory>
#include <KConfig>
#include <KAction>
#include <KIcon>
#include <KMessageBox>
#include <KDialog>
#include <KLocale>
#include <KToolBar>
#include <KMenu>
#include <KProtocolInfo>
#include <KDebug>
#include <KActionCollection>
#include "kameraconfigdialog.h"
#include "kameradevice.h"
K_PLUGIN_FACTORY(KKameraConfigFactory, registerPlugin<KKameraConfig>();)
K_EXPORT_PLUGIN(KKameraConfigFactory("kcmkamera"))
// --------------- Camera control center module widget ---
KKameraConfig::KKameraConfig(QWidget *parent, const QVariantList &)
: KCModule(KKameraConfigFactory::componentData(), parent/*, name*/)
{
m_devicePopup = new KMenu(this);
m_actions = new KActionCollection(this);
m_config = new KConfig(KProtocolInfo::config("camera"), KConfig::SimpleConfig);
m_context = gp_context_new();
if (m_context) {
// Register the callback functions
gp_context_set_cancel_func(m_context, cbGPCancel, this);
gp_context_set_idle_func(m_context, cbGPIdle, this);
displayGPSuccessDialogue();
} else {
displayGPFailureDialogue();
}
}
KKameraConfig::~KKameraConfig()
{
delete m_config;
}
void KKameraConfig::defaults()
{
}
void KKameraConfig::displayGPFailureDialogue(void)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing(0);
topLayout->setMargin(0);
QLabel *label = new QLabel(i18n("Unable to initialize the gPhoto2 libraries."), this);
topLayout->addWidget(label);
}
void KKameraConfig::displayGPSuccessDialogue(void)
{
// set the kcontrol module buttons
setButtons(Help | Apply );
// create a layout with two vertical boxes
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing(0);
topLayout->setMargin(0);
m_toolbar = new KToolBar(this, "ToolBar");
topLayout->addWidget(m_toolbar);
m_toolbar->setMovable(false);
// create list of devices
m_deviceSel = new QListView(this);
topLayout->addWidget(m_deviceSel);
m_deviceModel = new QStandardItemModel(this);
m_deviceSel->setModel(m_deviceModel);
connect(m_deviceSel, SIGNAL(customContextMenuRequested(const QPoint &)),
SLOT(slot_deviceMenu(const QPoint &)));
connect(m_deviceSel, SIGNAL(doubleClicked(const QModelIndex &)),
SLOT(slot_configureCamera()));
connect(m_deviceSel, SIGNAL(activated(const QModelIndex &)),
SLOT(slot_deviceSelected(const QModelIndex &)));
m_deviceSel->setViewMode(QListView::IconMode);
m_deviceSel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
m_deviceSel->setContextMenuPolicy(Qt::CustomContextMenu);
// create actions
QAction *act;
act = m_actions->addAction("camera_add");
act->setIcon(KIcon("camera-photo"));
act->setText(i18n("Add"));
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_addCamera()));
act->setWhatsThis(i18n("Click this button to add a new camera."));
m_toolbar->addAction(act);
m_toolbar->addSeparator();
act = m_actions->addAction("camera_test");
act->setIcon(KIcon("dialog-ok"));
act->setText(i18n("Test"));
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_testCamera()));
act->setWhatsThis(i18n("Click this button to test the connection to the selected camera."));
m_toolbar->addAction(act);
act = m_actions->addAction("camera_remove");
act->setIcon(KIcon("user-trash"));
act->setText(i18n("Remove"));
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_removeCamera()));
act->setWhatsThis(i18n("Click this button to remove the selected camera from the list."));
m_toolbar->addAction(act);
act = m_actions->addAction("camera_configure");
act->setIcon(KIcon("configure"));
act->setText(i18n("Configure..."));
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_configureCamera()));
act->setWhatsThis(i18n("Click this button to change the configuration of the selected camera.<br><br>The availability of this feature and the contents of the Configuration dialog depend on the camera model."));
m_toolbar->addAction(act);
act = m_actions->addAction("camera_summary");
act->setIcon(KIcon("hwinfo"));
act->setText(i18n("Information"));
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_cameraSummary()));
act->setWhatsThis(i18n("Click this button to view a summary of the current status of the selected camera.<br><br>The availability of this feature and the contents of the Information dialog depend on the camera model."));
m_toolbar->addAction(act);
m_toolbar->addSeparator();
act = m_actions->addAction("camera_cancel");
act->setIcon(KIcon("process-stop"));
act->setText(i18n("Cancel"));
connect(act, SIGNAL(triggered(bool)), this, SLOT(slot_cancelOperation()));
act->setWhatsThis(i18n("Click this button to cancel the current camera operation."));
act->setEnabled(false);
m_toolbar->addAction(act);
load();
}
void KKameraConfig::populateDeviceListView(void)
{
m_deviceModel->clear();
CameraDevicesMap::ConstIterator it;
for (it = m_devices.constBegin(); it != m_devices.constEnd(); ++it) {
if (it.value()) {
QStandardItem *deviceItem = new QStandardItem;
deviceItem->setEditable(false);
deviceItem->setText(it.key());
deviceItem->setIcon(KIcon("camera-photo"));
m_deviceModel->appendRow(deviceItem);
}
}
slot_deviceSelected(m_deviceSel->currentIndex());
}
void KKameraConfig::save(void)
{
CameraDevicesMap::Iterator it;
for (it = m_devices.begin(); it != m_devices.end(); it++)
{
it.value()->save(m_config);
}
m_config->sync();
}
void KKameraConfig::load(void)
{
QStringList groupList = m_config->groupList();
QStringList::Iterator it;
int i, count;
CameraList *list;
CameraAbilitiesList *al;
GPPortInfoList *il;
const char *model, *value;
KCamera *kcamera;
for (it = groupList.begin(); it != groupList.end(); it++) {
if (*it != "<default>") {
KConfigGroup cg(m_config, *it);
if (cg.readEntry("Path").contains("usb:"))
continue;
kcamera = new KCamera(*it, cg.readEntry("Path"));
connect(kcamera, SIGNAL(error(const QString &)), SLOT(slot_error(const QString &)));
connect(kcamera, SIGNAL(error(const QString &, const QString &)), SLOT(slot_error(const QString &, const QString &)));
kcamera->load(m_config);
m_devices[*it] = kcamera;
}
}
m_cancelPending = false;
gp_list_new (&list);
gp_abilities_list_new (&al);
gp_abilities_list_load (al, m_context);
gp_port_info_list_new (&il);
gp_port_info_list_load (il);
gp_abilities_list_detect (al, il, list, m_context);
gp_abilities_list_free (al);
gp_port_info_list_free (il);
count = gp_list_count (list);
QMap<QString,QString> ports, names;
for (i = 0 ; i<count ; i++) {
gp_list_get_name (list, i, &model);
gp_list_get_value (list, i, &value);
ports[value] = model;
if (!strcmp(value,"usb:"))
names[model] = value;
}
if (ports.contains("usb:") && names[ports["usb:"]]!="usb:")
ports.remove("usb:");
QMap<QString,QString>::iterator portit;
for (portit = ports.begin() ; portit != ports.end(); portit++) {
/* kDebug() << "Adding USB camera: " << portit.data() << " at " << portit.key(); */
kcamera = new KCamera(portit.value(), portit.key());
connect(kcamera, SIGNAL(error(const QString &)), SLOT(slot_error(const QString &)));
connect(kcamera, SIGNAL(error(const QString &, const QString &)), SLOT(slot_error(const QString &, const QString &)));
m_devices[portit.value()] = kcamera;
}
populateDeviceListView();
gp_list_free (list);
}
void KKameraConfig::beforeCameraOperation(void)
{
m_cancelPending = false;
m_actions->action("camera_test")->setEnabled(false);
m_actions->action("camera_remove")->setEnabled(false);
m_actions->action("camera_configure")->setEnabled(false);
m_actions->action("camera_summary")->setEnabled(false);
m_actions->action("camera_cancel")->setEnabled(true);
}
void KKameraConfig::afterCameraOperation(void)
{
m_actions->action("camera_cancel")->setEnabled(false);
// if we're regaining control after a Cancel...
if (m_cancelPending) {
qApp->restoreOverrideCursor();
m_cancelPending = false;
}
// if any item was selected before the operation was run
// it makes sense for the relevant toolbar buttons to be enabled
slot_deviceSelected(m_deviceSel->currentIndex());
}
QString KKameraConfig::suggestName(const QString &name)
{
QString new_name = name;
new_name.remove('/'); // we cannot have a slash in a URI's host
if (!m_devices.contains(new_name)) return new_name;
// try new names with a number appended until we find a free one
int i = 1;
while (i++ < 0xffff) {
new_name = name + " (" + QString::number(i) + ')';
if (!m_devices.contains(new_name)) return new_name;
}
return QString();
}
void KKameraConfig::slot_addCamera()
{
KCamera *m_device = new KCamera(QString::null, QString()); //krazy:exclusion=nullstrassign for old broken gcc
connect(m_device, SIGNAL(error(const QString &)), SLOT(slot_error(const QString &)));
connect(m_device, SIGNAL(error(const QString &, const QString &)), SLOT(slot_error(const QString &, const QString &)));
KameraDeviceSelectDialog dialog(this, m_device);
if (dialog.exec() == QDialog::Accepted) {
dialog.save();
m_device->setName(suggestName(m_device->model()));
m_devices.insert(m_device->name(), m_device);
populateDeviceListView();
emit changed(true);
} else {
delete m_device;
}
}
void KKameraConfig::slot_removeCamera()
{
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
if (m_devices.contains(name)) {
KCamera *m_device = m_devices.value(name);
m_devices.remove(name);
delete m_device;
m_config->deleteGroup(name);
populateDeviceListView();
emit changed(true);
}
}
void KKameraConfig::slot_testCamera()
{
beforeCameraOperation();
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
if (m_devices.contains(name)) {
KCamera *m_device = m_devices.value(name);
if (m_device->test())
KMessageBox::information(this, i18n("Camera test was successful."));
}
afterCameraOperation();
}
void KKameraConfig::slot_configureCamera()
{
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
if (m_devices.contains(name)) {
KCamera *m_device = m_devices[name];
m_device->configure();
}
}
void KKameraConfig::slot_cameraSummary()
{
const QString name = m_deviceSel->currentIndex().data(Qt::DisplayRole).toString();
if (m_devices.contains(name)) {
KCamera *m_device = m_devices[name];
QString summary = m_device->summary();
if (!summary.isNull()) {
KMessageBox::information(this, summary);
}
}
}
void KKameraConfig::slot_cancelOperation()
{
m_cancelPending = true;
// Prevent the user from keeping clicking Cancel
m_actions->action("camera_cancel")->setEnabled(false);
// and indicate that the click on Cancel did have some effect
qApp->setOverrideCursor(Qt::WaitCursor);
}
void KKameraConfig::slot_deviceMenu(const QPoint &point)
{
QModelIndex index = m_deviceSel->indexAt(point);
if (index.isValid()) {
m_devicePopup->clear();
m_devicePopup->addAction(m_actions->action("camera_test"));
m_devicePopup->addAction(m_actions->action("camera_remove"));
m_devicePopup->addAction(m_actions->action("camera_configure"));
m_devicePopup->addAction(m_actions->action("camera_summary"));
m_devicePopup->exec(m_deviceSel->viewport()->mapToGlobal(point));
}
}
void KKameraConfig::slot_deviceSelected(const QModelIndex &index)
{
bool isValid = index.isValid();
m_actions->action("camera_test")->setEnabled(isValid);
m_actions->action("camera_remove")->setEnabled(isValid);
m_actions->action("camera_configure")->setEnabled(isValid);
m_actions->action("camera_summary")->setEnabled(isValid);
}
void KKameraConfig::cbGPIdle(GPContext * /*context*/, void * /*data*/)
{
/*KKameraConfig *self( reinterpret_cast<KKameraConfig*>(data) );*/
qApp->processEvents();
}
GPContextFeedback KKameraConfig::cbGPCancel(GPContext * /*context*/, void *data)
{
KKameraConfig *self( reinterpret_cast<KKameraConfig*>(data) );
// Since in practice no camera driver supports idle callbacks yet,
// we'll use the cancel callback as opportunity to process events
qApp->processEvents();
// If a cancel request is pending, ask gphoto to cancel
if (self->m_cancelPending)
return GP_CONTEXT_FEEDBACK_CANCEL;
else
return GP_CONTEXT_FEEDBACK_OK;
}
QString KKameraConfig::quickHelp() const
{
return i18n("<h1>Digital Camera</h1>\n"
"This module allows you to configure support for your digital camera.\n"
"You need to select the camera's model and the port it is connected\n"
"to on your computer (e.g. USB, Serial, Firewire). If your camera does not\n"
"appear on the list of <i>Supported Cameras</i>, go to the\n"
"<a href=\"http://www.gphoto.org\">GPhoto web site</a> for a possible update.<br><br>\n"
"To view and download images from the digital camera, go to the address\n"
"<a href=\"camera:/\">camera:/</a> in Konqueror and other KDE applications.");
}
void KKameraConfig::slot_error(const QString &message)
{
KMessageBox::error(this, message);
}
void KKameraConfig::slot_error(const QString &message, const QString &details)
{
KMessageBox::detailedError(this, message, details);
}
#include "moc_kamera.cpp"

View file

@ -0,0 +1,214 @@
[Desktop Entry]
Comment=Configure Kamera
Comment[af]=Konfigureer Kamera
Comment[ar]=إعداد Kamera
Comment[ast]=Configurar Kamera
Comment[bg]=Настройки на фотоапарат
Comment[br]=Kefluniañ Kamera
Comment[bs]=Podešavanje Kamere
Comment[ca]=Configura el Kamera
Comment[ca@valencia]=Configura el Kamera
Comment[cs]=Nastavení fotoaparátu
Comment[cy]=Ffurfweddu Kamera
Comment[da]=Indstil kamera
Comment[de]=Kamera einrichten
Comment[el]=Διαμόρφωση Kamera
Comment[en_GB]=Configure Kamera
Comment[eo]=Agordi Kamera
Comment[es]=Configurar Kamera
Comment[et]=Kaamera seadistamine
Comment[eu]=Konfiguratu kamera
Comment[fa]=پیکربندی Kamera
Comment[fi]=Kameran asetukset
Comment[fr]=Configuration de Kamera
Comment[ga]=Cumraigh Kamera
Comment[gl]=Configurar Kamera
Comment[he]=שינוי הגדרות Kamera
Comment[hi]= ि
Comment[hne]= ि
Comment[hr]=Podešavanje kamere
Comment[hu]=A fényképezőgépek beállításai
Comment[ia]=Configura Kamera
Comment[is]=Stilla samskiptaforrit stafrænna myndavéla (Kamera)
Comment[it]=Configura Kamera
Comment[ja]=
Comment[kk]=Kamera баптауы
Comment[km]= Kamera
Comment[ko]=Kamera
Comment[ku]=Kamera Veava Bike
Comment[lt]=Konfigūruoti fotoaparatą
Comment[lv]=Konfigurēt fotoaparātu
Comment[mk]=Конфигурирајте ја Kamera
Comment[mr]=
Comment[ms]=Konfigurasi Kamera
Comment[nb]=Sett opp Kamera
Comment[nds]=Kamera instellen
Comment[ne]= ि
Comment[nl]=Camera instellen
Comment[nn]=Set opp Kamera
Comment[pa]=
Comment[pl]=Ustawienia aparatu cyfrowego
Comment[pt]=Configurar o Kamera
Comment[pt_BR]=Configura o Kamera
Comment[ro]=Configurează aparatul foto digital
Comment[ru]=Настройка камеры
Comment[se]=Heivet govvenapperáhta
Comment[si]=Kamera
Comment[sk]=Nastavenie fotoaparátu
Comment[sl]=Nastavi Kamero
Comment[sr]=Подешавање Камере
Comment[sr@ijekavian]=Подешавање Камере
Comment[sr@ijekavianlatin]=Podešavanje Kamere
Comment[sr@latin]=Podešavanje Kamere
Comment[sv]=Anpassa kamera
Comment[ta]=ி
Comment[tg]=Танзимоти камера
Comment[th]= '-K'
Comment[tr]=Kamerayı Yapılandır
Comment[ug]=كامېرانى سەپلەش
Comment[uk]=Налаштування Kamera
Comment[uz]=Fotoaparatni moslash
Comment[uz@cyrillic]=Фотоапаратни мослаш
Comment[vi]=Cu hình Kamera
Comment[xh]=Qwalasela Umfoti
Comment[x-test]=xxConfigure Kameraxx
Comment[zh_CN]= Kamera
Comment[zh_HK]= Kamera
Comment[zh_TW]=
X-KDE-Keywords=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[ar]=كاميرا,ويبكام,gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[bg]=фото, фотоапарат,камера,уебкамера,цифров,gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[bs]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[ca]=gphoto,càmera,digicam,webcam,kamera
X-KDE-Keywords[ca@valencia]=gphoto,càmera,digicam,webcam,kamera
X-KDE-Keywords[cs]=gphoto,fotoaparát,digikam,webkamera,kamera
X-KDE-Keywords[da]=gphoto,kamera,digicam,webcam,digitalkamera
X-KDE-Keywords[de]=gphoto,Kamera,Digicam,Webcam,Digitalkamera
X-KDE-Keywords[el]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[en_GB]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[es]=gphoto,cámara,digicam,webcam,kamera
X-KDE-Keywords[et]=gphoto,kaamera,digitaalkaamera,veebikaamera,kamera
X-KDE-Keywords[fi]=gphoto,kamera,digikamera,webkamera
X-KDE-Keywords[fr]=GPhoto, appareil photo, appareil numérique, webcam, Kamera
X-KDE-Keywords[ga]=gphoto,ceamara,digicam,ceamara Gréasáin,kamera
X-KDE-Keywords[gl]=gphoto,cámara,digicam,cámara dixital,cámara web,kamera
X-KDE-Keywords[hu]=gphoto,fényképezőgép,digitális fényképezőgép,webkamera,kamera
X-KDE-Keywords[ia]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[is]=gphoto,myndavél,digikam,vefmynd,kamera
X-KDE-Keywords[it]=gphoto,camera,digikam,webcam,kamera
X-KDE-Keywords[kk]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[km]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[ko]=gphoto,camera,digicam,webcam,kamera,, ,
X-KDE-Keywords[lt]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[lv]=gphoto, fotoaparāts,digitālais fotoaparāts,tīmekļa kamera
X-KDE-Keywords[mr]=, , िि, ,
X-KDE-Keywords[nb]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[nds]=gphoto,camera,digicam,webcam,nettkamera,kamera
X-KDE-Keywords[nl]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[pa]=gphoto,camera,digicam,webcam,kamera,,,
X-KDE-Keywords[pl]=gphoto,kamera,digicam,internetowa,camera
X-KDE-Keywords[pt]=gphoto,câmara,máquina,webcam,kamera
X-KDE-Keywords[pt_BR]=gphoto,câmera,digikam,webcam,kamera
X-KDE-Keywords[ro]=gphoto,aparat,foto,digicam,webcam,camera,kamera
X-KDE-Keywords[ru]=gphoto,camera,digicam,webcam,kamera,камера,фото
X-KDE-Keywords[sk]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[sl]=gphoto,camera,digicam,webcam,kamera
X-KDE-Keywords[sr]=gphoto,camera,digicam,webcam,kamera,Гфото,апарат,фотоапарат,Дигикам,веб камера,камера
X-KDE-Keywords[sr@ijekavian]=gphoto,camera,digicam,webcam,kamera,Гфото,апарат,фотоапарат,Дигикам,веб камера,камера
X-KDE-Keywords[sr@ijekavianlatin]=gphoto,camera,digicam,webcam,kamera,GPhoto,aparat,fotoaparat,Digikam,veb kamera,kamera
X-KDE-Keywords[sr@latin]=gphoto,camera,digicam,webcam,kamera,GPhoto,aparat,fotoaparat,Digikam,veb kamera,kamera
X-KDE-Keywords[sv]=gphoto,kamera,digicam,webbkamera,kamera
X-KDE-Keywords[tr]=gphoto,kamera,dijital fotoğraf makinesi,web kamerası,kamera,fotoğraf makinesi
X-KDE-Keywords[uk]=gphoto,camera,digicam,webcam,kamera,фотоапарат,камера
X-KDE-Keywords[x-test]=xxgphoto,camera,digicam,webcam,kameraxx
X-KDE-Keywords[zh_CN]=gphoto,camera,digicam,webcam,kamera,,,,,,
X-KDE-Keywords[zh_TW]=gphoto,camera,digicam,webcam,kamera
Name=Digital Camera
Name[af]=Digitaal Kamera
Name[ar]=كاميرا رقمية
Name[ast]=Cámara dixital
Name[be]=Камера
Name[bg]=Цифров фотоапарат
Name[br]=Kamera niverel
Name[bs]=Digitalna kamera
Name[ca]=Càmera digital
Name[ca@valencia]=Càmera digital
Name[cs]=Digitální fotoaparát
Name[cy]=Camera Digidol
Name[da]=Digitalt kamera
Name[de]=Digitalkamera
Name[el]=Ψηφιακή κάμερα
Name[en_GB]=Digital Camera
Name[eo]=Cifereca fotilo
Name[es]=Cámara digital
Name[et]=Digikaamera
Name[eu]=Kamera digitala
Name[fa]=دوربین رقمی
Name[fi]=Digitaalikamera
Name[fr]=Appareil photo numérique
Name[ga]=Ceamara Digiteach
Name[gl]=Cámara dixital
Name[he]=מצלמה דיגיטלית
Name[hi]=िि
Name[hne]=िि
Name[hr]=Digitalna kamera
Name[hu]=Fényképezőgép
Name[ia]=Camera digital
Name[is]=Stafræn myndavél
Name[it]=Macchina fotografica digitale
Name[ja]=
Name[kk]=Цифрлық камера
Name[km]=
Name[ko]=
Name[ku]=Kameraya Dîjîtal
Name[lt]=Skaitmeninis fotoaparatas
Name[lv]=Digitālais fotoaparāts
Name[mk]=Дигитална камера
Name[mr]=िि
Name[ms]=Kamera Digital
Name[nb]=Digitalkamera
Name[nds]=Digitaalkamera
Name[ne]=िि
Name[nl]=Digitale camera
Name[nn]=Digitalkamera
Name[pa]=ਿ
Name[pl]=Aparat cyfrowy
Name[pt]=Máquina Fotográfica Digital
Name[pt_BR]=Câmera digital
Name[ro]=Aparat foto digital
Name[ru]=Цифровая камера
Name[se]=Digitalalaš govvenapperáhtta
Name[si]=
Name[sk]=Digitálny fotoaparát
Name[sl]=Digitalni fotoaparat
Name[sr]=Дигитални фотоапарат
Name[sr@ijekavian]=Дигитални фотоапарат
Name[sr@ijekavianlatin]=Digitalni fotoaparat
Name[sr@latin]=Digitalni fotoaparat
Name[sv]=Digitalkamera
Name[ta]= Digital Camera
Name[tg]=Камераи digital
Name[th]=
Name[tr]=Dijital Kamera
Name[ug]=رەقەملىك كامېرا
Name[uk]=Цифровий фотоапарат
Name[uz]=Fotoaparat
Name[uz@cyrillic]=Фотоапарат
Name[vi]=Máy nh s
Name[xh]=Ikhamera Yesuntswana
Name[x-test]=xxDigital Cameraxx
Name[zh_CN]=
Name[zh_HK]=
Name[zh_TW]=
Terminal=false
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_kamera
X-KDE-ParentApp=kcontrol
X-KDE-System-Settings-Parent-Category=hardware
X-KDE-ModuleType=Library
Icon=camera-photo
Exec=kcmshell4 kamera
X-DocPath=kcontrol/kamera/index.html
Categories=Qt;KDE;X-KDE-settings-hardware;

109
kamera/kcontrol/kamera.h Normal file
View file

@ -0,0 +1,109 @@
/*
Copyright (C) 2001 The Kompany
2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
2002-2003 Marcus Meissner <marcus@jet.franken.de>
2003 Nadeem Hasan <nhasan@nadmm.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 __kamera_h__
#define __kamera_h__
#include <kcmodule.h>
#include <gphoto2.h>
#include <KPluginFactory>
class QWidget;
class QPushButton;
class QListView;
class QStandardItemModel;
class QModelIndex;
class KCamera;
class KameraDeviceSelectDialog;
class KConfig;
class KActionCollection;
class KToolBar;
class KMenu;
class KKameraConfig : public KCModule
{
Q_OBJECT
friend class KameraDeviceSelectDialog;
public:
KKameraConfig(QWidget *parent, const QVariantList &);
virtual ~KKameraConfig();
// KCModule interface methods
void load();
void save();
void defaults();
int buttons();
QString quickHelp() const;
protected:
QString suggestName(const QString &name);
protected slots:
void slot_deviceMenu(const QPoint &point);
void slot_deviceSelected(const QModelIndex &index);
void slot_addCamera();
void slot_removeCamera();
void slot_configureCamera();
void slot_cameraSummary();
void slot_testCamera();
void slot_cancelOperation();
void slot_error(const QString &message);
void slot_error(const QString &message, const QString &details);
private:
void displayGPFailureDialogue(void);
void displayGPSuccessDialogue(void);
void displayCameraAbilities(const CameraAbilities &abilities);
void populateDeviceListView(void);
void beforeCameraOperation(void);
void afterCameraOperation(void);
// gphoto callbacks
static void cbGPIdle(GPContext *context, void *data);
static GPContextFeedback cbGPCancel(GPContext *context, void *data);
private:
typedef QMap<QString, KCamera *> CameraDevicesMap;
KConfig *m_config;
CameraDevicesMap m_devices;
bool m_cancelPending;
// gphoto members
GPContext *m_context;
// widgets for the cameras listview
QListView *m_deviceSel;
QStandardItemModel *m_deviceModel;
KActionCollection *m_actions;
QPushButton *m_addCamera, *m_removeCamera, *m_testCamera, *m_configureCamera;
KToolBar *m_toolbar;
KMenu *m_devicePopup;
// true if libgphoto2 was initialised successfully in
// the constructor
bool m_gpInitialised;
};
#endif

View file

@ -0,0 +1,333 @@
/*
Copyright (C) 2001 The Kompany
2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
2002-2003 Marcus Meissner <marcus@jet.franken.de>
2003 Nadeem Hasan <nhasan@nadmm.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 <qlayout.h>
#include <qlabel.h>
#include <Q3GroupBox>
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qslider.h>
#include <Q3ButtonGroup>
#include <kvbox.h>
#include <qtabwidget.h>
//Added by qt3to4:
#include <QFrame>
#include <QVBoxLayout>
#include <klocale.h>
#include "kameraconfigdialog.h"
#include "moc_kameraconfigdialog.cpp"
KameraConfigDialog::KameraConfigDialog(Camera */*camera*/,
CameraWidget *widget,
QWidget *parent) :
KDialog(parent),
m_widgetRoot(widget)
{
setButtons( Ok|Cancel );
setDefaultButton( Ok );
setModal( true );
QFrame *main = new QFrame( this );
setMainWidget( main );
QVBoxLayout *topLayout = new QVBoxLayout(main);
topLayout->setMargin(0);
m_tabWidget = 0;
appendWidget(main, widget);
connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
}
void KameraConfigDialog::appendWidget(QWidget *parent, CameraWidget *widget)
{
QWidget *newParent = parent;
CameraWidgetType widget_type;
const char *widget_name;
const char *widget_info;
const char *widget_label;
float widget_value_float;
int widget_value_int;
const char *widget_value_string = NULL;
gp_widget_get_type(widget, &widget_type);
gp_widget_get_label(widget, &widget_label);
gp_widget_get_info(widget, &widget_info);
gp_widget_get_name(widget, &widget_name);
QString whats_this = QString::fromLocal8Bit(widget_info); // gphoto2 doesn't seem to have any standard for i18n
// Add this widget to parent
switch(widget_type) {
case GP_WIDGET_WINDOW:
{
setCaption(QString::fromLocal8Bit(widget_label));
break;
}
case GP_WIDGET_SECTION:
{
if (!m_tabWidget) {
m_tabWidget = new QTabWidget(parent);
parent->layout()->addWidget(m_tabWidget);
}
QWidget *tab = new QWidget(m_tabWidget);
// widgets are to be aligned vertically in the tab
QVBoxLayout *tabLayout = new QVBoxLayout(tab);
m_tabWidget->addTab(tab, QString::fromLocal8Bit(widget_label));
KVBox *tabContainer = new KVBox(tab);
tabLayout->addWidget(tabContainer);
newParent = tabContainer;
tabLayout->addStretch();
break;
}
case GP_WIDGET_TEXT:
{
gp_widget_get_value(widget, &widget_value_string);
QWidget *grid = new QWidget(parent);
QGridLayout *gridLayout = new QGridLayout(grid);
grid->setLayout(gridLayout);
parent->layout()->addWidget(grid);
QLabel *label = new QLabel(QString::fromLocal8Bit( widget_label )+':', grid);
QLineEdit *lineEdit = new QLineEdit(widget_value_string, grid);
gridLayout->addWidget(label, 0, 0, Qt::AlignLeft);
gridLayout->addWidget(label, 0, 1, Qt::AlignRight);
m_wmap.insert(widget, lineEdit);
if (!whats_this.isEmpty())
grid->setWhatsThis( whats_this);
break;
}
case GP_WIDGET_RANGE:
{
float widget_low;
float widget_high;
float widget_increment;
gp_widget_get_range(widget, &widget_low, &widget_high, &widget_increment);
gp_widget_get_value(widget, &widget_value_float);
Q3GroupBox *groupBox = new Q3GroupBox(1, Qt::Horizontal,QString::fromLocal8Bit(widget_label), parent);
parent->layout()->addWidget(groupBox);
QSlider *slider = new QSlider(Qt::Horizontal, groupBox);
slider->setMinimum((int)widget_low);
slider->setMaximum((int)widget_high);
slider->setPageStep((int)widget_increment);
slider->setValue((int)widget_value_float);
m_wmap.insert(widget, slider);
if (!whats_this.isEmpty())
groupBox->setWhatsThis( whats_this);
break;
}
case GP_WIDGET_TOGGLE:
{
gp_widget_get_value(widget, &widget_value_int);
QCheckBox *checkBox = new QCheckBox(QString::fromLocal8Bit(widget_label), parent);
parent->layout()->addWidget(checkBox);
checkBox->setChecked(widget_value_int);
m_wmap.insert(widget, checkBox);
if (!whats_this.isEmpty())
checkBox->setWhatsThis( whats_this);
break;
}
case GP_WIDGET_RADIO:
{
gp_widget_get_value(widget, &widget_value_string);
int count = gp_widget_count_choices(widget);
// for less than 5 options, align them horizontally
Q3ButtonGroup *buttonGroup;
if (count > 4)
buttonGroup = new Q3VButtonGroup(QString::fromLocal8Bit(widget_label), parent);
else
buttonGroup = new Q3HButtonGroup(QString::fromLocal8Bit(widget_label), parent);
parent->layout()->addWidget(buttonGroup);
for(int i = 0; i < count; ++i) {
const char *widget_choice;
gp_widget_get_choice(widget, i, &widget_choice);
new QRadioButton(widget_choice, buttonGroup);
if(widget_value_string && !strcmp(widget_value_string, widget_choice))
buttonGroup->setButton(i);
}
m_wmap.insert(widget, buttonGroup);
if (!whats_this.isEmpty())
buttonGroup->setWhatsThis( whats_this);
break;
}
case GP_WIDGET_MENU:
{
gp_widget_get_value(widget, &widget_value_string);
QComboBox *comboBox = new QComboBox(parent);
parent->layout()->addWidget(comboBox);
comboBox->clear();
for(int i = 0; i < gp_widget_count_choices(widget); ++i) {
const char *widget_choice;
gp_widget_get_choice(widget, i, &widget_choice);
comboBox->addItem(widget_choice);
if(widget_value_string && !strcmp(widget_value_string, widget_choice))
comboBox->setCurrentIndex(i);
}
m_wmap.insert(widget, comboBox);
if (!whats_this.isEmpty())
comboBox->setWhatsThis( whats_this);
break;
}
case GP_WIDGET_BUTTON:
{
// TODO
// I can't see a way of implementing this. Since there is
// no way of telling which button sent you a signal, we
// can't map to the appropriate widget->callback
QLabel *label = new QLabel(i18n("Button (not supported by KControl)"), parent);
parent->layout()->addWidget(label);
break;
}
case GP_WIDGET_DATE:
{
// TODO
QLabel * label = new QLabel(i18n("Date (not supported by KControl)"), parent);
parent->layout()->addWidget(label);
break;
}
default:
return;
}
// Append all this widgets children
for(int i = 0; i < gp_widget_count_children(widget); ++i) {
CameraWidget *widget_child;
gp_widget_get_child(widget, i, &widget_child);
appendWidget(newParent, widget_child);
}
// Things that must be done after all children were added
/*
switch (widget_type) {
case GP_WIDGET_SECTION:
{
tabLayout->addItem( new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) );
break;
}
}
*/
}
void KameraConfigDialog::updateWidgetValue(CameraWidget *widget)
{
CameraWidgetType widget_type;
gp_widget_get_type(widget, &widget_type);
switch(widget_type) {
case GP_WIDGET_WINDOW:
// nothing to do
break;
case GP_WIDGET_SECTION:
// nothing to do
break;
case GP_WIDGET_TEXT:
{
QLineEdit *lineEdit = static_cast<QLineEdit *>(m_wmap[widget]);
gp_widget_set_value(widget, (void *)lineEdit->text().toLocal8Bit().data());
break;
}
case GP_WIDGET_RANGE:
{
QSlider *slider = static_cast<QSlider *>(m_wmap[widget]);
float value_float = slider->value();
gp_widget_set_value(widget, (void *)&value_float);
break;
}
case GP_WIDGET_TOGGLE:
{
QCheckBox *checkBox = static_cast<QCheckBox *>(m_wmap[widget]);
int value_int = checkBox->isChecked() ? 1 : 0;
gp_widget_set_value(widget, (void *)&value_int);
break;
}
case GP_WIDGET_RADIO:
{
Q3ButtonGroup *buttonGroup = static_cast<Q3VButtonGroup *>(m_wmap[widget]);
gp_widget_set_value(widget, (void *)buttonGroup->selected()->text().toLocal8Bit().data());
break;
}
case GP_WIDGET_MENU:
{
QComboBox *comboBox = static_cast<QComboBox *>(m_wmap[widget]);
gp_widget_set_value(widget, (void *)comboBox->currentText().toLocal8Bit().data());
break;
}
case GP_WIDGET_BUTTON:
// nothing to do
break;
case GP_WIDGET_DATE:
{
// not implemented
break;
}
}
// Copy child widget values
for(int i = 0; i < gp_widget_count_children(widget); ++i) {
CameraWidget *widget_child;
gp_widget_get_child(widget, i, &widget_child);
updateWidgetValue(widget_child);
}
}
void KameraConfigDialog::slotOk()
{
// Copy Qt widget values into CameraWidget hierarchy
updateWidgetValue(m_widgetRoot);
// 'ok' dialog
accept();
}

View file

@ -0,0 +1,53 @@
/*
Copyright (C) 2001 The Kompany
2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
2002-2003 Marcus Meissner <marcus@jet.franken.de>
2003 Nadeem Hasan <nhasan@nadmm.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 __kameraconfigdialog_h__
#define __kameraconfigdialog_h__
#include <qmap.h>
#include <kdialog.h>
#include <qtabwidget.h>
extern "C" {
#include <gphoto2.h>
}
class KameraConfigDialog : public KDialog
{
Q_OBJECT
public:
KameraConfigDialog(Camera *camera, CameraWidget *widget,
QWidget *parent = 0);
private slots:
void slotOk();
private:
void appendWidget(QWidget *parent, CameraWidget *widget);
void updateWidgetValue(CameraWidget *widget);
QMap<CameraWidget *, QWidget *> m_wmap;
CameraWidget *m_widgetRoot;
QTabWidget *m_tabWidget;
};
#endif

View file

@ -0,0 +1,517 @@
/*
Copyright (C) 2001 The Kompany
2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
2002-2003 Marcus Meissner <marcus@jet.franken.de>
2003 Nadeem Hasan <nhasan@nadmm.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtGui/QComboBox>
#include <QtGui/QGroupBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QListView>
#include <QtGui/QRadioButton>
#include <QtGui/QStackedWidget>
#include <QtGui/QVBoxLayout>
#include <QStandardItemModel>
#include <KLocale>
#include <KConfig>
#include <KMessageBox>
#include "config-kamera.h"
extern "C" {
#include <gphoto2.h>
}
#include "kamera.h"
#include "kameraconfigdialog.h"
#include "moc_kameradevice.cpp"
// Define some parts of the old API
#define GP_PROMPT_OK 0
#define GP_PROMPT_CANCEL -1
static const int INDEX_NONE= 0;
static const int INDEX_SERIAL = 1;
static const int INDEX_USB= 2;
static GPContext *glob_context = 0;
KCamera::KCamera(const QString &name, const QString &path)
{
m_name = name;
m_model = name;
m_path = path;
m_camera = NULL;
m_abilitylist = NULL;
}
KCamera::~KCamera()
{
if(m_camera)
gp_camera_free(m_camera);
if(m_abilitylist)
gp_abilities_list_free(m_abilitylist);
}
bool KCamera::initInformation()
{
if (m_model.isNull())
return false;
if(gp_abilities_list_new(&m_abilitylist) != GP_OK) {
emit error(i18n("Could not allocate memory for the abilities list."));
return false;
}
if(gp_abilities_list_load(m_abilitylist, glob_context) != GP_OK) {
emit error(i18n("Could not load ability list."));
return false;
}
int index = gp_abilities_list_lookup_model(m_abilitylist, m_model.toLocal8Bit().data());
if(index < 0) {
emit error(i18n("Description of abilities for camera %1 is not available."
" Configuration options may be incorrect.", m_model));
return false;
}
gp_abilities_list_get_abilities(m_abilitylist, index, &m_abilities);
return true;
}
bool KCamera::initCamera()
{
if (m_camera)
return m_camera;
else {
int result;
initInformation();
if (m_model.isNull() || m_path.isNull())
return false;
result = gp_camera_new(&m_camera);
if (result != GP_OK) {
// m_camera is not initialized, so we cannot get result as string
emit error(i18n("Could not access driver. Check your gPhoto2 installation."));
return false;
}
// set the camera's model
GPPortInfo info;
GPPortInfoList *il;
gp_port_info_list_new(&il);
gp_port_info_list_load(il);
gp_port_info_list_get_info(il, gp_port_info_list_lookup_path(il, m_path.toLocal8Bit().data()), &info);
gp_camera_set_abilities(m_camera, m_abilities);
gp_camera_set_port_info(m_camera, info);
gp_port_info_list_free(il);
// this might take some time (esp. for non-existent camera) - better be done asynchronously
result = gp_camera_init(m_camera, glob_context);
if (result != GP_OK) {
gp_camera_free(m_camera);
m_camera = NULL;
emit error(
i18n("Unable to initialize camera. Check your port settings and camera connectivity and try again."),
QString::fromLocal8Bit(gp_result_as_string(result)));
return false;
}
return m_camera;
}
}
Camera* KCamera::camera()
{
initCamera();
return m_camera;
}
QString KCamera::summary()
{
int result;
CameraText summary;
initCamera();
result = gp_camera_get_summary(m_camera, &summary, glob_context);
if (result != GP_OK)
return i18n("No camera summary information is available.\n");
return QString::fromLocal8Bit(summary.text);
}
bool KCamera::configure()
{
CameraWidget *window;
int result;
initCamera();
result = gp_camera_get_config(m_camera, &window, glob_context);
if (result != GP_OK) {
emit error(i18n("Camera configuration failed."), QString::fromLocal8Bit(gp_result_as_string(result)));
return false;
}
KameraConfigDialog kcd(m_camera, window);
result = kcd.exec() ? GP_PROMPT_OK : GP_PROMPT_CANCEL;
if (result == GP_PROMPT_OK) {
result = gp_camera_set_config(m_camera, window, glob_context);
if (result != GP_OK) {
emit error(i18n("Camera configuration failed."), QString::fromLocal8Bit(gp_result_as_string(result)));
return false;
}
}
return true;
}
bool KCamera::test()
{
// TODO: Make testing non-blocking (maybe via KIO?)
// Currently, a failed serial test times out at about 30 sec.
return camera() != 0;
}
void KCamera::load(KConfig *config)
{
KConfigGroup group = config->group(m_name);
if (m_model.isNull())
m_model = group.readEntry("Model");
if (m_path.isNull())
m_path = group.readEntry("Path");
invalidateCamera();
}
void KCamera::save(KConfig *config)
{
KConfigGroup group = config->group(m_name);
group.writeEntry("Model", m_model);
group.writeEntry("Path", m_path);
}
QString KCamera::portName()
{
QString port = m_path.left(m_path.indexOf(":")).toLower();
if (port == "serial") return i18n("Serial");
if (port == "usb") return i18n("USB");
return i18n("Unknown port");
}
void KCamera::setName(const QString &name)
{
m_name = name;
}
void KCamera::setModel(const QString &model)
{
m_model = model;
invalidateCamera();
initInformation();
}
void KCamera::setPath(const QString &path)
{
m_path = path;
invalidateCamera();
}
void KCamera::invalidateCamera()
{
if (m_camera) {
gp_camera_free(m_camera);
m_camera = NULL;
}
}
bool KCamera::isTestable() const
{
return true;
}
bool KCamera::isConfigurable()
{
initInformation();
return m_abilities.operations & GP_OPERATION_CONFIG;
}
QStringList KCamera::supportedPorts()
{
initInformation();
QStringList ports;
if (m_abilities.port & GP_PORT_SERIAL)
ports.append("serial");
if (m_abilities.port & GP_PORT_USB)
ports.append("usb");
return ports;
}
CameraAbilities KCamera::abilities()
{
return m_abilities;
}
// ---------- KameraSelectCamera ------------
KameraDeviceSelectDialog::KameraDeviceSelectDialog(QWidget *parent, KCamera *device)
: KDialog(parent)
{
setCaption( i18n("Select Camera Device") );
setButtons( Ok | Cancel );
setDefaultButton( Ok );
setModal( true );
showButtonSeparator( true );
m_device = device;
connect(m_device, SIGNAL(error(const QString &)),
SLOT(slot_error(const QString &)));
connect(m_device, SIGNAL(error(const QString &, const QString &)),
SLOT(slot_error(const QString &, const QString &)));
QWidget *page = new QWidget( this );
setMainWidget(page);
// a layout with vertical boxes
QHBoxLayout *topLayout = new QHBoxLayout(page);
topLayout->setSpacing(KDialog::spacingHint());
topLayout->setMargin(0);
// the models list
m_modelSel = new QListView(page);
m_model = new QStandardItemModel(this);
m_model->setColumnCount(1);
m_model->setHeaderData(0, Qt::Horizontal, i18nc("@title:column", "Supported Cameras"));
m_modelSel->setModel(m_model);
topLayout->addWidget( m_modelSel );
connect(m_modelSel, SIGNAL(activated(const QModelIndex &)),
SLOT(slot_setModel(const QModelIndex &)));
// make sure listview only as wide as it needs to be
m_modelSel->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,
QSizePolicy::Preferred));
QVBoxLayout *rightLayout = new QVBoxLayout();
rightLayout->setSpacing(KDialog::spacingHint());
rightLayout->setMargin(0);
topLayout->addLayout( rightLayout );
m_portSelectGroup = new QGroupBox(i18n("Port"), page);
QVBoxLayout *vertLayout = new QVBoxLayout;
m_portSelectGroup->setLayout( vertLayout );
rightLayout->addWidget(m_portSelectGroup);
m_portSettingsGroup = new QGroupBox(i18n("Port Settings"), page);
QVBoxLayout *lay = new QVBoxLayout;
m_portSettingsGroup->setLayout( lay );
rightLayout->addWidget(m_portSettingsGroup);
// Create port type selection radiobuttons.
m_serialRB = new QRadioButton(i18n("Serial"));
vertLayout->addWidget(m_serialRB );
m_serialRB->setWhatsThis( i18n("If this option is checked, the camera has to be connected to one of the computer's serial ports (known as COM ports in Microsoft Windows.)"));
m_USBRB = new QRadioButton(i18n("USB"));
vertLayout->addWidget(m_USBRB );
m_USBRB->setWhatsThis( i18n("If this option is checked, the camera has to be connected to one of the computer's USB ports, or to a USB hub."));
// Create port settings widget stack
m_settingsStack = new QStackedWidget;
QWidget *grid2 = new QWidget(m_settingsStack);
QGridLayout *gridLayout2 = new QGridLayout(grid2);
gridLayout2->setSpacing(KDialog::spacingHint());
grid2->setLayout(gridLayout2);
QLabel *label2 = new QLabel(i18n("Port"), grid2);
gridLayout2->addWidget(label2, 0, 0, Qt::AlignLeft);
lay->addWidget(grid2);
lay->addWidget( m_settingsStack );
connect(m_serialRB, SIGNAL( toggled(bool) ),
this, SLOT( changeCurrentIndex() ) );
connect(m_USBRB, SIGNAL( toggled(bool) ),
this, SLOT( changeCurrentIndex() ) );
// none tab
m_settingsStack->insertWidget(INDEX_NONE, new QLabel(i18n("No port type selected."),
m_settingsStack));
// serial tab
QWidget *grid = new QWidget(m_settingsStack);
QGridLayout *gridLayout = new QGridLayout(grid);
gridLayout->setSpacing(KDialog::spacingHint());
grid->setLayout(gridLayout);
QLabel *label = new QLabel(i18n("Port:"), grid);
m_serialPortCombo = new QComboBox(grid);
m_serialPortCombo->setEditable(true);
m_serialPortCombo->setWhatsThis( i18n("Specify here the serial port to which you connect the camera."));
gridLayout->addWidget(label, 1, 0, Qt::AlignLeft);
gridLayout->addWidget(m_serialPortCombo, 1, 1, Qt::AlignRight);
m_settingsStack->insertWidget(INDEX_SERIAL, grid);
m_settingsStack->insertWidget(INDEX_USB, new
QLabel(i18n("No further configuration is required for USB cameras."),
m_settingsStack));
// query gphoto2 for existing serial ports
GPPortInfoList *list;
GPPortInfo info;
int gphoto_ports=0;
gp_port_info_list_new(&list);
if(gp_port_info_list_load(list) >= 0) {
gphoto_ports = gp_port_info_list_count(list);
}
for (int i = 0; i < gphoto_ports; i++) {
if (gp_port_info_list_get_info(list, i, &info) >= 0) {
#ifdef HAVE_GPHOTO2_5
char *xpath;
gp_port_info_get_path (info, &xpath);
if (strncmp(xpath, "serial:", 7) == 0)
m_serialPortCombo->addItem(QString::fromLocal8Bit(xpath).mid(7));
#else
if (strncmp(info.path, "serial:", 7) == 0)
m_serialPortCombo->addItem(QString::fromLocal8Bit(info.path).mid(7));
#endif
}
}
gp_port_info_list_free(list);
// add a spacer
rightLayout->addStretch();
populateCameraListView();
load();
enableButtonOk(false );
m_portSelectGroup->setEnabled( false );
m_portSettingsGroup->setEnabled( false );
}
void KameraDeviceSelectDialog::changeCurrentIndex()
{
QRadioButton *send = dynamic_cast<QRadioButton*>( sender() );
if ( send )
{
if ( send == m_serialRB )
{
m_settingsStack->setCurrentIndex( INDEX_SERIAL );
}
else if ( send == m_USBRB )
{
m_settingsStack->setCurrentIndex( INDEX_USB );
}
}
}
bool KameraDeviceSelectDialog::populateCameraListView()
{
gp_abilities_list_new (&m_device->m_abilitylist);
gp_abilities_list_load(m_device->m_abilitylist, glob_context);
int numCams = gp_abilities_list_count(m_device->m_abilitylist);
CameraAbilities a;
if(numCams < 0) {
// XXX libgphoto2 failed to get te camera list
return false;
} else {
for(int x = 0; x < numCams; ++x) {
if(gp_abilities_list_get_abilities(m_device->m_abilitylist, x, &a) == GP_OK) {
QStandardItem *cameraItem = new QStandardItem;
cameraItem->setEditable(false);
cameraItem->setText(a.model);
m_model->appendRow(cameraItem);
}
}
return true;
}
}
void KameraDeviceSelectDialog::save()
{
m_device->setModel(m_modelSel->currentIndex().data(Qt::DisplayRole).toString());
if (m_serialRB->isChecked())
m_device->setPath("serial:" + m_serialPortCombo->currentText());
else if ( m_USBRB->isChecked() )
m_device->setPath("usb:");
}
void KameraDeviceSelectDialog::load()
{
QString path = m_device->path();
QString port = path.left(path.indexOf(':')).toLower();
if (port == "serial") setPortType(INDEX_SERIAL);
if (port == "usb") setPortType(INDEX_USB);
QList<QStandardItem *> items = m_model->findItems(m_device->model());
foreach (QStandardItem *item, items) {
const QModelIndex index = m_model->indexFromItem(item);
m_modelSel->selectionModel()->select(index, QItemSelectionModel::Select);
}
}
void KameraDeviceSelectDialog::slot_setModel(const QModelIndex &modelIndex)
{
enableButtonOk(true);
m_portSelectGroup->setEnabled(true);
m_portSettingsGroup->setEnabled(true);
QString model = modelIndex.data(Qt::DisplayRole).toString();
CameraAbilities abilities;
int index = gp_abilities_list_lookup_model(m_device->m_abilitylist, model.toLocal8Bit().data());
if(index < 0) {
slot_error(i18n("Description of abilities for camera %1 is not available."
" Configuration options may be incorrect.", model));
}
int result = gp_abilities_list_get_abilities(m_device->m_abilitylist, index, &abilities);
if (result == GP_OK) {
// enable radiobuttons for supported port types
m_serialRB->setEnabled(abilities.port & GP_PORT_SERIAL);
m_USBRB->setEnabled(abilities.port & GP_PORT_USB);
// if there's only one available port type, make sure it's selected
if (abilities.port == GP_PORT_SERIAL)
setPortType(INDEX_SERIAL);
if (abilities.port == GP_PORT_USB)
setPortType(INDEX_USB);
} else {
slot_error(i18n("Description of abilities for camera %1 is not available."
" Configuration options may be incorrect.", model));
}
}
void KameraDeviceSelectDialog::setPortType(int type)
{
// Enable the correct button
if ( type == INDEX_USB )
m_USBRB->setChecked( true );
else if ( type == INDEX_SERIAL )
m_serialRB->setChecked( true );
// Bring the right tab to the front
m_settingsStack->setCurrentIndex(type);
}
void KameraDeviceSelectDialog::slot_error(const QString &message)
{
KMessageBox::error(this, message);
}
void KameraDeviceSelectDialog::slot_error(const QString &message, const QString &details)
{
KMessageBox::detailedError(this, message, details);
}

View file

@ -0,0 +1,119 @@
/*
Copyright (C) 2001 The Kompany
2002-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
2002-2003 Marcus Meissner <marcus@jet.franken.de>
2003 Nadeem Hasan <nhasan@nadmm.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 __kameradevice_h__
#define __kameradevice_h__
#include <qmap.h>
#include <kdialog.h>
class KConfig;
class QString;
class QListView;
class QStackedWidget;
class QComboBox;
class QLineEdit;
class QRadioButton;
class QGroupBox;
class QStandardItemModel;
class QModelIndex;
class KCamera : public QObject {
friend class KameraDeviceSelectDialog;
Q_OBJECT
public:
KCamera(const QString &name, const QString &path);
~KCamera();
void invalidateCamera();
bool configure();
void load(KConfig *m_config);
void save(KConfig *m_config);
bool test();
QStringList supportedPorts();
Camera* camera();
QString name() const { return m_name ; }
QString model() const { return m_model; }
QString path() const { return m_path; }
QString portName();
QString summary();
CameraAbilities abilities();
void setName(const QString &name);
void setModel(const QString &model);
void setPath(const QString &path);
bool isTestable() const;
bool isConfigurable();
signals:
void error(const QString &message);
void error(const QString &message, const QString &details);
protected:
bool initInformation();
bool initCamera();
// void doConfigureCamera(Camera *camera, CameraWidget *widgets);
// int frontend_prompt(Camera *camera, CameraWidget *widgets);
Camera *m_camera;
// KConfig *m_config;
QString m_name; // the camera's real name
QString m_model;
QString m_path;
CameraAbilities m_abilities;
CameraAbilitiesList *m_abilitylist;
};
class KameraDeviceSelectDialog : public KDialog
{
Q_OBJECT
public:
KameraDeviceSelectDialog(QWidget *parent, KCamera *device);
void save();
void load();
protected slots:
void slot_setModel(const QModelIndex &index);
void slot_error(const QString &message);
void slot_error(const QString &message, const QString &details);
void changeCurrentIndex();
protected:
KCamera *m_device;
bool populateCameraListView(void);
void setPortType(int type);
// port settings widgets
QListView *m_modelSel;
QStandardItemModel *m_model;
QLineEdit *m_nameEdit;
QStackedWidget *m_settingsStack;
QGroupBox *m_portSelectGroup;
QGroupBox *m_portSettingsGroup;
QComboBox *m_serialPortCombo;
// port selection radio buttons
QRadioButton *m_serialRB;
QRadioButton *m_USBRB;
};
#endif

View file

@ -0,0 +1,17 @@
########### next target ###############
set(kio_kamera_PART_SRCS kamera.cpp )
kde4_add_plugin(kio_kamera ${kio_kamera_PART_SRCS})
target_link_libraries(kio_kamera ${KDE4_KIO_LIBS} ${GPHOTO2_LIBRARIES} )
install(TARGETS kio_kamera DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES camera.protocol DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -0,0 +1,16 @@
[Protocol]
exec=kio_kamera
protocol=camera
input=none
output=filesystem
listing=Name,Type
reading=true
writing=false
deleting=true
source=true
makedir=false
linking=false
moving=false
Icon=camera-photo
maxInstances=1
Class=:local

1085
kamera/kioslave/kamera.cpp Normal file

File diff suppressed because it is too large Load diff

82
kamera/kioslave/kamera.h Normal file
View file

@ -0,0 +1,82 @@
/*
Copyright (C) 2001 The Kompany
2001-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
2001-2008 Marcus Meissner <marcus@jet.franken.de>
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 __kamera_h__
#define __kamera_h__
#include <kio/slavebase.h>
#include <gphoto2.h>
class KConfig;
class KameraProtocol : public KIO::SlaveBase
{
public:
KameraProtocol(const QByteArray &pool, const QByteArray &app);
virtual ~KameraProtocol();
virtual void get(const KUrl &url);
virtual void stat(const KUrl &url);
virtual void del(const KUrl &url, bool isFile);
virtual void listDir(const KUrl &url);
virtual void special(const QByteArray &data);
CameraFile *getFile() { return m_file; }
KIO::filesize_t getFileSize() { return m_fileSize; }
void setFileSize(KIO::filesize_t newfs) { m_fileSize = newfs; }
private:
Camera *m_camera;
QString current_camera, current_port;
CameraAbilities m_abilities;
KConfig *m_config;
GPContext *m_context;
void split_url2camerapath(QString url, QString &directory, QString &file);
void setCamera(const QString &cam, const QString &port);
void reparseConfiguration(void);
bool openCamera(QString& str);
bool openCamera(void ) {
QString errstr;
return openCamera(errstr);
}
void closeCamera(void);
void statRoot(void);
void statRegular(const KUrl &url);
void translateTextToUDS(KIO::UDSEntry &udsEntry, const QString &info, const char *txt);
void translateFileToUDS(KIO::UDSEntry &udsEntry, const CameraFileInfo &info, QString name);
void translateDirectoryToUDS(KIO::UDSEntry &udsEntry, const QString &dirname);
bool cameraSupportsPreview(void);
bool cameraSupportsDel(void);
bool cameraSupportsPut(void);
int readCameraFolder(const QString &folder, CameraList *dirList, CameraList *fileList);
QString m_lockfile;
int idletime;
KIO::filesize_t m_fileSize;
CameraFile *m_file;
bool actiondone, cameraopen;
};
#endif

View file

@ -0,0 +1,64 @@
[Desktop Entry]
X-KDE-Solid-Predicate=Camera.supportedDrivers == 'gphoto'
Type=Service
Actions=open;
[Desktop Action open]
Exec=kioclient exec camera:/
Icon=system-file-manager
Name=Open with File Manager
Name[ar]=افتح بمدير الملفات
Name[ast]=Abrir con Xestor de Ficheros
Name[bg]=Отваряне в файлов браузър
Name[bs]=Otvori menadžerom datoteka
Name[ca]=Obre amb el gestor de fitxers
Name[ca@valencia]=Obri amb el gestor de fitxers
Name[cs]=Otevřít ve správci souborů
Name[da]=Åbn med filhåndtering
Name[de]=Mit Dateimanager öffnen
Name[el]=Άνοιγμα με τον διαχειριστή αρχείων
Name[en_GB]=Open with File Manager
Name[es]=Abrir con el gestor de archivos
Name[et]=Avamine failihalduriga
Name[eu]=Ireki fitxategi kudeatzailearekin
Name[fi]=Avaa tiedostonhallinnassa
Name[fr]=Ouvrir dans le gestionnaire de fichiers
Name[ga]=Oscail i mBainisteoir Comhad
Name[gl]=Abrir co xestor de ficheiros
Name[hr]=Otvori s preglednikom datoteka
Name[hu]=Megnyitás fájlkezelővel
Name[ia]=Aperi file con le gerente de file
Name[is]=Opna með skráastjóra
Name[it]=Apri con il gestore dei file
Name[ja]=
Name[kk]=Файл менеджерінде ашу
Name[km]=
Name[ko]=
Name[lt]=Atverti su failų tvarkykle
Name[lv]=Atvērt failu pārvaldniekā
Name[mr]=
Name[nb]=Åpne med filbehandler
Name[nds]=Mit Dateipleger opmaken
Name[nl]=Openen met bestandsbeheerder
Name[nn]=Opna med filhandsamaren
Name[pa]=
Name[pl]=Otwórz w przeglądarce plików
Name[pt]=Abrir com o Gestor de Ficheiros
Name[pt_BR]=Abrir com o gerenciador de arquivos
Name[ro]=Deschide cu gestionarul de fișiere
Name[ru]=Открыть в диспетчере файлов
Name[si]=
Name[sk]=Otvoriť v správcovi súborov
Name[sl]=Odpri v upravljalniku datotek
Name[sr]=Отвори менаџером фајлова
Name[sr@ijekavian]=Отвори менаџером фајлова
Name[sr@ijekavianlatin]=Otvori menadžerom fajlova
Name[sr@latin]=Otvori menadžerom fajlova
Name[sv]=Öppna med filhanterare
Name[th]=
Name[tr]=Dosya Yöneticisi ile Aç
Name[ug]=ھۆججەت باشقۇرغۇدا ئاچ
Name[uk]=Відкрити за допомогою менеджера файлів
Name[x-test]=xxOpen with File Managerxx
Name[zh_CN]=
Name[zh_TW]=使

View file

@ -0,0 +1,65 @@
project(kfilereplace)
find_package(KDE4 4.14.3 REQUIRED)
include(KDE4Defaults)
include(MacroLibrary)
add_definitions(${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
add_subdirectory( toolbar )
########### next target ###############
set(kfilereplacepart_PART_SRCS
kfilereplacepart.cpp
kfilereplaceview.cpp
kaddstringdlg.cpp
knewprojectdlg.cpp
koptionsdlg.cpp
kfilereplacelib.cpp
report.cpp
commandengine.cpp
configurationclasses.cpp )
qt4_add_dbus_adaptor( kfilereplacepart_PART_SRCS org.kde.kfilereplace.xml kfilereplacepart.h KFileReplacePart )
kde4_add_ui_files(kfilereplacepart_PART_SRCS
kfilereplaceviewwdg.ui
kaddstringdlgs.ui
knewprojectdlgs.ui
koptionsdlgs.ui )
kde4_add_plugin(kfilereplacepart WITH_PREFIX ${kfilereplacepart_PART_SRCS})
target_link_libraries(kfilereplacepart ${KDE4_KDECORE_LIBS} ${KDE4_KPARTS_LIBS} )
install(TARGETS kfilereplacepart DESTINATION ${PLUGIN_INSTALL_DIR})
########### next target ###############
set(kfilereplace_SRCS kfilereplace.cpp main.cpp )
kde4_add_executable(kfilereplace ${kfilereplace_SRCS})
target_link_libraries(kfilereplace ${KDE4_KPARTS_LIBS} )
install(TARGETS kfilereplace ${INSTALL_TARGETS_DEFAULT_ARGS} )
########### install files ###############
install( FILES kfilereplace.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install( FILES kfilereplacepartui.rc DESTINATION ${DATA_INSTALL_DIR}/kfilereplacepart)
install( FILES kfilereplaceui.rc DESTINATION ${DATA_INSTALL_DIR}/kfilereplace)
install( FILES kfilereplacepart.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install( FILES org.kde.kfilereplace.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR} )
kde4_install_icons( ${ICON_INSTALL_DIR} )

280
kfilereplace/COPYING Normal file
View file

@ -0,0 +1,280 @@
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

211
kfilereplace/ChangeLog Normal file
View file

@ -0,0 +1,211 @@
2005-02-20: Andras Mantia <amantia@kde.org>
* Added the possibility to select the encoding of the files and a warning about
the possible damaged result if the wrong encoding is chosen
2005-02-16: Andras Mantia <amantia@kde.org>
* Accept paths as command line arguments
2005-01-29 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* Cleaning up.
2005-01-23 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* Some clean up.
* Now the text 'captured text "blabla" at line...' etc. is substituted with
'Line:xyz, Col:abc "blabla"'
* Fixed a bug in the string view, that cause KFR to crash if the string list is empty
and the user click on it with the mouse.
2005-01-17 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* Now it should be possible to handle other characters encoding, like japanese.
* Added, but still buggy, a "replace confirmation" option.
* Now when open KFilereplace as standalone application it uses
this "*.c*;*.h*;*.sh;*.txt*;*.p*;*.java;*.log" string as default filter.
2005-01-14 Andras Mantia <amantia@kde.org>
* Don't show the cannot open file dialogs for directories
* Don't create a backup for every scanned file, only for those that were modified
* Don't update the timestap for every scanned file
* Fix installation of the icons (they go to the part's data dir now)
2005-01-13 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I added some other infos to the docbook manual, I hope to complete it as soon as possible.
* I added a new command: [$mathexp:some_expression$]. It uses the bc calculator to
compute the result of an expression.
2005-01-11 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* Fixed a bug in KAddStringDlg: now when we want edit a string the search-only mode and search-replace mode
don't merge.
* Modified KFR file format: I added the tag '<mode search=""/>' just after the root <kfr> to allows
kfilereplace to recognize if the list to load is a list of only search strings. I added some lines of code
to permit users to load files that don't have this new tag.
* I'm writing docbook manual.
2005-01-10 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* The KFilereplaceView widget has been modified. Now it change the layout of kfilereplace depending of the
value of m_option->m_searchOnlyMode.
* I fixed a bug in the backup file option.
2004-12-13 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I modified the way we can open files in quanta. Now we can select one or more entries
in the QListView that store the results, and open several files, at the same time.
For selecting more than one file, we must press CTRL button while clicking with mouse
on the entry we want open.
2004-11-10 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I added a graphical file counter.
* I added a semaphore to notify user about the state of the search.
* I improved a little the speed.
* I made some cleanup.
2004-09-27 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I fixed a bug that affect some strings in case of translation.
* I fixed a bug that affect "Create backup" option, I think that now this feature should work
properly.
2004-09-26 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I did some cleanup.
2004-09-11 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I added the class ResultViewEntry in configurationclasses.(h,cpp) to make the replace algorithm more clean.
* I make multiline text searching more useable.
* Now the file entries in the result view are shown with descriptive icons.
* I'm trying to write some documentation, in the meanwhile a tutorial is present.
2004-08-13 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I added CommandEngine class and Report class.
In fact I moved the code that do the report document and the
code that do commands feature from KFileREplaceLib to these two classes.
2004-08-09 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I fixed a bug that affected the method "void KFileReplaceView::slotStringsClear()" in kfilereplaceview.cpp file.
This bug caused the list of strings not to be correctly erased.
2004-08-07 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I modified the save-results system(thanks Luciano for the idea of using xml/css tecnology).
Now KFR creates a directory with name "NAME" that contains a xml file "NAME.xml"
and a css file "NAME.css". These two files are the new "report document"
that substitutes the xhtml file. To try it choose "Search/Replace|Results|Create Report File" menu option.
* I fixed a bug that causes Quanta to crash when we push Cancel button in new project
dialog.
* I finished the tutorial.
2004-08-01 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* The line "if(::access(directory.local8Bit(), R_OK | X_OK) == -1)" has been removed,
and subtitued with "QFileInfo dirInfo(directory); "
"if(not(dirInfo.isReadable() and dirInfo.isExecutable())"
" or "
" not(dirInfo.isWritable())) "
in kfilereplacepart.cpp
2004-07-30 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* The icons have been fixed!!! What a miracle!!!
2004-07-24 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I added a little feature. When KFR matches a string, it shows the row and the column
where that match is, by using a message like this:
/my/path/file
|
|__ string "xyz" found at line:40, column:2
|__ string "xyz" found at line:18, column:57
|__.............
Now if you use "Edit with Quanta" popup menu option, say, on the line:
"string "xyz" found at line:40, column:2"
of the result view, Quanta will open the file /my/path/file at row 40, column 2.
2004-07-20 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I fixed a bug that affects the generation of extension of
the backup files.
2004-07-17 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I fixed the bug that causes quanta to crash when KFR is active.
* I fixed (I hope!) the simulation feature.
* I reorganize the KOptionsDlg UI.
* I Added some tool tips.
* I' m tired and I go on bed ;-)
2004-07-16 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* The KNewProjectDlg was modified, adding quick search/replace line edit objects
* A option in KOptionDlg was added, so that the files that don't
contain the strings we are searching for, will not be shown.
* Some code clean-up
* A bug with KAddStringDlg was fixed.
* I found a bug that makes quanta to crash when we close quanta with the x button...
I'm trying to fix it.
2004-05-30 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* Well, KFR has been entirely (more or less :-)) rewrote.
the files:
apistruct.h
kernel.(cpp,h)
kexpression.(cpp,h)
kfilereplacedoc.(cpp,h)
kfilereplacepref.(cpp,h)
were removed and these files are added:
configurationclasses.h
. the internal architecture was redesigned, to use QT/KDE tecnologies in particular:
. C-like code were removed (where possible).
. some system dependent functions were substituted with more portable code.
. the apistructs.h file were substituted with one class in configurationclasses.h.
. the UIs were modified in particular:
. new "add string" dialog were added.
. project dialog were modified.
. some new features were added in particular:
. the variable replace mechanism were modified.
. the result view shows the line and column where the string has been found.
. now the mechanism of search/replace with wildcards inherits from QT regular expression engine.
* I wrote a little tutorial(TUTOR.txt), but a more exhaustive tutorial will be released soon.
Note: there some bugs to fix and some feature to implement, in particular:
. Simulation is not yet implemented.
. Some options are presents but disabled.
. I want to add more KFR variable commands.
2004-03-26 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* Added a feature. Now we can open a file from the result view of KFR in Quanta(thanks Andras).
2004-03-14 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* Replaced two QLineEdit with two QSpinbox in knewprojectdlg.ui
* Fixed a bug in the new kfr (XML-based) file format.
2004-03-12 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* Removed KresultView(.h,.cpp). Now KFileReplaceView is a QWidget that contains results and
strings view.
* Added whatthis.h that contains the "what's this" strings.
* Fixed a bug that generate a wrong XHTML result file.
2004-03-06 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* Added kconfirmdlgs.ui.
* Fixed a bug in KOptionDlg, now when we select a option, the selection is shown correctly.
* Fixed a bug KNewProjectDlg.
2004-02-26 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* I added a method 'editStrings' that fixes tha behaviour when a user
chooses edit string option instead of add string option.
* I modified the property textFormat of the QTextEdit widgets of
KAddstringDlg, from the value 'AutoText' to the value 'PlainText',
so the QTextEdit widgets will not try to render a string containing
html code.
2004-02-24 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* kfilereplacepref.(h,cpp) were removed.
* kernel.(h,cpp) now are a singleton class.
* Some macros in kernel.h were replaced with integer constants.
* Methods in kernel.h file were renamed.
* Some superflous #include lines were removed.
* The filelib.(h,cpp) were subtituted with KFilereplaceLib singleton class.
* Now kfilereplace logo and icons in the result view appear.
2004-02-18 Emiliano Gulmini <emi_barbarossa@yahoo.it>
* The icons in toolbar directory were redrawn.
* Deleted the KFRHeader struct from apistruct.h.
* The mechanism of saving the string rules has been modified: now we can save the rules in a
file like this "a_file_name.kfr" that is an XML file.
* The file containing the results of the operations is now a XHTML file.
* Two new files UI added: now KOptionDlg inherits from KOptionDlgS and KAddstringDlg inherits
from KAddstringDlgS.
* The klistviewstring.(h,cpp) were removed.
* A lot of clean up has been made in all files.

3
kfilereplace/Messages.sh Executable file
View file

@ -0,0 +1,3 @@
#! /usr/bin/env bash
$EXTRACTRC *.rc *.ui >> rc.cpp
$XGETTEXT *.cpp *.h -o $podir/kfilereplace.pot

View file

@ -0,0 +1,214 @@
/***************************************************************************
commandengine.cpp - kfr commands feature class
-------------------
begin : fri aug 13 15:29:46 CEST 2004
copyright : (C) 2004 Emiliano Gulmini
email : emi_barbarossa@yahoo.it
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// QT
#include <qdatetime.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qdom.h>
//Added by qt3to4:
#include <Q3CString>
// KDE
#include <kuser.h>
#include <krandomsequence.h>
#include <k3process.h>
// local
#include "commandengine.h"
QString CommandEngine::datetime(const QString& opt, const QString& arg)
{
Q_UNUSED(arg);
if(opt == "iso")
return QDateTime::currentDateTime().toString(Qt::ISODate);
if(opt == "local")
return QDateTime::currentDateTime().toString(Qt::LocalDate);
return QString();
}
QString CommandEngine::user(const QString& opt, const QString& arg)
{
Q_UNUSED(arg);
KUser u;
if(opt == "uid")
return QString::number(u.uid(),10);
if(opt == "gid")
return QString::number(u.gid(),10);
if(opt == "loginname")
return u.loginName();
if(opt == "fullname")
return u.fullName();
if(opt == "homedir")
return u.homeDir();
if(opt == "shell")
return u.shell();
return QString();
}
QString CommandEngine::loadfile(const QString& opt, const QString& arg)
{
Q_UNUSED(arg);
QFile f(opt);
if(!f.open(QIODevice::ReadOnly)) return QString();
QTextStream t(&f);
QString s = t.readAll();
f.close();
return s;
}
QString CommandEngine::empty(const QString& opt, const QString& arg)
{
Q_UNUSED(opt);
Q_UNUSED(arg);
return "";
}
QString CommandEngine::mathexp(const QString& opt, const QString& arg)
{
/* We will use bc 1.06 by Philip A. Nelson <philnelson@acm.org> */
//Q_UNUSED(opt);
Q_UNUSED(arg);
QString tempOpt = opt;
tempOpt.replace("ln","l");
tempOpt.replace("sin","s");
tempOpt.replace("cos","c");
tempOpt.replace("arctan","a");
tempOpt.replace("exp","e");
QString program = "var=("+tempOpt+");print var";
QString script = "echo '"+program+"' | bc -l;";
K3Process* proc = new K3Process();
proc->setUseShell(true);
*(proc) << script;
connect(proc, SIGNAL(receivedStdout(K3Process*,char*,int)), this, SLOT(slotGetScriptOutput(K3Process*,char*,int)));
connect(proc, SIGNAL(receivedStderr(K3Process*,char*,int)), this, SLOT(slotGetScriptError(K3Process*,char*,int)));
connect(proc, SIGNAL(processExited(K3Process*)), this, SLOT(slotProcessExited(K3Process*)));
//Through slotGetScriptOutput, m_processOutput contains the result of the K3Process call
if(!proc->start(K3Process::Block, K3Process::All))
{
return QString();
}
else
{
proc->wait();
}
delete proc;
QString tempbuf = m_processOutput;
m_processOutput = QString();
return tempbuf;
}
QString CommandEngine::random(const QString& opt, const QString& arg)
{
Q_UNUSED(arg);
long seed;
if(opt.isEmpty())
{
QDateTime dt;
seed = dt.toTime_t();
}
else
seed = opt.toLong();
KRandomSequence seq(seed);
return QString::number(seq.getLong(1000000),10);
}
QString CommandEngine::stringmanip(const QString& opt, const QString& arg)
{
Q_UNUSED(opt);
Q_UNUSED(arg);
return "";
}
QString CommandEngine::variableValue(const QString &variable)
{
QString s = variable;
s.remove("[$").remove("$]").remove(" ");
if(s.contains(":") == 0)
return variable;
else
{
QString leftValue = s.section(":",0,0),
midValue = s.section(":",1,1),
rightValue = s.section(":",2,2);
QString opt = midValue;
QString arg = rightValue;
if(leftValue == "stringmanip")
return stringmanip(opt, arg);
if(leftValue == "datetime")
return datetime(opt, arg);
if(leftValue == "user")
return user(opt, arg);
if(leftValue == "loadfile")
return loadfile(opt, arg);
if(leftValue == "empty")
return empty(opt, arg);
if(leftValue == "mathexp")
return mathexp(opt, arg);
if(leftValue == "random")
return random(opt, arg);
return variable;
}
}
//SLOTS
void CommandEngine::slotGetScriptError(K3Process* proc, char* s, int i)
{
Q_UNUSED(proc);
Q_UNUSED(proc);
Q3CString temp(s,i+1);
if(temp.isEmpty() || temp == "\n") return;
}
void CommandEngine::slotGetScriptOutput(K3Process* proc, char* s, int i)
{
Q_UNUSED(proc);
Q3CString temp(s,i+1);
if(temp.isEmpty() || temp == "\n") return;
m_processOutput += QString::fromLocal8Bit(temp);
}
void CommandEngine::slotProcessExited(K3Process* proc)
{
Q_UNUSED(proc);
}
#include "moc_commandengine.cpp"

View file

@ -0,0 +1,57 @@
/***************************************************************************
commandengine.h - kfr commands feature class
-------------------
begin : fri aug 13 15:29:46 CEST 2004
copyright : (C) 2004 Emiliano Gulmini
email : emi_barbarossa@yahoo.it
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef COMMANDENGINE_H
#define COMMANDENGINE_H
// QT
class QString;
#include <qobject.h>
//KDE
class K3Process;
class CommandEngine : public QObject
{
Q_OBJECT
private:
QString m_processOutput;
public:
CommandEngine() {}
public:
/**
These functions implement the KFR commands
*/
QString datetime(const QString& opt, const QString& arg);
QString user(const QString& opt, const QString& arg);
QString loadfile(const QString& opt, const QString& arg);
QString empty(const QString& opt, const QString& arg);
QString mathexp(const QString& opt, const QString& arg);
QString random(const QString& opt, const QString& arg);
QString stringmanip(const QString& opt, const QString& arg);
QString variableValue(const QString &variable);
private slots:
void slotGetScriptOutput(K3Process*,char*,int);
void slotGetScriptError(K3Process*,char*,int);
void slotProcessExited(K3Process*);
};
#endif // COMMANDENGINE_H

View file

@ -0,0 +1,188 @@
/***************************************************************************
configurationclasses.cpp - description
-------------------
begin : Sat Sep 11 2004
copyright : (C) 2004 Emiliano Gulmini
email : emi_barbarossa@yahoo.it
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// QT
// KDE
// local
#include "configurationclasses.h"
#include "whatthis.h"
using namespace whatthisNameSpace;
//RCOptions Class
RCOptions::RCOptions()
{
m_searchingOnlyMode = false;
}
RCOptions& RCOptions::operator=(const RCOptions& ci)
{
//m_callResetActions = ci.m_callResetActions;
m_directories = ci.m_directories;
m_filters = ci.m_filters;
m_currentDirectory = ci.m_currentDirectory;
m_minSize = ci.m_minSize;
m_maxSize = ci.m_maxSize;
m_dateAccess = ci.m_dateAccess;
m_minDate = ci.m_minDate;
m_maxDate = ci.m_maxDate;
m_caseSensitive = ci.m_caseSensitive;
m_recursive = ci.m_recursive;
m_followSymLinks = ci.m_followSymLinks;
m_allStringsMustBeFound = ci.m_allStringsMustBeFound;
m_backup = ci.m_backup;
m_backupExtension = ci.m_backupExtension;
m_ignoreFiles = ci.m_ignoreFiles;
m_regularExpressions = ci.m_regularExpressions;
m_variables = ci.m_variables;
m_haltOnFirstOccur = ci.m_haltOnFirstOccur;
m_ignoreHidden = ci.m_ignoreHidden;
m_simulation = ci.m_simulation;
m_searchingOnlyMode = ci.m_searchingOnlyMode;
m_ownerUserIsChecked = ci.m_ownerUserIsChecked;
m_ownerGroupIsChecked = ci.m_ownerGroupIsChecked;
m_ownerUserBool = ci.m_ownerUserBool;
m_ownerGroupBool = ci.m_ownerGroupBool;
m_ownerUserType = ci.m_ownerUserType;
m_ownerGroupType = ci.m_ownerGroupType;
m_ownerUserValue = ci.m_ownerUserValue;
m_ownerGroupValue = ci.m_ownerGroupValue;
m_mapStringsView = ci.m_mapStringsView;
m_quickSearchString = ci.m_quickSearchString;
m_quickReplaceString = ci.m_quickReplaceString;
m_recentStringFileList = ci.m_recentStringFileList;
m_notifyOnErrors = ci.m_notifyOnErrors;
return (*this);
}
//ResultViewEntry Class
ResultViewEntry::ResultViewEntry(const QString &nkey, const QString &ndata, bool regexp, bool caseSensitive)
{
m_caseSensitive = caseSensitive;
m_regexp = regexp;
if(regexp)
{
m_rxKey = QRegExp('('+nkey+')', caseSensitive, false);
}
else
{
m_key = nkey;
}
m_data = ndata;
m_matchedStringsOccurrence = 0;
m_pos = 0;
}
int ResultViewEntry::lineNumber(const QString& line) const
{
return line.mid(0,m_pos).count('\n')+1;
}
int ResultViewEntry::columnNumber(const QString& line) const
{
return(m_pos - line.lastIndexOf('\n',m_pos));
}
void ResultViewEntry::incOccurrences()
{
m_matchedStringsOccurrence++;
}
int ResultViewEntry::occurrences() const
{
return m_matchedStringsOccurrence;
}
bool ResultViewEntry::regexp()const
{
return m_regexp;
}
int ResultViewEntry::pos(const QString& line)
{
if(m_regexp)
m_pos = m_rxKey.search(line,m_pos);
else
m_pos = line.find(m_key, m_pos, m_caseSensitive);
return m_pos;
}
void ResultViewEntry::incPos()
{
int kl = keyLength(),
dl = dataLength();
if(kl < dl)
m_pos += kl;
else
m_pos += dl;
}
QString ResultViewEntry::capturedText(const QString& line)
{
QString cap;
if(m_regexp)
cap = m_rxKey.cap(1);
else
cap =line.mid(m_pos,m_key.length());
return cap;
}
QString ResultViewEntry::message(const QString& capturedText, int x, int y) const
{
QString data = m_data;
//return i18n(" captured text \"%1\" replaced with \"%2\" at line: %3, column: %4 ", capturedText, data, x, y);
return i18n(" Line:%3,Col:%4 - \"%1\" -> \"%2\"", capturedText, data, x, y);
}
int ResultViewEntry::keyLength() const
{
if(m_regexp)
return m_rxKey.matchedLength();
else
return m_key.length();
}
int ResultViewEntry::dataLength() const
{
return m_data.length();
}
void ResultViewEntry::updateLine(QString& line)
{
line.insert(m_pos, m_data);
line.remove(m_pos + dataLength(), keyLength());
}

View file

@ -0,0 +1,165 @@
/***************************************************************************
configurationclasses.h - description
-------------------
begin : Sat Apr 17 2004
copyright : (C) 2004 Emiliano Gulmini
email : <emi_barbarossa@yahoo.it>
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef CONFIGURATIONCLASSES_H
#define CONFIGURATIONCLASSES_H
// QT
#include <qstring.h>
#include <qstringlist.h>
#include <qdatetime.h>
#include <qmap.h>
#include <qregexp.h>
typedef QMap<QString,QString> KeyValueMap;
// entry strings in the kfilereplacerc file
const QString rcDirectoriesList = "Directories list";
const QString rcFiltersList = "Filters list";
const QString rcRecentFiles = "Recent files";
const QString rcAllStringsMustBeFound = "All strings must be found";
const char rcEncoding[] = "Encoding";
const QString rcCaseSensitive = "Case sensitive";
const QString rcConfirmStrings = "Confirm strings";
const QString rcConfirmFiles = "Confirm files";
const QString rcConfirmDirs = "Confirm directories";
const QString rcFollowSymLinks = "Follow symbolic links";
const QString rcHaltOnFirstOccur = "Halt on first occurrence";
const QString rcIgnoreHidden = "Ignore hidden files";
const QString rcRecursive = "Search/replace in sub folders";
const QString rcVariables = "Enable variables";
const QString rcRegularExpressions = "Enable regular expressions";
const QString rcMinFileSize = "Minimum file size";
const QString rcMaxFileSize = "Maximum file size";
const QString rcValidAccessDate = "Access mode";
const QString rcMinDate = "Minimum access date";
const QString rcMaxDate = "Maximum access date";
const QString rcOwnerUser = "Owner user filters";
const QString rcOwnerGroup = "Owner group filters";
const QString rcSearchMode = "Search only mode";
const QString rcBackupExtension = "Backup file extension";
const QString rcIgnoreFiles = "Ignore files if there is no match";
const QString rcNotifyOnErrors = "NotifyOnErrors";
const QString rcAskConfirmReplace = "Ask confirmation on replace";
const QString rcDontAskAgain = "Don't ask again";
// Default configuration options
const QString EncodingOption = "utf8";
const bool RecursiveOption = true;
const bool CaseSensitiveOption = false;
const bool FollowSymbolicLinksOption = false;
const bool RegularExpressionsOption = false;
const bool VariablesOption = false;
const bool StopWhenFirstOccurenceOption = false;
const bool IgnoreHiddenOption = false;
const int FileSizeOption = -1;
const QString AccessDateOption="unknown";
const QString ValidAccessDateOption="unknown";
const QString OwnerOption="false,Name,Equals To";
const bool SearchModeOption=true;
const QString BackupExtensionOption="false,~";
const bool IgnoreFilesOption = true;
const bool NotifyOnErrorsOption = false;
const bool AskConfirmReplaceOption = false;
// This class stores configuration information
class RCOptions
{
public:
bool m_callResetActions;
bool m_askConfirmReplace,
m_dontAskAgain;
QString m_directories,
m_filters,
m_currentDirectory;
int m_minSize,
m_maxSize;
QString m_dateAccess,
m_minDate,
m_maxDate;
QString m_encoding;
bool m_caseSensitive,
m_recursive,
m_followSymLinks,
m_allStringsMustBeFound,
m_backup,
m_regularExpressions;
bool m_variables,
m_haltOnFirstOccur,
m_ignoreHidden,
m_simulation,
m_searchingOnlyMode;
bool m_ownerUserIsChecked,
m_ownerGroupIsChecked;
QString m_ownerUserType,
m_ownerGroupType,
m_ownerUserValue,
m_ownerGroupValue,
m_ownerUserBool,
m_ownerGroupBool;
QString m_backupExtension;
bool m_ignoreFiles;
KeyValueMap m_mapStringsView;
QString m_quickSearchString,
m_quickReplaceString;
QStringList m_recentStringFileList;
bool m_notifyOnErrors;
public:
RCOptions();
RCOptions& operator=(const RCOptions& ci);
};
class ResultViewEntry
{
private:
QString m_key;
QString m_data;
QRegExp m_rxKey;
bool m_regexp;
bool m_caseSensitive;
int m_pos;
int m_matchedStringsOccurrence;
public:
ResultViewEntry(const QString &nkey, const QString &ndata, bool regexp, bool caseSensitive);
int lineNumber(const QString& line) const ;
int columnNumber(const QString& line) const ;
void incOccurrences();
int occurrences() const ;
bool regexp()const ;
int pos(const QString& line) ;
void incPos();
QString capturedText(const QString& line) ;
QString message(const QString& capturedText, int x, int y) const;
int keyLength() const;
int dataLength() const;
void updateLine(QString& line);
};
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 978 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -0,0 +1,272 @@
/***************************************************************************
KAddStringDlg.cpp - description
-------------------
begin : Sat Oct 16 1999
copyright : (C) 1999 by François Dupoux
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.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. *
* *
***************************************************************************/
// QT
#include <qlabel.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <q3listview.h>
// KDE
#include <kmessagebox.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <kconfig.h>
#include <kapplication.h>
#include <ktoolinvocation.h>
// local
#include "kaddstringdlg.h"
#include "whatthis.h"
using namespace whatthisNameSpace;
KAddStringDlg::KAddStringDlg(RCOptions* info, bool wantEdit, QWidget *parent, const char *name) : KAddStringDlgS(parent,name,true)
{
m_option = info;
m_wantEdit = wantEdit;
m_currentMap = m_option->m_mapStringsView;
initGUI();
connect(m_pbOK, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(m_rbSearchOnly, SIGNAL(pressed()), this, SLOT(slotSearchOnly()));
connect(m_rbSearchReplace, SIGNAL(pressed()), this, SLOT(slotSearchReplace()));
connect(m_pbAdd, SIGNAL(clicked()), this, SLOT(slotAddStringToView()));
connect(m_pbDel, SIGNAL(clicked()), this, SLOT(slotDeleteStringFromView()));
connect(m_pbHelp, SIGNAL(clicked()), this ,SLOT(slotHelp()));
whatsThis();
}
//PRIVATE
void KAddStringDlg::initGUI()
{
m_pbAdd->setIconSet(SmallIconSet(QString::fromLatin1("go-next")));
m_pbDel->setIconSet(SmallIconSet(QString::fromLatin1("go-previous")));
m_stack->addWidget(m_stringView);
m_stack->addWidget(m_stringView_2);
if(m_option->m_searchingOnlyMode)
{
if(m_wantEdit)
m_rbSearchReplace->setEnabled(false);
m_rbSearchOnly->setChecked(true);
m_edSearch->setEnabled(true);
m_edReplace->setEnabled(false);
m_tlSearch->setEnabled(true);
m_tlReplace->setEnabled(false);
}
else
{
if(m_wantEdit)
m_rbSearchOnly->setEnabled(false);
m_rbSearchReplace->setChecked(true);
m_edSearch->setEnabled(true);
m_edReplace->setEnabled(true);
m_tlSearch->setEnabled(true);
m_tlReplace->setEnabled(true);
}
raiseView();
if(m_wantEdit)
loadMapIntoView();
}
void KAddStringDlg::eraseViewItems()
{
Q3ListViewItem* item = m_sv->firstChild();
if(item == 0)
return;
else
{
while(item)
{
Q3ListViewItem* tempItem = item;
item = item->nextSibling();
delete tempItem;
}
}
}
void KAddStringDlg::raiseView()
{
if(m_option->m_searchingOnlyMode)
m_sv = m_stringView_2;
else
m_sv = m_stringView;
m_stack->raiseWidget(m_sv);
}
bool KAddStringDlg::columnContains(Q3ListView* lv,const QString& s, int column)
{
Q3ListViewItem* i = lv->firstChild();
while (i != 0)
{
if(i->text(column) == s)
return true;
i = i->nextSibling();
}
return false;
}
void KAddStringDlg::saveViewContentIntoMap()
{
Q3ListViewItem* i = m_sv->firstChild();
while(i != 0)
{
if(m_option->m_searchingOnlyMode)
m_currentMap[i->text(0)] = QString();
else
m_currentMap[i->text(0)] = i->text(1);
i = i->nextSibling();
}
}
void KAddStringDlg::loadMapIntoView()
{
KeyValueMap::Iterator itMap;
for (itMap = m_currentMap.begin(); itMap != m_currentMap.end(); ++itMap)
{
Q3ListViewItem* temp = new Q3ListViewItem(m_sv);
temp->setText(0,itMap.key());
if(!m_option->m_searchingOnlyMode)
temp->setText(1,itMap.data());
}
}
void KAddStringDlg::whatsThis()
{
m_rbSearchOnly->setWhatsThis( rbSearchOnlyWhatthis);
m_rbSearchReplace->setWhatsThis( rbSearchReplaceWhatthis);
m_edSearch->setWhatsThis( edSearchWhatthis);
m_edReplace->setWhatsThis( edReplaceWhatthis);
}
//PRIVATE SLOTS
void KAddStringDlg::slotOK()
{
m_option->m_mapStringsView = m_currentMap;
accept();
}
void KAddStringDlg::slotSearchOnly()
{
m_option->m_searchingOnlyMode = true;
m_rbSearchOnly->setChecked(true);
m_edSearch->setEnabled(true);
m_edReplace->setEnabled(false);
m_tlSearch->setEnabled(true);
m_tlReplace->setEnabled(false);
//sets the right view appearance
raiseView();
//empties the view content
eraseViewItems();
}
void KAddStringDlg::slotSearchReplace()
{
m_option->m_searchingOnlyMode = false;
m_rbSearchReplace->setChecked(true);
m_edSearch->setEnabled(true);
m_edReplace->setEnabled(true);
m_tlSearch->setEnabled(true);
m_tlReplace->setEnabled(true);
//sets the right view appearance
raiseView();
//empties the view content
eraseViewItems();
}
void KAddStringDlg::slotAddStringToView()
{
if(m_option->m_searchingOnlyMode)
{
QString text = m_edSearch->text();
if(!(text.isEmpty() || columnContains(m_sv, text, 0)))
{
Q3ListViewItem* lvi = new Q3ListViewItem(m_sv);
lvi->setMultiLinesEnabled(true);
lvi->setText(0,text);
m_currentMap[text] = QString();
m_edSearch->clear();
}
}
else
{
QString searchText = m_edSearch->text(),
replaceText = m_edReplace->text();
if(!(searchText.isEmpty() || replaceText.isEmpty() || columnContains(m_sv,searchText,0) || columnContains(m_sv,replaceText,1)))
{
Q3ListViewItem* lvi = new Q3ListViewItem(m_sv);
lvi->setMultiLinesEnabled(true);
lvi->setText(0,searchText);
m_edSearch->clear();
lvi->setText(1,replaceText);
m_currentMap[searchText] = replaceText;
m_edReplace->clear();
}
}
}
void KAddStringDlg::slotDeleteStringFromView()
{
// Choose current item or selected item
Q3ListViewItem* currentItem = m_sv->currentItem();
// Do nothing if list is empty
if(currentItem == 0)
return;
m_currentMap.remove(currentItem->text(0));
if(m_option->m_searchingOnlyMode)
{
m_edSearch->setText(currentItem->text(0));
m_edReplace->clear();
//currentItem->setText(1,m_edReplace->text());
}
else
{
m_edSearch->setText(currentItem->text(0));
m_edReplace->setText(currentItem->text(1));
}
delete currentItem;
currentItem = 0;
}
void KAddStringDlg::slotHelp()
{
KToolInvocation::invokeHelp(QString::null, "kfilereplace"); //krazy:exclude=nullstrassign for old broken gcc
}
#include "moc_kaddstringdlg.cpp"

View file

@ -0,0 +1,75 @@
/***************************************************************************
KAddStringDlg.h - description
-------------------
begin : Sat Oct 16 1999
copyright : (C) 1999 by François Dupoux
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.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. *
* *
***************************************************************************/
#ifndef KADDSTRINGDLG_H
#define KADDSTRINGDLG_H
// local
#include "kaddstringdlgs.h"
#include "configurationclasses.h"
/**
* This is the dialog used to add a list of searching/replacing strings
*/
class KAddStringDlg : public KAddStringDlgS
{
Q_OBJECT
private:
RCOptions* m_option;
Q3ListView* m_sv;
KeyValueMap m_currentMap;
bool m_wantEdit;
public: //Constructors
KAddStringDlg(RCOptions* info, bool wantEdit, QWidget *parent=0, const char *name=0);
private slots:
void slotOK();
void slotSearchOnly();
void slotSearchReplace();
void slotAddStringToView();
void slotDeleteStringFromView();
void slotHelp();
private:
/**
* inits... the GUI :-)
*/
void initGUI();
/**
* Deletes all the items of the view
*/
void eraseViewItems();
/**
* Deletes all the items of the map
*/
void clearMap() { KeyValueMap m; m_option->m_mapStringsView = m; }
/**
* The view is actually a stack widget that contains two different views widget
*/
void raiseView();
/**
* Verifies whether 'lv' contains 's'
*/
bool columnContains(Q3ListView* lv,const QString& s, int column);
void saveViewContentIntoMap();
void loadMapIntoView();
void whatsThis();
};
#endif // KADDSTRINGDLG_H

View file

@ -0,0 +1,342 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0" stdsetdef="1">
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>KAddStringDlgS</class>
<widget class="QDialog" name="KAddStringDlgS">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>347</height>
</rect>
</property>
<property name="windowTitle">
<string>Insert Searching/Replacing Strings</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout">
<item>
<widget class="Q3ButtonGroup" name="bgChoose">
<property name="title">
<string>Choose String Adding Mode</string>
</property>
<property name="exclusive">
<bool>true</bool>
</property>
<layout class="QGridLayout">
<item row="1" column="0">
<widget class="QRadioButton" name="m_rbSearchReplace">
<property name="text">
<string>Search and replace mode</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="m_rbSearchOnly">
<property name="text">
<string>Search only mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Q3Frame" name="frame4">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="m_tlSearch">
<property name="text">
<string>Search for:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="Q3TextEdit" name="m_edSearch">
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="m_tlReplace">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Replace with:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="Q3TextEdit" name="m_edReplace">
<property name="enabled">
<bool>false</bool>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout">
<item>
<spacer name="spacer8">
<property name="sizeHint">
<size>
<width>20</width>
<height>90</height>
</size>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="orientation">
<enum>Qt::Qt::Vertical</enum>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="m_pbDel">
<property name="maximumSize">
<size>
<width>30</width>
<height>32767</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_pbAdd">
<property name="maximumSize">
<size>
<width>30</width>
<height>32767</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer9">
<property name="sizeHint">
<size>
<width>20</width>
<height>90</height>
</size>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="orientation">
<enum>Qt::Qt::Vertical</enum>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="2">
<widget class="Q3WidgetStack" name="m_stack">
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="WStackPage">
<attribute name="id">
<number>0</number>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="Q3ListView" name="m_stringView_2">
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<property name="showSortIndicator">
<bool>false</bool>
</property>
<property name="resizeMode">
<enum>Q3ListView::AllColumns</enum>
</property>
<column>
<property name="text">
<string>Search For</string>
</property>
<property name="clickable">
<bool>true</bool>
</property>
<property name="resizable">
<bool>true</bool>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="WStackPage">
<attribute name="id">
<number>1</number>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="Q3ListView" name="m_stringView">
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<property name="showSortIndicator">
<bool>false</bool>
</property>
<property name="resizeMode">
<enum>Q3ListView::AllColumns</enum>
</property>
<column>
<property name="text">
<string>Search For</string>
</property>
<property name="clickable">
<bool>true</bool>
</property>
<property name="resizable">
<bool>true</bool>
</property>
</column>
<column>
<property name="text">
<string>Replace With</string>
</property>
<property name="clickable">
<bool>true</bool>
</property>
<property name="resizable">
<bool>true</bool>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="m_pbHelp">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Help</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer1">
<property name="sizeHint">
<size>
<width>90</width>
<height>20</height>
</size>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="orientation">
<enum>Qt::Qt::Horizontal</enum>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="m_pbOK">
<property name="text">
<string>&amp;OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_pbCancel">
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<connections>
<connection>
<sender>m_pbCancel</sender>
<signal>clicked()</signal>
<receiver>KAddStringDlgS</receiver>
<slot>reject()</slot>
</connection>
</connections>
</ui>

View file

@ -0,0 +1,117 @@
/***************************************************************************
kfilereplace.cpp - KFileReplace shell implementation
-------------------
begin : Thu Sep 16 14:14:09 2004
copyright : (C) 2004 by Andras Mantia <amantia@kde.org>
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
//kde includes
#include <kedittoolbar.h>
#include <klibloader.h>
#include <klocale.h>
#include <kshortcutsdialog.h>
#include <kmessagebox.h>
#include <kxmlguifactory.h>
//app includes
#include "kfilereplace.h"
//Added by qt3to4:
#include <kactioncollection.h>
#include <kstandardaction.h>
KFileReplace::KFileReplace()
: KParts::MainWindow()
{
setObjectName("KFileReplace");
KLibFactory *factory = KLibLoader::self()->factory("libkfilereplacepart");
if (factory)
{
m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this, "KParts::ReadOnlyPart"));
if (m_part)
{
m_part->setObjectName("kfilereplace_part");
setCentralWidget(m_part->widget());
KStandardAction::quit(this, SLOT(close()), actionCollection());
KStandardAction::keyBindings(this, SLOT(slotConfigureKeys()), actionCollection());
KStandardAction::configureToolbars(this, SLOT(slotConfigureToolbars()), actionCollection());
setStandardToolBarMenuEnabled(true);
createGUI(m_part);
removeDuplicatedActions();
} else
{
KMessageBox::error(this, i18n("Could not load the KFileReplace part."));
close();
return;
}
}
else
{
KMessageBox::error(this, i18n("Could not find the KFileReplace part."));
close();
return;
}
}
KFileReplace::~KFileReplace()
{
}
void KFileReplace::openURL(const KUrl &url)
{
m_part->openUrl(url);
}
void KFileReplace::slotConfigureKeys()
{
KShortcutsDialog dlg( KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this );
QList<KXMLGUIClient*> clients = guiFactory()->clients();
foreach(KXMLGUIClient *client, clients)
dlg.addCollection(client->actionCollection());
dlg.configure();
}
void KFileReplace::slotConfigureToolbars()
{
saveMainWindowSettings(KGlobal::config()->group( autoSaveGroup()) );
KEditToolBar dlg(factory());
connect(&dlg, SIGNAL(newToolbarConfig()),
this, SLOT(applyNewToolbarConfig()));
dlg.exec();
}
void KFileReplace::applyNewToolbarConfig()
{
applyMainWindowSettings(KGlobal::config()->group( autoSaveGroup()) );
}
void KFileReplace::removeDuplicatedActions()
{
KActionCollection* part_action_collection = m_part->actionCollection();
QAction* part_about_action = part_action_collection->action("help_about_kfilereplace");
QAction* part_report_action = part_action_collection->action("report_bug");
QAction* part_help_action= part_action_collection->action("help_kfilereplace");
if (!part_about_action || !part_report_action || !part_help_action || !part_action_collection)
return;
QWidget* container = part_about_action->associatedWidgets().value(0);
container->removeAction(part_about_action);
container->removeAction(part_report_action);
container->removeAction(part_help_action);
part_action_collection->removeAction(part_about_action);
part_action_collection->removeAction(part_report_action);
part_action_collection->removeAction(part_help_action);
}
#include "moc_kfilereplace.cpp"

View file

@ -0,0 +1,114 @@
[Desktop Entry]
Name=KFileReplace
Name[bg]=KFileReplace
Name[br]=KFileReplace
Name[bs]=KFileReplace
Name[ca]=KFileReplace
Name[ca@valencia]=KFileReplace
Name[cs]=KFileReplace
Name[cy]=KFileReplace
Name[da]=KFileReplace
Name[de]=KFileReplace
Name[el]=KFileReplace
Name[en_GB]=KFileReplace
Name[es]=KFileReplace
Name[et]=KFileReplace
Name[eu]=KFileReplace
Name[fi]=KFileReplace
Name[fr]=KFileReplace
Name[ga]=KFileReplace
Name[gl]=KFileReplace
Name[he]=KFileReplace
Name[hne]=--ि
Name[hr]=KFileReplace
Name[hu]=KFileReplace
Name[is]=KFileReplace
Name[it]=KFileReplace
Name[ja]=KFileReplace
Name[kk]=KFileReplace
Name[ko]=KFileReplace
Name[lt]=KFileReplace
Name[lv]=KFileReplace
Name[ms]=KFileReplace
Name[nb]=KFileReplace
Name[nds]=KFileReplace
Name[ne]= ि
Name[nl]=KFileReplace
Name[nn]=KFileReplace
Name[pa]=KFileReplace
Name[pl]=KFileReplace
Name[pt]=KFileReplace
Name[pt_BR]=KFileReplace
Name[ro]=KFileReplace
Name[ru]=KFileReplace
Name[sk]=KFile zameniť
Name[sl]=KFileReplace
Name[sv]=Kfilereplace
Name[ta]=K
Name[tg]=KФайлро ҷойгузор кардан
Name[th]= KFileReplace
Name[tr]=KFileReplace
Name[ug]=KFileReplace
Name[uk]=KFileReplace
Name[x-test]=xxKFileReplacexx
Name[zh_CN]=KFileReplace
Name[zh_HK]=KFileReplace
Name[zh_TW]=KFileReplace
Exec=kfilereplace %i -caption %c
Icon=kfilereplace
Type=Application
X-DocPath=kfilereplace/index.html
Terminal=false
GenericName=Search & Replace Tool
GenericName[bg]=Търсене и замяна
GenericName[br]=Ostilh klask hag erlec'hiañ
GenericName[bs]=Alat za traženje i zamjeu
GenericName[ca]=Eina cerca i substitueix
GenericName[ca@valencia]=Eina cerca i substitueix
GenericName[cs]=Nástroj pro vyhledání a nahrazení
GenericName[da]=Søg og erstat-værktøj
GenericName[de]=Werkzeug zum Suchen & Ersetzen
GenericName[el]=Εργαλείο αναζήτησης & αντικατάστασης
GenericName[en_GB]=Search & Replace Tool
GenericName[es]=Herramienta de búsqueda y remplazo
GenericName[et]=Otsimise ja asendamise tööriist
GenericName[eu]=Bilaketa eta ordezkapen tresna
GenericName[fa]=ابزار جستجو و جایگزینی
GenericName[fi]=Etsi ja korvaa -työkalu
GenericName[fr]=Outil de recherche et de remplacement
GenericName[ga]=Uirlis Chuardaigh/Ionadaithe
GenericName[gl]=Utilidade de procura e substitución
GenericName[he]=כלי חיפוש והחלפה
GenericName[hne]=
GenericName[hu]=Keresés és csere eszköz
GenericName[is]=Tól til að leita að texta og skipta út
GenericName[it]=Strumento di ricerca e sostituzione
GenericName[ja]=
GenericName[kk]=Іздеу және ауыстыру құралы
GenericName[ko]=
GenericName[ku]=Amûra Lêgerîn û Guherandinê
GenericName[lt]=Paieškos ir keitimo įrankis
GenericName[lv]=Meklēšanas uz aizvietošanas rīks
GenericName[nb]=Søk/erstatt-verktøy
GenericName[nds]=Söök- un Utwesselwarktüüch
GenericName[ne]=
GenericName[nl]=Gereedschap voor zoeken en vervangen
GenericName[nn]=Verktøy for søk og erstatt
GenericName[pa]=
GenericName[pl]=Narzędzie do wyszukiwania i zamiany
GenericName[pt]=Ferramenta de Procura e Substituição
GenericName[pt_BR]=Ferramenta de pesquisa e substituição
GenericName[ro]=Unealtă de căutare și înlocuire
GenericName[ru]=Поиск и замена
GenericName[sk]=Nájsť a zameniť
GenericName[sl]=Orodje za iskanje in zamenjavo
GenericName[sv]=Sök- och ersättningsverktyg
GenericName[th]=
GenericName[tr]=Arama Ve Değiştirme Aracı
GenericName[ug]=ئىزدەش ۋە ئالماشتۇرۇش قورالى
GenericName[uk]=Засіб пошуку та заміни
GenericName[x-test]=xxSearch & Replace Toolxx
GenericName[zh_CN]=
GenericName[zh_HK]=
GenericName[zh_TW]=
Categories=Qt;KDE;Utility;X-KDE-Utilities-File;

View file

@ -0,0 +1,45 @@
/***************************************************************************
kfilereplace.h - KFileReplace header
-------------------
begin : Thu Sep 16 14:14:09 2004
copyright : (C) 2004 by Andras Mantia <amantia@kde.org>
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef KFILEREPLACE_H
#define KFILEREPLACE_H
#include <kparts/mainwindow.h>
/**
Shell application for the KFileReplace part.
@author Andras Mantia
*/
class KFileReplace : public KParts::MainWindow
{
Q_OBJECT
public:
KFileReplace();
~KFileReplace();
void openURL(const KUrl &url);
private slots:
void slotConfigureKeys();
void slotConfigureToolbars();
void applyNewToolbarConfig();
private:
void removeDuplicatedActions();
KParts::ReadOnlyPart *m_part;
};
#endif

View file

@ -0,0 +1,190 @@
<?xml version = '1.0'?>
<kdevelop>
<general>
<author/>
<email/>
<version>$VERSION$</version>
<projectmanagement>KDevKDEAutoProject</projectmanagement>
<primarylanguage>C++</primarylanguage>
<keywords>
<keyword>Qt</keyword>
<keyword>KDE</keyword>
</keywords>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<ignoreparts/>
<secondaryLanguages/>
<versioncontrol>kdevcvsservice</versioncontrol>
</general>
<kdevfileview>
<groups>
<group pattern="*.cpp;*.cxx;*.h" name="Sources" />
<group pattern="*.ui" name="User Interface" />
<group pattern="*.png" name="Icons" />
<group pattern="*.po;*.ts" name="Translations" />
<group pattern="*" name="Others" />
<hidenonprojectfiles>false</hidenonprojectfiles>
<hidenonlocation>false</hidenonlocation>
</groups>
<tree>
<showvcsfields>false</showvcsfields>
<hidenonprojectfiles>false</hidenonprojectfiles>
<hidepatterns>*.o,*.lo,CVS</hidepatterns>
</tree>
</kdevfileview>
<kdevdoctreeview>
<ignoretocs>
<toc>ada</toc>
<toc>ada_bugs_gcc</toc>
<toc>bash</toc>
<toc>bash_bugs</toc>
<toc>clanlib</toc>
<toc>fortran_bugs_gcc</toc>
<toc>gnome1</toc>
<toc>gnustep</toc>
<toc>gtk</toc>
<toc>gtk_bugs</toc>
<toc>haskell</toc>
<toc>haskell_bugs_ghc</toc>
<toc>java_bugs_gcc</toc>
<toc>java_bugs_sun</toc>
<toc>opengl</toc>
<toc>pascal_bugs_fp</toc>
<toc>php</toc>
<toc>php_bugs</toc>
<toc>perl</toc>
<toc>perl_bugs</toc>
<toc>python</toc>
<toc>python_bugs</toc>
<toc>ruby</toc>
<toc>ruby_bugs</toc>
<toc>sdl</toc>
<toc>stl</toc>
<toc>sw</toc>
<toc>w3c-dom-level2-html</toc>
<toc>w3c-svg</toc>
<toc>w3c-uaag10</toc>
<toc>wxwidgets_bugs</toc>
</ignoretocs>
<ignoreqt_xml>
<toc>qmake User Guide</toc>
</ignoreqt_xml>
</kdevdoctreeview>
<kdevdebugger>
<general>
<dbgshell>libtool</dbgshell>
<programargs/>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
</general>
<display>
<staticmembers>false</staticmembers>
<demanglenames>true</demanglenames>
<outputradix>10</outputradix>
</display>
</kdevdebugger>
<kdevfilecreate>
<filetypes/>
<useglobaltypes>
<type ext="ui" />
<type ext="cpp" />
<type ext="h" />
</useglobaltypes>
</kdevfilecreate>
<kdevautoproject>
<make>
<envvars>
<envvar value="1" name="WANT_AUTOCONF_2_5" />
<envvar value="1" name="WANT_AUTOMAKE_1_6" />
</envvars>
<abortonerror>true</abortonerror>
<numberofjobs>1</numberofjobs>
<dontact>false</dontact>
<makebin/>
<prio>0</prio>
</make>
<run>
<directoryradio>build</directoryradio>
<customdirectory>/</customdirectory>
<mainprogram>kfilereplace/kfilereplace</mainprogram>
<programargs/>
<terminal>false</terminal>
<autocompile>true</autocompile>
<envvars/>
</run>
<general>
<useconfiguration>default</useconfiguration>
<activetarget>kfilereplace</activetarget>
</general>
<configurations>
<default>
<envvars>
<envvar value="kommander klinkstatus kxsldbg kimagemapeditor quanta" name="DO_NOT_COMPILE" />
</envvars>
<configargs>--enable-debug=full --prefix=/opt/kde3 --enable-editors</configargs>
<builddir>/home/andris/development/build/kde-head/kdewebdev</builddir>
<topsourcedir>/home/andris/development/sources/kde-head/kdewebdev</topsourcedir>
<cppflags>-DKDE_NO_COMPAT -DQT_NO_COMPAT -DDEBUG_PARSER</cppflags>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevpgf77options</f77compiler>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
</default>
</configurations>
</kdevautoproject>
<cppsupportpart>
<filetemplates>
<interfacesuffix>.h</interfacesuffix>
<implementationsuffix>.cpp</implementationsuffix>
</filetemplates>
</cppsupportpart>
<kdevcppsupport>
<codecompletion>
<includeGlobalFunctions>true</includeGlobalFunctions>
<includeTypes>true</includeTypes>
<includeEnums>true</includeEnums>
<includeTypedefs>false</includeTypedefs>
<automaticCodeCompletion>true</automaticCodeCompletion>
<automaticArgumentsHint>true</automaticArgumentsHint>
<automaticHeaderCompletion>true</automaticHeaderCompletion>
<codeCompletionDelay>250</codeCompletionDelay>
<argumentsHintDelay>400</argumentsHintDelay>
<headerCompletionDelay>250</headerCompletionDelay>
</codecompletion>
<references/>
<creategettersetter>
<prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
<inlineGet>true</inlineGet>
<inlineSet>true</inlineSet>
</creategettersetter>
</kdevcppsupport>
<kdevdocumentation>
<projectdoc>
<docsystem/>
<docurl/>
<usermanualurl/>
</projectdoc>
</kdevdocumentation>
<kdevcvsservice>
<recursivewhenupdate>true</recursivewhenupdate>
<prunedirswhenupdate>true</prunedirswhenupdate>
<createdirswhenupdate>true</createdirswhenupdate>
<recursivewhencommitremove>true</recursivewhencommitremove>
<revertoptions>-C</revertoptions>
</kdevcvsservice>
</kdevelop>

View file

@ -0,0 +1,30 @@
/***************************************************************************
kfilereplaceif.h - description
-------------------
copyright : (C) 1999 by François Dupoux
(C) 2003 Andras Mantia
email : dupoux@dupoux.com, amantia@kde.org
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef KFILEREPLACEIFACE_H
#define KFILEREPLACEIFACE_H
#include <dcopobject.h>
class KFileReplaceIface : virtual public DCOPObject
{
K_DCOP
k_dcop:
virtual void openURL(const QString& url) = 0;
};
#endif // KFILEREPLACEIFACE_H

View file

@ -0,0 +1,363 @@
/***************************************************************************
kfilereplacelib.cpp - File library
-------------------
begin : lun mai 3 20:19:52 CEST 1999
copyright : (C) 1999 by François Dupoux
(C) 2003 Andras Mantia <amantia@kde.org>
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.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. *
* *
***************************************************************************/
//QT
#include <qstringlist.h>
#include <qwidget.h>
#include <qlistview.h>
#include <qfileinfo.h>
#include <qpixmap.h>
//KDE
#include <kdebug.h>
#include <kmessagebox.h>
#include <kiconloader.h>
//needed for malloc/free
#include <stdlib.h>
// local
#include "kfilereplacelib.h"
/**
Format a path, from a path and a filename, or another sub-path (avoid double '/' risks)
Parameters::.....* basePath: fist path (can be "/" if root, or "/usr/bin/" or "/usr/bin" for example)
.................* fileName: second path (can be "/doc/html/", or "doc/html/" or "doc/html/index.html" for example)
Return values:...* Full valid path (without double "/")
*/
QString KFileReplaceLib::formatFullPath(const QString& basePath, const QString &fileName)
{
QString fullPath = basePath;
QString fname = fileName;
if (fname.startsWith('/')) // skip beginning '/'
fname = fname.remove(0,1);
if (fullPath.endsWith('/'))
fullPath.append(fname);
else
fullPath.append('/'+fname);
return fullPath;
}
/**
Add an extension to a filename, or a filepath
Parameters::.....* fileName: filename or filepath (it can have already the extension)
.................* extension: extension to add without "." (ex: "html", "kfr")
Return values:...* Filename / Filepath with the extension
*/
QString KFileReplaceLib::addExtension(const QString& fileName, const QString& extension)
{
QString fullExtension = ".";
QString fname = fileName;
fullExtension.append(extension);
// filename cannot contain ".ext" ==> Add it
if(fname.length() <= fullExtension.length())
fname.append(fullExtension);
else // filename can contain ".ext"
{
if (fname.right(fullExtension.length()) != fullExtension)
fname.append(fullExtension);
}
return fname;
}
QString KFileReplaceLib::formatFileSize(double size)
{
QString stringSize;
if(size < 10000)
{
const int asInt = (int) size;
stringSize = i18np("1 byte", "%1 bytes", asInt);
}
else
{
stringSize = KGlobal::locale()->formatByteSize(size, 2);
}
return stringSize;
}
void KFileReplaceLib::convertOldToNewKFRFormat(const QString& fileName, QListWidget* stringView)
{
//this method convert old format in new XML-based format
typedef struct
{
char pgm[13]; // Must be "KFileReplace" : like MZ for EXE files
int stringNumber; // Number of strings in file
char reserved[64]; // Reserved for future use
} KFRHeader;
KFRHeader head;
FILE* f = fopen(QFile::encodeName(fileName),"rb");
int err = fread(&head, sizeof(KFRHeader), 1, f);
QString pgm(head.pgm);
if(!f || (err != 1) || (pgm != "KFileReplace"))
{
KMessageBox::error(0, i18n("<qt>Cannot open the file <b>%1</b> and load the string list. This file seems not to be a valid old kfr file or it is broken.</qt>", fileName));
return ;
}
stringView->clear();
int oldTextSize,
newTextSize,
errors = 0,
stringSize;
QStringList l;
int i ;
for (i=0; i < head.stringNumber; i++)
{
errors += (fread(&oldTextSize, sizeof(int), 1, f)) != 1;
errors += (fread(&newTextSize, sizeof(int), 1, f)) != 1;
if(errors > 0)
KMessageBox::error(0, i18n("Cannot read data."));
else
{
stringSize = ((oldTextSize > newTextSize) ? oldTextSize : newTextSize) + 2;
char* oldString = (char*) malloc(stringSize+10),
* newString = (char*) malloc(stringSize+10);
if (oldString == 0 || newString == 0)
KMessageBox::error(0, i18n("Out of memory."));
else
{
memset(oldString, 0, stringSize);
memset(newString,0, stringSize);
if (fread(oldString, oldTextSize, 1, f) != 1)
KMessageBox::error(0, i18n("Cannot read data."));
else
{
if (newTextSize > 0) // If there is a Replace text
{
if (fread(newString, newTextSize, 1, f) != 1)
KMessageBox::error(0, i18n("Cannot read data."));
else
{
Q3ListViewItem* lvi = new Q3ListViewItem(stringView);
lvi->setText(0,oldString);
lvi->setText(1,newString);
}
}
}
}
if(newString)
free(newString);
if(oldString)
free(oldString);
}
}
fclose(f);
return ;
}
bool KFileReplaceLib::isAnAccessibleFile(const QString& filePath, const QString& fileName, RCOptions* info)
{
QString bkExt = info->m_backupExtension;
if(fileName == ".." || fileName == "." || (!bkExt.isEmpty() && fileName.right(bkExt.length()) == bkExt))
return false;
QFileInfo fi;
if(filePath.isEmpty())
fi.setFile(fileName);
else
fi.setFile(filePath+'/'+fileName);
if(fi.isDir())
return true;
int minSize = info->m_minSize,
maxSize = info->m_maxSize;
QString minDate = info->m_minDate,
maxDate = info->m_maxDate,
dateAccess = info->m_dateAccess;
// Avoid files that not match access date requirements
QString last = "unknown";
if(dateAccess == "Last Writing Access")
last = fi.lastModified().toString(Qt::ISODate);
if(dateAccess == "Last Reading Access")
last = fi.lastRead().toString(Qt::ISODate);
if(last != "unknown")
{
if(minDate != "unknown" && maxDate != "unknown")
{ //If out of range then exit
if((minDate > last) || (maxDate < last))
return false;
}
else
{
if(minDate != "unknown")
{ //If out of range then exit
if(minDate > last)
return false;
}
else
{
if(maxDate != "unknown")
//If out of range then exit
if(maxDate < last)
return false;
}
}
}
// Avoid files that not match size requirements
int size = fi.size();
if(maxSize != FileSizeOption && minSize != FileSizeOption)
if(size > (maxSize*1024) || size < (minSize*1024))
return false;
// Avoid files that not match ownership requirements
if(info->m_ownerUserIsChecked)
{
QString fileOwnerUser;
if(info->m_ownerUserType == "Name")
fileOwnerUser = fi.owner();
else
fileOwnerUser = QString::number(fi.ownerId(),10);
if(info->m_ownerUserBool == "Equals To")
{
if(info->m_ownerUserValue != fileOwnerUser)
return false;
}
else
{
if(info->m_ownerUserValue == fileOwnerUser)
return false;
}
}
if(info->m_ownerGroupIsChecked)
{
QString fileOwnerGroup;
if(info->m_ownerGroupType == "Name")
fileOwnerGroup = fi.group();
else
fileOwnerGroup = QString::number(fi.groupId(),10);
if(info->m_ownerGroupBool == "Equals To")
{
if(info->m_ownerGroupValue != fileOwnerGroup)
return false;
}
else
{
if(info->m_ownerGroupValue == fileOwnerGroup)
return false;
}
}
//If we are here then all requirements have been verified
return true;
}
void KFileReplaceLib::setIconForFileEntry(Q3ListViewItem* item, const QString &path)
{
QFileInfo fi(path);
QString extension = fi.completeSuffix(),
baseName = fi.baseName();
KeyValueMap extensionMap;
extensionMap["a"] = "binary";
extensionMap["am"] = "shellscript";
extensionMap["bz"] = "zip";
extensionMap["bz2"] = "zip";
extensionMap["c"] = "source_c";
extensionMap["cc"] = "source_cpp";
extensionMap["cpp"] = "source_cpp";
extensionMap["eml"] = "message";
extensionMap["exe"] = "exec_wine";
extensionMap["gz"] = "zip";
extensionMap["h"] = "source_h";
extensionMap["htm"] = "html";
extensionMap["html"] = "html";
extensionMap["in"] = "shellscript";
extensionMap["java"] = "source_java";
extensionMap["jpg"] = "image";
extensionMap["kfr"] = "html";
extensionMap["kmdr"] = "widget_doc";
extensionMap["kwd"] = "kword_kwd";
extensionMap["log"] = "log";
extensionMap["moc"] = "source_moc";
extensionMap["mp3"] = "sound";
extensionMap["o"] = "source_o";
extensionMap["pdf"] = "pdf";
extensionMap["php"] = "source_php";
extensionMap["py"] = "source_py";
extensionMap["pl"] = "source_pl";
extensionMap["p"] = "source_p";
extensionMap["ps"] = "postscript";
extensionMap["png"] = "image";
extensionMap["sa"] = "binary";
extensionMap["sh"] = "shellscript";
extensionMap["so"] = "binary";
extensionMap["tar"] = "tar";
extensionMap["tex"] = "tex";
extensionMap["tgz"] = "tgz";
extensionMap["txt"] = "txt";
extensionMap["ui"] = "widget_doc";
extensionMap["uml"] = "umbrellofile";
extensionMap["wav"] = "sound";
extensionMap["xml"] = "html";
extensionMap["xpm"] = "image";
KeyValueMap::Iterator itExtensionMap;
for(itExtensionMap = extensionMap.begin(); itExtensionMap != extensionMap.end(); ++itExtensionMap)
{
if(extension == itExtensionMap.key())
{
item->setPixmap(0,SmallIcon(itExtensionMap.data()));
return;
}
}
KeyValueMap baseNameMap;
baseNameMap["configure"] = "shellscript";
baseNameMap["core"] = "core";
baseNameMap["makefile"] = "make";
baseNameMap["readme"] = "readme";
baseNameMap["README"] = "readme";
baseNameMap["Readme"] = "readme";
baseNameMap["TODO"] = "txt";
KeyValueMap::Iterator itBaseNameMap;
for(itBaseNameMap = baseNameMap.begin(); itBaseNameMap != baseNameMap.end(); ++itBaseNameMap)
{
if(baseName == itBaseNameMap.key())
{
item->setPixmap(0,SmallIcon(itBaseNameMap.data()));
return;
}
}
}

View file

@ -0,0 +1,66 @@
/***************************************************************************
kfilereplacelib.h - File library, derived from filelib.h
-------------------
begin : lun mai 3 20:19:52 CEST 1999
copyright : (C) 1999 by François Dupoux
(C) 2003 Andras Mantia <amantia@kde.org>
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.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. *
* *
***************************************************************************/
#ifndef KFILEREPLACELIB_H
#define KFILEREPLACELIB_H
#include <QListWidget>
// KDE
#include <klocale.h>
// local
#include "configurationclasses.h"
class KFileReplaceLib
{
public:
/**
Format a path, from a path and a filename, or another sub-path (avoid double '/' risks)
Parameters::.....* basePath: fist path (can be "/" if root, or "/usr/bin/" or "/usr/bin" for example)
.................* filename: second path (can be "/doc/html/", or "doc/html/" or "doc/html/index.html" for example)
Return values:...* Full valid path (without double "/")
*/
static QString formatFullPath(const QString& basePath, const QString& fileName);
/**
Add an extension to a filename, or a filepath
Parameters::.....* filename: filename or filepath (it can have already the extension)
.................* extension: extension to add without "." (ex: "html", "kfr")
Return values:...* Filename / Filepath with the extension
*/
static QString addExtension(const QString& fileName, const QString& extension);
static QString formatFileSize(double size);
/**
converts the old kfr format file in the new xml-based format.
*/
static void convertOldToNewKFRFormat(const QString& fileName, QListWidget* stringView);
/**
Verifies that files, which we are scanning, respect some
conditions
*/
static bool isAnAccessibleFile(const QString& filePath, const QString& fileName, RCOptions* info);
static void setIconForFileEntry(QListWidgetItem* item, const QString &path);
};
#endif // KFILEREPLACEFILELIB_H

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,162 @@
[Desktop Entry]
Type=Service
MimeType=inode/directory;
Icon=kfilereplace.png
X-KDE-ServiceTypes=KParts/ReadOnlyPart
X-KDE-Library=libkfilereplacepart
Comment=A batch search and replace tool
Comment[bg]=Инструмент за групово търсене и замяна
Comment[bs]=Grupni alat za traženje i zamjenu
Comment[ca]=Una eina de cerca i substitució per lots
Comment[ca@valencia]=Una eina de cerca i substitució per lots
Comment[cs]=Dávkový nástroj pro hledání a nahrazování
Comment[da]=Søg- og erstat-gruppekørselsværktøj
Comment[de]=Ein Werkzeug zum Suchen und Ersetzen im Stapelbetrieb
Comment[el]= Εργαλείο πολλαπλής αναζήτησης και αντικατάστασης
Comment[en_GB]=A batch search and replace tool
Comment[es]=Una herramienta de búsqueda y remplazo por lotes
Comment[et]=Otsimise ja asendamise tööriist
Comment[eu]=Bilaketa eta ordezkapen tresna
Comment[fa]=ابزار جستجو و جایگزینی دستهای
Comment[fi]=Etsinnän ja korvauksen eräajotyökalu
Comment[fr]=Un outil de recherche et de remplacement par lot
Comment[ga]=Uirlis chuardaigh/ionadaithe
Comment[gl]=Unha utilidade de busca e substitución por lotes
Comment[he]=כלי אצווה לחיפוש והחלפה
Comment[hne]=
Comment[hu]=Egy kötegelt keresés és csere eszköz
Comment[is]=Tól til að leita að texta og skipta út
Comment[it]=Uno strumento per la ricerca e la sostituzione in sequenza
Comment[ja]=
Comment[kk]=Дестелеп іздеу және ауыстыру құралы
Comment[ko]=
Comment[lt]=Paketinis paieškos ir keitimo įrankis
Comment[lv]=Masveida meklēšanas un aizvietošanas rīks
Comment[ms]=Gugusan alatan cari dan ganti
Comment[nb]=Et verktøy for satsvis søk og erstatt
Comment[nds]=En Söök- un Utwesselwarktüüch för Stapelbedrief
Comment[ne]=
Comment[nl]=Een gereedschap voor zoeken en vervangen
Comment[nn]=Søk og erstatt i mange filer samtidig
Comment[pl]=Narzędzie do wsadowego wyszukiwania i zamiany
Comment[pt]=Uma ferramenta de procura e substituição em lote
Comment[pt_BR]=Uma ferramenta de pesquisa e substituição em lote
Comment[ro]=Unealtă de căutare și înlocuire în serie
Comment[ru]=Пакетный поиск и замена
Comment[sk]=Dávkovací nástroj pre nájsť a zameniť
Comment[sl]=Orodje paketnega iskanja in zamenjave
Comment[sv]=Ett sök- och ersättningsverktyg
Comment[ta]=ி ி
Comment[tg]=Ҷустуҷӯи пакет ва ивази асбоб
Comment[th]=
Comment[tr]=Bir toplu arama ve değiştirme aracı
Comment[uk]=Засіб пакетного пошуку та заміни
Comment[x-test]=xxA batch search and replace toolxx
Comment[zh_CN]=
Comment[zh_HK]=
Comment[zh_TW]=
Name=KFileReplace
Name[bg]=KFileReplace
Name[br]=KFileReplace
Name[bs]=KFileReplace
Name[ca]=KFileReplace
Name[ca@valencia]=KFileReplace
Name[cs]=KFileReplace
Name[cy]=KFileReplace
Name[da]=KFileReplace
Name[de]=KFileReplace
Name[el]=KFileReplace
Name[en_GB]=KFileReplace
Name[es]=KFileReplace
Name[et]=KFileReplace
Name[eu]=KFileReplace
Name[fi]=KFileReplace
Name[fr]=KFileReplace
Name[ga]=KFileReplace
Name[gl]=KFileReplace
Name[he]=KFileReplace
Name[hne]=--ि
Name[hr]=KFileReplace
Name[hu]=KFileReplace
Name[is]=KFileReplace
Name[it]=KFileReplace
Name[ja]=KFileReplace
Name[kk]=KFileReplace
Name[ko]=KFileReplace
Name[lt]=KFileReplace
Name[lv]=KFileReplace
Name[ms]=KFileReplace
Name[nb]=KFileReplace
Name[nds]=KFileReplace
Name[ne]= ि
Name[nl]=KFileReplace
Name[nn]=KFileReplace
Name[pa]=KFileReplace
Name[pl]=KFileReplace
Name[pt]=KFileReplace
Name[pt_BR]=KFileReplace
Name[ro]=KFileReplace
Name[ru]=KFileReplace
Name[sk]=KFile zameniť
Name[sl]=KFileReplace
Name[sv]=Kfilereplace
Name[ta]=K
Name[tg]=KФайлро ҷойгузор кардан
Name[th]= KFileReplace
Name[tr]=KFileReplace
Name[ug]=KFileReplace
Name[uk]=KFileReplace
Name[x-test]=xxKFileReplacexx
Name[zh_CN]=KFileReplace
Name[zh_HK]=KFileReplace
Name[zh_TW]=KFileReplace
GenericName=File Replace View
GenericName[bg]=Изглед с файлове за замяна
GenericName[bs]=Pogled zamjene datoteke
GenericName[ca]=Vista per a substituir fitxers
GenericName[ca@valencia]=Vista per a substituir fitxers
GenericName[cs]=Nahrazení souborů
GenericName[da]=Filerstatningsvisning
GenericName[de]=KFileReplace
GenericName[el]=Προβολή αντικατάστασης αρχείου
GenericName[en_GB]=File Replace View
GenericName[es]=Vista de remplazo de archivo
GenericName[et]=Failide asendamise vaade
GenericName[eu]=Fitxategi ordezkapen ikuspegia
GenericName[fa]=نمای جایگزینی پرونده
GenericName[fi]=Tiedoston korvausnäyttö
GenericName[fr]=Vue pour le remplacement de fichiers
GenericName[ga]=Amharc Ionadaithe Comhad
GenericName[gl]=Vista de substitución en ficheiro
GenericName[he]=תצוגת החלפת קובץ
GenericName[hne]=
GenericName[hu]=Fájlcsere nézet
GenericName[is]=Texta útskiptingarsýn
GenericName[it]=Vista di sostituzione file
GenericName[ja]=
GenericName[kk]=Файлда тауып ауыстыру көрінісі
GenericName[ko]=
GenericName[lt]=Keitimų failuose vaizdas
GenericName[lv]=Failu aizvietošanas skats
GenericName[ms]=Paparan Ganti Fail
GenericName[nb]=Filerstatt-visning
GenericName[nds]=Datei-Utwesselansicht
GenericName[ne]=
GenericName[nl]=Weergave van bestanden vervangen
GenericName[nn]=Filerstattingsvising
GenericName[pa]=
GenericName[pl]=Widok zamiany w plikach
GenericName[pt]=Área de Substituição de Ficheiros
GenericName[pt_BR]=Visão de substituição de arquivos
GenericName[ru]=Средство поиска и замены в файлах
GenericName[sk]=Pohľad zámeny súboru
GenericName[sl]=Prikaz zamenjave datotek
GenericName[sv]=Filersättningsvy
GenericName[ta]= ி
GenericName[th]=
GenericName[tr]=Dosya Değiştirme Görünümü
GenericName[uk]=Перегляд заміни в файлах
GenericName[x-test]=xxFile Replace Viewxx
GenericName[zh_CN]=
GenericName[zh_HK]=
GenericName[zh_TW]=

View file

@ -0,0 +1,159 @@
//
//
// C++ Interface: kfilereplacepart
//
// Description:
//
//
// Author: Andras Mantia <amantia@kde.org>, (C) 2003
// Maintainer: Emiliano Gulmini <emi_barbarossa@yahoo.it>, (C) 2004
//
// Copyright: GPL v2. See COPYING file that comes with this distribution
//
//
#ifndef KFILEREPLACEPART_H
#define KFILEREPLACEPART_H
// QT
#include <QDir>
// KDE
#include <kparts/part.h>
class KAboutApplicationDialog;
class KAboutData;
class KConfig;
// local
#include "configurationclasses.h"
class KFileReplaceView;
#define KFR_VERSION "0.8.1"
class KFileReplacePart: public KParts::ReadOnlyPart
{
Q_OBJECT
private: //MEMBERS
KFileReplaceView* m_view;
QWidget* m_parentWidget,
* m_w;
KConfig* m_config;
KAboutApplicationDialog* m_aboutDlg;
KeyValueMap m_replacementMap;
RCOptions* m_option;
bool m_stop,
m_searchingOperation;
QFlags<QDir::Filter> m_optionMask;
public://Constructors
KFileReplacePart(QWidget *parentWidget,
QObject *parent,
const QStringList &args);
~KFileReplacePart();
//SLOTS
private slots:
void slotSetNewParameters();
void slotSearchingOperation();
void slotReplacingOperation();
void slotSimulatingOperation();
void slotStop();
void slotCreateReport();
void slotStringsAdd();
void slotQuickStringsAdd();
void slotStringsDeleteItem();
void slotStringsEmpty();
void slotStringsEdit();
void slotStringsSave();
void slotStringsLoad();
void slotStringsInvertCur();
void slotStringsInvertAll();
void slotOpenRecentStringFile(const KUrl& urlFile);
void slotOptionRecursive();
void slotOptionBackup();
void slotOptionCaseSensitive();
void slotOptionVariables();
void slotOptionRegularExpressions();
void slotOptionPreferences();
void showAboutApplication(void);
void appHelpActivated();
void reportBug();
void resetActions();
void slotSearchMode(bool b){ m_option->m_searchingOnlyMode = b; }
//METHODS
public:
static KAboutData* createAboutData();
KConfig *config(){ return m_config; }
virtual bool openURL (const KUrl &url);
protected:
virtual bool openFile() { return false; }
private:
/**
* Initialization methods
*/
void initGUI();
void initView();
/**
* This method freezes the GUI of kfilereplace during searching
*/
void freezeActions();
/**
* These methods load the resources from kfilereplacerc
*/
void loadOptionsFromRC();
void loadOptions();
void loadFileSizeOptions();
void loadDateAccessOptions();
void loadOwnerOptions();
void loadLocationsList();
void loadFiltersList();
void loadBackupExtensionOptions();
/**
* These methods save the resources to kfilereplacerc
*/
void saveOptionsToRC();
void saveOptions();
void saveFileSizeOptions();
void saveDateAccessOptions();
void saveOwnerOptions();
void saveLocationsList();
void saveFiltersList();
void saveBackupExtensionOptions();
/**
* Replacing methods
*/
void fileReplace();
void recursiveFileReplace(const QString& dirName, int& filesNumber);
void replaceAndBackup(const QString& currentDir, const QString& oldFileName);
void replaceAndOverwrite(const QString& currentDir, const QString& oldFileName);
void replacingLoop(QString& line, QListView** item, bool& atLeastOneStringFound, int& occur, bool regularExpression, bool& askConfirmReplace);
/**
* Searching methods
*/
void fileSearch(const QString& dirName, const QString& filters);
void recursiveFileSearch(const QString& dirName, const QString& filters, uint& filesNumber);
void search(const QString& currentDir, const QString& fileName);
/**
* Others methods
*/
void loadViewContent();
void loadRulesFile(const QString& fileName);
bool launchNewProjectDialog(const KUrl& startURL);
void setOptionMask();
bool checkBeforeOperation();
bool dontAskAgain();
void whatsThis();
};
#endif// KFileReplacePart

View file

@ -0,0 +1,75 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kfilereplace" version="6">
<MenuBar>
<Menu name="kfilerepace"><text>Search/&amp;Replace</text>
<Action name="new_project"/>
<Action name="search"/>
<Action name="file_simulate"/>
<Action name="replace"/>
<Action name="stop"/>
<Separator/>
<Menu name="strings"><text>&amp;Strings</text>
<Action name="strings_add"/>
<Action name="strings_del"/>
<Action name="strings_empty"/>
<Action name="strings_edit"/>
<Separator/>
<Action name="strings_save"/>
<Action name="strings_load"/>
<Action name="strings_load_recent"/>
<Separator/>
<Action name="strings_invert"/>
<Action name="strings_invert_all"/>
</Menu>
<Menu name="results"><text>&amp;Results</text>
<Action name="results_openfile"/>
<Action name="results_opendir"/>
<Action name="results_editfile"/>
<Action name="results_delete"/>
<Action name="results_infos"/>
<Separator/>
<Action name="save_results"/>
<Separator/>
<Action name="results_treeexpand"/>
<Action name="results_treereduce"/>
</Menu>
<Menu name="options"><text>&amp;Options</text>
<Action name="options_recursive"/>
<Action name="options_backup"/>
<Action name="options_case"/>
<Action name="options_var"/>
<Action name="options_regularexpressions"/>
</Menu>
</Menu>
<Menu name="settings"><text>&amp;Settings</text>
<Action name="configure_kfilereplace"/>
</Menu>
<Menu name="help"><text>&amp;Help</text>
<Separator/>
<Action name="help_kfilereplace" />
<Action name="report_bug" />
<Action name="help_about_kfilereplace" />
</Menu>
</MenuBar>
<ToolBar noMerge="1" name="mainToolBar">
<text>KFileReplace Main Toolbar</text>
<Action name="new_project" />
<Action name="search"/>
<Action name="file_simulate"/>
<Action name="replace"/>
<Action name="stop"/>
<Separator/>
<Action name="strings_add"/>
<Action name="strings_del"/>
<Action name="strings_edit"/>
<Action name="strings_empty"/>
<Action name="strings_invert"/>
<Action name="strings_load"/>
<Separator/>
<Action name="options_recursive"/>
<Action name="options_backup"/>
<Action name="options_case"/>
<Action name="options_var"/>
<Action name="options_regularexpressions"/>
</ToolBar>
</kpartgui>

View file

@ -0,0 +1,10 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kfilereplace" version="1">
<MenuBar>
<Menu noMerge="1" name="file"><text>&amp;File</text>
<Action name="file_quit"/>
</Menu>
<Menu name="kfilerepace"><text>Search/&amp;Replace</text>
</Menu>
</MenuBar>
</kpartgui>

View file

@ -0,0 +1,681 @@
/*****************************************************************************
kfilereplaceview.cpp - description
-------------------
begin : sam oct 16 15:28:00 CEST 1999
copyright : (C) 1999 by François Dupoux <dupoux@dupoux.com>
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
*****************************************************************************/
/*****************************************************************************
* *
* 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. *
* *
*****************************************************************************/
// Qt
#include <qmap.h>
#include <qfileinfo.h>
#include <QTextStream>
// KDE
#include <kmessagebox.h>
#include <klocale.h>
#include <kmenu.h>
#include <krun.h>
#include <kpropertiesdialog.h>
#include <kapplication.h>
#include <QDBusConnection>
#include <QDBusReply>
#include <QDBusConnectionInterface>
//#include <kdebug.h>
#include <kiconloader.h>
#include <kled.h>
#include <kfiledialog.h>
// local
#include "kfilereplaceview.h"
#include "kfilereplacelib.h"
#include "kaddstringdlg.h"
#include "whatthis.h"
using namespace whatthisNameSpace;
KFileReplaceView::KFileReplaceView(RCOptions* info, QWidget *parent,const char *name):KFileReplaceViewWdg(parent,name)
{
m_option = info;
initGUI();
// connect events
connect(m_lvResults, SIGNAL(mouseButtonClicked(int, QListWidgetItem *, const QPoint &, int)), this, SLOT(slotMouseButtonClicked(int, QListWidgetItem *, const QPoint &)));
connect(m_lvResults_2, SIGNAL(mouseButtonClicked(int, QListWidgetItem *, const QPoint &, int)), this, SLOT(slotMouseButtonClicked(int, QListWidgetItem *, const QPoint &)));
connect(m_lvStrings, SIGNAL(doubleClicked(QListWidgetItem *)), this, SLOT(slotStringsEdit()));
connect(m_lvStrings_2, SIGNAL(doubleClicked(QListWidgetItem *)), this, SLOT(slotStringsEdit()));
whatsThis();
}
QString KFileReplaceView::currentPath()
{
QListWidgetItem *lvi;
if(! m_lviCurrent) lvi = m_rv->currentItem();
else lvi = (QListWidgetItem*) m_lviCurrent;
while (lvi->parent())
lvi = lvi->parent();
return QString(lvi->text(1)+'/'+lvi->text(0));
}
void KFileReplaceView::showSemaphore(const QString &s)
{
if(s == "green")
{
m_ledGo->setState(KLed::On);
m_ledWait->setState(KLed::Off);
m_ledStop->setState(KLed::Off);
}
else
if(s == "yellow")
{
m_ledGo->setState(KLed::Off);
m_ledWait->setState(KLed::On);
m_ledStop->setState(KLed::Off);
}
else
if(s == "red")
{
m_ledGo->setState(KLed::Off);
m_ledWait->setState(KLed::Off);
m_ledStop->setState(KLed::On);
}
}
void KFileReplaceView::stringsInvert(bool invertAll)
{
QListWidgetItem* lviCurItem,
* lviFirst;
QListView* sv = getStringsView();
if(invertAll)
lviCurItem = lviFirst = sv->firstChild();
else
lviCurItem = lviFirst = sv->currentItem();
if(lviCurItem == 0)
return ;
do
{
QString searchText = lviCurItem->text(0),
replaceText = lviCurItem->text(1);
// Cannot invert the string when search string is empty
if (replaceText.isEmpty())
{
KMessageBox::error(0, i18n("<qt>Cannot invert string <b>%1</b>, because the search string would be empty.</qt>", searchText));
return;
}
lviCurItem->setText(0, replaceText);
lviCurItem->setText(1, searchText);
lviCurItem = lviCurItem->nextSibling();
if(!invertAll)
break;
} while(lviCurItem && lviCurItem != lviFirst);
setCurrentStringsViewMap();
}
void KFileReplaceView::changeView(bool searchingOnlyMode)
{
if(searchingOnlyMode)
{
m_stackResults->raiseWidget(m_lvResults_2);
m_stackStrings->raiseWidget(m_lvStrings_2);
m_rv = m_lvResults_2;
m_sv = m_lvStrings_2;
}
else
{
m_stackResults->raiseWidget(m_lvResults);
m_stackStrings->raiseWidget(m_lvStrings);
m_rv = m_lvResults;
m_sv = m_lvStrings;
}
}
QListView* KFileReplaceView::getResultsView()
{
if(m_option->m_searchingOnlyMode)
m_rv = m_lvResults_2;
else
m_rv = m_lvResults;
return m_rv;
}
QListView* KFileReplaceView::getStringsView()
{
if(m_option->m_searchingOnlyMode)
m_sv = m_lvStrings_2;
else
m_sv = m_lvStrings;
return m_sv;
}
//PUBLIC SLOTS
void KFileReplaceView::slotMouseButtonClicked (int button, QListWidgetItem *lvi, const QPoint &pos)
{
if (lvi == 0) // No item selected
return;
// RIGHT BUTTON
if (button == Qt::RightButton)
{
m_lviCurrent = static_cast<QListViewItem*>(lvi);
m_menuResult->popup(pos);
}
}
void KFileReplaceView::slotResultProperties()
{
QString currItem = currentPath();
if(! currItem.isEmpty())
{
KUrl item_url(currItem);
KPropertiesDialog dlg(item_url, this);
dlg.exec();
m_lviCurrent = 0;
}
}
void KFileReplaceView::slotResultOpen()
{
QString currItem = currentPath();
if(!currItem.isEmpty())
{
(void) new KRun(KUrl(currItem), 0, true, true);
m_lviCurrent = 0;
}
}
void KFileReplaceView::slotResultOpenWith()
{
QString currItem = currentPath();
if(!currItem.isEmpty())
{
KUrl::List kurls;
kurls.append(KUrl(currItem));
KRun::displayOpenWithDialog(kurls, this);
m_lviCurrent = 0;
}
}
void KFileReplaceView::slotResultDirOpen()
{
QString currItem = currentPath();
if(!currItem.isEmpty())
{
QFileInfo fi;
fi.setFile(currItem);
(void) new KRun (KUrl::fromPathOrUrl(fi.path()), 0, true, true);
m_lviCurrent = 0;
}
}
void KFileReplaceView::slotResultEdit()
{
#ifdef __GNUC__
#warning "Port to DBUS"
#endif
//FIXME: Port to DBUS
/*
QListWidgetItem *lvi = m_rv->firstChild();
while (lvi)
{
DCOPClient *client = kapp->dcopClient();
DCOPRef quanta(client->appId(),"WindowManagerIf");
QString path = QString(lvi->text(1)+'/'+lvi->text(0));
QListWidgetItem *lviChild = lvi;
while(lviChild)
{
if(lviChild->isSelected())
{
coord c;
if(lviChild == lvi)
{
c.line = 0;
c.column = 0;
}
else
{
c= extractWordCoordinates(lviChild);
}
bool success = quanta.send("openFile", path, c.line, c.column);
if(!success)
{
QString message = i18n("File %1 cannot be opened. Might be a DCOP problem.", path);
KMessageBox::error(parentWidget(), message);
}
}
if (lviChild == lvi)
lviChild = lviChild->firstChild();
else
lviChild = lviChild->nextSibling();
}
lvi = lvi->nextSibling();
}
m_lviCurrent = 0;
*/
}
void KFileReplaceView::slotResultDelete()
{
QString currItem = currentPath();
if (!currItem.isEmpty())
{
QFile fi;
int answer = KMessageBox::warningContinueCancel(this, i18n("Do you really want to delete %1?", currItem),
QString::null,KStandardGuiItem::del()); //krazy:exclude=nullstrassign for old broken gcc
if(answer == KMessageBox::Continue)
{
fi.setFileName(currItem);
fi.remove();
delete m_lviCurrent;
m_lviCurrent = 0;
}
}
}
void KFileReplaceView::slotResultTreeExpand()
{
QListWidgetItem *lviRoot = getResultsView()->firstChild();
if(lviRoot)
expand(lviRoot, true);
}
void KFileReplaceView::slotResultTreeReduce()
{
QListWidgetItem *lviRoot = getResultsView()->firstChild();
if(lviRoot)
expand(lviRoot, false);
}
void KFileReplaceView::slotStringsAdd()
{
KeyValueMap oldMap(m_option->m_mapStringsView);
KAddStringDlg addStringDlg(m_option, false);
if(!addStringDlg.exec())
return;
KeyValueMap addedStringsMap(m_option->m_mapStringsView);
KeyValueMap::Iterator itMap;
for(itMap = oldMap.begin(); itMap != oldMap.end(); ++itMap)
addedStringsMap.insert(itMap.key(),itMap.data());
m_option->m_mapStringsView = addedStringsMap;
raiseResultsView();
raiseStringsView();
loadMapIntoView(addedStringsMap);
}
void KFileReplaceView::slotQuickStringsAdd(const QString& quickSearch, const QString& quickReplace)
{
if(!quickSearch.isEmpty())
{
KeyValueMap map;
if(quickReplace.isEmpty())
{
map[quickSearch] = QString::null; //krazy:exclude=nullstrassign for old broken gcc
m_option->m_searchingOnlyMode = true;
}
else
{
map[quickSearch] = quickReplace;
m_option->m_searchingOnlyMode = false;
}
m_option->m_mapStringsView = map;
raiseResultsView();
raiseStringsView();
loadMapIntoView(map);
}
}
void KFileReplaceView::slotStringsEdit()
{
KeyValueMap oldMap(m_option->m_mapStringsView);
if(oldMap.isEmpty()) return;
bool oldSearchFlagValue = m_option->m_searchingOnlyMode;
oldMap.remove(m_sv->currentItem()->text(0));
m_option->m_mapStringsView.clear();
m_option->m_mapStringsView.insert(m_sv->currentItem()->text(0), m_sv->currentItem()->text(1));
KAddStringDlg addStringDlg(m_option, true);
if(!addStringDlg.exec())
return;
KeyValueMap newMap(m_option->m_mapStringsView);
if(oldSearchFlagValue == m_option->m_searchingOnlyMode)
{
KeyValueMap::Iterator itMap;
//merges the two maps
for(itMap = oldMap.begin(); itMap != oldMap.end(); ++itMap)
newMap.insert(itMap.key(),itMap.data());
}
m_option->m_mapStringsView = newMap;
raiseResultsView();
raiseStringsView();
loadMapIntoView(newMap);
}
void KFileReplaceView::slotStringsSave()
{
// Check there are strings in the list
QListView* sv = getStringsView();
if (sv->firstChild() == 0)
{
KMessageBox::error(0, i18n("No strings to save as the list is empty."));
return ;
}
QString header("<?xml version=\"1.0\" ?>\n<kfr>"),
footer("\n</kfr>"),
body;
if(m_option->m_searchingOnlyMode)
header += "\n\t<mode search=\"true\"/>";
else
header += "\n\t<mode search=\"false\"/>";
QListWidgetItem* lvi = sv->firstChild();
while( lvi )
{
body += QString("\n\t<replacement>"
"\n\t\t<oldstring><![CDATA[%1]]></oldstring>"
"\n\t\t<newstring><![CDATA[%2]]></newstring>"
"\n\t</replacement>").arg(lvi->text(0)).arg(lvi->text(1));
lvi = lvi->nextSibling();
}
// Selects the file where strings will be saved
QString menu = "*.kfr|" + i18n("KFileReplace Strings") + " (*.kfr)\n*|" + i18n("All Files") + " (*)";
QString fileName = KFileDialog::getSaveFileName(KUrl(), menu, 0, i18n("Save Strings to File"));
if (fileName.isEmpty())
return;
// Forces the extension to be "kfr" == KFileReplace extension
fileName = KFileReplaceLib::addExtension(fileName, "kfr");
QFile file( fileName );
if(!file.open( QIODevice::WriteOnly ))
{
KMessageBox::error(0, i18n("File %1 cannot be saved.", fileName));
return ;
}
Q3TextStream oTStream( &file );
oTStream.setCodec(QTextCodec::codecForName("UTF-8"));
oTStream << header
<< body
<< footer;
file.close();
}
void KFileReplaceView::slotStringsDeleteItem()
{
QListWidgetItem* item = m_sv->currentItem();
if(item != 0)
{
KeyValueMap m = m_option->m_mapStringsView;
m.remove(item->text(0));
m_option->m_mapStringsView = m;
delete item;
}
}
void KFileReplaceView::slotStringsEmpty()
{
QListWidgetItem * myChild = m_sv->firstChild();
while( myChild )
{
QListWidgetItem* item = myChild;
myChild = myChild->nextSibling();
delete item;
}
KeyValueMap m;
m_option->m_mapStringsView = m;
}
//PRIVATE
void KFileReplaceView::initGUI()
{
m_option->m_searchingOnlyMode = true;
m_stackResults->addWidget(m_lvResults);
m_stackResults->addWidget(m_lvResults_2);
m_stackStrings->addWidget(m_lvStrings);
m_stackStrings->addWidget(m_lvStrings_2);
bool quantaFound = false;
QDBusConnection dbus = QDBusConnection::sessionBus();
QDBusReply<QStringList> reply = dbus.interface()->registeredServiceNames();
if ( !reply.isValid() )
return;
const QStringList allServices = reply;
for ( QStringList::const_iterator it = allServices.begin(), end = allServices.end() ; it != end ; ++it ) {
const QString service = *it;
if ( service.startsWith( "org.kde.quanta" ) ) {
quantaFound = true;
break;
}
}
m_menuResult = new KMenu(this);
m_menuResult->insertItem(SmallIconSet(QString::fromLatin1("document-open")),
i18n("&Open"),
this,
SLOT(slotResultOpen()));
if(!quantaFound)
{
m_menuResult->insertItem(i18n("Open &With..."),
this,
SLOT(slotResultOpenWith()));
}
if(quantaFound)
{
m_menuResult->insertItem(SmallIconSet("quanta"),
i18n("&Edit in Quanta"),
this,
SLOT(slotResultEdit()));
}
m_menuResult->insertItem(SmallIconSet(QString::fromLatin1("go-up")),
i18n("Open Parent &Folder"),
this,
SLOT(slotResultDirOpen()));
m_menuResult->insertItem(SmallIconSet(QString::fromLatin1("edit-delete")),
i18n("&Delete"),
this,
SLOT(slotResultDelete()));
m_menuResult->insertSeparator();
m_menuResult->insertItem(SmallIconSet(QString::fromLatin1("document-properties")),
i18n("&Properties"),
this,
SLOT(slotResultProperties()));
raiseResultsView();
raiseStringsView();
}
void KFileReplaceView::raiseStringsView()
{
if(m_option->m_searchingOnlyMode)
m_sv = m_lvStrings_2;
else
m_sv = m_lvStrings;
m_stackStrings->raiseWidget(m_sv);
}
void KFileReplaceView::raiseResultsView()
{
if(m_option->m_searchingOnlyMode)
m_rv = m_lvResults_2;
else
m_rv = m_lvResults;
m_stackResults->raiseWidget(m_rv);
}
coord KFileReplaceView::extractWordCoordinates(QListWidgetItem* lvi)
{
//get coordinates of the first string of the current selected file
coord c;
c.line = 0;
c.column = 0;
QString s = lvi->text(0);
//qWarning("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW=%s",s.latin1());
/* if(lvi->parent()) s = lvi->text(0);
else return c;*/
QString temp;
int i = 0;
//extracts line and column from lvi->text(0)
//FIXME: Don't get the line and column number from the text as it's translated and it will
//fail for non-English languages!
//EMILIANO: This is not a good fixing but for now it should reduce the problems
while(true)
{
if(s[i] < '0' || s[i] > '9')
i++;
else
break;
}
while(true)
{
if(s[i] >= '0' && s[i] <= '9')
{
temp += s[i];
i++;
}
else
break;
}
c.line = temp.toInt();
temp.clear();
while(true)
{
if(s[i] < '0' || s[i] > '9')
i++;
else
break;
}
while(true)
{
if(s[i] >= '0' && s[i] <= '9')
{
temp += s[i];
i++;
}
else
break;
}
c.column = temp.toInt();
if(c.line > 0) c.line--;
if(c.column > 0) c.column--;
return c;
}
void KFileReplaceView::expand(QListWidgetItem *lviCurrent, bool b)
{
// current item
lviCurrent->setOpen(b);
// recursivity
while((lviCurrent = lviCurrent->nextSibling()) != 0)
{
lviCurrent->setOpen(b);
if (lviCurrent->firstChild())
expand(lviCurrent->firstChild(), b);
}
}
void KFileReplaceView::setMap()
{
KeyValueMap map;
QListWidgetItem* i = m_sv->firstChild();
while(i != 0)
{
if(m_option->m_searchingOnlyMode)
map[i->text(0)] = QString::null; //krazy:exclude=nullstrassign for old broken gcc
else
map[i->text(0)] = i->text(1);
i = i->nextSibling();
}
m_option->m_mapStringsView = map;
}
void KFileReplaceView::loadMapIntoView(KeyValueMap map)
{
m_sv->clear();
KeyValueMap::Iterator itMap;
for(itMap = map.begin(); itMap != map.end(); ++itMap)
{
QListWidgetItem* lvi = new QListWidgetItem(m_sv);
lvi->setMultiLinesEnabled(true);
lvi->setText(0,itMap.key());
if(!m_option->m_searchingOnlyMode)
lvi->setText(1,itMap.data());
}
}
void KFileReplaceView::whatsThis()
{
getResultsView()->setWhatsThis( lvResultWhatthis);
getStringsView()->setWhatsThis( lvStringsWhatthis);
}
#include "moc_kfilereplaceview.cpp"

View file

@ -0,0 +1,111 @@
/***************************************************************************
kfilereplaceview.h - description
-------------------
begin : sam oct 16 15:28:00 CEST 1999
copyright : (C) 1999 by François Dupoux <dupoux@dupoux.com>
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef KFILEREPLACEVIEW_H
#define KFILEREPLACEVIEW_H
//QT
#include <qlcdnumber.h>
#include <QListWidget>
//KDE
class KMenu;
class QListWidget;
//local
#include "ui_kfilereplaceviewwdg.h"
#include "configurationclasses.h"
class coord
{
public:
int line,
column;
public:
coord(){ line = 1;
column = 1;}
coord(const coord& c) { line = c.line;
column = c.column;}
coord operator=(const coord& c) { line = c.line;
column = c.column;
return (*this);}
};
/**
* The view of KFilereplace.
*/
class KFileReplaceView : public KFileReplaceViewWdg
{
Q_OBJECT
private:
KMenu* m_menuResult;
RCOptions* m_option;
QListWidgetItem* m_lviCurrent;
QListWidget* m_rv,
* m_sv;
public://Constructors
KFileReplaceView(RCOptions* info, QWidget *parent,const char *name);
public:
QString currentPath();
void showSemaphore(const QString &s);
void displayScannedFiles(int filesNumber) { m_lcdFilesNumber->display(QString::number(filesNumber,10)); }
void stringsInvert(bool invertAll);
void changeView(bool searchingOnlyMode);
QListWidget* getResultsView();
QListWidget* getStringsView();
void updateOptions(RCOptions* info) { m_option = info; }
void loadMap(KeyValueMap extMap){ loadMapIntoView(extMap); }
KeyValueMap getStringsViewMap()const { return m_option->m_mapStringsView;}
void setCurrentStringsViewMap(){ setMap(); }
//void emitSearchingOnlyMode(bool b) { emit searchingOnlyMode(b); }
public slots:
void slotMouseButtonClicked (int button, QListWidgetItem *lvi, const QPoint &pos);
void slotResultProperties();
void slotResultOpen();
void slotResultOpenWith();
void slotResultDirOpen();
void slotResultEdit();
void slotResultDelete();
void slotResultTreeExpand();
void slotResultTreeReduce();
void slotStringsAdd();
void slotQuickStringsAdd(const QString& quickSearch, const QString& quickReplace);
void slotStringsDeleteItem();
void slotStringsEmpty();
void slotStringsEdit();
void slotStringsSave();
private:
void initGUI();
void raiseStringsView();
void raiseResultsView();
coord extractWordCoordinates(QListWidgetItem* lvi);
void expand(QListWidgetItem *lviCurrent, bool b);
void setMap();
void loadMapIntoView(KeyValueMap map);
void whatsThis();
/*signals:
void resetActions();
void searchingOnlyMode(bool);*/
};
#endif // KFILEREPLACEVIEW_H

View file

@ -0,0 +1,245 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KFileReplaceViewWdg</class>
<widget class="QWidget" name="KFileReplaceViewWdg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>635</width>
<height>370</height>
</rect>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QSplitter" name="splitter3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QStackedWidget" name="m_stackResults">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="WStackPage">
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QListWidget" name="m_lvResults">
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="resizeMode">
<enum>QListView::Fixed</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="WStackPage">
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QListWidget" name="m_lvResults_2">
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="resizeMode">
<enum>QListView::Fixed</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QStackedWidget" name="m_stackStrings">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="WStackPage">
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QListWidget" name="m_lvStrings">
<property name="resizeMode">
<enum>QListView::Fixed</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="WStackPage">
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QListWidget" name="m_lvStrings_2">
<property name="resizeMode">
<enum>QListView::Fixed</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="KLed" name="m_ledGo">
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Green means ready</string>
</property>
<property name="whatsThis">
<string>Ready</string>
</property>
<property name="state">
<enum>KLed::On</enum>
</property>
<property name="color">
<color>
<red>170</red>
<green>255</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item>
<widget class="KLed" name="m_ledWait">
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Yellow means wait while sorting list</string>
</property>
<property name="whatsThis">
<string>Please wait while sorting list</string>
</property>
<property name="state">
<enum>KLed::On</enum>
</property>
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item>
<widget class="KLed" name="m_ledStop">
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Red means scanning files</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer1">
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>354</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="m_tlFilesNumber">
<property name="text">
<string>Scanned files:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="m_lcdFilesNumber">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="numDigits">
<number>7</number>
</property>
<property name="mode">
<enum>QLCDNumber::Dec</enum>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
<property name="intValue" stdset="0">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLed</class>
<extends>QWidget</extends>
<header>kled.h</header>
</customwidget>
</customwidgets>
<includes>
<include location="local">kled.h</include>
</includes>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,529 @@
/***************************************************************************
knewprojectdlg.cpp - description
-------------------
begin : Tue Dec 28 1999
copyright : (C) 1999 by François Dupoux
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.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. *
* *
***************************************************************************/
//QT
#include <qcheckbox.h>
#include <qspinbox.h>
#include <qlabel.h>
#include <qradiobutton.h>
#include <qlistview.h>
//Added by qt3to4:
#include <QPixmap>
//KDE
#include <kseparator.h>
#include <kmessagebox.h>
#include <kcharsets.h>
#include <kcombobox.h>
#include <kconfig.h>
#include <kfiledialog.h>
#include <klineedit.h>
#include <kglobal.h>
#include <klocale.h>
#include <kpushbutton.h>
#include <kstandarddirs.h>
#include <kdeversion.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <kapplication.h>
// local
#include "knewprojectdlg.h"
#include "whatthis.h"
using namespace whatthisNameSpace;
KNewProjectDlg::KNewProjectDlg(RCOptions* info, QWidget *parent, const char *name) : KNewProjectDlgS(parent, name)
{
m_searchNowFlag = "";
m_option = info;
initGUI();
connect(m_pbLocation, SIGNAL(clicked()), this, SLOT(slotDir()));
connect(m_pbCancel, SIGNAL(clicked()), this, SLOT(slotReject()));
connect(m_pbSearchNow, SIGNAL(clicked()), this, SLOT(slotSearchNow()));
connect(m_pbSearchLater, SIGNAL(clicked()), this, SLOT(slotSearchLater()));
connect(m_leSearch, SIGNAL(textChanged(const QString&)), this, SLOT(slotSearchLineEdit(const QString&)));
connect(m_chbSizeMin, SIGNAL(toggled(bool)), this, SLOT(slotEnableSpinboxSizeMin(bool)));
connect(m_chbSizeMax, SIGNAL(toggled(bool)), this, SLOT(slotEnableSpinboxSizeMax(bool)));
connect(m_chbDateMin, SIGNAL(toggled(bool)), m_dedDateMin, SLOT(setEnabled(bool)));
connect(m_chbDateMax, SIGNAL(toggled(bool)), m_dedDateMax, SLOT(setEnabled(bool)));
connect(m_chbDateMin,SIGNAL(toggled(bool)),this, SLOT(slotEnableCbValidDate(bool)));
connect(m_chbDateMax,SIGNAL(toggled(bool)),this, SLOT(slotEnableCbValidDate(bool)));
connect(m_chbOwnerUser, SIGNAL(toggled(bool)), this, SLOT(slotEnableChbUser(bool)));
connect(m_chbOwnerGroup, SIGNAL(toggled(bool)), this, SLOT(slotEnableChbGroup(bool)));
connect(m_chbBackup, SIGNAL(toggled(bool)), this, SLOT(slotEnableChbBackup(bool)));
connect(m_pbHelp, SIGNAL(clicked()), this, SLOT(slotHelp()));
whatsThis();
}
KNewProjectDlg::~KNewProjectDlg()
{
}
void KNewProjectDlg::saveRCOptions()
{
saveOptions();
saveFileSizeOptions();
saveDateAccessOptions();
saveOwnerOptions();
saveLocationsList();
saveFiltersList();
saveBackupExtensionOptions();
}
void KNewProjectDlg::slotDir()
{
QString directoryString = KFileDialog::getExistingDirectory(KUrl(), this, i18n("Project Directory"));
if(!directoryString.isEmpty())
m_cbLocation->setEditText(directoryString);
}
void KNewProjectDlg::slotOK()
{
// Check that Search text and Filter are not empty
m_option->m_directories = m_cbLocation->currentText();
m_option->m_filters = m_cbFilter->currentText();
if(!m_leSearch->text().isEmpty())
{
if(m_leReplace->text().isEmpty())
m_option->m_searchingOnlyMode = true;
else
m_option->m_searchingOnlyMode = false;
}
m_option->m_quickSearchString = m_searchNowFlag + m_leSearch->text();
m_option->m_quickReplaceString = m_searchNowFlag + m_leReplace->text();
if (m_option->m_directories.isEmpty() || m_option->m_filters.isEmpty())
{
KMessageBox::error(this, i18n("You must fill the combo boxes (location and filter) before continuing."));
return;
}
// OWNER OPTIONS
if ((m_chbOwnerUser->isChecked() && m_edOwnerUser->text().isEmpty()) ||
(m_chbOwnerGroup->isChecked() && m_edOwnerGroup->text().isEmpty()))
{
KMessageBox::error(this, i18n("Some edit boxes are empty in the <b>Owner</b> page."));
return ;
}
// Check option "Size Min/Max": check MinSize is not greater than MaxSize
int minSize = m_spbSizeMin->value(),
maxSize = m_spbSizeMax->value();
if ((minSize != FileSizeOption) && (maxSize != FileSizeOption))
if (minSize > maxSize)
{
KMessageBox::error(this, i18n("The minimum size is greater than the maximum size."));
return ;
}
accept();
}
void KNewProjectDlg::slotReject()
{
m_option->m_quickSearchString = m_searchNowFlag;
m_option->m_quickReplaceString = m_searchNowFlag;
reject();
}
void KNewProjectDlg::slotSearchNow()
{ //Add a 'N' to represent the status search-now
m_searchNowFlag = "N";
slotOK();
}
void KNewProjectDlg::slotSearchLater()
{ //Add a 'L' to represent the status search-later
m_searchNowFlag = "L";
slotOK();
}
void KNewProjectDlg::slotSearchLineEdit(const QString& t)
{
m_pbSearchNow->setEnabled(!t.isEmpty());
}
void KNewProjectDlg::slotEnableSpinboxSizeMin(bool b)
{
m_spbSizeMin->setEnabled(b);
}
void KNewProjectDlg::slotEnableSpinboxSizeMax(bool b)
{
m_spbSizeMax->setEnabled(b);
}
void KNewProjectDlg::slotEnableCbValidDate(bool b)
{
Q_UNUSED(b);
m_cbDateValid->setEnabled(m_chbDateMax->isChecked() || m_chbDateMin->isChecked());
}
void KNewProjectDlg::slotEnableChbUser(bool b)
{
m_cbOwnerUserType->setEnabled(b);
m_cbOwnerUserBool->setEnabled(b);
m_edOwnerUser->setEnabled(b);
}
void KNewProjectDlg::slotEnableChbGroup(bool b)
{
m_cbOwnerGroupType->setEnabled(b);
m_cbOwnerGroupBool->setEnabled(b);
m_edOwnerGroup->setEnabled(b);
}
void KNewProjectDlg::slotEnableChbBackup(bool b)
{
m_leBackup->setEnabled(b);
m_tlBackup->setEnabled(b);
}
//PRIVATE
void KNewProjectDlg::initGUI()
{
QIcon iconSet = SmallIconSet("document-open");
QPixmap pixMap = iconSet.pixmap( QIcon::Small, QIcon::Normal );
m_pbLocation->setIconSet(iconSet);
m_pbLocation->setFixedSize(pixMap.width() + 8, pixMap.height() + 8);
m_pbSearchNow->setEnabled(false);
loadOptions();
loadFileSizeOptions();
loadDateAccessOptions();
loadOwnerOptions();
loadBackupExtensionOptions();
loadLocationsList();
loadFiltersList();
}
void KNewProjectDlg::loadOptions()
{
QStringList availableEncodingNames(KGlobal::charsets()->availableEncodingNames());
m_cbEncoding->addItems(availableEncodingNames);
int idx = -1;
int utf8Idx = -1;
for (int i = 0; i < availableEncodingNames.count(); i++)
{
if (availableEncodingNames[i] == m_option->m_encoding)
{
idx = i;
break;
}
if (availableEncodingNames[i] == "UTF-8")
{
utf8Idx = i;
}
}
if (idx != -1)
m_cbEncoding->setCurrentIndex(idx);
else
m_cbEncoding->setCurrentIndex(utf8Idx);
m_chbIncludeSubfolders->setChecked(m_option->m_recursive);
m_chbCaseSensitive->setChecked(m_option->m_caseSensitive);
m_chbEnableVariables->setChecked(m_option->m_variables);
m_chbRegularExpressions->setChecked(m_option->m_regularExpressions);
}
void KNewProjectDlg::loadFileSizeOptions()
{
int size = m_option->m_minSize;
if(size == FileSizeOption)
{
m_chbSizeMin->setChecked(false);
m_spbSizeMin->setEnabled(false);
m_spbSizeMin->setValue(0);
}
else
{
m_chbSizeMin->setChecked(true);
m_spbSizeMin->setEnabled(true);
m_spbSizeMin->setValue(size);
}
size = m_option->m_maxSize;
if(size == FileSizeOption)
{
m_chbSizeMax->setChecked(false);
m_spbSizeMax->setEnabled(false);
m_spbSizeMax->setValue(0);
}
else
{
m_chbSizeMax->setChecked(true);
m_spbSizeMax->setEnabled(true);
m_spbSizeMax->setValue(size);
}
}
void KNewProjectDlg::loadDateAccessOptions()
{
// ================== DATE OPTIONS ========================
QString date = m_option->m_minDate;
if(date == AccessDateOption)
{
m_chbDateMin->setChecked(false);
m_dedDateMin->setDate(m_dedDateMin->minValue());
m_dedDateMin->setEnabled(false);
}
else
{
m_chbDateMin->setChecked(true);
m_dedDateMin->setDate(QDate::fromString(date,Qt::ISODate));
m_dedDateMin->setEnabled(true);
}
date = m_option->m_maxDate;
if(date == AccessDateOption)
{
m_chbDateMax->setChecked(false);
m_dedDateMax->setDate(m_dedDateMax->maxValue());
m_dedDateMax->setEnabled(false);
}
else
{
m_chbDateMax->setChecked(true);
m_dedDateMax->setDate(QDate::fromString(date,Qt::ISODate));
m_dedDateMax->setEnabled(true);
}
m_cbDateValid->setEnabled(m_chbDateMax->isChecked() || m_chbDateMin->isChecked());
}
void KNewProjectDlg::loadOwnerOptions()
{
bool enableOwner = m_option->m_ownerUserIsChecked;
m_chbOwnerUser->setChecked(enableOwner);
m_cbOwnerUserType->setEnabled(enableOwner);
m_cbOwnerUserBool->setEnabled(enableOwner);
m_edOwnerUser->setEnabled(enableOwner);
m_cbOwnerUserType->setCurrentText(m_option->m_ownerUserType);
m_cbOwnerUserBool->setCurrentText(m_option->m_ownerUserBool);
m_edOwnerUser->setText(m_option->m_ownerUserValue);
enableOwner = m_option->m_ownerGroupIsChecked;
m_chbOwnerGroup->setChecked(enableOwner);
m_cbOwnerGroupType->setEnabled(enableOwner);
m_cbOwnerGroupBool->setEnabled(enableOwner);
m_edOwnerGroup->setEnabled(enableOwner);
m_cbOwnerGroupType->setCurrentText(m_option->m_ownerGroupType);
m_cbOwnerGroupBool->setCurrentText(m_option->m_ownerGroupBool);
m_edOwnerGroup->setText(m_option->m_ownerGroupValue);
}
void KNewProjectDlg::loadLocationsList()
{
m_cbLocation->addItems(m_option->m_directories.split(","));
}
void KNewProjectDlg::loadFiltersList()
{
m_cbFilter->addItems(m_option->m_filters.split(","));
}
void KNewProjectDlg::loadBackupExtensionOptions()
{
bool enableBackup = m_option->m_backup;
m_chbBackup->setChecked(enableBackup);
m_leBackup->setEnabled(enableBackup);
m_tlBackup->setEnabled(enableBackup);
m_leBackup->setText(m_option->m_backupExtension);
}
void KNewProjectDlg::saveOptions()
{
m_option->m_encoding = m_cbEncoding->currentText();
m_option->m_recursive = m_chbIncludeSubfolders->isChecked();
m_option->m_caseSensitive = m_chbCaseSensitive->isChecked();
m_option->m_variables = m_chbEnableVariables->isChecked();
m_option->m_regularExpressions = m_chbRegularExpressions->isChecked();
}
void KNewProjectDlg::saveFileSizeOptions()
{
if(m_chbSizeMax->isChecked())
m_option->m_maxSize = m_spbSizeMax->value();
else
m_option->m_maxSize = FileSizeOption;
if(m_chbSizeMin->isChecked())
m_option->m_minSize = m_spbSizeMin->value();
else
m_option->m_minSize = FileSizeOption;
}
void KNewProjectDlg::saveDateAccessOptions()
{
if(m_chbDateMin->isChecked() || m_chbDateMax->isChecked())
m_option->m_dateAccess = m_cbDateValid->currentText();
else
m_option->m_dateAccess = ValidAccessDateOption;
if(m_chbDateMin->isChecked())
{
QString date = m_dedDateMin->date().toString(Qt::ISODate);
m_option->m_minDate = date;
}
else
m_option->m_minDate = AccessDateOption;
if(m_chbDateMax->isChecked())
{
QString date = m_dedDateMax->date().toString(Qt::ISODate);
m_option->m_maxDate = date;
}
else
m_option->m_maxDate = AccessDateOption;
}
void KNewProjectDlg::saveOwnerOptions()
{
bool isChecked = m_chbOwnerUser->isChecked();
if(isChecked)
{
m_option->m_ownerUserIsChecked = true;
m_option->m_ownerUserType = m_cbOwnerUserType->currentText();
m_option->m_ownerUserBool = m_cbOwnerUserBool->currentText();
m_option->m_ownerUserValue = m_edOwnerUser->text();
}
else
{
m_option->m_ownerUserIsChecked = false;
m_option->m_ownerUserType = "Name";
m_option->m_ownerUserBool = "Equals To";
m_option->m_ownerUserValue = "";
}
isChecked = m_chbOwnerGroup->isChecked();
if(isChecked)
{
m_option->m_ownerGroupIsChecked = true;
m_option->m_ownerGroupType = m_cbOwnerGroupType->currentText();
m_option->m_ownerGroupBool = m_cbOwnerGroupBool->currentText();
m_option->m_ownerGroupValue = m_edOwnerGroup->text();
}
else
{
m_option->m_ownerGroupIsChecked = false;
m_option->m_ownerGroupType = "Name";
m_option->m_ownerGroupBool = "Equals To";
m_option->m_ownerGroupValue = "";
}
}
void KNewProjectDlg::saveLocationsList()
{
QString current = m_cbLocation->currentText(), list = current;
int count = m_cbLocation->count(),
i;
for(i = 0; i < count; i++)
{
QString text = m_cbLocation->itemText(i);
if(text != current)
list += ','+text;
}
m_option->m_directories = list;
}
void KNewProjectDlg::saveFiltersList()
{
QString current = m_cbFilter->currentText(), list = current;
int count = m_cbFilter->count(),
i;
for(i = 0; i < count; i++)
{
QString text = m_cbFilter->itemText(i);
if(text != current)
list += ','+text;
}
m_option->m_filters = list;
}
void KNewProjectDlg::saveBackupExtensionOptions()
{
QString backupExt = m_leBackup->text();
m_option->m_backup = (m_chbBackup->isChecked() && !backupExt.isEmpty());
m_option->m_backupExtension = backupExt;
}
void KNewProjectDlg::setDatas(const QString& directoryString, const QString& filterString)
{
if (!directoryString.isEmpty())
m_cbLocation->setEditText(directoryString);
if (!filterString.isEmpty())
m_cbFilter->setEditText(filterString);
}
bool KNewProjectDlg::contains(QListWidget* lv,const QString& s, int column)
{
QListWidgetItem* i = lv->firstChild();
while (i != 0)
{
if(i->text(column) == s)
return true;
i = i->nextSibling();
}
return false;
}
void KNewProjectDlg::whatsThis()
{
m_cbLocation->setWhatsThis( cbLocationWhatthis);
m_cbFilter->setWhatsThis( cbFilterWhatthis);
m_spbSizeMin->setWhatsThis( edSizeMinWhatthis);
m_spbSizeMax->setWhatsThis( edSizeMaxWhatthis);
m_cbDateValid->setWhatsThis( cbDateValidWhatthis);
m_chbDateMin->setWhatsThis( chbDateMinWhatthis);
m_chbDateMax->setWhatsThis( chbDateMaxWhatthis);
m_chbIncludeSubfolders->setWhatsThis( chbRecursiveWhatthis);
m_chbRegularExpressions->setWhatsThis( chbRegularExpressionsWhatthis);
m_chbEnableVariables->setWhatsThis( chbVariablesWhatthis);
m_chbCaseSensitive->setWhatsThis( chbCaseSensitiveWhatthis);
m_chbBackup->setWhatsThis( chbBackupWhatthis);
m_leBackup->setWhatsThis( chbBackupWhatthis);
m_leSearch->setWhatsThis( leSearchWhatthis);
m_leReplace->setWhatsThis( leReplaceWhatthis);
}
#include "moc_knewprojectdlg.cpp"

View file

@ -0,0 +1,84 @@
/***************************************************************************
knewprojectdlg.h - description
-------------------
begin : Tue Dec 28 1999
copyright : (C) 1999 by François Dupoux
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.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. *
* *
***************************************************************************/
#ifndef KNEWPROJECTDLG_H
#define KNEWPROJECTDLG_H
//KDE
//local
#include "ui_knewprojectdlgs.h"
#include "configurationclasses.h"
#include "ktoolinvocation.h"
class KNewProjectDlg : public KNewProjectDlgS
{
Q_OBJECT
private:
QString m_searchNowFlag;
RCOptions* m_option;
public:
explicit KNewProjectDlg(RCOptions* info, QWidget *parent=0, const char *name=0);
~KNewProjectDlg();
public:
//void updateOptions(const RCOptions& info);
void saveRCOptions();
protected slots:
void slotDir();
void slotOK();
void slotReject();
void slotSearchNow();
void slotSearchLater();
void slotSearchLineEdit(const QString& t);
void slotEnableSpinboxSizeMin(bool b);
void slotEnableSpinboxSizeMax(bool b);
void slotEnableCbValidDate(bool b);
void slotEnableChbUser(bool b);
void slotEnableChbGroup(bool b);
void slotEnableChbBackup(bool b);
void slotHelp(){ KToolInvocation::invokeHelp(QString::null, "kfilereplace"); } //krazy:exclude=nullstrassign for old broken gcc
private:
void initGUI();
void loadOptions();
void loadFileSizeOptions();
void loadDateAccessOptions();
void loadOwnerOptions();
void loadLocationsList();
void loadFiltersList();
void loadBackupExtensionOptions();
void saveOptions();
void saveFileSizeOptions();
void saveDateAccessOptions();
void saveOwnerOptions();
void saveLocationsList();
void saveFiltersList();
void saveBackupExtensionOptions();
bool contains(QListWidget* lv,const QString& s, int column);
void setDatas(const QString& directoryString, const QString& filterString);
void whatsThis();
};
#endif // KNewProjectDlg

View file

@ -0,0 +1,777 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0" stdsetdef="1">
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>KNewProjectDlgS</class>
<widget class="QDialog" name="KNewProjectDlgS">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>568</width>
<height>609</height>
</rect>
</property>
<property name="windowTitle">
<string>Search &amp; Replace in Files</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout">
<item row="1" column="0">
<layout class="QHBoxLayout">
<item>
<widget class="KPushButton" name="m_pbHelp">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>32767</height>
</size>
</property>
<property name="text">
<string>&amp;Help</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer7">
<property name="sizeHint">
<size>
<width>150</width>
<height>20</height>
</size>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="orientation">
<enum>Qt::Qt::Horizontal</enum>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="m_pbSearchNow">
<property name="text">
<string>Search Now</string>
</property>
<property name="shortcut">
<string/>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_pbSearchLater">
<property name="text">
<string>Search Later</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item>
<widget class="KPushButton" name="m_pbCancel">
<property name="sizePolicy">
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>32767</height>
</size>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget2">
<widget class="QWidget" name="tab">
<attribute name="title">
<string>&amp;General</string>
</attribute>
<layout class="QGridLayout">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox5">
<property name="title">
<string>Startup Folder Options</string>
</property>
<layout class="QGridLayout">
<item row="1" column="0">
<widget class="QLabel" name="m_tlFilter">
<property name="text">
<string>Filter:</string>
</property>
<property name="buddy" stdset="0">
<cstring>cbFilter</cstring>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="m_tlLocation">
<property name="text">
<string>Location:</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="buddy" stdset="0">
<cstring>cbLocation</cstring>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="m_cbLocation">
<property name="sizePolicy">
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="maxCount">
<number>10</number>
</property>
<property name="insertionPolicy">
<enum>AtTop</enum>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<property name="whatsThis" stdset="0">
<string>Insert a search path here. You can use the search path button.</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="m_pbLocation">
<property name="text">
<string/>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="1" colspan="2">
<widget class="KComboBox" name="m_cbFilter">
<property name="sizePolicy">
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="maxCount">
<number>10</number>
</property>
<property name="insertionPolicy">
<enum>AtTop</enum>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<property name="whatsThis" stdset="0">
<string/>
</property>
</widget>
</item>
<item row="2" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbIncludeSubfolders">
<property name="text">
<string>&amp;Include subfolders</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox6">
<property name="title">
<string>Search/Replace Strings</string>
</property>
<layout class="QGridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="m_leSearch"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="m_leReplace"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="m_tlSearch">
<property name="text">
<string>Search:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="m_tlReplace">
<property name="text">
<string>Replace:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox4">
<property name="title">
<string>General Options</string>
</property>
<layout class="QGridLayout">
<item row="2" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbRegularExpressions">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Enable &amp;regular expressions</string>
</property>
</widget>
</item>
<item row="4" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbBackup">
<property name="text">
<string>Do &amp;backup copy instead of overwrite</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbCaseSensitive">
<property name="text">
<string>&amp;Case sensitive</string>
</property>
</widget>
</item>
<item row="3" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbEnableVariables">
<property name="text">
<string>Enable co&amp;mmands in the replace string</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="m_tlBackup">
<property name="text">
<string>Backup copy suffix:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1" rowspan="1" colspan="2">
<widget class="QLineEdit" name="m_leBackup">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="KComboBox" name="m_cbEncoding">
<property name="sizePolicy">
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="1" colspan="2">
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Encoding of the files:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>&amp;Advanced</string>
</attribute>
<layout class="QGridLayout">
<item row="2" column="0">
<widget class="QGroupBox" name="gbOwnership">
<property name="title">
<string>Ownership Filtering</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="m_chbOwnerUser">
<property name="text">
<string>User: </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="m_cbOwnerUserType">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maxCount">
<number>2</number>
</property>
<property name="duplicatesEnabled">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>Name</string>
</property>
</item>
<item>
<property name="text">
<string>ID (Number)</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="KComboBox" name="m_cbOwnerUserBool">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maxCount">
<number>2</number>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Equals To</string>
</property>
</item>
<item>
<property name="text">
<string>Is Not</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2">
<widget class="KComboBox" name="m_cbOwnerGroupBool">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maxCount">
<number>2</number>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Equals To</string>
</property>
</item>
<item>
<property name="text">
<string>Is Not</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="m_cbOwnerGroupType">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maxCount">
<number>2</number>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Name</string>
</property>
</item>
<item>
<property name="text">
<string>ID (Number)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="m_chbOwnerGroup">
<property name="text">
<string>Group:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="KLineEdit" name="m_edOwnerUser">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="KLineEdit" name="m_edOwnerGroup">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="gbAccessDate">
<property name="title">
<string>Access Date Filtering</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="m_tlDateValid">
<property name="text">
<string>Dates valid for:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_chbDateMin">
<property name="text">
<string>Accessed after:</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_chbDateMax">
<property name="text">
<string>Accessed before: </string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout">
<item>
<widget class="KComboBox" name="m_cbDateValid">
<property name="maxCount">
<number>2</number>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Last Writing Access</string>
</property>
</item>
<item>
<property name="text">
<string>Last Reading Access</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QDateEdit" name="m_dedDateMin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="date">
<date>
<year>2000</year>
<month>1</month>
<day>1</day>
</date>
</property>
<property name="autoAdvance">
<bool>true</bool>
</property>
<property name="maxValue">
<date>
<year>2100</year>
<month>12</month>
<day>31</day>
</date>
</property>
<property name="minValue">
<date>
<year>1900</year>
<month>12</month>
<day>31</day>
</date>
</property>
</widget>
</item>
<item>
<widget class="QDateEdit" name="m_dedDateMax">
<property name="enabled">
<bool>false</bool>
</property>
<property name="date">
<date>
<year>2000</year>
<month>1</month>
<day>1</day>
</date>
</property>
<property name="autoAdvance">
<bool>true</bool>
</property>
<property name="maxValue">
<date>
<year>2100</year>
<month>12</month>
<day>31</day>
</date>
</property>
<property name="minValue">
<date>
<year>1900</year>
<month>9</month>
<day>14</day>
</date>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer3">
<property name="sizeHint">
<size>
<width>190</width>
<height>16</height>
</size>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="orientation">
<enum>Qt::Qt::Horizontal</enum>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="gbSize">
<property name="title">
<string>Size Filtering</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QCheckBox" name="m_chbSizeMin">
<property name="text">
<string>Minimum si&amp;ze:</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_chbSizeMax">
<property name="text">
<string>Maximum size:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QSpinBox" name="m_spbSizeMin">
<property name="maximum">
<number>4000000</number>
</property>
<property name="minimum">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_spbSizeMax">
<property name="maximum">
<number>4000000</number>
</property>
<property name="minimum">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="m_tlSizeMin">
<property name="text">
<string>KB</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_tlSizeMax">
<property name="text">
<string>KB</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer2">
<property name="sizeHint">
<size>
<width>330</width>
<height>16</height>
</size>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="orientation">
<enum>Qt::Qt::Horizontal</enum>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header location="global">kcombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget2</tabstop>
<tabstop>m_leSearch</tabstop>
<tabstop>m_leReplace</tabstop>
<tabstop>m_cbLocation</tabstop>
<tabstop>m_pbLocation</tabstop>
<tabstop>m_cbFilter</tabstop>
<tabstop>m_chbIncludeSubfolders</tabstop>
<tabstop>m_cbEncoding</tabstop>
<tabstop>m_chbCaseSensitive</tabstop>
<tabstop>m_chbRegularExpressions</tabstop>
<tabstop>m_chbEnableVariables</tabstop>
<tabstop>m_chbBackup</tabstop>
<tabstop>m_leBackup</tabstop>
<tabstop>m_pbSearchNow</tabstop>
<tabstop>m_pbSearchLater</tabstop>
<tabstop>m_pbCancel</tabstop>
<tabstop>m_pbHelp</tabstop>
<tabstop>m_chbSizeMin</tabstop>
<tabstop>m_spbSizeMin</tabstop>
<tabstop>m_chbSizeMax</tabstop>
<tabstop>m_spbSizeMax</tabstop>
<tabstop>m_cbDateValid</tabstop>
<tabstop>m_chbDateMin</tabstop>
<tabstop>m_chbDateMax</tabstop>
<tabstop>m_chbOwnerUser</tabstop>
<tabstop>m_cbOwnerUserType</tabstop>
<tabstop>m_cbOwnerUserBool</tabstop>
<tabstop>m_edOwnerUser</tabstop>
<tabstop>m_chbOwnerGroup</tabstop>
<tabstop>m_cbOwnerGroupType</tabstop>
<tabstop>m_cbOwnerGroupBool</tabstop>
<tabstop>m_edOwnerGroup</tabstop>
<tabstop>m_dedDateMin</tabstop>
<tabstop>m_dedDateMax</tabstop>
</tabstops>
</ui>

View file

@ -0,0 +1,235 @@
/***************************************************************************
koptionsdlg.cpp - description
-------------------
begin : Tue Dec 28 1999
copyright : (C) 1999 by François Dupoux
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.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. *
* *
***************************************************************************/
// QT
#include <qcheckbox.h>
#include <qspinbox.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qlineedit.h>
// KDE
#include <kcharsets.h>
#include <kcombobox.h>
#include <kconfig.h>
#include <kglobal.h>
#include <kstandarddirs.h>
#include <kapplication.h>
//#include <kdebug.h>
// local
#include "whatthis.h"
#include "ui_koptionsdlg.h"
using namespace whatthisNameSpace;
KOptionsDlg::KOptionsDlg(RCOptions* info, QWidget *parent, const char *name) : KOptionsDlgS(parent,name,true)
{
m_config = new KConfig("kfilereplacerc");
m_option = info;
initGUI();
connect(m_pbOK, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(m_pbDefault, SIGNAL(clicked()),this,SLOT(slotDefaults()));
connect(m_chbBackup, SIGNAL(toggled(bool)), this, SLOT(slotChbBackup(bool)));
connect(m_pbHelp, SIGNAL(clicked()), this, SLOT(slotHelp()));
connect(m_chbConfirmStrings, SIGNAL(toggled(bool)), this, SLOT(slotChbConfirmStrings(bool)));
connect(m_chbShowConfirmDialog, SIGNAL(toggled(bool)), this, SLOT(slotChbShowConfirmDialog(bool)));
whatsThis();
}
KOptionsDlg::~KOptionsDlg()
{
}
//PRIVATE SLOTS
void KOptionsDlg::slotOK()
{
saveRCOptions();
accept();
}
/** Set defaults values for all options of the dialog */
void KOptionsDlg::slotDefaults()
{
m_chbCaseSensitive->setChecked(CaseSensitiveOption);
m_chbRecursive->setChecked(RecursiveOption);
m_chbHaltOnFirstOccurrence->setChecked(StopWhenFirstOccurenceOption);
m_chbFollowSymLinks->setChecked(FollowSymbolicLinksOption);
m_chbIgnoreHidden->setChecked(IgnoreHiddenOption);
m_chbRegularExpressions->setChecked(RegularExpressionsOption);
m_chbIgnoreFiles->setChecked(IgnoreFilesOption);
m_chbConfirmStrings->setChecked(AskConfirmReplaceOption);
QStringList bkList = BackupExtensionOption.split(",",QString::KeepEmptyParts);
bool enableBackup = (bkList[0] == "true" ? true : false);
m_chbBackup->setChecked(enableBackup);
m_leBackup->setEnabled(enableBackup);
m_tlBackup->setEnabled(enableBackup);
m_leBackup->setText(bkList[1]);
m_chbVariables->setChecked(VariablesOption);
m_chbNotifyOnErrors->setChecked(NotifyOnErrorsOption);
}
void KOptionsDlg::slotChbBackup(bool b)
{
m_leBackup->setEnabled(b);
m_tlBackup->setEnabled(b);
}
void KOptionsDlg::slotChbConfirmStrings(bool b)
{
KConfigGroup grp(m_config, "Notification Messages");
if(b)
{
m_chbShowConfirmDialog->setEnabled(true);
m_chbShowConfirmDialog->setChecked(true);
grp.writeEntry(rcDontAskAgain,"no");
}
else
{
m_chbShowConfirmDialog->setEnabled(false);
m_chbShowConfirmDialog->setChecked(false);
grp.writeEntry(rcDontAskAgain,"yes");
}
}
void KOptionsDlg::slotChbShowConfirmDialog(bool b)
{
KConfigGroup grp(m_config, "Notification Messages");
if(b)
{
grp.writeEntry(rcDontAskAgain,"no");
}
else
{
grp.writeEntry(rcDontAskAgain,"yes");
}
}
//PRIVATE
void KOptionsDlg::initGUI()
{
m_config->sync();
KConfigGroup grp(m_config, "Notification Messages");
m_option->m_notifyOnErrors = grp.readEntry(rcNotifyOnErrors, true);
QString dontAskAgain = grp.readEntry(rcDontAskAgain, QString("no"));
m_chbConfirmStrings->setChecked(m_option->m_askConfirmReplace);
if(m_chbConfirmStrings->isChecked())
{
if(dontAskAgain == "yes")
m_chbShowConfirmDialog->setChecked(false);
else
m_chbShowConfirmDialog->setChecked(true);
}
QStringList availableEncodingNames(KGlobal::charsets()->availableEncodingNames());
m_cbEncoding->addItems( availableEncodingNames );
int idx = -1;
int utf8Idx = -1;
for (int i = 0; i < availableEncodingNames.count(); i++)
{
if (availableEncodingNames[i] == m_option->m_encoding)
{
idx = i;
break;
}
if (availableEncodingNames[i] == "utf8")
{
utf8Idx = i;
}
}
if (idx != -1)
m_cbEncoding->setCurrentIndex(idx);
else
m_cbEncoding->setCurrentIndex(utf8Idx);
m_chbCaseSensitive->setChecked(m_option->m_caseSensitive);
m_chbRecursive->setChecked(m_option->m_recursive);
bool enableBackup = m_option->m_backup;
m_chbBackup->setChecked(enableBackup);
m_leBackup->setEnabled(enableBackup);
m_tlBackup->setEnabled(enableBackup);
m_leBackup->setText(m_option->m_backupExtension);
m_chbVariables->setChecked(m_option->m_variables);
m_chbRegularExpressions->setChecked(m_option->m_regularExpressions);
m_chbHaltOnFirstOccurrence->setChecked(m_option->m_haltOnFirstOccur);
m_chbFollowSymLinks->setChecked(m_option->m_followSymLinks);
m_chbIgnoreHidden->setChecked(m_option->m_ignoreHidden);
m_chbIgnoreFiles->setChecked(m_option->m_ignoreFiles);
m_chbNotifyOnErrors->setChecked(m_option->m_notifyOnErrors);
}
void KOptionsDlg::saveRCOptions()
{
m_option->m_encoding = m_cbEncoding->currentText();
m_option->m_caseSensitive = m_chbCaseSensitive->isChecked();
m_option->m_recursive = m_chbRecursive->isChecked();
QString backupExt = m_leBackup->text();
m_option->m_backup = (m_chbBackup->isChecked() && !backupExt.isEmpty());
m_option->m_backupExtension = backupExt;
m_option->m_variables = m_chbVariables->isChecked();
m_option->m_regularExpressions = m_chbRegularExpressions->isChecked();
m_option->m_haltOnFirstOccur = m_chbHaltOnFirstOccurrence->isChecked();
m_option->m_followSymLinks = m_chbFollowSymLinks->isChecked();
m_option->m_ignoreHidden = m_chbIgnoreHidden->isChecked();
m_option->m_ignoreFiles = m_chbIgnoreFiles->isChecked();
m_option->m_askConfirmReplace = m_chbConfirmStrings->isChecked();
m_option->m_notifyOnErrors = m_chbNotifyOnErrors->isChecked();
KConfigGroup grp(m_config, "Notification Messages");
grp.writeEntry(rcNotifyOnErrors, m_option->m_notifyOnErrors);
m_config->sync();
}
void KOptionsDlg::whatsThis()
{
// Create help QWhatsThis
m_chbCaseSensitive->setWhatsThis( chbCaseSensitiveWhatthis);
m_chbRecursive->setWhatsThis( chbRecursiveWhatthis);
m_chbHaltOnFirstOccurrence->setWhatsThis( chbHaltOnFirstOccurrenceWhatthis);
m_chbFollowSymLinks->setWhatsThis( chbFollowSymLinksWhatthis);
m_chbIgnoreHidden->setWhatsThis( chbIgnoreHiddenWhatthis);
m_chbIgnoreFiles->setWhatsThis( chbIgnoreFilesWhatthis);
m_chbRegularExpressions->setWhatsThis( chbRegularExpressionsWhatthis);
m_chbVariables->setWhatsThis( chbVariablesWhatthis);
m_chbBackup->setWhatsThis( chbBackupWhatthis);
m_chbConfirmStrings->setWhatsThis( chbConfirmStringsWhatthis);
}
#include "moc_koptionsdlg.cpp"

View file

@ -0,0 +1,59 @@
/***************************************************************************
koptionsdlg.h - description
-------------------
begin : Tue Dec 28 1999
copyright : (C) 1999 by François Dupoux
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.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. *
* *
***************************************************************************/
#ifndef KOPTIONSDLG_H
#define KOPTIONSDLG_H
// KDE
class KConfig;
//local
#include "configurationclasses.h"
#include "ui_koptionsdlgs.h"
#include <ktoolinvocation.h>
/**
*@author François Dupoux
*/
class KOptionsDlg : public KOptionsDlgS
{
Q_OBJECT
public:
KOptionsDlg(RCOptions* info, QWidget *parent, const char *name);
~KOptionsDlg();
private:
RCOptions* m_option;
KConfig *m_config;
private slots:
void slotOK();
void slotDefaults();
void slotChbBackup(bool b);
void slotChbConfirmStrings(bool b);
void slotChbShowConfirmDialog(bool b);
void slotHelp(){ KToolInvocation::invokeHelp(QString::null, "kfilereplace"); } //krazy:exclude=nullstrassign for old broken gcc
private:
void initGUI();
void saveRCOptions();
void whatsThis();
};
#endif // KOPTIONSDLG_H

View file

@ -0,0 +1,309 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0" stdsetdef="1">
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>KOptionsDlgS</class>
<widget class="QDialog" name="KOptionsDlgS">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>572</width>
<height>420</height>
</rect>
</property>
<property name="windowTitle">
<string>Options</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QGridLayout">
<item row="0" column="0" rowspan="1" colspan="5">
<widget class="QTabWidget" name="tabWidget2">
<widget class="QWidget" name="tab1">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox7">
<property name="title">
<string>General Options</string>
</property>
<layout class="QGridLayout">
<item row="4" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbVariables">
<property name="text">
<string>Enable commands in replace strings</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="m_tlBackup">
<property name="text">
<string>Backup copy suffix:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="1" rowspan="1" colspan="2">
<widget class="QLineEdit" name="m_leBackup">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbNotifyOnErrors">
<property name="text">
<string>Notif&amp;y on errors</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbCaseSensitive">
<property name="text">
<string>Case sensitive</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item row="2" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbRecursive">
<property name="text">
<string>Recursive (search/replace in all sub folders)</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item row="3" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbRegularExpressions">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Enable regular e&amp;xpressions</string>
</property>
</widget>
</item>
<item row="6" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox" name="m_chbBackup">
<property name="text">
<string>Do &amp;backup copy</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="1" colspan="2">
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Encoding of the files:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="KComboBox" name="m_cbEncoding">
<property name="sizePolicy">
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="Tab3">
<attribute name="title">
<string>&amp;Advanced</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="gbxConfirm">
<property name="title">
<string>Advanced Options</string>
</property>
<layout class="QGridLayout">
<item row="5" column="0">
<widget class="QCheckBox" name="m_chbIgnoreHidden">
<property name="text">
<string>Ignore hidden files and folders</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="m_chbFollowSymLinks">
<property name="text">
<string>Follow s&amp;ymbolic links</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="m_chbHaltOnFirstOccurrence">
<property name="text">
<string>When searching, stop on first string found (faster but no details)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="m_chbIgnoreFiles">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Do not show file if no strings are found or replaced</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout">
<item>
<spacer name="spacer2">
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="orientation">
<enum>Qt::Qt::Horizontal</enum>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="m_chbShowConfirmDialog">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Show confirmation dialog</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="m_chbConfirmStrings">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Confirm before replace each string</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="m_pbHelp">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Help</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="spacer1">
<property name="sizeHint">
<size>
<width>202</width>
<height>20</height>
</size>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="orientation">
<enum>Qt::Qt::Horizontal</enum>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="m_pbDefault">
<property name="text">
<string>&amp;Default Values</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="m_pbOK">
<property name="text">
<string>&amp;OK</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="m_pbCancel">
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header location="global">kcombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget2</tabstop>
<tabstop>m_cbEncoding</tabstop>
<tabstop>m_chbCaseSensitive</tabstop>
<tabstop>m_chbRecursive</tabstop>
<tabstop>m_chbRegularExpressions</tabstop>
<tabstop>m_chbVariables</tabstop>
<tabstop>m_chbNotifyOnErrors</tabstop>
<tabstop>m_chbBackup</tabstop>
<tabstop>m_leBackup</tabstop>
<tabstop>m_pbDefault</tabstop>
<tabstop>m_pbOK</tabstop>
<tabstop>m_pbCancel</tabstop>
<tabstop>m_pbHelp</tabstop>
<tabstop>m_chbConfirmStrings</tabstop>
<tabstop>m_chbShowConfirmDialog</tabstop>
<tabstop>m_chbIgnoreFiles</tabstop>
<tabstop>m_chbHaltOnFirstOccurrence</tabstop>
<tabstop>m_chbFollowSymLinks</tabstop>
<tabstop>m_chbIgnoreHidden</tabstop>
</tabstops>
<connections>
<connection>
<sender>m_pbCancel</sender>
<signal>clicked()</signal>
<receiver>KOptionsDlgS</receiver>
<slot>reject()</slot>
</connection>
</connections>
</ui>

74
kfilereplace/main.cpp Normal file
View file

@ -0,0 +1,74 @@
/***************************************************************************
main.cpp - Main file for the KFileReplace shell
-------------------
begin : Thu Sep 16 14:14:09 2004
copyright : (C) 2004 by Andras Mantia <amantia@kde.org>
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "kfilereplace.h"
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <klocale.h>
static const char description[] =
I18N_NOOP("Batch search and replace tool");
static const char version[] = "0.1";
int main(int argc, char *argv[])
{
KAboutData about("kfilereplace", 0, ki18n("KFileReplace"), version, ki18n(description),
KAboutData::License_GPL_V2, ki18n("(C) 2004-2005 Andras Mantia\n(C) 2004-2005 Emiliano Gulmini\n(C) 1999-2002 François Dupoux"), ki18n("Part of the KDEWebDev module."),
"http://kde.org/applications/utilities/kfilereplace/");
about.addAuthor(ki18n("Andras Mantia"), ki18n("Shell author, KPart creator, co-maintainer"), "amantia@kde.org");
about.addAuthor(ki18n("Emiliano Gulmini"), ki18n("Current maintainer, code cleaner and rewriter"),"emi_barbarossa@yahoo.it");
about.addAuthor(ki18n("François Dupoux"),
ki18n("Original author of the KFileReplace tool"),
"dupoux@dupoux.com");
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions options;
options.add("+[PATH]", ki18n( "Starting folder" ));
KCmdLineArgs::addCmdLineOptions( options );
KApplication app;
// see if we are starting with session management
if (app.isSessionRestored())
{
RESTORE(KFileReplace);
}
else
{
// no session.. just start up normally
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KFileReplace *kfr = new KFileReplace;
kfr->show();
if (args->count() == 0)
{
kfr->openURL(KUrl());
}
else
{
kfr->openURL(args->url(0));
}
args->clear();
}
return app.exec();
}

View file

@ -0,0 +1,9 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.kfilereplace">
<method name="openURL">
<arg name="url" type="s" direction="in"/>
</method>
</interface>
</node>

284
kfilereplace/report.cpp Normal file
View file

@ -0,0 +1,284 @@
/***************************************************************************
report.cpp - Report document class
-------------------
begin : fri aug 13 15:29:46 CEST 2004
copyright : (C) 2004 Emiliano Gulmini
email : emi_barbarossa@yahoo.it
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// QT
#include <qstring.h>
#include <qfile.h>
//Added by qt3to4:
#include <QTextStream>
#include <QListWidget>
// KDE
#include <kmessagebox.h>
#include <kuser.h>
// local
#include "report.h"
#include "configurationclasses.h"
void Report::createReportFile()
{
QString xmlFileName = m_docPath + ".xml",
cssFileName = m_docPath + ".css";
// Generates a report file
// a) Open the file
QFile report(xmlFileName);
if (!report.open( QIODevice::WriteOnly ))
{
KMessageBox::error(0, i18n("<qt>Cannot open the file <b>%1</b>.</qt>", xmlFileName));
return ;
}
// b) Write the header of the XML file
QDateTime datetime = QDateTime::currentDateTime(Qt::LocalTime);
QString dateString = datetime.toString(Qt::LocalDate);
KUser user;
QString columnTextFour,
columnReplaceWith;
if(!m_isSearchFlag)
{
columnTextFour = i18n("Replaced Strings");
columnReplaceWith = i18n("Replace with");
}
else
{
columnTextFour = i18n("Total number occurrences");
columnReplaceWith = i18n("-");
}
QString css = cssFileName.mid(cssFileName.lastIndexOf("/")+1,cssFileName.length()-(cssFileName.lastIndexOf("/")+1));
QTextStream oTStream( &report );
oTStream << "<?xml version=\"1.0\"?>\n"
"<?xml-stylesheet href=\""+css+"\" type=\"text/css\"?>"
"<report>\n"
" <title> "+i18n("KFileReplace Report")+" </title>\n"
" <createdby>"+user.fullName()+'('+user.loginName()+")</createdby>\n"
" <date>"+dateString+"</date>\n"
"<hr/>\n"
" <table>\n"
" <tablecaption> "+i18n("Searching/Replacing Strings Table")+" </tablecaption>\n"
" <header>\n"
" <row>\n"
" <searchfor class=\"header\">"+i18n("Search for")+"</searchfor>\n";
if(!m_isSearchFlag)
oTStream<< " <replacewith class=\"header\" >"+columnReplaceWith+"</replacewith>\n";
oTStream<< " </row>\n"
" </header>\n";
// c) Write the strings list
Q3ListViewItem *lviCurItem,
*lviFirst;
lviCurItem = lviFirst = m_stringsView->firstChild();
if(lviCurItem == 0)
return ;
QString rowType="a1";
do
{ QString rowTag = "<row >\n"
" <searchfor class=\""+rowType+"\"><![CDATA["+lviCurItem->text(0)+"]]></searchfor>\n"
" <replacewith class=\""+rowType+"\"><![CDATA["+lviCurItem->text(1)+"]]></replacewith>\n"
"</row>\n";
oTStream << rowTag;
rowType = ((rowType == "a1") ? "a2" : "a1");
lviCurItem = lviCurItem->nextSibling();
} while(lviCurItem && lviCurItem != lviFirst);
oTStream<< "</table>\n";
oTStream<< "<whiteline/>\n"
" <table>\n"
" <tablecaption> "+i18n("Results Table")+ " </tablecaption>"
" <header>\n"
" <row>\n"
" <name class=\"header\">"+i18n("Name")+"</name>\n"
" <folder class=\"header\">"+i18n("Folder")+"</folder>\n";
if(m_isSearchFlag)
{
oTStream<< " <oldsize class=\"header\">"+i18n("Size")+"</oldsize>\n";
}
else
{
oTStream<< " <oldsize class=\"header\">"+i18n("Old Size")+"</oldsize>\n"
" <newsize class=\"header\">"+i18n("New Size")+"</newsize>\n";
}
oTStream<< " <replacedstrings class=\"header\" >"+columnTextFour+"</replacedstrings>\n"
" <owneruser class=\"header\">"+i18n("Owner User")+"</owneruser>\n"
" <ownergroup class=\"header\">"+i18n("Owner Group")+"</ownergroup>\n"
" </row>\n"
" </header>\n";
// d) Write the result list
lviCurItem = lviFirst = m_resultsView->firstChild();
if(lviCurItem == 0)
return ;
unsigned int totalOccurrences = 0;
rowType="a1";
do
{ QString rowTag = " <row >\n"
" <name class=\""+rowType+"\"><![CDATA["+lviCurItem->text(0)+"]]></name>\n"
" <folder class=\""+rowType+"\"><![CDATA["+lviCurItem->text(1)+"]]></folder>\n";
if(m_isSearchFlag)
{
rowTag += " <oldsize class=\""+rowType+"\"><![CDATA["+lviCurItem->text(2)+"]]></oldsize>\n"
" <replacedstrings class=\""+rowType+"\"><![CDATA["+lviCurItem->text(3)+"]]></replacedstrings>\n"
" <owneruser class=\""+rowType+"\"><![CDATA["+lviCurItem->text(4)+"]]></owneruser>\n"
" <ownergroup class=\""+rowType+"\"><![CDATA["+lviCurItem->text(5)+"]]></ownergroup>\n"
" </row>\n";
}
else
{
rowTag += " <oldsize class=\""+rowType+"\"><![CDATA["+lviCurItem->text(2)+"]]></oldsize>\n"
" <newsize class=\""+rowType+"\"><![CDATA["+lviCurItem->text(3)+"]]></newsize>\n"
" <replacedstrings class=\""+rowType+"\"><![CDATA["+lviCurItem->text(4)+"]]></replacedstrings>\n"
" <owneruser class=\""+rowType+"\"><![CDATA["+lviCurItem->text(5)+"]]></owneruser>\n"
" <ownergroup class=\""+rowType+"\"><![CDATA["+lviCurItem->text(6)+"]]></ownergroup>\n"
" </row>\n";
}
oTStream << rowTag;
rowType = ((rowType == "a1") ? "a2" : "a1");
if(m_isSearchFlag)
totalOccurrences += lviCurItem->text(3).toInt();
else
totalOccurrences += lviCurItem->text(4).toInt();
lviCurItem = lviCurItem->nextSibling();
} while(lviCurItem && lviCurItem != lviFirst);
// e) Write the end of the file
oTStream<< " </table>\n"
"<totaloccurrences>"
<< totalOccurrences
<< "</totaloccurrences>\n"
"</report>\n";
report.close();
}
void Report::createStyleSheet()
{
QString cssFileName = m_docPath +".css";
QFile styleSheet(cssFileName);
if (!styleSheet.open( QIODevice::WriteOnly ))
{
KMessageBox::error(0, i18n("<qt>Cannot open the file <b>%1</b>.</qt>", cssFileName));
return ;
}
QTextStream oTStream( &styleSheet );
QString css = "title { display:block;font:40px bold sans-serif; }\n\n"
"createdby:before { content :\""+i18n("Created by")+": \"; }\n"
"createdby { display:inline; }\n\n"
"date:before { content :\"-"+i18n("date")+": \"; }\n"
"date { display:inline; }\n\n"
"totaloccurrences:before { content :\""+i18n("Total occurrences")+": \"; }\n"
"totaloccurrences { display:block;text-align:right; font-weight:bold;margin-top:5px;margin-right:5px;}\n"
"tablecaption {display:table-caption;font:20px bold sans-serif;}\n\n"
"hr {display:block;background:black;height:1px;margin:5px 0px 5px;}\n"
"whiteline {display:block;height:16px;}\n\n"
"searchfor {\n"
" display:table-cell;\n"
" border:1px solid black;\n"
" padding:0 7px 0; }\n\n";
if(!m_isSearchFlag)
{
css += "replacewith {\n"
" display:table-cell;\n"
" border:1px solid black;\n"
" padding:0 7px 0; }\n\n";
}
css += "folder {\n"
" display:table-cell;\n"
" border:1px solid black;\n"
" padding:0 7px 0; }\n\n"
"header { display: table-header-group; }\n\n"
"name {\n"
" display:table-cell;\n"
" border:1px solid black;\n"
" padding:0 7px 0; }\n\n"
"newsize {\n"
" display:table-cell;\n"
" border:1px solid black;\n"
" padding:0 7px 0;\n"
" text-align:right; }\n\n"
"oldsize {\n"
" display:table-cell;\n"
" border:1px solid black;\n"
" padding:0 7px 0;\n"
" text-align:right; }\n\n"
"ownergroup {\n"
" display:table-cell;\n"
" border:1px solid black;\n"
" padding:0 7px 0; }\n\n"
"owneruser {\n"
" display:table-cell;\n"
" border:1px solid black;\n"
" padding:0 7px 0; }\n\n"
"replacedstrings {\n"
" text-align:right;\n"
" display:table-cell;\n"
" border:1px solid black;\n"
" padding:0 7px 0; }\n\n"
"*[class~=header] {\n"
" background : lightgray;\n"
" text-align : center; }\n\n"
"row { display : table-row; }\n\n"
"table {\n"
" display:table;\n"
" border-collapse: collapse; }\n\n"
"*[class~=a1] {\n"
" background-color:aliceblue;\n"
" font-weight : bold;font-size:15px; }\n\n"
"*[class~=a2] {\n"
" background-color:khaki;\n"
" font-weight : bold;\n"
" font-size:15px; }\n\n";
oTStream << css;
styleSheet.close();
}
void Report::createDocument(const QString& docPath)
{
m_docPath = docPath;
createStyleSheet();
createReportFile();
}

58
kfilereplace/report.h Normal file
View file

@ -0,0 +1,58 @@
/***************************************************************************
report.h - Report document class
-------------------
begin : fri aug 13 15:29:46 CEST 2004
copyright : (C) 2004 Emiliano Gulmini
email : emi_barbarossa@yahoo.it
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef REPORT_H
#define REPORT_H
// QT
class QString;
// KDE
#include <klocale.h>
#include "configurationclasses.h"
class QListWidget;
/** Report class is used to create a pair of files (a xml and a css file) which are
* a short statistical report of the operations.
*/
class Report
{
private:
QListWidget* m_stringsView,
* m_resultsView;
QString m_docPath;
bool m_isSearchFlag;
RCOptions* m_option;
public:
Report(RCOptions* info, QListWidget* rv, QListWidget* sv) { m_option = info;
m_resultsView = rv;
m_stringsView = sv;
m_isSearchFlag = m_option->m_searchingOnlyMode;
}
~Report() { m_option = 0; }
private:
void createReportFile();
void createStyleSheet();
public:
void createDocument(const QString& docPath);
};
#endif // REPORT_H

View file

@ -0,0 +1,3 @@
kde4_install_icons( ${DATA_INSTALL_DIR}/kfilereplacepart/icons )

Binary file not shown.

After

Width:  |  Height:  |  Size: 947 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 B

BIN
kfilereplace/tutorial.kwd Normal file

Binary file not shown.

101
kfilereplace/whatthis.h Normal file
View file

@ -0,0 +1,101 @@
/***************************************************************************
whatthis.h - description
-------------------
begin : fri 12 march CEST 2004
copyright : (C) 2004 Emiliano Gulmini
email : <emi_barbarossa@yahoo.it>
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef WHATTHIS_H
#define WHATTHIS_H
// QT
#include <qstring.h>
// KDE
#include <klocale.h>
namespace whatthisNameSpace
{
//KFileReplaceView messages
const QString lvResultWhatthis = i18n("Shows the statistics of your operations. Note that the columns content changes depending on what kind of operation you are performing.");
const QString lvStringsWhatthis = i18n("Shows a list of strings to search for (and if you specified it, a list of strings to replace with). Use the \"add strings\" dialog to edit your string list or double click on a string.");
//KNewProjectDlg messages
const QString cbLocationWhatthis = i18n("Base folder for operations of search/replace. Insert path string here by hand or use the search button.");
const QString cbFilterWhatthis = i18n("Shell-like wildcards. Example: \"*.html;*.txt;*.xml\".");
const QString edSizeMinWhatthis = i18n("Insert the minimum file size you want to search, or leave it unchecked if you do not want a minimum size limit.");
const QString edSizeMaxWhatthis = i18n("Insert the maximum file size you want to search, or leave it unchecked if you do not want a maximum size limit.");
const QString edDateMinWhatthis = i18n("Insert the minimum value for file access date that you want to search, or leave it unchecked if you do not want a minimum limit.");
const QString edDateMaxWhatthis = i18n("Insert the maximum value for file access date that you want to search, or leave it unchecked if you do not want a maximum limit.");
const QString cbDateValidWhatthis = i18n("Select \"writing\" if you want to use the date of the last modification, or \"reading\" to use the date of the last access.");
const QString chbDateMinWhatthis = i18n("Minimum value for access date.");
const QString chbDateMaxWhatthis = i18n("Maximum value for access date.");
const QString leSearchWhatthis = i18n("Insert here the string to search for.");
const QString leReplaceWhatthis = i18n("Insert here the string to replace with.");
//KOptionsDlg messages
const QString chbCaseSensitiveWhatthis = i18n("Enable this option if your search is case sensitive.");
const QString chbRecursiveWhatthis = i18n("Enable this option to search in sub folders too.");
const QString chbHaltOnFirstOccurrenceWhatthis = i18n("Enable this option when you are searching for a string and you are only interested to know if the string is present or not in the current file.");
const QString chbIgnoreWhitespacesWhatthis ="";
const QString chbFollowSymLinksWhatthis = i18n("If set, then if kfilereplace encounters a symbolic link it treats it like a normal folder or file.");
const QString chbIgnoreHiddenWhatthis = i18n("Enable this option to ignore hidden files or folders.");
const QString chbIgnoreFilesWhatthis = i18n("If this option is enabled, KFR will show even the names of the files in which no string has been found or replaced.");
const QString chbRegularExpressionsWhatthis = i18n("Allows you to apply Qt-like regular expressions on the search string. Note that a complex regular expression could affect speed performance.");
const QString chbVariablesWhatthis = i18n("Enable \"commands\". For example: if search string is \"user\" and replace string is the command \"[$user:uid$]\", KFR will substitute \"user\" with the uid of the user.");
const QString chbBackupWhatthis = i18n("Enable this option if you want leave original files untouched.");
const QString chbConfirmStringsWhatthis = i18n("Enable this option if you want to be asked for single string replacement confirmation.");
//KFileReplacePart
const QString fileSimulateWhatthis = i18n("Enable this option to perform replacing as a simulation, i.e. without making any changes to files.");
const QString optionsRegularExpressionsWhatthis = chbRegularExpressionsWhatthis;
const QString optionsBackupWhatthis = chbBackupWhatthis;
const QString optionsCaseWhatthis = chbCaseSensitiveWhatthis;
const QString optionsVarWhatthis = chbVariablesWhatthis;
const QString optionsRecursiveWhatthis = chbRecursiveWhatthis;
//KAddStringDlg
const QString rbSearchOnlyWhatthis = i18n("Select search-only mode.");
const QString rbSearchReplaceWhatthis = i18n("Select search-and-replace mode.");
const QString edSearchWhatthis = i18n("Insert here a string you want search for.");
const QString edReplaceWhatthis = i18n("Insert here the string that KFR will use to replace the search string.");
}
#endif