Added KDE3 version of krename

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/krename@1094420 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 15 years ago
commit aec5a84267

@ -0,0 +1,8 @@
|=======================================|
| Dominik Seichter <domseichter@web.de> |
| http://www.krename. net |
|=======================================|
(c) 2001-2003 Dominik Seichter

@ -0,0 +1,286 @@
NOTE! The GPL below is copyrighted by the Free Software Foundation, but
the instance of code that it refers to (the krename application) is copyrighted
by the author (Dominik Seichter) who actually wrote it.
---------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, 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

@ -0,0 +1,674 @@
Version 3.0 stable
3.0.0 (Release Date 28.06.2004):
Fixed undo of renamed directories and their contents
Added a Polish translation by Krzysztof Pawlak
3.0.1 (Release Date 17.07.2004):
Fixed a memory leak (create KRecursiveLister instances without deleting)
Updated the Polish translation
Loading fileplugins after startup is now possible
Added option to create symlinks again (only for advanced mode)
Fixed preview moved out of screen
Added a Russian translation by Ilya Ivkov
Fixed a bug: Appended strings should be allowed to contain braced; [1-5{\{Hallo\}}] should work
Escaping of braces is now possible \{ \}
Tooltip improvements
Added extension renaming to the easy mode
Added find and replace to the easy mode
3.0.2 (Release Date 09.08.2004):
Fixed a numbering bug with random start values
Updated Russian, Polish and French translation
Added a Bosnian Trasnlation by Asim Husanovic
3.0.3 (Release Date 13.02.2005):
ESC doesn't close KRename anymore
Fixed many typos (thanks to Arpad Biro)
Updated hungarian translation
Fixed inserting of \
Added a few tooltips to the add dialog
Fixed escaping of # in filenames so that files containing a # can be added using drag and drop
Added the option to sort filenames in random order
Filename tab is made visible if filenames have been passed over the commandline
Updated russian translation by Nick Shaforostoff
Updated german, japanese and netherlands translation
Added profile management (removed save settings in number and find/replace dialog therefore)
Added plugin data reloading
Added Nummeric Sorting mode
Added function help dialog also to the beginners mode
Fixed keyboard accels in German translation
Fixed filenames containing a slash
Added formating of datetypes (e.g.: [date;yyyy-MM-dd] or [accessdate;dd-MM-yyyy_hh:mm])
Better feedback during renaming lots of files in the ProgressDialog
ProgressDialog is closed correctly after an undo
Updated translations and fixed typos
Fixed advanced date formatting, upercase letters were converted to lowercase
Apply patch from Laurent Montel to exclude devices from the servicemenu
Make adding of files multithreaded to be faster and fix some bugs
Fixed reload plugin data (just clears the cache of all plugins)
Let the KDE KRename documentation point to the pdf handbook
Made KRename more responsive when changing the template for many files
Fixed adding files by drag and drop and from commandline options
3.0.4 (Release Date 21.04.2005):
Fixed keyboard shortcut ALT+F being used twice
Make saving profiles more easier to understand for the user
Disable delete button for default profiles
Support default profiles
Declared lot's of functions as inline for speed reasons
Added support for resetting counters on new directories
3.0.5 (Release Date 25.05.2005):
Updated Russian translation by Alexey Kouznetsov
Updated Polish translation by Krzysztof Pawlak
Added Chinese Simplified translation by Dehua Qin
Fixed a bug in the strip whitespace function \
Added Brazilian Portugues translation by Paulo Zambon and Michele Fasoli
Display error warning message only if errors have occured
Updated Italian translation by Patrick Bellasi
3.0.6 (Release Date 25.05.2005):
Allow to set the profile with a commandline switch
Added brazillian translation to the service menu
Fixed crash with the --start option
Fixed adding directories from the commandline with the --start option
Fixed the taborder in the ProgressDialog
Fixed find and replace with regular expressions
3.0.7 (Release Date: 28.08.2005):
Fixed for the pt_BR translation
changed Krename -> KRename in myinputdialog.cpp
Fixed plugins in second run of KRename
Added Transliteration Plugin by Oleg Ivanov
Set focus to the template field when switching to the filename tab
in advanced mode
Added keyboard shortcut F2 to change filename manually as
requestet by Paulo
Updated Hungarian Translation by Arpad Biro
Fixed servicemenu files
3.0.8 (Release Date: 24.09.2005):
Updated German translation (thanks to the debian team)
Fixed on the fly mode switching
Fixed the profile commandline option when a default profile was specified
Fixed a crash with loading the KDE file plugins after KRename was started
Fixed a few smaller memory leaks (thanks to valgrind)
Code review with many smaller optimization (mostly using inline
for functions and references for parameters)
Fixed hide and show of KRename window on startup
3.0.9 (Release Date: 18.10.2005):
Fixed the .desktop file to open only one KRename window when
multiple files are dragged on the icon
Added Slovinean translation by Matej Urbanèiè
3.0.10 (Release Date: 11.01.2006):
Swedish translation by Peter Landgren
Updated Polish translation by Krzysztof Pawlak
Added context menu to all template text fields to quickly insert
KRename tokens
Updated Hungarian translation by Arpad Biro
3.0.11 (Release Date: 22.02.2006):
Cleaned up Makefile.am
Fixed desktop files
Fixed {,} and * when returned from plugins
Fixed add files here label on the first page in wizard mode
Show last tab when files are passed on the commandline
Updated Swedish translation by Peter Landgren
Updated Italian translation by Vincenzo Reale
Updated admin directory to KDE 3.5
3.0.12 (Release Date: 14.08.2006):
Updated Spanish and Italian translation
Fixed a compilation problem with gcc 2.95
Fixed servicemenu installation
Fixed a possible crash
German translation fixes by Frederik Schwarzer
Fixed drag and drop of files to KRename
3.0.13 (Release Date: 03.12.2006):
Emre Alada contributed a Turkish translation
Improved speed when a plugin token was not found
Fixed encoding plugin
Added commandline switch to specify the number of previewitems
3.0.14:
Fixed a crash with plugin previews
Fixed adding directories recursive when dropped from another application
Added a unit test
Fixed plugin tokens with additional arguments e.g. [date;dd-mm-yyyy]
Fixed the seconds in the time [token]
Corrected documentation of [user] and [group] tokens
Patch by Otakar Trunecek to add Czech transliteration characters
Version 2.9
2.9.0 (Release Date 24.01.2004):
Added KIO slave support (e.g.: fish:// and ftp://)
Use the mimetype icon if no icon is found
File preview is much faster now
Moving of items in large lists if faster now
Removed stupid tooltip for filelist
Improved ProgressDialog
Fixed plugin finished being called even if the user canceled renaming
Added option to easily use the filename of the input file (when changing manually)
Fixed enabled state of up and down buttons
Using Jonathon Sim's KRecursiveLister
Added a refresh preview button
Removed ask on exit option (KRename doesn't ask anymore)
Fileextension start dot, can now be configured easier
Fixed capitalization for apostrophes
Removed stupid warning message, about files not being added twice
Made PluginLoader a singleton -> KRename is faster if a second window is opened
Added a very simple DCOP interface (more functions to come in the next release)
Fixed a bug that caused [x] (x being a number) to fail in some cases
Fixed manual changing filenames
2.9.1 (Release Date 01.02.2004):
Compilation fix (cannot declare member function as static)
Fixed keyboard access to file template lineedit
Improved plugin system, no need to enable certain plugins anymore
Removed write meta info function, as it did not work very well
Refactored the image plugin to look like the other plugins and use a cache
2.9.2 (Release Date 29.02.2004):
Added a hungarian translation from the SuSE 9.0 rpm
Date and time functions are now a plugin
Added [user], [group], [modificationdate], [creationdate] and [accessdate] tokens
Fixed a bug with the [date] token
Fixed the command, permissions and date and time plugin
Added lot's of examples to the command plugin
Updated the German translation
Renaming speed got greatly improved (FileCopyJob is used instead of CopyJob)
Overwriting of files works again
Removed option to create symlinks, who needs that?
Added a [length] token, returning the length of the input filename
Support for nested tokens like: [[length-4]-[length-2]]
Fixed mouse problems on the first page of the wizard
The part string token supports appended strings: [2;4{[dirname]}] or [2-4{KRENAME}]
Fixed a bug with special tokens in directories which are created during runtime
Added a few new DCOP functions
Fixed regular expressions find and replace
Much faster adding of files, because of a better sorting algorithm
Updated the French translation
Depends on KDE 3.1 now, because of KDirLister
Fixed an annoying message box popping up, when an error occurs
2.9.3 (Release Date 09.04.2004):
Updated Spanish translation
Updated German translation
Fixed a crash when adding directories recursively
All plugin tokens have a prefix now for consistency
Added new DCOP methods
2.9.4 (Release Date 15.04.2004):
Fixed [length-2] token (substracted only 1 instead of 2)
Set default to tabbed mode for GUI
Added a powerful easy mode dialog
KMyHistoryCombo saves its settings itsself, saving lots of code duplication
Fixed the annoying error messages again
Improved ProgressedDialog
All files (even files with errors) can now be renamed again
3.0.0-rc1 (Release Date 04.05.2004):
Updated French translation
Updated Spanish translation
Updated German translation
Fixed spelling errors (thanks goes to Arpad Biro)
Updated admin dir to work with automake 1.8
Service menu is installed by default, saving lot's of code
Fixed a bug with FilePlugins
3.0.0-rc2 (Release Date 26.05.2004):
Updated Netherlands translation
Fixed a bug with § which could result in an endless loop
Replaced § with [&1][%2-]
Fixed multi-line error message in progress dialog
Nicer file preview (previews are centered and text is aligned)
Start index defaults now to 1
Changed button order in ProgressDialog and Tabs Mode (Close)
Move change filename manually to the top of the context menu
Append a / to directory names so that files are copied/moved correctly
Do not display file:// for local files
KRename creates missing directories automatically for you
KRename window size on startup was fixed
Only one button to add directories and files
Many messages where simplified
Undo file can only be created if files are not copied
Added an automatic undo function
Plugin page was removed from the wizard
Fixed unexpected close of wizard after renaming
Improved directory selection
Better sorting of files
No update preview when find and replace dialog was canceled
3.0.0-rc3 (Release Date 13.06.2004):
Removed help buttons
Fixed lots of typos
previous -> original
Added small icons to help dialog
Added a small text notice to tell the user he should add some files
Selecting items by dragging a frame with the mouse is now possible
Fixed hiding the plugin page in wizard mode
Plugin page shows only plugins that are not automatically used
Fixed image highlighting of selected items
Fixed image preview
Fixed creating directories inside of created directories
Version 2.8 stable
2.8.0 (Release Date 08.07.2003):
Speed up file plugins by adding a cache to them
Fixed GUI mode switching with Qt 3.0.x
Fixed service menu entry for all languages
Adjust width of insert part of filename dialog dynamically
--use-plugin is now case insensitive
Fixed a bug with the first start dialog
Added spanish translation of service menu entries
Redrawing GUI while generating real time preview with plugin
2.8.1 (Release Date 24.07.2003):
Fixed compilation errors on FreeBSD
Fixed a memory leak with invalid file plugins
Added support for all fileplugin tokens, not only the preffered ones
Switched add dirname dialog to KDirSelectDialog
Fixed a bug which caused KRename to remain in memory even if all windows were closed
2.8.2 (Release Date 06.08.2003):
Removed STL dependency and fixed compilation errors
Fixed a memory leak in addThisDir
Added support to add directory names recursively
2.8.3 (Release Date 22.10.2003):
Removed add recursively button and merged functionality into add dir
Added a simple sort function
Inserting parts of filenames replaces $
Fixed a layout bug, with the undo groupbox
2.8.4 (Release Date 05.12.2003):
Added a netherlands translation by Frank Schoolmeesters
Fixed find and replace code
Fixed compilation with --enable-final
Fixed compilation on debian and fedora
Added support for escaped special characters (e.g. \&)
Fixed a segmentation fault on startup
2.8.5 (Release Date 05.01.2004):
Fixed dir selection dialog growing larger and larger
Fixed bug: manual changes are delete for removed files, too
Fixed compiler warning: unexpected variable declaration
Version 2.7
2.7.0 (Release Date 17.05.2003):
Style guide fixes
Improved user interface
Removed save button from final dialog (who needs it?)
Ported ReplaceDialog to KDialogBase
2.7.1 (Release Date: 18.05.2003):
Fixed Compilation with KDE 3.0
2.7.2 (Release Date: 04.06.2003):
Added Japanese translation
Removed visible/invisible plugin stuff
Fixed minimum size of krename
Fixed sorting of functions help
Fixed bug with wrong file extension settings from krenamerc
Added tabbed GUI mode
Refactored preferences
Removed advanced titlebar
Redesigned plugin GUI page
Remove buttons are disabled as long as there are no files in the list
Added a separator line between dialogs and buttons
Improved undo dialog
Fixed loading of saved skip and find/replace lists
Made filename template lineedit much wider
Lot's of style guide fixes
Fixed accel conflicts in English version
Fixed the picture plugin
Simplified Plugin code (use QPtrList instead of QDict)
2.7.3 (Release Date: 30.06.2003):
Runtime switching of GUI mode is now possible
Fixed compilation problems on SuSE 8.0 (Qt <= 3.0.5)
Defined const functions as const
Fixed includes (thanks to the excellent fixincludes script from kdesdk)
Added a GUI mode selection dialog on first start
Added support for formating numbers from plugins (e.g.: [##Tracknumber])
Fixed service menu entries (thanks to Mark Volkert)
Fixed a small memory leak in service menu code
Fixed crash with RegExp dialog
Added a lot of useful commandline options
Fixed the spelling of KRename
Added an icon for the permissions plugin
Fixed a long standing bug that the users own group was not shown in the permissions plugin
Added an open context menu item to the preview
Fixed adding of two files with same name but in different capitilization
Double clicking on an item in the search and replace dialog edits it
Added French translation
Version 2.6 stable
2.6.0 (Release Date: 18.04.2003):
Fixed crash on installing servicemenu
Added icon and accel to servicemenu entry
Fixed bug with manual changed filenames
2.6.1 (Release Date: 25.04.2003):
Make Renaming with KFilePlugins work again
2.6.2 (Release Date: 11.05.2003):
Fixed manually changing names of dirs
Fixed some update count problems
Added spanish translation
Fixed help dialog
Version 2.5
2.5.0 (Release Date: 27.12.2002):
Added italian translation
Fixed layout bug in maximized windows
Fixed compiling problems (vector) (Thanks to Stephan Johach)
Added kde preview support
Faster File Preview
Removed all extern declarations
Removed uses of goto, cause I'm not coding basic :-)
Added support for renaming directories
Added open destination button
Added support for changing meta info's on all files
2.5.1 (Release Date: 02.02.2003):
Added support for recursively adding hidden directories
Added new preview mode
Added command execution plugin
Thumbnails size is a configure option now
Fixed startup notification bug
Improved documentation on leading zeros
2.5.2 (Release Date: 13.02.2003):
Fixed [date] bug (DD-MM-YYYY)
Plugin loading can be disabled for faster startup
Easier selection of part filenames
Fixed column bugs
Only one message box is shown when multiple files are added twice to the list
Added prefernces dialog
Fixed arrow buttons
Refactored source
2.5.3 (Release Date: 14.02.2003):
Fixed a gcc 3.x compilation bug
2.5.4 (Release Date: 14.03.2003):
Fixed a column bug
Improved some default settings
Fixed some problems with non ascii chars
Fixed service menu installation
Fixed problems with cyrillic characters
Spell checking of ui texts
Added auto directory creation ( ##/$ is now a valid template )
Fixed adding of directory names
Added caption with full path to the preview context menu
Added strip whitespace operator "\"
Fixed filenames containing "/"
Fixed display of preview failed icon
Removed debug output when writing meta info
Refactored and simplified plugin processing
2.5.5 (Release Date: 28.03.2003):
Updated README
Titlebar labels are now shown translated
Fixed ERROR messages after renaming
Fixed truncating of filenames with the get coordinates function
Fixed window layout restoring at startup
Added an autosize option for the column width in the preview
2.6-rc1 (Release Date: 06.04.2003):
Added icon to service menu entry
Fixed gcc 3.x compiler warnings
Fixed kfile plugins returning spaces at the end
Greatly improved startup time
2.6-rc2 (Release Date: 11.04.2003):
History size can be configured now
Fixed compilation with Qt/KDE 3.0
Fixed disabled controls in Preferences Dialog
Fixed a memory leak in FileOperation::geName();
Fixed file extension problems
Fixed renaming of directory names and the directories contents
Fixed one crash with the reqexp editor
Version 2.4 stable
2.4.0 (Release Date: 16.10.2002):
German Translation Fixes
Fixed bug in service menu installtion
Output Dialog is visible in the taskbar
Current page has bold letters in titlebar
Fixed image preview
Fixed service menu installation
Fixed toggling of titlebar
2.4.1: (Release Date: 30.10.2002):
Header files aren't installed anymore
Updated admin dir/build system
Fixed some memory leaks
Fixed crash with KFilePlugins
Fixed memory leaks in PicturePlugin
Improved speed in PicturePlugin
Support of more image formats in PicturePlugin and preview
2.4.2: (Release Date: 27.11.2002):
Window state is restored after restart of krename
Added [dirname] keyword
Fixed bug with files added more than once to file list
Confirmation at exit can be disabled
Fixed problems with advanced titlebar
Fixel compilation problems
Fixed layout on small resolutions
Added help dialog, that displays all avaible tokens
Removed Mp3/Ogg Plugin, KDE Plugins do the same stuff better
Version 2.3 (Release Date: 03.06.2002)
Translation fixes
Added undo feature
Code cleanups (use of static QFile::exists method )
Removed the splash screen (because I hate the one from OpenOffice
and I do not want to annoy people with krename's splash screen)
Added [track] keyword (needs id3v2 support)
Added function wizard
2.3.1 (Release Date: 10.07.2002):
Added support for KFilePlugins
Added show all plugins button
Added commandline option to undo scripts for security purpose
Smaller bug fixes
Fixed replacing of special chars $, &, ...
2.3.2 (Release Date: 12.09.2002):
Service menu entry is not installed by default, user can isntall it
GUI improvements
Root warning messagebox can be disabled
Added context menu to preview box
Finish button is default button
Fixed renaming of files without extension
Added chinese translation
Regular Expression changes
2.3.3 (Release Date: 09.10.2002):
GCC 3.2 fixes from Gentoo
Added menubar
Fixed plugins not working when show all was selected
Tokens for file plugins are case insensitive now
Pages of the wizard can now be set invisible
Source code clean ups in PluginLoader, BatchRenamer
DateTime, Permission and Dir Plugin are compiled into KRename
Added settings and help menu
Made OK default button in find and replace dialog
Made Start default button in undo dialog
Fixed crash when pressing return after startup
Using qDebug instead of cout in some places
Added advanced title bar
Fixed bug that config wasn't saved sometimes
Removed some asserts
Fixed tab order
Version 2.2 stable (Release Date: 01.05.2002)
Layout fixes in the replace dialog
Bug fixes in the replace dialog
Bug fixes in the copy function
Bug fixes in the build system
Bug fixed with plugins and special chars ( [, ], $, %, ... )
Version 2.1 (Release Date: 26.04.2002)
Added own ListView widget
Added arrow buttons
Removed preview button (disabled since 1.4(?))
User can change a filename by double clicking on a filename in the preview
Added a colored preview box
Translation fixes
ID3v2 tags supported throu id3lib
User can save setting for find & replace and skipping numbers
GUI improvements
User can set a filter for recursive dir adding
Improved recursive scanning of directories
Fixed ogg tag renaming bug
Fixed genre bug
Added plugin for picture renaming
Fixed a bug in the service menu entry
Fixed bug with replacing special chars ( [, ], $, %, ... )
Fixed a bug with the * operator
Added faster copying funtion
Fixed bugs in the replace dialog
Version 2.0 stable (Release Date: 27.03.2002)
Minor changes to README and ChangeLog file :)
Version 1.9 (Release Date: 22.03.2002)
Port to KDE3
Fixed layout bugs on page3 && page2
Added service menu entry for konqueror
Added regular expressions editor
Fixed bug with files ending in a dot or without extension
Version 1.8 stable (Release Date: 28.02.2002)
Added plugin API
Rewrite of BatchRenamer class
API clean up's
Changed handling of numbers and fixed (hopefully) some bugs in it
Fixed (again) bug with filenames containing $,%,&,,#,[ or ]
Fixed bug that didn't allowed doing [1-]
Fixed history bug
Fixed a drag and drop bug
Preview window is resized correctly
Rewrote date time stuff as plugin
Rewrote permissions stuff as plugin
Added mp3/ogg plugin
Added dir sorting plugin.
Changed Listbox selection mode
Added -p commandline option for additional plugin dirs
Added a image preview
Updated translation
Added splash screen
Moved About Button to first page
Added .spec file
Version 1.7 stable (Release Date: 30.12.2001)
Fixed Find and replace bug
Added Add Dir Recursively Button
Group is set correctly in the permissions dialog
Simplified code in batchrenamer.cpp
GUI is repainted during adding a directory recursively
Added warn message if started from root
Version 1.6 stable (Release Date: 27.12.2001)
GUI Changes
Fixed translation bug in the About dialog
Fixed bug with filenames containig spaces
Added advanced file extension handling
Added find and replace of regular expressions
Added * operator (converts first letter of words to upper case)
Speed improvement ( <= 0 replaced with < 0 )
Added build date and time to the about dialog
Fixed history bug in ComboBox
Added handling of filenames containing $,%,&,,#,[ or ]
Version 1.5 (Release Date: 23.11.2001)
Added realtime preview
Added step by value
Added handling of parts of the filename
Added find and replace
Added renaming of output files
All enabling/disabling of widgets is now done in one funtion ( enableControls() )
Many internal code changes
Fixed bug with ,$,& and % in the extension
Added --nopreview commandline option
i18n'ed some more strings, I had forgotten
Fixed keyboard focus and taborder
Version 1.4 stable (Release Date: 08.11.2001)
Rewritten GUI
Added German translation
Changed ToolTips and other texts
Version 1.3 (Release Date: 04.11.2001)
Rewritten, resizeable ProgressDialog (with clipboard support)
Fixed bug in history combo
Smaller speed optimizations ( addDir() ;)
Added skipping of numbers
Removed all the useless struct's in the source code
Using KDE file selection dialog instead of QT's
i18n most strings ( translations are still missing ;)
Fixed crash during saving krenames output in ProgressDialog
Cleaned code (moved include statements from header to source files)
Version 1.2 (Release Date: 28.10.2001)
Added GetCurrentTime Button
Added giving files as commandline parameter
Added conversion
Code clean up's
Added recursive renaming of directories with commandline parameters
Changed help files
Bug fixes
Version 1.1 (Release Date: 23.10.2001)
Fixed bug with non existing directories
Added Up/Down Buttons fo changing the file order
Added restart button
Rewritten KMyListBox class
Krename stores path and templates for later sessions
Added creation of symbolic links
Added dropping of dirs
Added conversion of filenames to upper case
Improved drag'n'drop support
Added template for the file extension.
Changed GUI
Fixed ToolTips
Version 1.0 stable (Release Date: 10.10.2001) stable
Krename is called stable ;)
Fixed problem with the same file twice in the list (The same file is allowed only once in the list)
Files are correctly removed from the list.
Fixed warning messages at compile time.
Fixed bug in Add Dir.
Changed some key accels.
Added 'OK to all' button.
Fixed error checking
Version 0.9 (Release Date: 03.10.2001)
Added Add Directory Button
Fixed drag'n'drop code
Fixed problem with Cancel
Added Convert extension to lower case
Version 0.8 (Release Date: 26.09.2001)
Changed syntax for adding numbers.
Added Copyright Note to the COPYING file.
User is asked if Krename should quit.
Changed some texts.
Updated and changed documentation.
Changed maxvalue of start index.
Version 0.7 (Release Date: 20.09.2001)
Added Progress Dialog.
Krename displays the correct number of successfully renamed files.
Better error checking.
Added warning fucntion to ProgressDialog.
Added overwrite existing files function.
Changed some description texts.
Version 0.6 (Release Date: 12.09.2001)
Added cancel button to ProgressDialog
Fixed a bug that fclose wasn't called under certain conditions
Added save output button to ProgressDialog
ProgressDialog should be faster because of using QListBox instead of QMultiLineEdit
Fixed a bug that ocurred when changing date & time
krename displays now the elapsed time.
Speed optimations, mainly because of changing struct data
Fixed some problems with adding correct numbers to filenames if startindex is not 0.
Version 0.5 (Release Date: 08.09.2001)
Changed description texts.
Changed API of ProgressDialog a little bit.
Files can be opened from krename by pressing return or double clicking on the file.
Krename can change owner and group of all files
Krename can change permissions of all files
Added label that counts the number of files
Version 0.4 (Release Date: 04.09.2001)
Krename can now change time of last access and modification
Added preview button
Bug fixes
code clean up's
Better Help
Krename is added to the KMenu's Utilities section instead of Applications.
Version 0.3 (Release Date: 31.08.2001)
Added functions for changing access and modification date
Added drag'n'drop support
Bug fixes
Code layout changes
Added thanks to section to About dialog
Version 0.2 (Release Date: 23.08.2001)
New KWizard GUI
ProgressDialog is updated
Code layout changes
Version 0.1 (Release Date: 22.08.2001)
Initial release

@ -0,0 +1,246 @@
# Doxyfile 1.3.4-KDevelop
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = krename.kdevelop
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = /home/dominik/Desktop/Programming/krename
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.C \
*.H \
*.tlh \
*.diff \
*.patch \
*.moc \
*.xpm \
*.dox
RECURSIVE = yes
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = yes
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

@ -0,0 +1,167 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes a while. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Type `make install' to install the programs and any data files and
documentation.
4. You can remove the program binaries and object files from the
source code directory by typing `make clean'.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made.
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

@ -0,0 +1,30 @@
####### kdevelop will overwrite this part!!! (begin)##########
SUBDIRS = krename po doc
EXTRA_DIST = krename.kdevelop admin AUTHORS COPYING ChangeLog INSTALL README TODO krename.spec
####### kdevelop will overwrite this part!!! (end)############
# not a GNU package. You can remove this line, if
# have all needed files, that a GNU package needs
AUTOMAKE_OPTIONS = foreign
$(top_srcdir)/configure.in: configure.in.in $(top_srcdir)/subdirs
cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common configure.in ;
$(top_srcdir)/subdirs:
cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common subdirs
$(top_srcdir)/acinclude.m4: $(top_srcdir)/admin/acinclude.m4.in $(top_srcdir)/admin/libtool.m4.in
@cd $(top_srcdir) && cat admin/acinclude.m4.in admin/libtool.m4.in > acinclude.m4
MAINTAINERCLEANFILES = subdirs configure.in acinclude.m4 configure.files
package-messages:
$(MAKE) -f admin/Makefile.common package-messages
$(MAKE) -C po merge
dist-hook:
cd $(top_distdir) && perl admin/am_edit -padmin
cd $(top_distdir) && $(MAKE) -f admin/Makefile.common subdirs

@ -0,0 +1,14 @@
all:
@echo "This Makefile is only for the CVS repository"
@echo "This will be deleted before making the distribution"
@echo ""
@if test ! -d admin; then \
echo "Please recheckout this module!" ;\
echo "for cvs: use checkout once and after that update again" ;\
echo "for cvsup: checkout kde-common from cvsup and" ;\
echo " link kde-common/admin to ./admin" ;\
exit 1 ;\
fi
$(MAKE) -f admin/Makefile.common cvs
.SILENT:

@ -0,0 +1,44 @@
Krename is a very powerfull batch file renamer for KDE3.
Features include:
-renaming a list of files based on a set of expressions
-copying/moving a list of files to another directory
-convert filenames to upper/lower case
-adding numbers to filenames
-finding and replacing parts of the filename
-rename Mp3/Ogg Vorbis files based on their ID3 tags.
-setting access and modification dates
-permissions and file ownership
-a plug-in API which allows you to extend krename's features
-rename directories recursively
-support for KFilePlugins
-create undo file
-and many more...
Visit the Krename Homepage at: http://www.krename.net
HAVE FUN!
Dominik Seichter <domseichter@web.de>
==============================
Old Version of the text above:
==============================
Krename is a very powerful batch file renamer for KDE2 which
can rename a list of files based on a set of expressions.
It can copy/move the files to another directory or simply
rename the input files. Krename supports many conversion
operations, including conversion of a filename to lowercase
or to uppercase, conversion of the first letter of every
word to uppercase, adding numbers to filenames, finding
and replacing parts of the filename, and many more.
Krename can rename Mp3/Ogg Vorbis files based on the
information stored in their ID3 tags.
It can also change access and modification dates,
permissions, and file ownership.
WARNING! It will not compile with automake 1.5, automake 1.4 is required.
Visit the Krename Homepage at: http://krename.sourceforge.net
HAVE FUN!
Dominik Seichter <domseichter@web.de>

383
TODO

@ -0,0 +1,383 @@
DOM: Copying extremely slows
DOM: Remember the last 10 selected tokens in HelpDialog
DOM: Display in Realtime Preview a new first column which contains a small warning icons
If the new and the old filename are identical
DOM: Kontext menü im advance mode für alle text boxen:
Insert -> Filename To Lowercase
-> Filename To Upercase
-> Number
-> Date
-> ...
DOM: First Start Dialog:
* 2 Screenshots von den beiden Modi
* + Beschreibungstext
-> KDE 4 Layout!!!!
Stonki: Thumbnails auch im rename-tab fenster
========================================
Here's some feedback on it. I like it, but the "find and replace"
function was unclear. Was it finding and replacing parts of the
filename, or inside the contents of the files?
========================================
Thanks for making krename, it is truly a great piece of software. It saved
me litteraly hours of painful work in sorting the hundreds of photographs
given to us by at least a dozen different people for our wedding. It would
have taken me ages to sort them by hand.
This is only a small donation but I hope it will help in making krename
even better.
I had sent my comments earlier but to mention them again here are the only
4 problems I have faced with krename (all relate to beginner mode, 'add
files' section), none of them are show-stoppers bwt :) :
1) in thumbnail view, when selecting a block of files to move around, they
get copied to their destination in reverse order
2) for some reason, the thumbnails do not always display (as in, the image
thumbnails do not show, they stay as file type icons instead) when I select
add files and only 'show thumbnail' is selected ('show file name' not
checked). However, if I select add files with only 'show file name'
checked, and THEN (after files are shown in list) check 'show thumbnails',
then all the thumbnails will show properly.
Cheers and thanks again for this great piece of software.
========================================
Hallo
Erst mal vielen Dank für das Programm; es sparte mir eine Menge Zeit
beim Re-Organisieren meiner MP3-Sammlung.
Dabei habe ich es ziemlich oft benutzt, und mir sind einige Dinge
aufgefallen, die vielleicht verbessert werden könnten. (Ich beziehe mich
auf die Version 2.8.5. Falls eine neuere Version da ist, die meine
Anmerkungen überflüssig macht, verzeih mir bitte):
- Beim Hinzufügen von Verzeichnissen werden die selbst definierten
Filter (*.mp3) und die Einstellung für "Unterverzeichnisse rekursiv
hinzufügen" nicht gespeichert; vor allem die Rekursivität hat mich
genervt, weil ich die immer wieder vergessen hab.
Dankeschön für deine Mühe!
Regards/MfG,
Christian Weiske
=======================================
Hi,
Ich habe ein paar verbesserungsvorschläge für Dein super Tool KRename:
-) Bei den Plugins für auf KFilePlugins zurückgreifen, listest Du all ihre
möglichen Felder auf. I fände es sehr hilfreich, wenn der ausgewählte
Platzhalter automatisch bei einem Doppelklick darauf an Cursorposition in das
Eingabefeld für das Namensmuster eingefühgt würde.
Für die Übersicht wäre es auch schön, wenn dieses Eingabefeld nochmal (ohne
drop-down menü) unter den plugins sichtbar wäre....
-) Wäre es möglich, als Startwert nicht nur eine Zahl (0, 1, 2,...) sondern
auch Buchstaben (a, b, c, ... / A, B, C, ...) angeben zu können?
-) Es wäre super, wenn man verschiedene Zähler seperat definieren könnte. zB.
mit einem Tabinterface für den Konfigurationsdialog "1. Zähler", "2. Zähler",
etc, wenn mehr als eine ##-Grupe im Muster auftaucht
-) Was ich immer wieder brauche ist eine reset-Bedingung, die den Zähler
wieder auf seinen Startwert setzt, so das er quasi im Kreis zählt (1, 2, 3,
1, 2, 3, 1, 2, 3,... mit 3 als reset)
Ich könnte mir das als eine Zeile mit
Checkbox "reset bei"; Combobox "<self> | 1. Zähler | 2. Zähler | ...";
Combobox "> | >= | = | <= | <"; Spinbox für Zahl
-) Was ich persönlich seltener brauche, für manche aber bestimmt hilfreich
ist, wäre die Möglichkeit auch Schrittweiten a la "1/2" od. "1/3" zuzulassen.
Im Falle "1/3" würde dann so gezählt: "1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4,
5, ..."
Gruss,
Jonas
=======================================
On Sat June 12 2004 04:40 am, Dominik Seichter wrote:
> Hi,
>
> This idea is also a good idea. KRename had a similar feature already in
> earlier version (but not that powerful - you could only specify a fixed
> tag). I do not know if this will be possible in 3.1 but I promisse that I
> will look into this issue.
>
> CU Dom
>
> Am Freitag, 11. Juni 2004 05:51 schrieben Sie:
> > At present you have tags to take information from a file and rename the
> > file.
> >
> > Now think in reverse - krename plugins allow the possibility for a
> > multiple format tagger.
> >
> > So a new tab would allow....
> >
> > artist - track - title - xxx.ogg
> >
> > to be parse with the following command
> >
> > [Artist] - [Track] - [Title] - xxx
> >
> > The info then could be written to the file tag.
> >
> > Also the inclusion of modifiers (and Search & Replace) allow for the
> > information to be cleaned up before it is written.
> >
> > Phoenix
This was inspired from using Cantus.
TTC Timothy Taylor - Economics Lecture 20-A Global Economic Perspective.mp3
Please enter the formatting string (%t - %s): TTC %a - %b %g %t-%s
Feedback...
20 A Global Economic Perspective ~ Timothy Taylor ~ Economics ~ 0 ~ Lecture
The course is "Economics"
%b stands for aBlum
Now I could have done %x %a - %x %x %t-%s or variations there of
%x stands for ignore.
powerful concept, no? Like I said, krename has one extra twist no one else has
done yet - multiple file formats
And for another wow: combine the actions so the following happens
filename -> tag -> filename
This is what part of my script does.
The only usability issue is the length of the tag names themselves,
TTC [artist] - [album] [genre] [track]-[title]
Is a tad long to write, no?
[x] for ignore?
Of course a drop-down combo "memory" would help.
I hope my "annoyance" is helpful, Phoenix
===================================================================
[23:32:12] <Keimix> BTW is there a possibility to load just one of the kfile-plugins at krename startup, because loading all slows krename down alot?
[23:35:49] <domseichter> No, not yet. But it's a good idea. Strange that I did not have it and nobody asked me for this feature!
===================================================================
"Squashing weird characters" sollte auf die ToDO liste
===================================================================
> Remark Dom, 4-10-2004
> - Add a random token (maybe even a random number and a random string token)
> In the first case the range and in the latter case the length should be specified
===================================================================
Arpad Biro <biro_arpad@yahoo.com>:
----------------------
an undo script bug:
1. cd to a temporary dir (for example /tmp)
2. touch file1
mkdir dir1
touch dir1/file2
3. rename the above 3 items (use the "Add directory names with filenames" option),
and also create an undo script
4. run the undo script
The directory is renamed back first, and the file in it cannot be renamed back.
other text-related things
-------------------------
The "WARNING..." string in the encoding conversion plugin is unlocalizable.
===================================================================
---------- Weitergeleitete Nachricht ----------
Subject: krename - vorschlaege/diskussion
Date: Dienstag, 13. September 2005 00:41
From: Christian Goehl <pastulio@gmx.net>
To: support@stonki.de
Hello, as you live in germany I assume you speak German. If not,
tell me.
Wenn man ueber den dsdirselectdialog Dateien/Ordner hinzufuegt und
die Anzahl enorm ist (70gb mp3s), wird die aktuelle kde session
beendet. Man kann noch den Crash-Handler sehen. Wahrscheinlich ist
das ein Bug in KFileDialog oder in Qt. Als Ausweg kann man
natuerlich die Dateien via D'n'D hinzufuegen, allerdings kann hat
man dann nicht die vielseitigen Optionen des Dialogs.
Nun aber zu meinem eigentlichen Anliegen: Ich besitze eine riesige
Musiksammlung, leider sind aber nicht alle Dateien einheitlich
benannt. Generell waere es mit Krename schon moeglich diese zu
vereinheitlichen, es ist aber sehr aufwendig, vorallem weil es
keine Verallgemeinerung von Dateitypen(z.B. Audiodatei) gibt, so
muss man immer beide Tags fuer mp3 und ogg einfuegen.
Desweiteren waere eine Art KI wuenschenswert, welche bei bestimmten
Stichwoertern wie zum Beispiel "Unbekannt, unknown, track" anhand
des Ordnernamens und MusicBrainz oder CDDB Vorschlaege zum taggen
macht.
Vielleicht kann man auch noch einen Normalisierer einbauen, wobei
ich mir nicht genauch vorstellen kann, wie aufwendig sowas ist.
Die oben genannten Vorschlaege sind nicht unbedingt als eine
Erweiterung zu Krename zu sehen, vielleicht sollten sie auch in
einer getrennten Anwendung realisiert werden. Denn der Vorgang
sollte auch fuer Anfaenger einfach sein. Moeglicherweise kommt
auch einfach ein neues Profil in Frage.
Ich waere bereit an diesem Projekt mitzuarbeiten, obgleich meine
Programmierfaehigkeiten eher im Hobbybereich liegen. Dennoch habe
ich schon Erfahrungen mit KDE/Qt gesammelt.
MfG,
Christian Goehl
==================================================
[14:43:43] <[Stonki]> 1) Man kann kein existierendes Profil ?berschreiben !
[14:44:33] <Dom64> ok, stimmt das sollte möglich sein.
[14:44:37] <Dom64> Kann man leicht hinzugeben
[14:45:41] <[Stonki]> und bei den profilen m?chte ich noch paar andere EInstellungen sein
[14:46:15] <[Stonki]> zum beispiel rufe ich krename ?ber krusader auf. Da w?re eine option bei den profilen toll, in der man automatisch im Reiter "Dateiname" landet
[14:46:24] <[Stonki]> und NACH dem umbenennen automatisch krename schliessen
[14:46:54] <Dom64> Praktisch einen "Profile Settings" Dialog mit:
[14:46:58] <Dom64> -> Krename Default Page
[14:46:59] <[Stonki]> und man sollte anzeigen lassen, WAS bei den profilen eigentlich nun gespeichert wird
[14:47:04] <Dom64> -> Close Krename after renaming
[14:47:23] <[Stonki]> -> Behaviour after renaming
[14:47:30] <[Stonki]> rather than just closing
[14:47:47] <Dom64> Ok, und da evtl. auch alles zum ändern. Also dass man dort auch direkt zum beispiel das template umstellen kann.
[14:47:58] <Dom64> Stimmt, kann man ja mehr optionen machen als nur schliessen.
[14:48:25] <[Stonki]> viel spass :)
[14:48:29] <[Stonki]> UND
[14:48:56] <Dom64> *g
[14:49:01] <[Stonki]> es ging doch irgendwie die tracknummer von MP3 songs automatisch nach ## zu formatieren, oder ?
[14:49:25] <[Stonki]> und das wird dann puenktlich zu kde 3.5 krename 3.50 :)
[14:50:27] <Dom64> ja [###mp3TrackNumber]
[14:50:41] <Dom64> einfach beliebig viele #'s voranstellen, geht bei jeder zahl die von einem plugin kommt
[14:50:53] <Dom64> KRename 3.50 :)
========
[quote]
1. If I select files in Konqueror and then right click too select actions|krename, then it takes me to the [files] section - but it would be more efficient to go straight to [filenames].
[/quote]
This was fixed some time ago. But does not work with the latest release. I will fix it for the next version.
========
Hello,
This is a great software but there is a powerful feature that I'd like
to see in the future.
When you use the 'find and replace' feature, you only can give rules
that apply on the original filename. Why don't give the possibility to
apply a new rule on the original file changed by the past rules ?
An exemple :
the original file : "artist - the song.mp3"
the result I want : "artist__the_song.mp3"
The way I did that on windows (in the past :-) ) with emusic tag editor :
rule 1 " " --> "_" the current filename is "artist_-_the_song.mp3"
rule 2 "-" --> "_" the current filename is "artist___the_song.mp3"
rule 3 "___" --> "__" the current filename is "artist__the_song.mp3"
With this software, rules n applies on the filename modified by rules
n-1, n-2, n-p and so on (this could be annoying, that's why the best is
to give the possibility to have the present behaviour or 'my' feature
enabled).
With the current version (ok, I only have 3.03) it is not possible to do
so in one shot. With the pas example :
Find and replace:
- add " " --> "_"
- add "-" --> "_"
- add "___" --> "__" ==> no effect because there is no such string in
the original filename.
The result is "artist___the_song.mp3".
I could tried
- add " - " --> __
- add " " --> _
There is a conflict and not all the changes are applied.
Thank you for your response.
Best regards.
mailto : benoit.turpin@ecl2005.ec-lyon.fre
============
Package: krename
Version: 3.0.9 3.5.1, Debian Package 4:3.5.1-4 (testing/unstable)
Severity: wishlist
Compiler: Target: x86_64-linux-gnu
OS: Linux 2.6.15-1-amd64-k8-smp x86_64 (Debian Package 4:3.5.1-4 (testing/unstable))
In konqueror file management, say you right-click on a file and select krename from actions. When krename comes up and displays the chosen file, click Add.
Current behavior: the file selector opens in the user's home directory.
Requested behavior: open in the same directory as the currently chosen file.
Great program!
Dave
======================
I just thought that krename is a great tool! And could be best: due its
integration with konqueror it could manage a download directory in such
manner that when a batch of files just arrives ( may be downloaded by kget),
krename renames it and then moves it to another directory, keeping track of
its activities, so the recent arrives never collides with elder files.
Please, excuse my poor english.
Best regards,
Marcelo Mazini.
==========================
Hi, I download many scientific articles, usualy in pdf or ps, with httrack. When on my disk, names are often like 4523.pdf and I would like to use krename as :
Withdraw title property in document to use it as a new fiel in rename items. If title property do not exist, use some heuristic to find the best candidate (say for example, in the first pages, usually the very first one, center aligned, biggest font size, bold, uppercase, and a ponderation rule of all this kind of criteria).
Hope you like it and that it will be available. Let me now. I remain at your disposal if you want to discuss this feature. Best regards,
Laurent.
~~
It is a good idea to add a feature to KRename so that you can check wether a token is empty (doesn't exist) and only use it if it does exist and use something else if it does not exist. I will try to add something to the next version.
Unfortunately it would be a too big issue to add support for extracting headlines from a PDF file to KRename. This would require a complete PDF parser in KRename. If you want this functionallity it is better to write an external tool and use KRename's command plugin.
best regards,
Dom
==========================
Morgen!
Danke für die Idee. Das ist auf jeden Fall sinvoll, werde ich für die nächste Version hinzufügen.
CU Dom
Am Friday, 1. December 2006 19:38 schrieben Sie:
> Kam gerade im Chat
>
> Bei den Settings von krename einstellen, wie viele Dateien er
> wirklich anzeigt im Preview Fenster. Default: unlimited, aber wenn
> man wirklich mal 10.000 Dateien umbenennt, dann kann man das z.B
> auf 200 stellen, er macht das preview dann nur für 200 und erst
> beim eigentlich start dann alle 10.000
>
>
> cu
> stonki
==========================

File diff suppressed because it is too large Load Diff

863
aclocal.m4 vendored

@ -0,0 +1,863 @@
# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.9.6])])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 7
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])
AC_SUBST([$1_FALSE])
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
case $depmode in
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
none) break ;;
esac
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this.
if depmode=$depmode \
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 3
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[for mf in $CONFIG_FILES; do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# So let's grep whole file.
if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 12
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.58])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
# test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" &&
test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AM_PROG_INSTALL_SH
AM_PROG_INSTALL_STRIP
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_CC],
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_CXX],
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
])
])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$1 | $1:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
install_sh=${install_sh-"$am_aux_dir/install-sh"}
AC_SUBST(install_sh)])
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo done
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
am__include=include
am__quote=
_am_result=GNU
fi
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
am__include=.include
am__quote="\""
_am_result=BSD
fi
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it supports --run.
# If it does, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
fi
])
# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_MKDIR_P
# ---------------
# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
#
# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
# created by `make install' are always world readable, even if the
# installer happens to have an overly restrictive umask (e.g. 077).
# This was a mistake. There are at least two reasons why we must not
# use `-m 0755':
# - it causes special bits like SGID to be ignored,
# - it may be too restrictive (some setups expect 775 directories).
#
# Do not use -m 0755 and let people choose whatever they expect by
# setting umask.
#
# We cannot accept any implementation of `mkdir' that recognizes `-p'.
# Some implementations (such as Solaris 8's) are not thread-safe: if a
# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
# concurrently, both version can detect that a/ is missing, but only
# one can create it and the other will error out. Consequently we
# restrict ourselves to GNU make (using the --version option ensures
# this.)
AC_DEFUN([AM_PROG_MKDIR_P],
[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
# We used to keeping the `.' as first argument, in order to
# allow $(mkdir_p) to be used without argument. As in
# $(mkdir_p) $(somedir)
# where $(somedir) is conditionally defined. However this is wrong
# for two reasons:
# 1. if the package is installed by a user who cannot write `.'
# make install will fail,
# 2. the above comment should most certainly read
# $(mkdir_p) $(DESTDIR)$(somedir)
# so it does not work when $(somedir) is undefined and
# $(DESTDIR) is not.
# To support the latter case, we have to write
# test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
# so the `.' trick is pointless.
mkdir_p='mkdir -p --'
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
for d in ./-p ./--version;
do
test -d $d && rmdir $d
done
# $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
if test -f "$ac_aux_dir/mkinstalldirs"; then
mkdir_p='$(mkinstalldirs)'
else
mkdir_p='$(install_sh) -d'
fi
fi
AC_SUBST([mkdir_p])])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT(yes)])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor `install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in `make install-strip', and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of `v7', `ustar', or `pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility.
AM_MISSING_PROG([AMTAR], [tar])
m4_if([$1], [v7],
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
[m4_case([$1], [ustar],, [pax],,
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
# Do not fold the above two line into one, because Tru64 sh and
# Solaris sh will not grok spaces in the rhs of `-'.
for _am_tool in $_am_tools
do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar;
do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar <conftest.tar])
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([acinclude.m4])

@ -0,0 +1,237 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Define to 1 if you have the <Carbon/Carbon.h> header file. */
#undef HAVE_CARBON_CARBON_H
/* Define if you have the CoreAudio API */
#undef HAVE_COREAUDIO
/* Define to 1 if you have the <crt_externs.h> header file. */
#undef HAVE_CRT_EXTERNS_H
/* Defines if your system has the crypt function */
#undef HAVE_CRYPT
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if you have libjpeg */
#undef HAVE_LIBJPEG
/* Define if you have libpng */
#undef HAVE_LIBPNG
/* Define if you have a working libpthread (will enable threaded code) */
#undef HAVE_LIBPTHREAD
/* Define if you have libz */
#undef HAVE_LIBZ
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if your system needs _NSGetEnviron to set up the environment */
#undef HAVE_NSGETENVIRON
/* Define if you have res_init */
#undef HAVE_RES_INIT
/* Define if you have the res_init prototype */
#undef HAVE_RES_INIT_PROTO
/* Define if you have a STL implementation by SGI */
#undef HAVE_SGI_STL
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have strlcat */
#undef HAVE_STRLCAT
/* Define if you have the strlcat prototype */
#undef HAVE_STRLCAT_PROTO
/* Define if you have strlcpy */
#undef HAVE_STRLCPY
/* Define if you have the strlcpy prototype */
#undef HAVE_STRLCPY_PROTO
/* Define to 1 if you have the <sys/bitypes.h> header file. */
#undef HAVE_SYS_BITYPES_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
/* Suffix for lib directories */
#undef KDELIBSUFF
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `char *', as computed by sizeof. */
#undef SIZEOF_CHAR_P
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `short', as computed by sizeof. */
#undef SIZEOF_SHORT
/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
/* The size of `unsigned long', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Defined if compiling without arts */
#undef WITHOUT_ARTS
/*
* jpeg.h needs HAVE_BOOLEAN, when the system uses boolean in system
* headers and I'm too lazy to write a configure test as long as only
* unixware is related
*/
#ifdef _UNIXWARE
#define HAVE_BOOLEAN
#endif
/*
* AIX defines FD_SET in terms of bzero, but fails to include <strings.h>
* that defines bzero.
*/
#if defined(_AIX)
#include <strings.h>
#endif
#if defined(HAVE_NSGETENVIRON) && defined(HAVE_CRT_EXTERNS_H)
# include <sys/time.h>
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#endif
#if !defined(HAVE_RES_INIT_PROTO)
#ifdef __cplusplus
extern "C" {
#endif
int res_init(void);
#ifdef __cplusplus
}
#endif
#endif
#if !defined(HAVE_STRLCAT_PROTO)
#ifdef __cplusplus
extern "C" {
#endif
unsigned long strlcat(char*, const char*, unsigned long);
#ifdef __cplusplus
}
#endif
#endif
#if !defined(HAVE_STRLCPY_PROTO)
#ifdef __cplusplus
extern "C" {
#endif
unsigned long strlcpy(char*, const char*, unsigned long);
#ifdef __cplusplus
}
#endif
#endif
/*
* On HP-UX, the declaration of vsnprintf() is needed every time !
*/
#if !defined(HAVE_VSNPRINTF) || defined(hpux)
#if __STDC__
#include <stdarg.h>
#include <stdlib.h>
#else
#include <varargs.h>
#endif
#ifdef __cplusplus
extern "C"
#endif
int vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
#ifdef __cplusplus
extern "C"
#endif
int snprintf(char *str, size_t n, char const *fmt, ...);
#endif
#if defined(__SVR4) && !defined(__svr4__)
#define __svr4__ 1
#endif
/* type to use in place of socklen_t if not defined */
#undef kde_socklen_t
/* type to use in place of socklen_t if not defined (deprecated, use
kde_socklen_t) */
#undef ksize_t

@ -0,0 +1,2 @@
./admin/configure.in.min
configure.in.in

@ -0,0 +1,121 @@
dnl =======================================================
dnl FILE: ./admin/configure.in.min
dnl =======================================================
dnl This file is part of the KDE libraries/packages
dnl Copyright (C) 2001 Stephan Kulow (coolo@kde.org)
dnl This file is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Library General Public
dnl License as published by the Free Software Foundation; either
dnl version 2 of the License, or (at your option) any later version.
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Library General Public License for more details.
dnl You should have received a copy of the GNU Library General Public License
dnl along with this library; see the file COPYING.LIB. If not, write to
dnl the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
dnl Boston, MA 02110-1301, USA.
# Original Author was Kalle@kde.org
# I lifted it in some mater. (Stephan Kulow)
# I used much code from Janos Farkas
dnl Process this file with autoconf to produce a configure script.
AC_INIT(acinclude.m4) dnl a source file from your sub dir
dnl This is so we can use kde-common
AC_CONFIG_AUX_DIR(admin)
dnl This ksh/zsh feature conflicts with `cd blah ; pwd`
unset CDPATH
dnl Checking host/target/build systems, for make, install etc.
AC_CANONICAL_SYSTEM
dnl Perform program name transformation
AC_ARG_PROGRAM
dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(krename, 3.0.14) dnl searches for some needed programs
KDE_SET_PREFIX
dnl generate the config header
AM_CONFIG_HEADER(config.h) dnl at the distribution this done
dnl Checks for programs.
AC_CHECK_COMPILERS
AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
KDE_PROG_LIBTOOL
dnl for NLS support. Call them in this order!
dnl WITH_NLS is for the po files
AM_KDE_WITH_NLS
KDE_USE_QT(3.0)
AC_PATH_KDE
dnl =======================================================
dnl FILE: configure.in.in
dnl =======================================================
#MIN_CONFIG(3.0)
dnl PACKAGE set before
KDE_CREATE_SUBDIRSLIST
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ doc/Makefile ])
AC_CONFIG_FILES([ doc/en/Makefile ])
AC_CONFIG_FILES([ doc/en/HTML/Makefile ])
AC_CONFIG_FILES([ krename/Makefile ])
AC_CONFIG_FILES([ po/Makefile ])
AC_OUTPUT
# Check if KDE_SET_PREFIX was called, and --prefix was passed to configure
if test -n "$kde_libs_prefix" -a -n "$given_prefix"; then
# And if so, warn when they don't match
if test "$kde_libs_prefix" != "$given_prefix"; then
# And if kde doesn't know about the prefix yet
echo ":"`kde-config --path exe`":" | grep ":$given_prefix/bin/:" 2>&1 >/dev/null
if test $? -ne 0; then
echo ""
echo "Warning: you chose to install this package in $given_prefix,"
echo "but KDE was found in $kde_libs_prefix."
echo "For this to work, you will need to tell KDE about the new prefix, by ensuring"
echo "that KDEDIRS contains it, e.g. export KDEDIRS=$given_prefix:$kde_libs_prefix"
echo "Then restart KDE."
echo ""
fi
fi
fi
if test x$GXX = "xyes" -a x$kde_have_gcc_visibility = "xyes" -a x$kde_cv_val_qt_gcc_visibility_patched = "xno"; then
echo ""
echo "Your GCC supports symbol visibility, but the patch for Qt supporting visibility"
echo "was not included. Therefore, GCC symbol visibility support remains disabled."
echo ""
echo "For better performance, consider including the Qt visibility supporting patch"
echo "located at:"
echo ""
echo "http://bugs.kde.org/show_bug.cgi?id=109386"
echo ""
echo "and recompile all of Qt and KDE. Note, this is entirely optional and"
echo "everything will continue to work just fine without it."
echo ""
fi
if test "$all_tests" = "bad"; then
if test ! "$cache_file" = "/dev/null"; then
echo ""
echo "Please remove the file $cache_file after changing your setup"
echo "so that configure will find the changes next time."
echo ""
fi
else
echo ""
echo "Good - your configure finished. Start make now"
echo ""
fi

@ -0,0 +1,3 @@
#MIN_CONFIG(3.0)
AM_INIT_AUTOMAKE(krename,3.0.14)

@ -0,0 +1,6 @@
####### kdevelop will overwrite this part!!! (begin)##########
SUBDIRS = en
####### kdevelop will overwrite this part!!! (end)############

@ -0,0 +1,13 @@
####### kdevelop will overwrite this part!!! (begin)##########
EXTRA_DIST = index.html
install-data-local:
$(mkinstalldirs) $(kde_htmldir)/en/krename/
$(INSTALL_DATA) $(srcdir)/index.html $(kde_htmldir)/en/krename/index.html
uninstall-local:
-rm -f $(kde_htmldir)/en/krename/index.html
####### kdevelop will overwrite this part!!! (end)############

@ -0,0 +1,63 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>
The Krename Handbook
</title>
<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.64">
<link rel="NEXT" title="Introduction" href="introduction.html">
<meta name="KEYWORD" content="KDE">
<meta name="KEYWORD" content="Krename">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="common/kde-common.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<link rel="stylesheet" href="common/kde-localised.css" type="text/css" title="KDE-English">
<link rel="stylesheet" href="common/kde-default.css" type="text/css" title="KDE-Default">
<meta name="KEYWORDS" content="KDE, Krename">
</head>
<body class="BOOK" bgcolor="#FFFFFF" text="#000000" link="#AA0000" vlink="#AA0055" alink="#AA0000" style="font-family: sans-serif;">
<div class="logoheader">
<a href="http://www.kde.org/"><img src="common/logotp3.png" border="0" alt="The K Desktop Environment" height="62" width="229"></a>
</div>
<div class="BOOK">
<div class="TITLEPAGE">
<h1 class="TITLE">
<a name="AEN2">The KRename Handbook</a>
</h1>
</span>Last updated:<span class="DATE">06/01/2005</span>
<h3 class="AUTHOR">
<a name="AEN5">Dominik Seichter</a>
</h3>
<div class="AFFILIATION">
<div class="ADDRESS">
<p class="ADDRESS">
<a href="mailto:domseichter@web.de">domseichter@web.de</a>
</p>
</div>
</div>
<p class="COPYRIGHT">
Copyright &copy; 2001-2005 by <span class="HOLDER">Dominik Seichter</span>
</p>
<div>
<p><h3>Introduction</h3></p>
<p>
KRename is a batch renamer or a mass renamer, how it is called by a few people, for KDE. A batch renamer takes a list of files and renames them all at once using a given set of expressions. KRename has lot's of features which makes the renaming easier.
</p>
<p>
First of all there is the powerful GUI with two GUI modes: One mode (called wizard-mode) is for first time KRename users witch only want to do simple tasks and the other mode (called tabbedmode) shows the full power of KRename and allows you to do allmost everything with your filenames. But there is much more than only the GUI. KRename supports all of the great KDE technologies, like KIO-Slaves, which allow to rename files almost everywhere (on ftp:// servers, over fish:// or on smb:// shares), DCOP, giving you easy scripting access to KRename, and the powerful KDE file plugins. Thanks to the file plugins of KDE, KRename can access information, such as the interpret of a mp3 or ogg file or the creation date of a jpeg image.
</p>
<p>
And of course there is support for simple stuff like converting a filename from upper case to lower case, adding to a number to a filename or doing simple find and replace on filenames. Finally KRename comes with an undo function so that you do not break anything while playing with KRename.
</p>
<p><h3>Documentation</h3></p>
<p>The complete KRename handbook ist available as PDF file and can be downloaded from <a href="http://www.krename.net/Documentation.20.0.html">www.krename.net</a>.</p>
</div>
<hr>
</div>
</div>
</body>
</html>

@ -0,0 +1,10 @@
####### kdevelop will overwrite this part!!! (begin)##########
SUBDIRS = HTML
####### kdevelop will overwrite this part!!! (end)############
KDE_LANG = en
KDE_DOCS = krename

@ -0,0 +1,195 @@
<!DOCTYPE kdevelop>
<kdevelop>
<general>
<author>Dominik Seichter</author>
<email>domseichter@web.de</email>
<projectmanagement>KDevKDEAutoProject</projectmanagement>
<primarylanguage>C++</primarylanguage>
<keywords>
<keyword>KDE</keyword>
<keyword>Qt</keyword>
</keywords>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<version>3.0.3</version>
<description/>
<ignoreparts/>
<secondaryLanguages/>
</general>
<kdevautoproject>
<general>
<mainprogram>krename</mainprogram>
<useconfiguration>default</useconfiguration>
<activetarget>krename/krename</activetarget>
</general>
<configure>
<configargs>\s--build=i386-linux --host=i386-linux --target=i386-linux --prefix=/opt/kde3\s</configargs>
</configure>
<make>
<abortonerror>false</abortonerror>
<numberofjobs>1</numberofjobs>
<dontact>false</dontact>
<makebin/>
<envvars>
<envvar value="1" name="WANT_AUTOCONF_2_5" />
<envvar value="1" name="WANT_AUTOMAKE_1_6" />
</envvars>
</make>
<compiler>
<cflags/>
<cxxflags>\s-O2 -g2 -Wall</cxxflags>
</compiler>
<run>
<directoryradio>executable</directoryradio>
<customdirectory>/</customdirectory>
<mainprogram>krename/krename</mainprogram>
<programargs/>
<terminal>false</terminal>
<autocompile>true</autocompile>
<envvars/>
</run>
<configurations>
<default>
<configargs/>
<builddir/>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
</default>
<debug>
<configargs>--enable-debug</configargs>
<builddir>debug</builddir>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
</debug>
</configurations>
</kdevautoproject>
<kdevfileview>
<groups>
<group pattern="*.h;*.hh;*.hxx;*.hpp;*.H" name="Header" />
<group pattern="*.cpp;*.c;*.cc;*.C;*.cxx;*.ec;*.ecpp;*.lxx;*.l++;*.ll;*.l" name="Quellen" />
<group pattern="*.kdevdlg;*.ui;*.rc" name="Benutzerschnittstelle" />
<group pattern="*.po" name="Übersetzungen" />
<group pattern="AUTHORS;COPYING;ChangeLog;INSTALL;README;TODO;NEWS" name="GNU" />
<group pattern="*.html;*.HTML;*.htm;*.html" name="Documentation" />
<group pattern="*" name="Andere" />
<hidenonprojectfiles>false</hidenonprojectfiles>
<hidenonlocation>false</hidenonlocation>
</groups>
<tree>
<hidepatterns>*.o,*.lo,CVS</hidepatterns>
<hidenonprojectfiles>false</hidenonprojectfiles>
<showvcsfields>false</showvcsfields>
</tree>
</kdevfileview>
<kdevdoctreeview>
<ignoretocs>
<toc>gtk</toc>
<toc>gnustep</toc>
<toc>python</toc>
<toc>php</toc>
<toc>perl</toc>
</ignoretocs>
<projectdoc>
<userdocDir>html/</userdocDir>
<apidocDir>html/</apidocDir>
</projectdoc>
<ignoreqt_xml/>
<ignoredoxygen/>
<ignorekdocs/>
<ignoredevhelp/>
</kdevdoctreeview>
<kdevdebugger>
<general>
<dbgshell>libtool</dbgshell>
<programargs/>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
</general>
<display>
<staticmembers>true</staticmembers>
<demanglenames>true</demanglenames>
<outputradix>10</outputradix>
</display>
</kdevdebugger>
<kdevcppsupport>
<references/>
<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>
</kdevcppsupport>
<kdevfilecreate>
<filetypes/>
<useglobaltypes/>
</kdevfilecreate>
<cppsupportpart>
<filetemplates>
<interfacesuffix>.h</interfacesuffix>
<implementationsuffix>.cpp</implementationsuffix>
</filetemplates>
</cppsupportpart>
<dist>
<custom>false</custom>
<bzip>false</bzip>
<archname/>
<appname/>
<version/>
<release/>
<vendor/>
<licence/>
<summary/>
<group/>
<packager/>
<description/>
<changelog/>
<devpackage>false</devpackage>
<docspackage>false</docspackage>
<appicon>false</appicon>
<arch>0</arch>
<genHTML>false</genHTML>
<useRPM>false</useRPM>
<ftpkde>false</ftpkde>
<appskde>false</appskde>
<url/>
</dist>
<kdevcvsservice>
<recursivewhenupdate>true</recursivewhenupdate>
<prunedirswhenupdate>true</prunedirswhenupdate>
<createdirswhenupdate>true</createdirswhenupdate>
<recursivewhencommitremove>true</recursivewhencommitremove>
<revertoptions>-C</revertoptions>
</kdevcvsservice>
</kdevelop>

@ -0,0 +1,53 @@
%define name krename
%define version 3.0.14
Summary: A powerfull batch renamer for KDE
Name: %{name}
Version: %{version}
Release: 1
License: GPL
Vendor: Dominik Seichter <domseichter@web.de>
Url: http://krename.sourceforge.net
Packager: Dominik Seichter <domseichter@web.de>
Group: kde/utilities
Source: %{name}-%{version}.tar.bz2
BuildRoot: /var/tmp/%{name}-%{version}
%description
Krename is a very powerful batch file renamer for KDE3 which can rename a list of files based on a set of expressions. It can copy/move the files to another directory or simply rename the input files. Krename supports many conversion operations, including conversion of a filename to lowercase or to uppercase, conversion of the first letter of every word to uppercase, adding numbers to filenames, finding and replacing parts of the filename, and many more. It can also change access and modification dates, permissions, and file ownership.
%prep
%setup
%build
# Look for common rpm-options:
if [ -f /etc/opt/kde3/common_options ]; then
. /etc/opt/kde3/common_options
./configure $configkde
else
./configure
fi
# Setup for parallel builds
numprocs=`egrep -c ^cpu[0-9]+ /proc/stat || :`
if [ "$numprocs" = "0" ]; then
numprocs=1
fi
make -j$numprocs
%install
make install-strip DESTDIR=$RPM_BUILD_ROOT
cd $RPM_BUILD_ROOT
find . -type d | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' > $RPM_BUILD_DIR/master.list
find . -type f | sed 's,^\.,\%attr(-\,root\,root) ,' >> $RPM_BUILD_DIR/master.list
find . -type l | sed 's,^\.,\%attr(-\,root\,root) ,' >> $RPM_BUILD_DIR/master.list
%clean
cd $RPM_BUILD_DIR
rm -rf $RPM_BUILD_ROOT
rm -rf %{name}-%{version}
rm master.list
%files -f ../master.list

@ -0,0 +1,49 @@
## Makefile.am for KRename
# set the include path for X, qt and KDE
INCLUDES = -I$(top_srcdir)/src $(all_includes)
# these are the headers for your project
# let automoc handle all of the meta source files (moc)
METASOURCES = AUTO
KDE_ICON = AUTO
messages: rc.cpp
$(XGETTEXT) *.cpp -o $(podir)/kdedcoptest.pot
# this is the program that gets installed. it's name is used for all
# of the other Makefile.am variables
bin_PROGRAMS = krename
# the application source, library search path, and link libraries
krename_LDFLAGS = $(KDE_RPATH) $(all_libraries)
krename_LDADD =$(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET)
noinst_HEADERS = ProgressDialog.h dateplugin.h fileplugin.h kmylistbox.h krenameimpl.h \
pictureplugin.h tabs.h batchrenamer.h datetime.h firststartdlg.h \
kmylistview.h mydirplugin.h plugin.h threadedlister.h commandplugin.h \
dsdirselectdialog.h guimodeselector.h krecursivelister.h myinputdialog.h \
pluginloader.h translitplugin.h confdialog.h encodingplugin.h helpdialog.h \
krename.h numberdialog.h profiledlg.h undodialog.h coorddialog.h \
fileoperation.h kmyhistorycombo.h krenamedcop.h permission.h replacedialog.h \
wizard.h
krename_SOURCES = guimodeselector.cpp firststartdlg.cpp tabs.cpp \
krenameimpl.cpp numberdialog.cpp coorddialog.cpp commandplugin.cpp helpdialog.cpp \
pictureplugin.cpp mydirplugin.cpp datetime.cpp permission.cpp fileplugin.cpp \
undodialog.cpp myinputdialog.cpp kmylistview.cpp wizard.cpp replacedialog.cpp \
pluginloader.cpp plugin.cpp kmylistbox.cpp kmyhistorycombo.cpp fileoperation.cpp \
confdialog.cpp batchrenamer.cpp ProgressDialog.cpp main.cpp krecursivelister.cpp \
dsdirselectdialog.cpp krenamedcop.skel dateplugin.cpp encodingplugin.cpp profiledlg.cpp \
threadedlister.cpp translitplugin.cpp
xdg_apps_DATA = krename.desktop
krenameservice_DATA = krenameservicemenu.desktop krename_dir.desktop
krenameservicedir = $(kde_datadir)/konqueror/servicemenus
datafiles_DATA = logo.png krename_system_default_tabbed.xml krename_system_default_wizard.xml
datafilesdir = $(kde_datadir)/krename

@ -0,0 +1,360 @@
/***************************************************************************
ProgressDialog.cpp - description
-------------------
begin : Die Mai 15 15:34:19 CEST 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
// QT Includes
#include <qlayout.h>
#include <qprogressbar.h>
#include <qtimer.h>
#include <qtooltip.h>
#if QT_VERSION < 0x030100
#include <qregexp.h>
#endif
// KDE includes
#include <kapplication.h>
#include <kiconloader.h>
#include <klistview.h>
#include <klocale.h>
#include <kpopupmenu.h>
#include <kpushbutton.h>
#include <krun.h>
#include <qfile.h>
// Own includes
#include "ProgressDialog.h"
#include "krenameimpl.h"
#include "undodialog.h"
#include "fileoperation.h"
#define MNU_ERROR_ID 33999
#define MNU_DONE_ID 33998
// update user interface every 1/2 second
#define TIMER_INTERVAL 500
ProgressDialog::ProgressDialog( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
renamedFiles = NULL;
resize( 400, 380 );
setCaption( i18n("Progress") );
setIcon( BarIcon( "krename" ) );
ProgressDialogLayout = new QVBoxLayout( this, 11, 6 );
Layout1 = new QHBoxLayout( 0, 0, 6 );
QHBoxLayout* Layout2 = new QHBoxLayout( 0, 6, 6 );
bar = new QProgressBar( this );
bar->setProgress( 0 );
buttonCancel = new KPushButton( i18n("&Cancel"), this );
display = new KListView( this );
display->addColumn( i18n("Messages") );
display->addColumn( "sort" );
display->setColumnWidthMode( 0, QListView::Maximum );
display->setColumnWidthMode( 1, QListView::Manual );
display->setColumnWidth( 1, 0 );
display->setSorting( -1 );
display->setUpdatesEnabled( false );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
buttonUndo = new KPushButton( this );
buttonUndo->setText( i18n("&Undo") );
buttonUndo->setEnabled( false );
mnuButton = new KPopupMenu( this );
mnuButton->insertItem( i18n("Restart KRename..."), this, SLOT( restart() ));
mnuButton->insertSeparator();
mnuButton->insertItem( i18n("Rename Processed Files &Again..."), this, SLOT( again() ), 0, MNU_DONE_ID );
mnuButton->insertItem( i18n("Rename Unprocessed Files &Again..."), this, SLOT( unAgain() ), 0, MNU_ERROR_ID );
mnuButton->insertItem( i18n("Rename All Files &Again..."), this, SLOT( allAgain() ));
buttonRestart = new KPushButton( this );
buttonRestart->setText( i18n( "&Rename More..." ) );
buttonRestart->setPopup( mnuButton );
buttonRestart->setEnabled( false );
buttonOpenDest = new KPushButton( this );
buttonOpenDest->setText( i18n("&Open Destination...") );
buttonClose = new KPushButton( this );
buttonClose->setText( i18n( "&Close" ) );
buttonClose->setEnabled( false );
Layout1->addItem( spacer );
Layout1->addWidget( buttonUndo );
Layout1->addWidget( buttonRestart );
Layout1->addWidget( buttonOpenDest );
Layout1->addWidget( buttonClose );
Layout1->addItem( spacer );
Layout2->addWidget( bar );
Layout2->addWidget( buttonCancel );
Layout2->setStretchFactor( bar, 2 );
ProgressDialogLayout->addLayout( Layout2 );
ProgressDialogLayout->addWidget( display );
ProgressDialogLayout->addLayout( Layout1 );
connect( buttonClose, SIGNAL(clicked()), this, SLOT(quitAll()));
connect( buttonOpenDest, SIGNAL(clicked()), this, SLOT(openDest()));
connect( buttonCancel, SIGNAL( clicked()), this, SLOT(canceled() ));
connect( buttonUndo, SIGNAL( clicked() ), this, SLOT( undo() ) );
m_count = 0;
m_canceled = false;
m_timer = new QTimer( this, "m_timer" );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( slotTimer() ) );
hide();
}
ProgressDialog::~ProgressDialog()
{
delete m_timer;
if( renamedFiles )
delete [] renamedFiles;
}
void ProgressDialog::print( QString text, QString pixmap )
{
if( !m_timer->isActive() )
{
KApplication::setOverrideCursor( Qt::waitCursor );
m_timer->start( TIMER_INTERVAL );
}
// set an icon if we have none yet
if( pixmap.isNull() )
pixmap = "ok";
KListViewItem* item = new KListViewItem( display, text, count() );
item->setPixmap( 0, SmallIcon(pixmap) );
display->insertItem( item );
}
void ProgressDialog::error( QString text )
{
if( !m_timer->isActive() )
{
KApplication::setOverrideCursor( Qt::waitCursor );
m_timer->start( TIMER_INTERVAL );
}
//TODO: simplify this (breaks i18n)
KListViewItem* item = new KListViewItem( display, QString( i18n("Error: %1") ).arg( QString::null ) + simplify( text ), count() );
item->setPixmap( 0, SmallIcon("cancel") );
display->insertItem( item );
}
void ProgressDialog::warning( QString text )
{
if( !m_timer->isActive() )
{
KApplication::setOverrideCursor( Qt::waitCursor );
m_timer->start( TIMER_INTERVAL );
}
KListViewItem* item = new KListViewItem( display, QString( i18n("Warning: %1") ).arg( QString::null ) + simplify( text ), count() );
item->setPixmap( 0, SmallIcon("idea") );
display->insertItem( item );
}
void ProgressDialog::quitAll()
{
KApplication::exit(0);
}
void ProgressDialog::done( int errors, int successfull, bool allowundo )
{
m_timer->stop();
KApplication::restoreOverrideCursor();
display->setUpdatesEnabled( true );
display->setSorting( 1, true );
display->sort();
display->setSorting( -1 );
display->triggerUpdate();
display->ensureItemVisible( display->lastItem() );
bar->setProgress( bar->totalSteps() );
mnuButton->setItemEnabled( MNU_ERROR_ID, errors );
mnuButton->setItemEnabled( MNU_DONE_ID, successfull );
buttonClose->setEnabled( true );
buttonRestart->setEnabled( true );
if( allowundo )
buttonUndo->setEnabled( true );
buttonCancel->setEnabled( false );
kapp->processEvents( 0 );
}
void ProgressDialog::show()
{
QWidget::show();
int w = kapp->desktop()->width();
int h = kapp->desktop()->height();
move( (w-width())/2,(h-height())/2 );
}
void ProgressDialog::restart()
{
QWidget* krename = KRenameImpl::launch( QRect( 0, 0, 0, 0 ), KURL::List() );
krename->show();
close();
}
void ProgressDialog::again()
{
KURL::List list;
for( unsigned int i = 0; i < m_size; i++ )
if( !renamedFiles[i].error )
list.append( renamedFiles[i].dst );
QWidget* krename = KRenameImpl::launch( QRect( 0, 0, 0, 0 ), list );
krename->show();
close();
}
void ProgressDialog::unAgain()
{
KURL::List list;
for( unsigned int i = 0; i < m_size; i++ )
if( renamedFiles[i].error )
list.append( renamedFiles[i].src );
QWidget* krename = KRenameImpl::launch( QRect( 0, 0, 0, 0 ), list );
krename->show();
close();
}
void ProgressDialog::allAgain()
{
KURL::List list;
for( unsigned int i = 0; i < m_size; i++ )
list.append( renamedFiles[i].error ? renamedFiles[i].src : renamedFiles[i].dst );
QWidget* krename = KRenameImpl::launch( QRect( 0, 0, 0, 0 ), list );
krename->show();
close();
}
void ProgressDialog::openDest()
{
new KRun( m_dest );
}
QString ProgressDialog::count()
{
QString s;
return s.sprintf( "%0*i", 7, ++m_count );
}
void ProgressDialog::setProgressTotalSteps( int t )
{
bar->setTotalSteps( t );
}
void ProgressDialog::setProgress( int p )
{
m_timer->start( TIMER_INTERVAL );
bar->setProgress( p );
}
void ProgressDialog::canceled()
{
warning( i18n("User pressed cancel!") );
warning( i18n("Aborting...") );
m_canceled = true;
}
const QString ProgressDialog::simplify( const QString & text )
{
// make error messages fit in one line!
QString t( text );
#if QT_VERSION >= 0x030100
t.remove( '\n' );
#else
t.replace( QRegExp("\n"), "" );
#endif
return t;
}
void ProgressDialog::undo()
{
KURL::List list;
FileOperation fop;
m_timer->start( TIMER_INTERVAL );
KApplication::setOverrideCursor( Qt::waitCursor );
for( unsigned int i = 0; i < m_size; i++ )
{
setProgress( i );
list.append( renamedFiles[i].src );
if( !renamedFiles[i].error )
{
if( renamedFiles[i].dir ) {
/** handle renamed directories and their contents
*/
QString ddir = renamedFiles[i].dst.path();
QString sdir = renamedFiles[i].src.path();
for( unsigned int c = i+1; c < m_size; c++ ) {
QString dpath = renamedFiles[c].dst.path();
QString spath = renamedFiles[c].src.path();
if( spath.startsWith( ddir ) )
{
spath = sdir + spath.right( spath.length() - ddir.length() );
renamedFiles[c].src.setPath( spath );
}
if( dpath.startsWith( ddir ) )
{
dpath = sdir + dpath.right( dpath.length() - ddir.length() );
renamedFiles[c].dst.setPath( dpath );
}
}
}
if(!fop.start( renamedFiles[i].dst, renamedFiles[i].src, MOVE, false ))
error( i18n("Undo: ") + fop.error() );
}
}
print( i18n("Undoing the renaming operation has been completed."), "undo" );
m_timer->stop();
KApplication::restoreOverrideCursor();
QWidget* krename = KRenameImpl::launch( QRect( 0, 0, 0, 0 ), list );
krename->show();
close();
}
void ProgressDialog::slotTimer()
{
kapp->processEvents( 0 );
}

@ -0,0 +1,129 @@
/***************************************************************************
ProgressDialog.h - description
-------------------
begin : Die Mai 15 15:34:19 CEST 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef PROGRESSDIALOG_H
#define PROGRESSDIALOG_H
#include <qwidget.h>
#include <kurl.h>
typedef struct RenamedList
{
KURL src;
KURL dst;
bool dir;
bool error;
};
class KRenameImpl;
class KListView;
class KPopupMenu;
class KPushButton;
class QProgressBar;
class QStringList;
class QStrList;
class QString;
class QTimer;
class QHBoxLayout;
class QVBoxLayout;
class ProgressDialog : public QWidget
{
Q_OBJECT
public:
ProgressDialog( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~ProgressDialog();
void setProgressTotalSteps( int t );
void setProgress( int p );
inline bool wasCancelled() const;
inline void setDestination( const KURL & dir );
inline void setRenamedFiles( RenamedList* list, unsigned int size ) ;
inline void setCreatedDirectories( const KURL::List & list );
void done( int errors, int successfull, bool allowundo );
void print( QString text, QString pixmap = 0 );
void error( QString text );
void warning( QString text );
public slots:
void show();
private slots:
void quitAll();
void restart();
void again();
void unAgain();
void allAgain();
void openDest();
void canceled();
void undo();
void slotTimer();
private:
QString count();
const QString simplify( const QString & text );
protected:
RenamedList* renamedFiles;
unsigned int m_size;
KURL m_dest;
int m_count;
bool m_canceled;
KURL::List m_created;
QTimer* m_timer;
KListView* display;
KPushButton* buttonClose;
KPushButton* buttonRestart;
KPushButton* buttonOpenDest;
KPushButton* buttonUndo;
KPushButton* buttonCancel;
KPopupMenu* mnuButton;
QProgressBar* bar;
QVBoxLayout* ProgressDialogLayout;
QHBoxLayout* Layout1;
};
bool ProgressDialog::wasCancelled() const
{
return m_canceled;
}
void ProgressDialog::setDestination( const KURL & dir )
{
m_dest = dir;
}
void ProgressDialog::setRenamedFiles( RenamedList* list, unsigned int size )
{
renamedFiles = list;
m_size = size;
}
void ProgressDialog::setCreatedDirectories( const KURL::List & list )
{
m_created = list;
}
#endif // PROGRESSDIALOG_H

@ -0,0 +1,950 @@
/***************************************************************************
batchrenamer.cpp - description
-------------------
begin : Sat Aug 18 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef VERSION
#define VERSION "unknown"
#endif
// OS includes
#include <stdio.h>
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
// chmod:
#include <sys/types.h>
#include <sys/stat.h>
// QT includes
#include <qdir.h>
#include <qregexp.h>
// KDE includes
#include <kapplication.h>
#include <kio/job.h>
#include <kio/netaccess.h>
#include <klocale.h>
// Own includes
#include "ProgressDialog.h"
#include "batchrenamer.h"
#include "fileoperation.h"
#include "pluginloader.h"
#include "kmylistview.h"
using namespace KIO;
BatchRenamer::BatchRenamer()
: m_index( 0 )
{
plug = PluginLoader::instance();
m_counter_index = 0;
}
BatchRenamer::~BatchRenamer()
{
}
void BatchRenamer::processFiles( ProgressDialog* p, QObject* object )
{
delete object;
t.start();
m_counters.clear();
for( unsigned int i = 0; i < m_files.count(); i++)
{
m_counter_index = 0;
if( m_mode == RENAME ) {// final Path = source Path
m_files[i].dst.directory = m_files[i].src.directory;
m_files[i].dst.url = m_files[i].src.url;
m_files[i].dst.url.setFileName( QString::null );
} else {
m_files[i].dst.directory = dirname.path();
m_files[i].dst.url = dirname;
}
if( i == 0 )
p->setDestination( m_files[i].dst.url );
else
{
if( m_reset )
findCounterReset( i );
}
m_files[i].dst.name = processString( text, m_files[i].src.name, i );
if( !extext.isEmpty() )
m_files[i].dst.extension = processString( extext, m_files[i].src.extension, i );
(void)applyManualChanges( i );
// Assemble filenames
parseSubdirs( &m_files[i] );
// TODO: DOM
// ESCAPE HERE
m_files[i].src.name = BatchRenamer::buildFilename( &m_files[i].src, true );
// Let's run the plugins that change the final filename,
// i.e the encodingsplugin
m_files[i].dst.name = parsePlugins( i, m_files[i].dst.name, TYPE_FINAL_FILENAME );
m_files[i].dst.name = BatchRenamer::buildFilename( &m_files[i].dst, true );
/*
* take care of renamed directories and
* correct the paths of their contents
*/
if( m_files[i].dir && (m_mode == RENAME || m_mode == MOVE) ) {
for( unsigned int c = i; c < m_files.count(); c++ ) {
if( m_files[c].src.directory.left( m_files[i].src.name.length() + 1 )
== ( m_files[i].src.name + "/" ) ) {
m_files[c].src.directory.replace( 0, m_files[i].src.name.length(), m_files[i].dst.name );
m_files[c].src.url.setPath( BatchRenamer::buildFilename( &m_files[c].src, true ) );
}
}
}
}
p->print( QString( i18n("Filenames Processed after %1 seconds.")).arg(t.elapsed()/1000) );
work( p );
}
QString BatchRenamer::processString( QString text, QString oldname, int i )
{
/*
* Come on! Grep for this text and help me!
*
* note about krename escape sequences
* for certain characters:
*
* Krename will have problems with files
* which contain one of the following
* unicode characters: 60000, 60001, 60002
* 60003, 60004, 60005, 60006.
*
* This is not a good solution, if you have a
* better one please tell me about it!
*/
doEscape( oldname );
/*
* Call here all functions that handle
* arguments that are single tokens (&,%,...).
* or in [brackets]
*/
text = findBrackets( oldname, text, i );
text = findAndProcess( "$", text, oldname );
text = findAndProcess( "%", text, oldname.lower() );
text = findAndProcess( "&", text, oldname.upper() );
text = findAndProcess( "\\", text, oldname.stripWhiteSpace() );
text = findStar( oldname, text );
text = findNumbers( text, m_files.count(), i );
/*
* text is used as argument token for plugins!
*/
text = parsePlugins( i, text, TYPE_TOKEN );
/*
* Replace after Plugins !
* Replace shoud be the last the
* before re-escaping tokens !
*/
text = findReplace( text );
// convert special chars back (e.g. &,$)
// TODO: this is to early, because
// parseSubdirs creates subdirectories
// for "/" returned by plugins!!!!
// text = unEscape( text );
return text;
}
QString BatchRenamer::parsePlugins( int i, const QString& text, int type )
{
QPtrListIterator<PluginLoader::PluginLibrary> it( plug->libs );
QString ret = text;
if( type == TYPE_FINAL_FILE )
ret = "";
for( ; it.current(); ++it )
if( (*it)->usePlugin && (*it)->plugin->type() == type )
{
ret = (*it)->plugin->processFile( this, i, text, type );
doEscape( ret );
}
return ret;
}
void BatchRenamer::createPreview( QListView* list )
{
KMyListViewItem* item1 = NULL;
QString tmp;
m_counters.clear();
for( unsigned int i = 0; i < m_files.count(); i++)
{
m_counter_index = 0;
if( i && m_reset )
findCounterReset( i );
m_files[i].dst.name = processString( text, m_files[i].src.name, i );
if( !extext.isEmpty() )
m_files[i].dst.extension = processString( extext, m_files[i].src.extension, i );
bool modified = applyManualChanges( i );
QString sname = BatchRenamer::buildFilename( &m_files[i].src, false );
// Let's run the plugins that change the final filename,
// i.e the encodingsplugin
m_files[i].dst.name = parsePlugins( i, m_files[i].dst.name, TYPE_FINAL_FILENAME );
QString dname = BatchRenamer::buildFilename( &m_files[i].dst, false );
item1 = new KMyListViewItem( modified, list, item1, sname, dname );
}
}
void BatchRenamer::work( ProgressDialog* p )
{
// TODO: use CopyJob here
FileOperation fop;
QFile* fundo ( NULL );
QTextStream* tundo ( NULL );
if( undo ) {
// Create header for undo script
fundo = new QFile( m_undoScript );
if( fundo->open( IO_WriteOnly ) ) {
tundo = new QTextStream( fundo );
writeUndoScript( tundo );
} else {
undo = false;
p->error( i18n("Can't create undo script :") + fundo->name() );
delete fundo;
}
}
int error = 0;
RenamedList* renamedFiles = new RenamedList[m_files.count()];
p->setProgressTotalSteps( m_files.count() + 1 );
/*
* Give the user some information...
*/
if( m_mode == COPY)
p->print( QString( i18n("Files will be copied to: %1") ).arg(m_files[0].dst.directory) );
else if( m_mode == MOVE )
p->print( QString( i18n("Files will be moved to: %1") ).arg(m_files[0].dst.directory) );
else if( m_mode == LINK )
p->print( QString( i18n("Symbolic links will be created in: %1") ).arg(m_files[0].dst.directory) );
else if( m_mode == RENAME )
p->print( i18n("Input files will be renamed.") );
unsigned int i;
for( i = 0; i < m_files.count(); i++) {
p->setProgress( i+1 );
if( p->wasCancelled() )
break;
KURL src = m_files[i].src.url;
KURL dst = m_files[i].dst.url;
dst.setPath( m_files[i].dst.name );
renamedFiles[i].src = src;
renamedFiles[i].dst = dst;
renamedFiles[i].dir = m_files[i].dir;
FileOperation fop;
if( !fop.start( src, dst, m_mode, overwrite ) ) {
p->error( fop.error() );
renamedFiles[i].error = true;
error++;
continue;
} else {
renamedFiles[i].error = false;
}
// TODO: overwriting of files!
/*
* The renamed file should be on its correct location now,
* so that we can call the last plugins (e.g. for changing permissions)
*
* Remember, the token argument is the filename for this type of plugins!
*
* If the return value is not empty an error has occured!
* The plugin should return an error message in this case!
*/
QString eplug = parsePlugins( i, QString::null, TYPE_FINAL_FILE );
if( !eplug.isEmpty() ) {
p->error( eplug );
error++;
}
/* Create the undo script now */
if( undo )
if( dst.isLocalFile() && src.isLocalFile() ) {
// Plugins ???
(*tundo) << "echo \"" << src.fileName()
<< " -> " << dst.fileName() << "\"" << endl;
(*tundo) << "mv --force -b --suffix=.krename_ \"" << m_files[i].dst.name
<< "\" \"" << m_files[i].src.name << "\"" << endl;
} else
p->warning( QString( i18n("Undo is not possible for remote file: %1") ).arg( dst.prettyURL() ) );
}
if( !p->wasCancelled() ) {
QPtrListIterator<PluginLoader::PluginLibrary> it( plug->libs );
for( ; it.current(); ++it ) {
if( (*it)->usePlugin )
(*it)->plugin->finished();
}
}
const QString m = QString( i18n("Renamed %1 files successfully.") ).arg(i-error);
( i - error ) ? p->print( m ) : p->warning( m );
if( error > 0 )
p->warning( QString( i18n("%2 errors occurred!") ).arg(error));
p->print( QString( i18n("Elapsed time: %1 seconds") ).arg( t.elapsed()/1000 ), "kalarm" );
p->print( i18n("KRename finished the renaming process."), "krename" );
p->print( i18n("Press close to quit!") );
p->setRenamedFiles( renamedFiles, m_files.count() );
if( undo ) {
(*tundo) << endl << "echo \"Finished undoing " << m_files.count() << " actions.\"" << endl;
delete tundo;
fundo->close();
// Make fundo exuteable
if( chmod( (const char*)m_undoScript, (unsigned int) S_IRUSR | S_IWUSR | S_IXUSR ) )
p->error( i18n("Can't set executable bit on undo script.") );
delete fundo;
}
p->done( error, i-error, m_mode == MOVE || m_mode == RENAME );
m_files.clear();
delete this;
}
void BatchRenamer::escape( QString & text, const QString & token, const QString & sequence )
{
/*
* NEVER, ABSOLUTELY NEVER change pos = 0
* to pos = -1, it won't work !
* This bug took hours to find and was
* a serious bug in 1.7.
*/
#if QT_VERSION >= 0x030100
text.replace( token, sequence );
#else
int pos = 0;
do {
pos = text.find( token, pos );
if( pos >= 0 )
text.replace( pos, token.length(), sequence );
} while ( pos >= 0 );
#endif
}
QString & BatchRenamer::doEscape( QString & text, bool filename )
{
if( filename ) {
BatchRenamer::escape( text, "&", QChar( 60000 ) );
BatchRenamer::escape( text, "$", QChar( 60001 ) );
BatchRenamer::escape( text, "%", QChar( 60002 ) );
BatchRenamer::escape( text, "#", QChar( 60004 ) );
BatchRenamer::escape( text, "[", QChar( 60005 ) );
BatchRenamer::escape( text, "]", QChar( 60006 ) );
BatchRenamer::escape( text, "\\", QChar( 60007 ) );
BatchRenamer::escape( text, "/", QChar( 60008 ) );
BatchRenamer::escape( text, "{", QChar( 60009 ) );
BatchRenamer::escape( text, "}", QChar( 60010 ) );
BatchRenamer::escape( text, "*", QChar( 60011 ) );
} else {
BatchRenamer::escape( text, "\\&", QChar( 60000 ) );
BatchRenamer::escape( text, "\\$", QChar( 60001 ) );
BatchRenamer::escape( text, "\\%", QChar( 60002 ) );
BatchRenamer::escape( text, "\\#", QChar( 60004 ) );
BatchRenamer::escape( text, "\\[", QChar( 60005 ) );
BatchRenamer::escape( text, "\\]", QChar( 60006 ) );
BatchRenamer::escape( text, "\\\\", QChar( 60007 ) );
BatchRenamer::escape( text, "\\/", QChar( 60008 ) );
BatchRenamer::escape( text, "\\{", QChar( 60009 ) );
BatchRenamer::escape( text, "\\}", QChar( 60010 ) );
BatchRenamer::escape( text, "\\*", QChar( 60011 ) );
}
return text;
}
QString & BatchRenamer::unEscape( QString & text )
{
BatchRenamer::escape( text, QChar( 60000 ), "&" );
BatchRenamer::escape( text, QChar( 60001 ), "$" );
BatchRenamer::escape( text, QChar( 60002 ), "%" );
BatchRenamer::escape( text, QChar( 60004 ), "#" );
BatchRenamer::escape( text, QChar( 60005 ), "[" );
BatchRenamer::escape( text, QChar( 60006 ), "]" );
BatchRenamer::escape( text, QChar( 60007 ), "\\" );
// %252f == /, it seems that filenames on unix cannot contain
// a /. So I use %252f, at least konqui displays it correctly
// this was needed, so that plugins that return a slash do not cause errors
BatchRenamer::escape( text, QChar( 60008 ), "%2f" );
BatchRenamer::escape( text, QChar( 60009 ), "{" );
BatchRenamer::escape( text, QChar( 60010 ), "}" );
BatchRenamer::escape( text, QChar( 60011 ), "*" );
return text;
}
int BatchRenamer::getCharacters( int n )
{
QString s;
s.sprintf( "%i", n );
return s.length();
}
QString BatchRenamer::findAndProcess( const QString & token, QString text, const QString & replace )
{
/*
* pos can here be -1 because
* findRev is called with it as a
* value !
*/
#if QT_VERSION >= 0x030100
text.replace( token, replace );
#else
int pos = -1;
do {
pos = text.findRev( token, pos );
if( pos >= 0 )
text.replace( pos, token.length(), replace );
} while( pos >= 0 );
#endif
return text;
}
QString BatchRenamer::findNumbers( QString text, int count, int i )
{
// Rewritten in Version 0.8
// Added numbers skipping in 1.3
// Changed again in Version 1.8 to optimize it and fix a bug with skipping numbers
int pos = 0, counter = 1;
tCounterValues countervalues;
countervalues.start = m_index;
countervalues.step = m_step;
if( text.contains( "#", FALSE ) <= 0 )
return text;
pos = text.find("#", pos);
pos++;
while( text[pos] == '#' ) {
text.remove(pos, 1);
counter++;
}
findNumberAppendix( text, pos, &countervalues.start, &countervalues.step );
pos = text.find("#", 0);
if( (signed int)m_counters.count() <= m_counter_index )
{
countervalues.value = countervalues.start - countervalues.step;
// other wise the counter would start at:
// start + step instead of start
m_counters.append( countervalues );
}
do {
m_counters[m_counter_index].value += m_counters[m_counter_index].step;
} while( m_skip.contains( m_counters[m_counter_index].value ) );
/*
int v = start + (i*step) + m_skip_add[m_counter_index];
for( unsigned int z = 0; z < m_skip.count(); z++ ) {
if( m_skip[z] == v ) {
m_skip_add[m_counter_index] += step;
v += step;
}
}
*/
QString temp;
temp.sprintf("%0*i", counter, m_counters[m_counter_index].value );
text.replace( pos, 1, temp);
++m_counter_index;
return findNumbers( text, count, i );
}
void BatchRenamer::findNumberAppendix( QString & text, int pos, int* start, int* step )
{
QString appendix = QString::null;
int tmp = 0;
int end = 0;
bool ok = false;
if( text[pos] == '{' && (end = text.find( "}", pos )) > -1)
{
//qDebug("Found an appendix:" + appendix );
appendix = text.mid( pos + 1, end - pos - 1);
text.remove( pos, end - pos + 1 );
tmp = appendix.section( ';', 0, 0 ).toInt( &ok ); // first section = start index
if( ok )
*start = tmp;
tmp = appendix.section( ';', 1, 1 ).toInt( &ok ); // second section = stepping
if( ok )
*step = tmp;
}
}
QString BatchRenamer::findStar( const QString & oldname, QString text )
{
int pos = -1;
do {
pos = text.findRev("*", pos);
if( pos >= 0 ) {
QString tmp = oldname.lower();
if( tmp[0].isLetter() )
tmp[0] = tmp[0].upper();
for( unsigned int i = 0; i < tmp.length(); i++ )
if( tmp[i+1].isLetter() && !tmp[i].isLetter() &&
tmp[i] != '\'' && tmp[i] != '?' && tmp[i] != '`' )
tmp[i+1] = tmp[i+1].upper();
text.replace( pos, 1, tmp);
}
} while( pos >= 0 );
return text;
}
QString BatchRenamer::findBrackets( QString oldname, QString text, int i )
{
/*
* looks for a statement in brackets [ ]
* and calls findToken() with this statement.
*/
int num, pos = -1, a;
QString token;
if( text.contains("]", FALSE) <= 0 || text.isEmpty() )
return text;
num = text.contains("[", FALSE);
if(num <= 0 )
return text;
pos = text.findRev("[", pos);
a = text.find("]", pos );
if( a < 0 && pos >= 0 )
return text;
if( pos < 0 && a >= 0 )
return text;
if( pos >= 0 && a >= 0 ) {
token = text.mid( pos+1, (a-pos)-1 );
// support [4-[length]]
token = findBrackets( oldname, token, i );
text.remove( pos, (a-pos)+1 );
text.insert( pos, findToken( oldname, token, i ));
}
return findBrackets( oldname, text, i );
}
QString BatchRenamer::processToken( QString token, QString oldname, int i )
{
QString tmp;
/*
* Call here all functions that handle
* arguments in brackets.
*/
tmp = findPartStrings( oldname, token );
if( !tmp.isEmpty() )
return tmp;
tmp = findDirName( token, m_files[i].src.directory );
if( !tmp.isEmpty() )
return tmp;
tmp = findLength( token, m_files[i].src.name );
if( !tmp.isEmpty() )
return tmp;
Plugin* p = plug->findPlugin( token );
if( p )
{
tmp = p->processFile( this, i, token, TYPE_BRACKET );
if( !tmp.isNull() )
{
doEscape( tmp );
return tmp;
}
}
/*
* Maybe I should remove this!
* Krename simply ignores unknown tokens!
* Usefull for the MP3 Plugin!
*/
return QString::null;
}
QString BatchRenamer::findToken( QString oldname, QString token, int i )
{
enum conversion { LOWER, UPPER, MIXED, STAR, STRIP, NONE, EMPTY, NUMBER };
unsigned int numwidth = 0;
conversion c = EMPTY;
if( !token.left(1).compare("$") )
c = NONE;
else if( !token.left(1).compare("%") )
c = LOWER;
else if( !token.left(1).compare("&") )
c = UPPER;
else if( !token.left(1).compare("") )
c = MIXED;
else if( !token.left(1).compare("*") )
c = STAR;
else if( !token.left(1).compare("\\") )
c = STRIP;
else if( !token.left(1).compare("#") ) {
while( !token.left(1).compare("#") ) {
token.remove( 0, 1 );
++numwidth;
}
c = NUMBER;
}
if( c != EMPTY && c != NUMBER )
token.remove( 0, 1 );
QString save = token;
token = processToken( token, oldname, i );
switch( c ) {
case LOWER:
token = token.lower();
break;
case UPPER:
token = token.upper();
break;
case MIXED:
token = token.lower();
token.replace( 0, 1, token[0].upper());
break;
case STAR:
token = findStar( token, "*" );
break;
case STRIP:
token = token.stripWhiteSpace();
break;
case NUMBER:
{
bool b = false;
int n = token.toInt( &b );
if( b )
token = token.sprintf("%0*i", numwidth, n );
}
break;
default:
break;
}
doEscape( token );
return token;
}
QString BatchRenamer::findPartStrings( QString oldname, QString token )
{
QString first, second;
int pos = -1;
// parse things like [2;4{[dirname]}]
if( token.contains( "{" ) >= 1 && token.contains( "}" ) >= 1 ) {
int pos = token.find( "{" );
oldname = token.mid( pos + 1, token.findRev( "}" ) - pos - 1 );
token = token.left( pos );
}
if( token.contains("-") ) {
pos = token.find( "-", 0 );
first = token.left( pos );
// ------- Code OK ^ !
second = token.mid( pos+1, token.length() );
// version < 1.7
// return oldname.mid( first.toInt()-1, second.toInt()-first.toInt() +1 );
// version > 1.7
//return oldname.mid( first.toInt()-1, second.toInt()-first.toInt() );
// version > 1.8
bool ok;
int sec = second.toInt( &ok );
if( !ok || sec == 0 )
sec = oldname.length();
/*
* x should not be larger than the old name
* and not smaller than zero.
*/
int x = sec-first.toInt();
if( x > (signed int)oldname.length() || x < 0 )
x = oldname.length()-first.toInt();
/*
* if I would comment my code I would understand this line :)
* without this line, there is sometimes the last letter
* of a filename missing.
*/
if( x != -1 )
x++;
return oldname.mid( first.toInt()-1, x );
} else if( token.contains(";") ) {
pos = token.find( ";", 0 );
first = token.left( pos );
second = token.mid( pos+1, token.length() );
return oldname.mid( first.toInt()-1, second.toInt() );
} else {
bool ok = false;
int number = token.toInt( &ok );
if( ok && (number <= (signed int)oldname.length() && number > 0 ) )
return QString(oldname[ number -1 ]);
else
return QString::null;
}
}
QString BatchRenamer::findDirName( QString token, QString path )
{
if( token.left( 7 ).lower() == "dirname" ) {
if( path.right( 1 ) == "/" )
path = path.left( path.length() - 1);
int recursion = 1;
if( token.length() > 7 ) {
token = token.right( token.length() - 7 );
recursion = token.contains( "." );
if( recursion != (signed int)token.length() )
return QString::null;
recursion++;
}
return path.section( "/", recursion * -1, recursion * -1);
}
return QString::null;
}
QString BatchRenamer::findLength( const QString & token, const QString & name )
{
if( token.lower().startsWith( "length" ) ) {
int minus = 0;
if( token[6] == '-' ) {
bool n = false;
minus = token.mid( 7, token.length() - 7 ).toInt( &n );
if( !n )
minus = 0;
}
return QString::number( name.length() - minus );
}
return QString::null;
}
QString BatchRenamer::findReplace( QString text )
{
// Call for each element in replace strings doReplace with correct values
for( unsigned int i = 0; i < m_replace.count(); i++ ) {
replacestrings s = m_replace[i];
text = doReplace( text, unEscape( s.find ), s.replace, s.reg );
}
return text;
}
QString BatchRenamer::doReplace( QString text, QString find, QString replace, bool reg )
{
if( !reg )
{
#if QT_VERSION >= 0x030100
// we use the escaped text here because the user might want
// to find a "&" and replace it
text.replace( doEscape( find ), replace );
#else
int pos = 0;
QString f = doEscape( find );
do {
pos = text.find( f, pos );
if( pos >= 0 ) {
text.replace( pos, f.length(), replace );
pos += replace.length();
}
} while( pos >= 0 );
#endif
}
else
{
#if QT_VERSION >= 0x030100
// no doEscape() here for the regexp, because it would destroy our regular expression
// other wise we will not find stuff like $, [ in the text
text = doEscape( unEscape( text ).replace( QRegExp( find ), replace ) );
#else
// Test this code more!
pos = 0;
do {
QRegExp exp( find );
pos = exp.search( text, pos );
if( pos >= 0 ) {
text = doEscape( unEscape( text ).replace( pos, exp.matchedLength(), replace ) );
pos += replace.length();
}
} while( pos >= 0 );
#endif
}
return text;
}
void BatchRenamer::writeUndoScript( QTextStream* t )
{
// write header comments
(*t) << "#!/bin/bash" << endl
<< "# KRename Undo Script" << endl << "#" << endl
<< "# KRename was written by:" << endl
<< "# Dominik Seichter <domseichter@web.de>" << endl
<< "# http://krename.sourceforge.net" << endl << "#" << endl
<< "# Script generated by KRename Version: " << VERSION << endl << endl
<< "# This script must be started with the option --krename to work!" << endl;
// write functions:
(*t) << "echo \"KRename Undo Script\"" << endl
<< "echo \"http://krename.sourceforge.net\"" << endl
<< "echo \"\"" << endl;
(*t) << "if test --krename = $1 ; then" << endl
<< " echo \"\"" << endl
<< "else" << endl
<< " echo \"You have to start this script\"" << endl
<< " echo \"with the command line option\"" << endl
<< " echo \"--krename\"" << endl
<< " echo \"to undo a rename operation.\"" << endl
<< " exit" << endl
<< "fi" << endl;
}
void BatchRenamer::parseSubdirs( data* f )
{
int pos = 0;
if( (pos = f->dst.name.findRev( "/", -1 ) ) > 0 ) {
QString dirs = f->dst.name.left( pos );
f->dst.name = f->dst.name.right( f->dst.name.length() - pos - 1 );
f->dst.directory += ( f->dst.directory.right( 1 ) == "/" ) ? "" : "/";
// create the missing subdir now
int i = 0;
QString d = "";
while( (d = dirs.section( "/", i, i, QString::SectionSkipEmpty )) && ! d.isEmpty() ) { // asignment here!
KURL url = f->dst.url;
// it is important to unescape here
// to support dirnames containing "&" or
// similar tokens
url.addPath( unEscape( d ) );
if( !NetAccess::exists( url ) && !NetAccess::mkdir( url ) )
// TODO: GUI bug report
qDebug("Can't create %s", url.prettyURL().latin1() );
f->dst.url.addPath( d );
f->dst.directory.append( d + "/" );
i++;
}
}
}
QString BatchRenamer::buildFilename( fileentry* entry, bool dir )
{
QString filename = ( dir ? entry->directory : QString::null ) + entry->name + ( entry->extension.isEmpty() ? QString::null : QString(".") ) + entry->extension;
// unescape here as filename is still escaped
unEscape( filename );
return filename;
}
bool BatchRenamer::applyManualChanges( int i )
{
/*
* The last step: make changes of
* the user visible
*/
if( !m_changes.isEmpty() )
for( unsigned int z = 0; z < m_changes.count(); z++ ) {
KURL file = m_changes[z].url;
if( file == m_files[i].src.url ) {
m_files[i].dst.name = m_changes[z].user;
// the file extension is already included
// in the users name
m_files[i].dst.extension = QString::null;
return true;
}
}
return false;
}
void BatchRenamer::findCounterReset( int i )
{
int z;
if( m_files[i-1].src.directory != m_files[i].src.directory )
for( z=0;z<(int)m_counters.count();z++ )
{
m_counters[z].value = m_counters[z].start - m_counters[z].step;
}
}

@ -0,0 +1,188 @@
/***************************************************************************
batchrenamer.h - description
-------------------
begin : Sat Aug 18 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef BATCHRENAMER_H
#define BATCHRENAMER_H
#include <qdatetime.h>
#include <qvaluelist.h>
#include <kurl.h>
class QFile;
class QProgressDialog;
class QString;
/* How many diferrent users and groups
* KRename supports. Values over 1000
* make KRename slow, but it may be
* necessary on bigger systems to
* increase this value.
* MAXENTRIES must be < sizeof(int)
*/
#define MAXENTRIES 1000
/* May Value for SpinBoxes
*
*/
#define SPINMAX 100000
enum {
COPY, MOVE, RENAME, PREVIEW, LINK
};
typedef struct fileentry {
QString name; // filename
QString directory; // directory
QString extension; // extension
KURL url;
};
typedef struct data {
fileentry src;
fileentry dst;
bool dir;
};
/*
* Changes made by hand by the user
* in the preview list view are
* stored here.
*/
typedef struct manualchanges {
KURL url; // input filename
QString user; // name the user wants
};
typedef struct replacestrings {
QString find; // Text to replace
QString replace; // Replace with
bool reg; // is it a reg expression ?
};
typedef struct tCounterValues {
int value; // current value of this counter
int start; // start value of this counter (for findResetCounter)
int step; // stepping value of this counter;
};
/**
*@author Dominik Seichter
*/
class QObject;
class QListView;
class ProgressDialog;
class PluginLoader;
class BatchRenamer {
public:
BatchRenamer();
~BatchRenamer();
void processFiles( ProgressDialog* p, QObject* object );
void createPreview( QListView* list );
inline void setText( const QString & t ) { text = t; doEscape( text, false ); }
inline void setExText( const QString & t ) { extext = t; }
inline void setDirname( const KURL & url ) { dirname = url; }
inline void setUndoScript( const QString & t ) { m_undoScript = t; }
inline void setUndo( bool b ) { undo = b; }
inline void setOverwrite( bool b ) { overwrite = b; }
inline void setIndex( int i ) { m_index = i; }
inline void setStep( int s ) { m_step = s; }
inline void setResetCounter( bool r ) { m_reset = r; }
inline void setSkipList( const QValueList<int> & s ) { m_skip = s; }
inline void setReplaceList( const QValueList<replacestrings> & r ) { m_replace = r; }
inline void setFiles( const QValueList<data> & f ) { m_files = f; } //TODO: use a pointer for more speed
inline QValueList<data> files() const { return m_files; }
inline void setChanges( const QValueList<manualchanges> & m ) { m_changes = m; }
inline void setMode( int m) { m_mode = m; }
inline int mode() const { return m_mode; }
// Since 2.1 public, because plugins may want to access them to:
QString findAndProcess( const QString & token, QString text, const QString & replace );
QString findNumbers( QString text, int count, int i );
QString findStar( const QString & oldname, QString text );
QString findBrackets( QString oldname, QString text, int i );
QString findToken( QString oldname, QString token, int i );
QString processToken( QString token, QString oldname, int i );
QString findPartStrings( QString oldname, QString token );
static QString findDirName( QString token, QString path );
QString findLength( const QString & token, const QString & name );
QString findReplace( QString text ); // text is here already the new filename !
QString doReplace( QString text, QString find, QString replace, bool reg ); // text is here already the new filename !
QString processString( QString text, QString oldname, int i );
static QString & doEscape( QString & text, bool filename = true );
static QString & unEscape( QString & text );
static void escape( QString & text, const QString & token, const QString & sequence );
static QString buildFilename( fileentry* entry, bool dir = true );
private:
/**
* Returns the length of the string when int n is converted to
* a string.
* @param n a number whose length as string is needed
* @returns stringlength of n converted to a string
*/
int getCharacters( int n ) ;
void work( ProgressDialog* p );
void writeUndoScript( QTextStream* t );
void parseSubdirs( data* f );
void findNumberAppendix( QString & text, int pos, int* start, int* step );
/** resets all counters to there start value if the directory name at @p i
* in m_files changes.
* The caller has to check m_reset before calling this function.
*/
void findCounterReset( int i );
QString parsePlugins( int i, const QString & text, int type );
bool applyManualChanges( int i );
QString text; // template
KURL dirname; // destination dir
QString extext; // Extension template
QString m_undoScript; // Filename of undoscript
bool undo; // create an undo script
int m_index; // index for numbers
int m_step; // step for numbers
bool m_reset; // reset counter on new directories
bool overwrite; // overwrite existing files
int m_mode; // renaming mode
QValueList<int> m_skip; // Numbers to skip
QValueList<replacestrings> m_replace; // Replace strings
QValueList<data> m_files;
QValueList<manualchanges> m_changes; // User made changes
PluginLoader* plug;
// a is used in find number and
// required for skipping.
int m_counter_index;
QValueList<tCounterValues> m_counters;
protected:
QFile* f;
QTime t;
QProgressDialog* progress;
};
#endif

@ -0,0 +1,200 @@
/***************************************************************************
commandplugin.cpp - description
-------------------
begin : Son Jan 5 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "commandplugin.h"
// QT includes
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
// KDE includes
#include <kapplication.h>
#include <kconfig.h>
#include <kiconloader.h>
#include <klocale.h>
#include <klineedit.h>
#include <klistbox.h>
#include <kmessagebox.h>
#include <kpushbutton.h>
#include <kprocess.h>
const QString CommandPlugin::getName() const
{
return i18n("Command Plugin");
}
const QString CommandPlugin::getAccelName() const
{
return i18n("&Command Plugin");
}
const int CommandPlugin::type() const
{
return TYPE_FINAL_FILE;
}
bool CommandPlugin::checkError()
{
if( commandline->text().isEmpty() ) {
KMessageBox::error( 0, i18n("You did not specify a command to execute.") );
return false;
}
return true;
}
void CommandPlugin::drawInterface( QWidget* w, QVBoxLayout* l )
{
m_widget = w;
QHBoxLayout* hb = new QHBoxLayout( 0, 0, 6 );
QVBoxLayout* vb = new QVBoxLayout( 0, 0, 6 );
QLabel* la = new QLabel( w );
la->setText( i18n("<b>Command Plugin</b>") );
l->addWidget( la );
la = new QLabel( w );
la->setText( i18n( "<qt>Executes a shell command on every file after it has been renamed. "
"Add %1 to the command line arguments to get the filename of the renamed file.</qt>") );
l->addWidget( la );
l->addWidget( new QLabel( i18n("Command:"), w ) );
commandline = new KLineEdit( w );
l->addWidget( commandline );
checkNoBlock = new QCheckBox( i18n("&Execute without blocking (not recommended)"), w );
l->addWidget( checkNoBlock );
buttonAdd = new KPushButton( i18n("&Add"), w );
buttonRemove = new KPushButton( i18n("&Remove"), w );
hb->addWidget( buttonAdd );
hb->addWidget( buttonRemove );
vb->addLayout( hb );
list = new KListBox( w );
vb->addWidget( list );
vb->setStretchFactor( list, 2 );
l->addLayout( vb );
connect( buttonAdd, SIGNAL( clicked() ), this, SLOT( add() ) );
connect( buttonRemove, SIGNAL( clicked() ), this, SLOT( remove() ) );
connect( list, SIGNAL( executed( QListBoxItem* ) ), this, SLOT( exec() ) );
KConfig* conf = kapp->config();
conf->setGroup("CommandPlugin");
list->insertStringList( conf->readListEntry("commandlines" ) );
QStringList examples;
examples.append( "chmod 0444 %1" );
examples.append( "convert %1 %1.png" );
examples.append( "echo %1 >> $HOME/file.list" );
// examples.append( ")
for( unsigned int i = 0; i < examples.count(); i++ )
if( !list->findItem( examples[i] ) )
list->insertItem( examples[i] );
}
void CommandPlugin::fillStructure()
{
command = commandline->text();
noblock = checkNoBlock->isChecked();
}
QString CommandPlugin::processFile( BatchRenamer* b, int i, QString, int )
{
QString filename = b->files()[i].dst.name;
QString c = command;
KShellProcess proc;
#if QT_VERSION >= 0x030100
c = c.replace( "%1", KShellProcess::quote( filename ) );
#else
int pos = 0;
do {
pos = c.find( "%1", pos );
if( pos >= 0 )
c.replace( pos, 2, KShellProcess::quote( filename ) );
} while ( pos >= 0 );
#endif
proc << c;
if( noblock )
proc.start( KProcess::DontCare, KProcess::NoCommunication );
else
proc.start( KProcess::Block, KProcess::NoCommunication );
proc.resume();
if( !noblock && proc.exitStatus() )
return command.arg( filename ) + QString( i18n(" exited with error: %1") ).arg( proc.exitStatus() );
return QString::null;
}
void CommandPlugin::finished()
{
KConfig* conf = kapp->config();
conf->setGroup("CommandPlugin");
QStringList slist;
for( unsigned int i = 0; i < list->count(); i++ )
slist.append( list->text( i ) );
conf->writeEntry("commandlines", slist );
conf->sync();
return;
}
void CommandPlugin::add()
{
if( !commandline->text().isEmpty() ) {
for( unsigned int i = 0; i < list->count(); i++ )
if( list->text( i ) == commandline->text() )
return;
list->insertItem( commandline->text() );
}
}
void CommandPlugin::remove()
{
unsigned int i = 0;
do {
if(list->isSelected( i ))
list->removeItem( i );
else
i++;
} while( i < list->count() );
}
void CommandPlugin::exec()
{
for( unsigned int i = 0; i < list->count(); i++ )
if( list->isSelected( i ) )
commandline->setText( list->text( i ) );
}
const QPixmap CommandPlugin::getIcon() const
{
return kapp->iconLoader()->loadIcon( "konsole", KIcon::Small );
}

@ -0,0 +1,62 @@
/***************************************************************************
commandplugin.h - description
-------------------
begin : Son Jan 5 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef COMMANDPLUGIN_H
#define COMMANDPLUGIN_H
#include "batchrenamer.h"
#include "pluginloader.h"
#include "plugin.h"
#include "helpdialog.h"
class QCheckBox;
class KLineEdit;
class KListBox;
class KPushButton;
class CommandPlugin : public Plugin {
Q_OBJECT
public:
const QString getName() const;
const QString getAccelName() const;
const int type() const;
bool checkError();
void drawInterface( QWidget* w, QVBoxLayout* l );
void fillStructure();
QString processFile( BatchRenamer*, int, QString token, int );
void finished();
bool alwaysUsed() const { return false; }
const QPixmap getIcon() const;
private slots:
void add();
void remove();
void exec();
private:
KLineEdit* commandline;
QCheckBox* checkNoBlock;
KListBox* list;
KPushButton* buttonAdd;
KPushButton* buttonRemove;
QString command;
bool noblock;
};
#endif

@ -0,0 +1,109 @@
/***************************************************************************
confdialog.cpp - description
-------------------
begin : Sun Jan 27 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
// Own includes
#include "confdialog.h"
// QT includes
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qtooltip.h>
// KDE includes
#include <kiconloader.h>
#include <klocale.h>
ConfDialog::ConfDialog( QWidget* parent, const char* name )
: KDialogBase( KDialogBase::IconList, "KRename",
KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Default, KDialogBase::Ok, parent, name, true, true ),
GUIModeSelector()
{
setupTab1();
setupTab2();
connect( this, SIGNAL( defaultClicked() ), this, SLOT( defaults() ) );
}
ConfDialog::~ConfDialog()
{
}
void ConfDialog::setupTab1()
{
const QString caption = i18n("Look and Feel");
QFrame* box = addPage( caption, caption, BarIcon("looknfeel") );
QVBoxLayout* layout = new QVBoxLayout( box );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
QButtonGroup* group = new QButtonGroup( box );
group->setColumnLayout(0, Qt::Vertical );
QVBoxLayout* lgroup = new QVBoxLayout( group->layout() );
optionWizard = new QRadioButton( group );
optionWizard->setText( i18n("Use &wizard style GUI (beginners)") );
optionTabs = new QRadioButton( group );
optionTabs->setText( i18n("Use &tabbed GUI (advanced users)") );
lgroup->addWidget( new QLabel( i18n("Configure the look and feel of the KRename GUI:<br>"), group ) );
lgroup->addWidget( optionWizard );
lgroup->addWidget( optionTabs );
lgroup->addItem( spacer );
layout->addWidget( group );
layout->addItem( spacer );
}
void ConfDialog::setupTab2()
{
const QString caption = i18n("KRename");
QFrame* box = addPage( caption, caption, BarIcon("krename") );
QVBoxLayout* layout = new QVBoxLayout( box );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
checkPlugins = new QCheckBox( i18n("&Load file plugins on start"), box );
checkAutosize = new QCheckBox( i18n("Auto &resize columns in preview"), box );
spinSize = new KIntNumInput( box );
spinSize->setRange( 20, 500, 1, false );
spinSize->setLabel( i18n( "&Thumbnail size:" ), AlignLeft | AlignVCenter );
spinHistory = new KIntNumInput( box );
spinHistory->setRange( 2, 500, 1, false );
spinHistory->setLabel( i18n( "&Number of template history items:" ), AlignLeft | AlignVCenter );
layout->addWidget( checkPlugins );
layout->addWidget( checkAutosize );
layout->addItem( spacer );
layout->addWidget( spinSize );
layout->addWidget( spinHistory );
layout->addItem( spacer );
QToolTip::add( checkPlugins, i18n("Disabling this option decreases KRename's startup time, because no KFilePlugins are loaded.") );
}
void ConfDialog::defaults()
{
checkPlugins->setChecked( true );
checkAutosize->setChecked( false );
optionWizard->setChecked( true );
spinSize->setValue( 80 );
}

@ -0,0 +1,66 @@
/***************************************************************************
confdialog.h - description
-------------------
begin : Sun Jan 27 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef CONFDIALOG_H
#define CONFDIALOG_H
// QT includes
#include <qcheckbox.h>
// KDE includes
#include <kdialogbase.h>
#include <knuminput.h>
#include "guimodeselector.h"
class QHBoxLayout;
class QVBoxLayout;
class QWidget;
class KIntNumInput;
class ConfDialog : public KDialogBase, public GUIModeSelector {
Q_OBJECT
public:
ConfDialog( QWidget* parent = 0, const char* name = 0 );
~ConfDialog();
inline bool loadplugins() const { return checkPlugins->isChecked(); }
inline int thumbSize() const { return spinSize->value(); }
inline bool autosize() const { return checkAutosize->isChecked(); }
inline int historyItems() const { return spinHistory->value(); }
inline void setLoadPlugins( bool b ) { checkPlugins->setChecked( b ); }
inline void setThumbSize( int b ) { spinSize->setValue( b ); }
inline void setAutosize( bool b ) { checkAutosize->setChecked( b ); }
inline void setHistoryItems( int b ) { spinHistory->setValue( b ); }
private slots:
void defaults();
private:
void setupTab1();
void setupTab2();
protected:
QCheckBox* checkAsk;
QCheckBox* checkPlugins;
QCheckBox* checkAutosize;
KIntNumInput* spinSize;
KIntNumInput* spinHistory;
};
#endif

@ -0,0 +1,142 @@
/***************************************************************************
coorddialog.cpp - description
-------------------
begin : Die Feb 4 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "coorddialog.h"
// Qt includes
#include <qcheckbox.h>
#include <qfontmetrics.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qvalidator.h>
// KDE includes
#include <kapplication.h>
#include <klocale.h>
DSLineEdit::DSLineEdit( QWidget* parent, const char* name )
: KLineEdit( parent, name )
{
}
void DSLineEdit::keyPressEvent( QKeyEvent* e )
{
KLineEdit::keyPressEvent( e );
emit changed();
}
void DSLineEdit::mousePressEvent( QMouseEvent* e )
{
KLineEdit::mousePressEvent( e );
emit changed();
}
bool CoordDialog::m_inversion = false;
CoordDialog::CoordDialog( const QString & file, QWidget *_parent, const char *name )
: KDialogBase( KDialogBase::Plain, "KRename",
KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, _parent, name, true, true ), m_file( file )
{
QFrame* parent = plainPage();
QVBoxLayout* layout = new QVBoxLayout( parent );
filename = new DSLineEdit( parent );
filename->setText( file );
filename->setValidator( new QRegExpValidator( QRegExp( file ), this ) );
preview = new QLabel( parent );
checkInvert = new QCheckBox( i18n("&Invert selection"), plainPage() );
checkInvert->setChecked( m_inversion );
layout->addWidget( new QLabel( i18n("Please select the text you want to insert:"), plainPage() ) );
layout->addWidget( filename );
layout->addWidget( checkInvert );
layout->addWidget( preview );
updateCommand();
connect( filename, SIGNAL( selectionChanged() ), this, SLOT( updateCommand() ) );
connect( checkInvert, SIGNAL( clicked() ), this, SLOT( updateCommand() ) );
connect( filename, SIGNAL( textChanged( const QString & ) ), this, SLOT( resetText() ) );
connect( filename, SIGNAL( changed() ), this, SLOT( updateCommand() ) );
show();
QFontMetrics fm( filename->font() );
int w = fm.width( file );
if( w > width() )
resize(
( w < KApplication::desktop()->width() - 40 ? w + 40 : KApplication::desktop()->width() ), height() );
}
CoordDialog::~CoordDialog()
{
}
void CoordDialog::updateCommand()
{
int start = 0;
int end = 0;
m_command = "";
(void)filename->getSelection( &start, &end );
if( !filename->text().isEmpty() ) {
if( checkInvert->isChecked() && filename->hasSelectedText() ) {
// inverted
if( end ) {
start++;
end++;
if( start > 1 )
m_command = QString("[$1;%1]").arg(start-1);
if( end <= (signed int)filename->text().length() )
m_command.append( QString("[$%1-[length]]").arg(end) );
}
} else if( checkInvert->isChecked() && !filename->hasSelectedText() ) {
int p = filename->cursorPosition();
m_command = QString("[$1;%1][$%2-[length]]").arg(p).arg(p+1);
} else if( !checkInvert->isChecked() && filename->hasSelectedText() ){
if( end ) {
start++;
end++;
if( end <= (signed int)filename->text().length() )
m_command = QString("[$%1;%2]").arg(start).arg(end-start);
else
m_command = QString("[$%1-[length]]").arg(start);
}
} else if( !checkInvert->isChecked() && !filename->hasSelectedText() ) {
int p = filename->cursorPosition();
m_command = QString("[$%1-[length]]").arg( p );
}
}
preview->setText( i18n("Preview: ") + m_command );
}
void CoordDialog::resetText()
{
filename->setText( m_file );
updateCommand();
}
QString CoordDialog::coords()
{
m_inversion = checkInvert->isChecked();
return m_command;
}

@ -0,0 +1,70 @@
/***************************************************************************
coorddialog.h - description
-------------------
begin : Die Feb 4 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef COORDDIALOG_H
#define COORDDIALOG_H
#include <kdialogbase.h>
#include <klineedit.h>
class QKeyEvent;
class DSLineEdit : public KLineEdit {
Q_OBJECT
public:
DSLineEdit( QWidget* parent = 0, const char* name = 0 );
signals:
void changed();
protected:
void keyPressEvent( QKeyEvent* e );
void mousePressEvent( QMouseEvent* e );
};
class QCheckBox;
class QLabel;
class QString;
/* The name of this class was a very bad choice.
* CoordDialog is an abreviation vor Coordinate Dialog,
* because this dialog is ought to be for selecting
* the coordinates of a filename using an [x;y] token.
*/
class CoordDialog : public KDialogBase {
Q_OBJECT
public:
CoordDialog( const QString & file, QWidget *_parent=0, const char *name=0);
~CoordDialog();
QString coords();
static bool m_inversion;
private slots:
void updateCommand();
void resetText();
private:
QString m_file;
QString m_command;
DSLineEdit* filename;
QCheckBox* checkInvert;
QLabel* preview;
};
#endif

@ -0,0 +1,153 @@
/***************************************************************************
dateplugin.cpp - description
-------------------
begin : Mon Feb 02 2004
copyright : (C) 2004 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "dateplugin.h"
// Qt includes
#include <qdatetime.h>
// KDE includes
#include <kfileitem.h>
#include <kio/netaccess.h>
#include <klocale.h>
DatePlugin::DatePlugin()
: FilePlugin(0)
{
keys.append("date");
keys.append("date;.*");
keys.append("year");
keys.append("month");
keys.append("day");
keys.append("time");
keys.append("hour");
keys.append("minute");
keys.append("second");
keys.append("user");
keys.append("group");
keys.append("creationdate");
keys.append("creationdate;.*");
keys.append("modificationdate");
keys.append("modificationdate;.*");
keys.append("accessdate");
keys.append("accessdate;.*");
setupKeys();
m_icon = "clock";
}
QString DatePlugin::processFile(BatchRenamer* b, int i, QString token, int )
{
if( !supports( token ) )
return QString::null;
if( token.lower().startsWith( getPattern() ) )
token = token.mid( getPattern().length(), token.length() - getPattern().length() );
QDate d = QDate::currentDate();
QTime t = QTime::currentTime();
QString tmp, text;
QString format = "dd-MM-yyyy";
if( token.contains( ";" ) )
{
format = token.section( ';', 1, 1 );
token = token.section( ';', 0, 0 ).lower();
} else
token = token.lower();
if( token == "date" ) {
return QDateTime::currentDateTime().toString( format );
} else if( token == "year" )
return QString( "%1" ).arg( d.year() );
else if( token == "month" )
return tmp.sprintf("%0*i", 2, d.month() );
else if( token == "day" )
return tmp.sprintf("%0*i", 2, d.day() );
else if( token == "time" )
return QString( "%1-%2-%3" ).arg( t.hour() ).arg( QString().sprintf("%0*i", 2, t.minute() ) ).arg( QString().sprintf("%0*i", 2, t.second() ) );
else if( token == "hour" )
return tmp.sprintf("%0*i", 2, t.hour() );
else if( token == "minute" )
return tmp.sprintf("%0*i", 2, t.minute() );
else if( token == "second" )
return tmp.sprintf("%0*i", 2, t.second() );
else {
KIO::UDSEntry entry;
KIO::NetAccess::stat( b->files()[i].src.url, entry );
KFileItem item( entry, b->files()[i].src.url );
if( token == "user" )
return item.user();
else if( token == "group" )
return item.group();
else if( token == "creationdate" )
return time( item.time( KIO::UDS_CREATION_TIME ), format );
else if( token == "modificationdate" )
return time( item.time( KIO::UDS_MODIFICATION_TIME ), format );
else if( token == "accessdate" )
return time( item.time( KIO::UDS_ACCESS_TIME ), format );
}
return QString::null;
}
const QString DatePlugin::getAccelName() const
{
return i18n("&System Functions");
}
const QString DatePlugin::getName() const
{
return i18n("System Functions");
}
const QString DatePlugin::getPattern() const
{
return QString::null;
}
const QString DatePlugin::time( time_t time, const QString & format )
{
QDateTime dt;
dt.setTime_t( time );
return dt.toString( format );
}
void DatePlugin::addHelp( HelpDialogData* data )
{
QStringList list;
list.append( "[date];;" + i18n("Insert the current date") );
list.append( "[date;yyyy-MM-dd];;" + i18n("Insert the current date using the formatting string yyyy-MM-dd") );
list.append( "[year];;" + i18n("Insert the current year") );
list.append( "[month];;" + i18n("Insert the current month as number") );
list.append( "[day];;" + i18n("Insert the current day as number") );
list.append( "[time];;" + i18n("Insert the current time") );
list.append( "[hour];;" + i18n("Insert the current hour as number") );
list.append( "[minute];;" + i18n("Insert the current minute as number") );
list.append( "[second];;" + i18n("Insert the current second as number") );
list.append( "[user];;" + i18n("Owner of the file") );
list.append( "[group];;" + i18n("Owning group of the file") );
list.append( "[creationdate];;" + i18n("Insert the files creation date"));
list.append( "[creationdate;yyyy-MM-dd];;" + i18n("Insert the formatted file creation date") );
list.append( "[modificationdate];;" + i18n("Insert the files modification date"));
list.append( "[modificationdate;yyyy-MM-dd];;" + i18n("Insert the formatted modification date") );
list.append( "[accessdate];;" + i18n("Insert the date of the last file access") );
list.append( "[accessdate;yyyy-MM-dd];;" + i18n("Insert the formatted date of the last file access") );
data->add( getName(), &list, getIcon() );
}

@ -0,0 +1,44 @@
/***************************************************************************
dateplugin.h - description
-------------------
begin : Mon Feb 02 2004
copyright : (C) 2004 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef DATEPLUGIN_H
#define DATEPLUGIN_H
#include <fileplugin.h>
// time_t support...
#include <time.h>
/**
@author Dominik Seichter
*/
class DatePlugin : public FilePlugin
{
public:
DatePlugin();
QString processFile(BatchRenamer* b, int i, QString token, int mode);
const QString getAccelName() const;
const QString getName() const;
const QString getPattern() const;
void addHelp( HelpDialogData* data );
private:
const QString time( time_t time, const QString & format );
};
#endif

@ -0,0 +1,238 @@
/***************************************************************************
datetime.cpp - description
-------------------
begin : Mon Jan 7 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "datetime.h"
// QT includes
#include <qcheckbox.h>
#include <qfileinfo.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
// KDE includes
#include <kapplication.h>
#include <kiconloader.h>
#include <kdatepik.h>
#include <knuminput.h>
#include <klocale.h>
// OS includes
#include <stdio.h>
#include <time.h>
#include <utime.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
const QString MyDatePlugin::getName() const
{
return i18n("Date & Time");
}
const QString MyDatePlugin::getAccelName() const
{
return i18n("Date && &Time");
}
const int MyDatePlugin::type() const
{
return TYPE_FINAL_FILE;
}
bool MyDatePlugin::checkError()
{
return true;
}
const QPixmap MyDatePlugin::getIcon() const
{
return kapp->iconLoader()->loadIcon( "kalarm", KIcon::Small );
}
void MyDatePlugin::drawInterface( QWidget* w, QVBoxLayout* l )
{
m_widget = w;
#ifdef BENNY
l->addWidget( new QLabel("Setze Modifiaction Time um eine Stunde zurück", w) );
#else
Layout0 = new QHBoxLayout( 0, 0, 6, "Layout0");
Layout1 = new QVBoxLayout( 0, 0, 6, "Layout1");
Layout2 = new QHBoxLayout( 0, 0, 6, "Layout2");
kDate = new KDatePicker( w );
checkAccess = new QCheckBox( w, "checkAccess" );
checkAccess->setText( i18n( "Change &access date && time" ) );
checkModification = new QCheckBox( w, "checkModification" );
checkModification->setText( i18n( "Change &modification date && time" ) );
labelTime = new QLabel( w, "labelTime" );
labelTime->setText( i18n( "Time:" ) );
spinHour = new KIntSpinBox( w, "spinHour" );
spinHour->setSuffix( i18n( "h" ) );
spinHour->setMaxValue( 23 );
spinMinute = new KIntSpinBox( w, "spinMinute" );
spinMinute->setSuffix( i18n( "min" ) );
spinMinute->setMaxValue( 59 );
spinSecond = new KIntSpinBox( w, "spinSecond" );
spinSecond->setSuffix( i18n( "s" ) );
spinSecond->setMaxValue( 59 );
buttonCurrentDT = new QPushButton( w, "buttonCurrentDT" );
buttonCurrentDT->setText( i18n( "&Get Current Date && Time" ) );
Layout2->addWidget( labelTime );
Layout2->addWidget( spinHour );
Layout2->addWidget( spinMinute );
Layout2->addWidget( spinSecond );
Layout1->addWidget( kDate );
Layout1->addWidget( checkAccess );
Layout1->addWidget( checkModification );
Layout1->addLayout( Layout2 );
Layout1->addWidget( buttonCurrentDT );
Layout0->addLayout( Layout1 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
Layout0->addItem( spacer );
l->addLayout( Layout0 );
connect( buttonCurrentDT, SIGNAL(clicked()), this, SLOT(changeDT()));
#endif
}
void MyDatePlugin::fillStructure()
{
#ifndef BENNY
dvals.date = kDate->getDate();
dvals.changeModification = checkModification->isChecked();
dvals.changeAccess = checkAccess->isChecked();
dvals.hour = spinHour->value();
dvals.minute = spinMinute->value();
dvals.second = spinSecond->value();
#endif
}
QString MyDatePlugin::processFile( BatchRenamer* b, int i, QString, int )
{
#ifdef BENNY
QString filename = b->files()[i].dst.name;
FILE * f;
struct utimbuf * t = new utimbuf();
struct tm tmp;
struct stat st;
time_t ti;
f = fopen((const char *)filename, "r");
if( f == NULL )
return QString( i18n("Can't change date of file %1.") ).arg(filename);
fclose( f );
QFileInfo info( filename );
tmp.tm_mday = info.lastModified().date().day();
tmp.tm_mon = info.lastModified().date().month() - 1;
tmp.tm_year = info.lastModified().date().year() - 1900;
tmp.tm_hour = info.lastModified().time().hour() - 1;
tmp.tm_min = info.lastModified().time().minute();
tmp.tm_sec = info.lastModified().time().second();
tmp.tm_isdst = -1;
ti = mktime( &tmp );
if( ti == -1 )
return QString( i18n("Can't change date of file %1.") ).arg(filename);
if( stat( (const char *)filename, &st ) == -1 )
return QString( i18n("Can't change date of file %1.") ).arg(filename);
t->actime = st.st_atime;
t->modtime = ti;
if(utime( (const char *)filename, t ) != 0)
return QString( i18n("Can't change date of file %1.") ).arg(filename);
return QString::null;
#else
QString filename = b->files()[i].dst.name;
FILE * f;
struct utimbuf * t = new utimbuf();
struct tm tmp;
struct stat st;
time_t ti;
f = fopen((const char *)filename, "r");
if( f == NULL )
return QString( i18n("Can't change date of file %1.") ).arg(filename);
fclose( f );
tmp.tm_mday = dvals.date.day();
tmp.tm_mon = dvals.date.month() - 1;
tmp.tm_year = dvals.date.year() - 1900;
tmp.tm_hour = dvals.hour;
tmp.tm_min = dvals.minute;
tmp.tm_sec = dvals.second;
tmp.tm_isdst = -1;
ti = mktime( &tmp );
if( ti == -1 )
return QString( i18n("Can't change date of file %1.") ).arg(filename);
if( stat( (const char *)filename, &st ) == -1 )
return QString( i18n("Can't change date of file %1.") ).arg(filename);
if(dvals.changeAccess)
t->actime = ti;
else
t->actime = st.st_atime;
if(dvals.changeModification)
t->modtime = ti;
else
t->modtime = st.st_mtime;
if(utime( (const char *)filename, t ) != 0)
return QString( i18n("Can't change date of file %1.") ).arg(filename);
return QString::null;
#endif
}
void MyDatePlugin::changeDT()
{
spinHour->setValue( QTime::currentTime().hour());
spinMinute->setValue( QTime::currentTime().minute());
spinSecond->setValue( QTime::currentTime().second());
kDate->setDate( QDate::currentDate() );
}

@ -0,0 +1,90 @@
/***************************************************************************
datetime.h - description
-------------------
begin : Mon Jan 7 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef DATETIME_H
#define DATETIME_H
/*
* This two includes are required, because you have to use
* KRenames internal structures and enums.
*/
#include "batchrenamer.h"
#include "pluginloader.h"
#include "plugin.h"
#include "helpdialog.h"
#include <stdio.h>
class KDatePicker;
class KIntSpinBox;
class QCheckBox;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QVBoxLayout;
class QHBoxLayout;
class QPushButton;
class QString;
class QWidget;
class MyDatePlugin: public Plugin {
Q_OBJECT
public:
const QString getName() const;
const QString getAccelName() const;
const int type() const;
bool checkError();
void drawInterface( QWidget* w, QVBoxLayout* l );
void fillStructure();
QString processFile( BatchRenamer*, int, QString token, int );
const QPixmap getIcon() const;
private slots:
void changeDT();
protected:
QCheckBox* checkAccess;
QCheckBox* checkModification;
KDatePicker* kDate;
QLabel* labelTime;
KIntSpinBox* spinHour;
KIntSpinBox* spinMinute;
KIntSpinBox* spinSecond;
QPushButton* buttonCurrentDT;
QHBoxLayout* Layout0;
QVBoxLayout* Layout1;
QHBoxLayout* Layout2;
struct datevals {
QDate date; // Date
bool changeModification; // Change modification date
bool changeAccess; // Change access date
int hour;
int minute;
int second;
} dvals;
};
#endif

@ -0,0 +1,112 @@
/***************************************************************************
dsdirselectdialog.cpp - description
-------------------
begin : Sat Jan 03 2004
copyright : (C) 2004 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "dsdirselectdialog.h"
// Qt includes
#include <qcheckbox.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qvbox.h>
// KDE includes
#include <kdiroperator.h>
#include <klocale.h>
#include <kurlcombobox.h>
DSDirSelectDialog::DSDirSelectDialog( QWidget* parent )
: KFileDialog( ":KRename", "*", parent, 0, false )
{
setOperationMode( KFileDialog::Opening );
setMode( KFile::Files | KFile::ExistingOnly );
QVBox* vbox = new QVBox( this );
if( layout() )
layout()->add( vbox );
else
qDebug("KFileDialog does not have a layout!!!");
checkDir = new QCheckBox( i18n("Add directory names &with filenames"), vbox );
check = new QCheckBox( i18n("Add subdirectories &recursively"), vbox );
QHBox* hbox = new QHBox( vbox );
QWidget* spacer = new QWidget( hbox );
spacer->setMinimumWidth( 20 );
checkHidden = new QCheckBox( i18n("Add &hidden directories"), hbox );
hbox->setStretchFactor( checkHidden, 4 );
checkOnlyDir = new QCheckBox( i18n("Add directory names only"), vbox );
connect( check, SIGNAL( clicked() ), this, SLOT( enableControls() ));
QToolTip::add( check, i18n("Walk recursively through the directory tree and add also the content of all subdirectories to the list of files to rename.") );
QToolTip::add( checkHidden, i18n("If not checked, KRename will ignore directories starting with a dot during recursive adding.") );
QToolTip::add( checkOnlyDir, i18n("Add only the directory names and not the names of the files in the directory to KRename.") );
QToolTip::add( checkDir, i18n("This option causes KRename to add also the name of the base directory of the selected files to its list.") );
enableControls();
}
bool DSDirSelectDialog::recursively() const
{
return check->isChecked();
}
bool DSDirSelectDialog::hidden() const
{
return checkHidden->isChecked();
}
bool DSDirSelectDialog::dirs() const
{
return checkDir->isChecked();
}
bool DSDirSelectDialog::onlyDirs() const
{
return checkOnlyDir->isChecked();
}
void DSDirSelectDialog::setRecursively( bool b )
{
check->setChecked( b );
}
void DSDirSelectDialog::enableControls()
{
checkHidden->setEnabled( check->isChecked() );
}
void DSDirSelectDialog::slotOk()
{
const KFileItemList *items = ops->selectedItems();
if ( !items || items->isEmpty() )
{
KDialogBase::accept();
} else
KFileDialog::slotOk();
}
KURL::List DSDirSelectDialog::selectedURLs()
{
KURL::List list = KFileDialog::selectedURLs();
if( list.isEmpty() )
list.append( baseURL() );
return list;
}
#include "dsdirselectdialog.moc"

@ -0,0 +1,54 @@
/***************************************************************************
dsdirselectdialog.h - description
-------------------
begin : Sat Jan 03 2004
copyright : (C) 2004 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef DSDIRSELECTDIALOG_H
#define DSDIRSELECTDIALOG_H
#include <kfiledialog.h>
class QCheckBox;
class QLabel;
class KComboBox;
/* A small helper class to allow layout changes in KDirSelectDialog */
class DSDirSelectDialog : public KFileDialog {
Q_OBJECT
public:
DSDirSelectDialog( QWidget* parent );
bool recursively() const;
bool hidden() const;
bool dirs() const;
bool onlyDirs() const;
void setRecursively( bool b );
KURL::List selectedURLs();
private slots:
void enableControls();
void slotOk();
private:
QCheckBox* check;
QCheckBox* checkHidden;
QCheckBox* checkDir;
QCheckBox* checkOnlyDir;
QLabel* label;
};
#endif

@ -0,0 +1,144 @@
/***************************************************************************
encodingplugin.cpp - description
-------------------
begin : Tue Jul 06 2004
copyright : (C) 2004 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "encodingplugin.h"
// QT includes
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qtextcodec.h>
#include <qvgroupbox.h>
// KDE includes
#include <kapplication.h>
#include <kcombobox.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kmessagebox.h>
const QString EncodingPlugin::getName() const
{
return i18n("Encoding Conversion Plugin");
}
const QString EncodingPlugin::getAccelName() const
{
return i18n("&Encoding Conversion Plugin");
}
const int EncodingPlugin::type() const
{
return TYPE_FINAL_FILENAME;
}
void EncodingPlugin::drawInterface( QWidget* w, QVBoxLayout* l )
{
// build a list of all available TextCodecs
QStringList codecs;
QTextCodec *codec;
for( int i=0; (codec = QTextCodec::codecForIndex(i));i++)
codecs.append( codec->name() );
m_widget = w;
codec = QTextCodec::codecForLocale();
m_locale_codec = codec->name();
QLabel* label = new QLabel(
i18n("<qt>This plugin is able to convert filenames between different "
"encodings. For example you can convert filenames from KOI8-R "
"to UTF-8 encoding.</qt>"), w );
l->addWidget( label );
QVGroupBox* groupInput = new QVGroupBox( i18n("Encoding of Input Files:"), w );
checkInput = new QCheckBox( i18n("&Use local encoding: %1").arg( m_locale_codec), groupInput );
comboInput = new KComboBox( false, groupInput );
comboInput->insertStringList( codecs );
QVGroupBox* groupOutput = new QVGroupBox( i18n("Encoding of Output Files:"), w );
checkOutput = new QCheckBox( i18n("&Use local encoding: %1").arg( m_locale_codec), groupOutput );
checkOutput->setChecked( true );
comboOutput = new KComboBox( false, groupOutput );
comboOutput->insertStringList( codecs );
l->addWidget( groupInput );
l->addWidget( groupOutput );
connect( checkInput, SIGNAL( clicked() ), this, SLOT( enableControls() ) );
connect( checkOutput, SIGNAL( clicked() ), this, SLOT( enableControls() ) );
connect( comboOutput, SIGNAL( activated(int) ),this, SLOT( updatePreview() ) );
connect( comboInput, SIGNAL( activated(int) ),this, SLOT( updatePreview() ) );
setLocale( comboInput );
setLocale( comboOutput );
enableControls();
}
void EncodingPlugin::fillStructure()
{
m_input_codec = (checkInput->isChecked() ? m_locale_codec : comboInput->currentText() );
m_output_codec = (checkOutput->isChecked() ? m_locale_codec : comboOutput->currentText() );
}
bool EncodingPlugin::checkError()
{
return true;
}
QString EncodingPlugin::processFile( BatchRenamer*, int, QString token, int )
{
QString input = token;
QString unicode = QString::null;
QTextCodec* toUnicode = QTextCodec::codecForName(m_input_codec); // get the codec for KOI8-R
QTextCodec* fromUnicode = QTextCodec::codecForName(m_output_codec);
unicode = toUnicode->toUnicode( input );
return fromUnicode->fromUnicode( unicode );
}
void EncodingPlugin::finished()
{
}
const QPixmap EncodingPlugin::getIcon() const
{
return kapp->iconLoader()->loadIcon( "fonts", KIcon::Small );
}
void EncodingPlugin::enableControls()
{
comboInput->setEnabled( !checkInput->isChecked() );
comboOutput->setEnabled( !checkOutput->isChecked() );
//updatePreview();
}
void EncodingPlugin::setLocale( KComboBox* combo )
{
for(int i=0;i<combo->count();i++)
if( combo->text(i) == m_locale_codec )
{
combo->setCurrentItem( i );
break;
}
}

@ -0,0 +1,68 @@
/***************************************************************************
encodingplugin.h - description
-------------------
begin : Tue Jul 06 2004
copyright : (C) 2004 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef _ENCODINGPLUGIN_H_
#define _ENCODINGPLUGIN_H_
#include "batchrenamer.h"
#include "pluginloader.h"
#include "plugin.h"
#include "helpdialog.h"
#include "fileoperation.h"
class KComboBox;
class QCheckBox;
class EncodingPlugin : public Plugin {
Q_OBJECT
public:
const QString getName() const;
const QString getAccelName() const;
const int type() const;
bool checkError();
void drawInterface( QWidget* w, QVBoxLayout* l );
void fillStructure();
QString processFile( BatchRenamer*, int, QString token, int );
void finished();
const QPixmap getIcon() const;
private slots:
void enableControls();
private:
void setLocale( KComboBox* combo );
FileOperation fop;
QString m_input_codec;
QString m_output_codec;
QString m_locale_codec;
int mib_input;
int mib_output;
QCheckBox* checkInput;
QCheckBox* checkOutput;
KComboBox* comboInput;
KComboBox* comboOutput;
};
#endif // _ENCODINGPLUGIN_H_

@ -0,0 +1,124 @@
/***************************************************************************
fileoperation.cpp - description
-------------------
begin : Sun Nov 11 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
// KDE includes
#include <kapplication.h>
#include <klocale.h>
#include <kio/netaccess.h>
#include <kio/job.h>
// QT includes
#if QT_VERSION >= 0x030100
#include <qeventloop.h>
#else
#include <qapplication.h>
#endif
#include <qfileinfo.h>
// OS includes
#include <stdio.h>
#include <unistd.h>
// Own includes
#include "fileoperation.h"
#include "ProgressDialog.h"
#include "batchrenamer.h"
using namespace KIO;
FileOperation::FileOperation()
{
canceled = false;
}
FileOperation::~FileOperation() { }
bool FileOperation::start( const KURL & src, const KURL & dest, int mode, bool overwrite )
{
locked = true;
result = 0;
if( src == dest && !overwrite ) {
m_error = QString( i18n( "File %1 exists already!") ).arg( dest.prettyURL() );
return false;
}
Job* job = 0;
switch( mode ) {
case RENAME:
case MOVE:
default:
job = file_move( src, dest, -1, overwrite, false, false );
break;
case COPY:
job = file_copy( src, dest, -1, overwrite, false, false );
break;
case LINK:
// Does only work if both files are on the same host
if( src.protocol() == dest.protocol() && src.host() == dest.host() )
{
job = symlink( src.path(), dest, overwrite, false );
}
else
{
m_error = i18n("Can't create symlinks on different hosts for file %1.").arg( src.prettyURL() );
result = true;
return !result;
}
break;
};
if( !job )
return false;
job->setAutoErrorHandlingEnabled( false, 0 );
connect( job, SIGNAL( result (KIO::Job *) ),
this, SLOT( slotResult (KIO::Job *) ) );
#if QT_VERSION >= 0x030100
kapp->eventLoop()->enterLoop();
#else
kapp->enter_loop();
#endif
return !result;
}
bool FileOperation::fcopy( const QString & src, const QString & dest )
{
return start( KURL( src ), KURL( dest ), KIO::CopyJob::Copy, false );
}
QString FileOperation::getName( const QString & file )
{
QFileInfo info( file );
return info.fileName();
}
void FileOperation::slotResult( KIO::Job * job )
{
result = job->error();
if( result )
m_error = job->errorString();
#if QT_VERSION >= 0x030100
kapp->eventLoop()->exitLoop();
#else
kapp->exit_loop();
#endif
}

@ -0,0 +1,54 @@
/***************************************************************************
fileoperation.h - description
-------------------
begin : Sun Nov 11 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef FILEOPERATION_H
#define FILEOPERATION_H
#include <qobject.h>
#include <kio/jobclasses.h>
#include <kurl.h>
class QString;
class FileOperation: public QObject {
Q_OBJECT
public:
FileOperation();
~FileOperation();
bool start( const KURL & src, const KURL & dest, int mode, bool overwrite );
bool fcopy( const QString & src, const QString & dest );
inline const QString & error() const;
static QString getName( const QString & file );
private slots:
void slotResult( KIO::Job * job );
private:
bool locked;
bool canceled;
int result;
QString m_error;
};
inline const QString & FileOperation::error() const
{
return m_error;
}
#endif

@ -0,0 +1,213 @@
/***************************************************************************
fileplugin.cpp - description
-------------------
begin : Mon Jul 1 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "fileplugin.h"
// Qt includes
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qregexp.h>
// KDE includes
#include <kapplication.h>
#include <kfilemetainfo.h>
#include <klineedit.h>
#include <klistbox.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kpushbutton.h>
FilePlugin::FilePlugin( KService* service )
{
if(!service) {
setupKeys();
return;
}
KFileMetaInfoProvider* mip = KFileMetaInfoProvider::self();
m_name = service->name();
m_comment = service->comment();
QStringList options = service->serviceTypes();
for( unsigned int i = 0; i < options.count(); i++ ) {
if( options[i] != "KFilePlugin" ) {
m_mimetype = options[i];
const KFileMimeTypeInfo* info = mip->mimeTypeInfo( m_mimetype );
if( info )
keys = info->supportedKeys();
fileplugin = mip->plugin( m_mimetype );
KMimeType::Ptr mime = KMimeType::mimeType( m_mimetype );
m_icon = mime->icon( QString::null, true ); // arguments are unused
setPattern( mime );
}
}
}
FilePlugin::~FilePlugin()
{ }
void FilePlugin::setPattern( KMimeType::Ptr mime )
{
QStringList pattern = mime->patterns();
if( pattern.count() ) {
m_pattern = pattern[0];
if( m_pattern.startsWith( "*." ) )
m_pattern = m_pattern.right( m_pattern.length() - 2 );
}
// TODO: REFACTOR
// We need a pattern
if( m_pattern.isEmpty() ) {
int a = 0;
a = m_name.find( "-" );
if( a > -1 )
m_pattern = m_name.left( a ).lower();
else {
a = m_pattern.find( " " );
if( a > -1 )
m_pattern = m_name.left( a ).lower();
else
m_pattern = m_name;
}
}
setupKeys();
}
void FilePlugin::setupKeys()
{
for( unsigned int i = 0; i < keys.count(); i++ )
keys[i] = getPattern() + keys[i];
}
const QString FilePlugin::getName() const
{
return m_name;
}
const QString FilePlugin::getAccelName() const
{
return "&" + getName();
}
const QString FilePlugin::getPattern() const
{
return m_pattern;
}
const int FilePlugin::type() const
{
return TYPE_BRACKET;
}
bool FilePlugin::checkError()
{
return true;
}
void FilePlugin::drawInterface( QWidget* w, QVBoxLayout* l )
{
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
QHBoxLayout* hbox = new QHBoxLayout( 0, 6, 6 );
QLabel* pix = new QLabel( w );
pix->setPixmap( kapp->iconLoader()->loadIcon( m_icon, KIcon::Desktop ) );
hbox->addWidget( pix );
hbox->addWidget( new QLabel( "<qt><b>"+getName()+"</b></qt>", w ) );
hbox->addItem( spacer );
l->addLayout( hbox );
l->addWidget( new QLabel( m_comment, w ) );
l->addWidget( new QLabel( i18n("Supported tokens:"), w ) );
KListBox* list = new KListBox( w );
list->setColumnMode( KListBox::FitToWidth );
for( unsigned int i = 0; i < keys.count(); i++ )
list->insertItem( "[" + keys[i] + "]" );
l->addWidget( list );
l->setStretchFactor( list, 2 );
}
QString FilePlugin::processFile( BatchRenamer* b, int i, QString token, int )
{
QString filename = BatchRenamer::buildFilename( &b->files()[i].src );
token = token.lower();
/*
* Check if we have something cached for this file
*/
if( cache.contains( filename + "::" + token ) )
return cache[filename + "::" + token ];
for( unsigned int i = 0; i < keys.count(); i++ ) {
if( token.lower() == keys[i].lower() ) {
KFileMetaInfo meta( filename );
if( meta.isValid() ) {
QString k = keys[i];
if( k.startsWith( getPattern() ) )
k = k.mid( getPattern().length(), k.length() - getPattern().length() );
QString ret = meta.item( k ).string( true ).stripWhiteSpace();
if( cache.count() >= CACHE_MAX )
cache.remove( cache.begin() );
cache.insert( filename + "::" + token, ret );
kapp->processEvents();
return ret;
}
}
}
return QString::null;
}
void FilePlugin::addHelp( HelpDialogData* data )
{
QStringList list;
for( unsigned int i = 0; i < keys.count(); i++ )
list.append( "[" + keys[i] + "]" + ";;" + keys[i] );
data->add( getName(), &list, getIcon() );
}
const QPixmap FilePlugin::getIcon() const
{
return kapp->iconLoader()->loadIcon( m_icon, KIcon::Small );
}
bool FilePlugin::supports( const QString & token )
{
for( unsigned int i = 0; i < keys.count(); i++ )
if( QRegExp( keys[i].lower() ).exactMatch( token.lower() ) )
return true;
return false;
}
void FilePlugin::clearCache()
{
cache.clear();
}

@ -0,0 +1,86 @@
/***************************************************************************
fileplugin.h - description
-------------------
begin : Mon Jul 1 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef FILEPLUGIN_H
#define FILEPLUGIN_H
#include "batchrenamer.h"
#include "pluginloader.h"
#include "plugin.h"
#include "helpdialog.h"
#include <kmimetype.h>
/*
* number of items we shall cache from file plugins
*/
#define CACHE_MAX 2000
class KFileMetaInfoProvider;
class KFileMimeTypeInfo;
class KPushButton;
class KService;
class QLabel;
class QWidget;
class QVBoxLayout;
class KFilePlugin;
class FilePlugin : public Plugin {
Q_OBJECT
public:
FilePlugin( KService* service );
~FilePlugin();
inline bool isValid() const;
virtual const QString getName() const;
virtual const QString getAccelName() const;
virtual const QString getPattern() const;
virtual const int type() const;
virtual bool checkError();
virtual void drawInterface( QWidget* w, QVBoxLayout* l );
virtual QString processFile( BatchRenamer* b, int i, QString token, int mode );
virtual void addHelp( HelpDialogData* data );
virtual const QPixmap getIcon() const;
virtual bool alwaysUsed() const { return true; }
virtual const QStringList getKeys() const { return keys; }
virtual void clearCache();
private:
void setPattern( KMimeType::Ptr mime );
protected:
bool supports( const QString & token );
void setupKeys();
QMap<QString,QString> cache;
KFilePlugin* fileplugin;
QString m_name, m_comment, m_icon, m_mimetype, m_pattern;
QStringList keys;
};
bool FilePlugin::isValid() const
{
return keys.count() > 0 && fileplugin ? true : false;
}
#endif

@ -0,0 +1,33 @@
/***************************************************************************
firststartdlg.cpp - description
-------------------
begin : Fre Jun 6 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "firststartdlg.h"
FirstStartDlg::FirstStartDlg(QWidget *parent, const char *name )
: KDialogBase( KDialogBase::Plain, "KRename",
KDialogBase::Ok, KDialogBase::Ok, parent, name, true, true ),
GUIModeSelector()
{
setCaption( guiModeCaption() );
createFrame( plainPage() );
setUseWizard( true );
}
FirstStartDlg::~FirstStartDlg()
{
}

@ -0,0 +1,32 @@
/***************************************************************************
firststartdlg.h - description
-------------------
begin : Fre Jun 6 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef FIRSTSTARTDLG_H
#define FIRSTSTARTDLG_H
#include <qwidget.h>
#include <kdialogbase.h>
#include "guimodeselector.h"
class FirstStartDlg : public KDialogBase, public GUIModeSelector {
Q_OBJECT
public:
FirstStartDlg(QWidget *parent=0, const char *name=0);
~FirstStartDlg();
};
#endif

@ -0,0 +1,78 @@
/***************************************************************************
guimodeselector.cpp - description
-------------------
begin : Fre Jun 6 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "guimodeselector.h"
// Qt includes
#include <qbuttongroup.h>
#include <qframe.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
// KDE includes
#include <klocale.h>
GUIModeSelector::GUIModeSelector()
{
optionWizard = optionTabs = 0;
}
GUIModeSelector::~GUIModeSelector()
{
}
bool GUIModeSelector::useWizard() const
{
return optionWizard->isChecked();
}
void GUIModeSelector::setUseWizard( bool b )
{
optionWizard->setChecked( b );
optionTabs->setChecked( !b );
}
const QString GUIModeSelector::guiModeCaption() const
{
return i18n("Look and Feel");
}
void GUIModeSelector::createFrame( QFrame* frame )
{
QVBoxLayout* layout = new QVBoxLayout( frame );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
QButtonGroup* group = new QButtonGroup( frame );
group->setColumnLayout(0, Qt::Vertical );
QVBoxLayout* lgroup = new QVBoxLayout( group->layout() );
optionWizard = new QRadioButton( group );
optionWizard->setText( i18n("Use &wizard style GUI (beginners)") );
optionTabs = new QRadioButton( group );
optionTabs->setText( i18n("Use &tabbed GUI (advanced users)") );
lgroup->addWidget( new QLabel( i18n("Configure the look and feel of the KRename GUI:<br>"), group ) );
lgroup->addWidget( optionWizard );
lgroup->addWidget( optionTabs );
lgroup->addItem( spacer );
layout->addWidget( group );
layout->addItem( spacer );
}

@ -0,0 +1,41 @@
/***************************************************************************
guimodeselector.h - description
-------------------
begin : Fre Jun 6 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef GUIMODESELECTOR_H
#define GUIMODESELECTOR_H
#include <qobject.h>
class QFrame;
class QRadioButton;
class GUIModeSelector {
public:
GUIModeSelector();
~GUIModeSelector();
bool useWizard() const;
void setUseWizard( bool b );
protected:
const QString guiModeCaption() const;
void createFrame( QFrame* frame );
QRadioButton* optionWizard;
QRadioButton* optionTabs;
};
#endif

@ -0,0 +1,159 @@
/***************************************************************************
helpdialog.cpp - description
-------------------
begin : Fr Nov 15 13:44:19 CEST 2001
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "helpdialog.h"
#include "krenameimpl.h"
// Qt includes
#include <qcombobox.h>
#include <qlayout.h>
#include <qlineedit.h>
// KDE includes
#include <klocale.h>
#include <klistview.h>
#include <kpushbutton.h>
#include <kstdguiitem.h>
void HelpDialogData::remove( const QString & headline )
{
if( m_map.contains( headline ) ) {
m_map.remove( headline );
m_icons.remove( headline );
emit updateHeadline();
emit updateItems();
}
}
void HelpDialogData::add( const QString & headline, QStringList* commands, const QPixmap & icon, bool first )
{
m_map.insert( headline, *commands );
m_icons.insert( headline, icon );
if( first )
m_first = headline;
emit updateHeadline();
emit updateItems();
}
QStringList HelpDialogData::tokens() const
{
QStringList list;
#if QT_VERSION >= 0x030005
// map.keys() seems only to be avaible in Qt >= 3.0.5
QStringList keys = m_map.keys();
#else
QStringList keys;
QMap<QString, QStringList>::Iterator it;
for ( it = m_map.begin(); it != m_map.end(); ++it )
keys.append( it.key() );
#endif
for( unsigned int i = 0; i < keys.count(); i++ )
for( unsigned int z = 0; z < m_map[keys[i]].count(); z++ )
list.append( m_map[keys[i]][z].section( ";;", 0, 0 ) );
return list;
}
HelpDialog::HelpDialog( HelpDialogData* data, QWidget* parent,
const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
text = NULL;
resize( 500, 400 );
setCaption( i18n( "Help" ) );
HelpDialogLayout = new QVBoxLayout( this, 11, 6, "HelpDialogLayout");
comboHeadline = new QComboBox( FALSE, this, "comboHeadline" );
HelpDialogLayout->addWidget( comboHeadline );
list = new KListView( this, "list" );
list->addColumn( i18n( "Token" ) );
list->addColumn( i18n( "Description" ) );
HelpDialogLayout->addWidget( list );
Layout1 = new QHBoxLayout( 0, 0, 6, "Layout1");
QSpacerItem* spacer = new QSpacerItem( 91, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
Layout1->addItem( spacer );
buttonAdd = new KPushButton( this, "buttonAdd" );
buttonAdd->setText( i18n( "&Add" ) );
Layout1->addWidget( buttonAdd );
buttonClose = createButton( KStdGuiItem::close(), this );
Layout1->addWidget( buttonClose );
HelpDialogLayout->addLayout( Layout1 );
// signals and slots connections
connect( buttonClose, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( buttonAdd, SIGNAL( clicked() ), this, SLOT( execute() ) );
connect( list, SIGNAL( executed(QListViewItem*) ), this, SLOT( execute() ) );
connect( comboHeadline, SIGNAL( activated(int) ), this, SLOT(updateItems() ) );
m_data = data;
connect( m_data, SIGNAL( updateItems() ), this, SLOT( updateItems() ) );
connect( m_data, SIGNAL( updateHeadline() ), this, SLOT( updateHeadline() ) );
}
HelpDialog::~HelpDialog()
{
disconnect( m_data, SIGNAL( updateItems() ), this, SLOT( updateItems() ) );
disconnect( m_data, SIGNAL( updateHeadline() ), this, SLOT( updateHeadline() ) );
}
void HelpDialog::execute()
{
if(!list->currentItem())
return;
QString t = text->text();
t.insert( text->cursorPosition(), list->currentItem()->text( 0 ) );
text->setText( t );
if( isModal() )
accept();
}
void HelpDialog::updateItems()
{
list->clear();
QStringList items = m_data->map()[comboHeadline->currentText()];
for( unsigned int i = 0; i < items.count(); i++ ) {
QString tmp = items[i];
new KListViewItem( list, tmp.section( ";;", 0, 0 ), tmp.section( ";;", 1, 1 ) );
}
}
void HelpDialog::updateHeadline()
{
comboHeadline->clear();
QMap<QString,QStringList> m = m_data->map();
QMap<QString,QPixmap> ic = m_data->icons();
comboHeadline->insertItem( ic[m_data->first()], m_data->first() );
QMap<QString, QStringList>::Iterator it;
for ( it = m.begin(); it != m.end(); ++it )
if( it.key() != m_data->first() )
comboHeadline->insertItem( ic[it.key()], it.key() );
}

@ -0,0 +1,111 @@
/***************************************************************************
helpdialog.h - description
-------------------
begin : Fr Nov 15 13:44:19 CEST 2001
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef HELPDIALOG_H
#define HELPDIALOG_H
#include <qdialog.h>
#include <qstringlist.h>
#include <qpixmap.h>
#include <qmap.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QComboBox;
class QLineEdit;
class QPixmap;
class KListView;
class KPushButton;
class HelpDialogData : public QObject {
Q_OBJECT
public:
HelpDialogData() {}
~HelpDialogData() {}
void add( const QString & headline, QStringList* commands, const QPixmap & icon, bool first = false );
void remove( const QString & headline );
/** returns all available and supported tokens
*/
QStringList tokens() const;
inline const QMap<QString,QStringList> & map() const
{
return m_map;
}
inline const QMap<QString,QPixmap> & icons() const
{
return m_icons;
}
inline const QString & first() const
{
return m_first;
}
signals:
void updateHeadline();
void updateItems();
private:
QMap<QString,QStringList> m_map;
QMap<QString,QPixmap> m_icons;
QString m_first;
};
class HelpDialog : public QDialog
{
Q_OBJECT
public:
HelpDialog( HelpDialogData* data, QWidget* parent = 0,
const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~HelpDialog();
inline void setLineEdit( QLineEdit* lineedit );
public slots:
void updateItems();
void updateHeadline();
private slots:
void execute();
private:
QComboBox* comboHeadline;
KListView* list;
KPushButton* buttonAdd;
KPushButton* buttonClose;
protected:
HelpDialogData* m_data;
QLineEdit* text;
QVBoxLayout* HelpDialogLayout;
QHBoxLayout* Layout1;
};
void HelpDialog::setLineEdit( QLineEdit* lineedit )
{
text = lineedit;
}
#endif // HELPDIALOG_H

Binary file not shown.

Binary file not shown.

@ -0,0 +1,167 @@
/***************************************************************************
kmyhistorycombo.cpp - description
-------------------
begin : Tue Oct 16 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
// QT includes
#include <qlistbox.h>
// Own includes
#include "kmyhistorycombo.h"
#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>
#include <qpopupmenu.h>
#include <qtimer.h>
#define TIMER_DELAY 500
#define KRENAME_FILENAME 5000
#define KRENAME_FILENAME_LOWER 5001
#define KRENAME_FILENAME_UPPER 5002
#define KRENAME_NUMBER 5003
#define KRENAME_DATE 5004
KMyHistoryCombo::KMyHistoryCombo( bool customPopup, QWidget* parent, const char* name)
: KHistoryCombo(parent, name)
{
QStringList history;
QStringList completion;
KConfig* config = kapp->config();
config->setGroup( name );
this->setDuplicatesEnabled( false );
history = config->readListEntry("History");
completion = config->readListEntry("CompletionItems");
m_timer = new QTimer();
setHistoryItems( history );
completionObject()->setItems( ( completion.isEmpty() ? history : completion ) );
setCompletionMode( (KGlobalSettings::Completion)config->readNumEntry( "CompletionMode",
KGlobalSettings::completionMode() ) );
connect( this, SIGNAL( textChanged( const QString & ) ), this, SLOT( textChangedGovernor() ) );
connect( m_timer, SIGNAL( timeout() ), this, SIGNAL( delayedTextChanged() ) );
if( customPopup )
connect( this, SIGNAL( aboutToShowContextMenu( QPopupMenu* ) ), this, SLOT( slotCustomContextMenu( QPopupMenu* ) ) );
}
KMyHistoryCombo::~KMyHistoryCombo()
{
delete m_timer;
}
void KMyHistoryCombo::saveSettings()
{
addToHistory( text() );
KConfig* config = kapp->config();
config->setGroup( name() ? name() : "KMyHistoryCombo" );
config->writeEntry( "History", historyItems() );
config->writeEntry( "CompletionItems", completionObject()->items() );
config->writeEntry( "CompletionMode", completionMode() );
config->sync();
}
QString KMyHistoryCombo::text( int index ) const
{
return this->listBox()->text( index );
}
void KMyHistoryCombo::setText( const QString & text )
{
this->lineEdit()->setText( text );
}
void KMyHistoryCombo::add( const QString & text )
{
int i;
for ( i = 0; i < this->count(); i++ )
if( this->text( i ) == text ) {
QString tmp = this->text( i );
this->listBox()->removeItem( i );
this->insertItem( tmp, 0 );
return;
}
if( this->count() == this->maxCount() )
this->listBox()->removeItem( this->maxCount() );
this->insertItem( text, 0 );
}
bool KMyHistoryCombo::isEmpty() const
{
return this->lineEdit()->text().isEmpty();
}
void KMyHistoryCombo::textChangedGovernor()
{
m_timer->stop();
m_timer->start( TIMER_DELAY, true );
}
void KMyHistoryCombo::slotCustomContextMenu( QPopupMenu* p )
{
QPopupMenu* krename = new QPopupMenu( p );
krename->insertItem( i18n("&Filename"), KRENAME_FILENAME );
krename->insertItem( i18n("Filename to &lowercase"), KRENAME_FILENAME_LOWER );
krename->insertItem( i18n("Filename to &uppercase"), KRENAME_FILENAME_UPPER );
krename->insertItem( i18n("&Number"), KRENAME_NUMBER );
krename->insertItem( i18n("&Date"), KRENAME_DATE );
connect( krename, SIGNAL( activated( int ) ), this, SLOT( slotInsertKRenameCommand( int ) ) );
p->insertSeparator( 0 );
p->insertItem( i18n("Insert &KRename token"), krename, 0, 0 );
}
void KMyHistoryCombo::slotInsertKRenameCommand( int id )
{
QString t;
// TODO:
// also use constants for KRename tokens!
switch( id )
{
case KRENAME_FILENAME:
t = "$";
break;
case KRENAME_FILENAME_LOWER:
t = "%";
break;
case KRENAME_FILENAME_UPPER:
t = "&";
break;
case KRENAME_NUMBER:
t = "#";
break;
case KRENAME_DATE:
t = "[date]";
break;
default:
break;
}
if( !t.isEmpty() )
this->lineEdit()->insert( t );
}

@ -0,0 +1,74 @@
/***************************************************************************
kmyhistorycombo.h - description
-------------------
begin : Tue Oct 16 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef KMYHISTORYCOMBO_H
#define KMYHISTORYCOMBO_H
// KDE includes
#include <kcombobox.h>
#include <kcompletion.h>
class QPopupMenu;
class QTimer;
class KMyHistoryCombo : public KHistoryCombo {
Q_OBJECT
public:
/** Create a new KMyHistoryCombo which has automatic KRename default history
* handling and a custom popup menu to insert tokens if customPopup is true
*
* \param customPopup insert custom menu items into context menu.
*/
KMyHistoryCombo(bool customPopup, QWidget* parent=0, const char* name=0);
~KMyHistoryCombo();
/**
* Saves the settings of the HistoryCombo in the applications
* config file in a group named name()
* Saved settings include:
* - history items
* - completion items
* - completion mode
*/
void saveSettings();
inline QString text() const;
QString text( int index ) const;
void setText( const QString & text );
void add( const QString & text );
bool isEmpty() const;
signals:
void delayedTextChanged();
private slots:
void textChangedGovernor();
void slotCustomContextMenu( QPopupMenu* p );
void slotInsertKRenameCommand( int id );
private:
QTimer* m_timer;
};
inline QString KMyHistoryCombo::text() const
{
return currentText();
}
#endif

@ -0,0 +1,839 @@
/***************************************************************************
kmylistbox.cpp - description
-------------------
begin : Tue Oct 16 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
// QT includes
#include <qcursor.h>
#include <qdir.h>
#include <qdragobject.h>
#include <qpainter.h>
#include <qpalette.h>
#include <qregexp.h>
// KDE includes
#include <kapplication.h>
#include <kdirlister.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kio/previewjob.h>
#include <kio/netaccess.h>
#include <qptrlist.h>
#include <kurldrag.h>
#include <kurllabel.h>
#include <kpixmap.h>
#include <kpixmapeffect.h>
// Own includes
#include "kmylistbox.h"
#include "krecursivelister.h"
#include "threadedlister.h"
using namespace KIO;
KMyListBox::KMyListBox(QWidget* parent, const char* name, WFlags fl)
:KListBox(parent, name, fl)
{
m_running_lister_counter = 0;
drag = ctrlPressed = shiftPressed = mousePressed = false;
moving = false;
m_sorting = UNSORTED;
label = new KURLLabel( QString::null, "<br>" + i18n("Please add some files...") + "<br>", this );
label->setFrameStyle( QFrame::GroupBoxPanel | QFrame::Sunken );
setAcceptDrops( true );
setSelectionMode(Extended); // was extended before 2.9.0
connect( this, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(openFile(QListBoxItem*)));
connect( this, SIGNAL(returnPressed(QListBoxItem*)), this, SLOT(openFile(QListBoxItem*)));
connect( label, SIGNAL( leftClickedURL() ), this, SIGNAL( addFiles() ) );
positionLabel();
}
KMyListBox::~KMyListBox()
{
}
KURL KMyListBox::url( int index ) const
{
return static_cast<KMyListBoxItem*>( item( index ) )->url();
}
bool KMyListBox::dir( int index ) const
{
return static_cast<KMyListBoxItem*>( item( index ) )->dir();
}
void KMyListBox::setPreviewSize( int size )
{
previewSize = size;
}
void KMyListBox::removeItem( int index )
{
KListBox::removeItem( index );
}
void KMyListBox::addFile( const KURL & filename, bool isfile )
{
// Check if the URL is a file and no dir
// Is the file already in our list ?
if( !isfile && !isFile( filename ) )
return;
if( isInList( filename ) )
return;
insertItem( new KMyListBoxItem( filename, false ), -1 );
positionLabel();
}
void KMyListBox::addDirName( const KURL & dirname )
{
if(!isInList( dirname ) )
{
insertItem( new KMyListBoxItem( dirname, true ), -1 );
positionLabel();
}
}
bool KMyListBox::isFile( const KURL & f, bool autoadd )
{
UDSEntry entry;
NetAccess::stat( f, entry );
KFileItem file( entry, f );
if( !file.isReadable() )
return false;
if( file.isDir() ) {
if( autoadd )
addDir( f, "*", false, true );
return false;
}
return true;
}
void KMyListBox::addDir( const KURL & dirname, const QString & filter, bool hidden, bool recursively, bool dirnames )
{
ThreadedLister* thl = new ThreadedLister( &m_add_mutex, &m_running_lister_counter, this );
thl->setDirname( dirname );
thl->setDirnames( dirnames );
thl->setFilter( filter );
thl->setHidden( hidden );
thl->setRecursive( recursively );
KApplication::setOverrideCursor( Qt::waitCursor );
thl->start();
}
void KMyListBox::addDirName( const KURL & dirname, const QString & filter, bool hidden, bool recursive )
{
KApplication::setOverrideCursor( Qt::waitCursor );
if( recursive ) {
ThreadedLister* thl = new ThreadedLister( &m_add_mutex, &m_running_lister_counter, this );
thl->setDirname( dirname );
thl->setDirnames( true );
thl->setFilter( filter );
thl->setHidden( hidden );
thl->setRecursive( recursive );
thl->setRecursiveDirOnlyMode( true );
thl->start();
} else {
// escape hiden directories
QString name = dirname.fileName();
if( !hidden && name.right( 1 ) != QString::fromLatin1(".") )
if( !isInList( dirname ) )
addDirName( dirname );
listerDone( NULL );
}
}
void KMyListBox::dropEvent(QDropEvent* e)
{
if( e->source() != this )
e->accept(QTextDrag::canDecode(e));
KURL::List list;
if( KURLDrag::decode( e, list ) )
{
KApplication::setOverrideCursor( Qt::waitCursor );
setUpdatesEnabled( false );
for( unsigned int i = 0; i < list.count(); i++ )
addFile( list[i], false );
setUpdatesEnabled( true );
listerDone( NULL );
}
}
void KMyListBox::dragEnterEvent(QDragEnterEvent* e)
{
if( e->source() != this )
e->accept(QTextDrag::canDecode(e));
}
void KMyListBox::viewportMousePressEvent( QMouseEvent* e )
{
if( moving )
move( index( itemAt( e->pos() ) ) );
else {
KListBox::viewportMousePressEvent( e );
QPoint p( e->pos() );
QListBoxItem *i = itemAt( p );
if ( i ) {
presspos = e->pos();
mousePressed = TRUE;
}
}
}
void KMyListBox::viewportMouseMoveEvent( QMouseEvent* e )
{
if ( mousePressed && ( presspos - e->pos() ).manhattanLength() > KApplication::startDragDistance() ) {
mousePressed = FALSE;
QListBoxItem *item = itemAt( presspos );
if ( item ) {
QStringList source = text( index( item ) );
for( int i = 0; i < (signed int)count(); i++ )
if( isSelected(i) && (i != index(item) ))
source.append( text(i) );
QUriDrag* ud = new QUriDrag(viewport());
ud->setUnicodeUris( source );
ud->drag();
}
} else
KListBox::viewportMouseMoveEvent( e );
}
void KMyListBox::viewportMouseReleaseEvent( QMouseEvent* e )
{
mousePressed = FALSE;
KListBox::viewportMouseReleaseEvent( e );
}
void KMyListBox::keyPressEvent( QKeyEvent* e )
{
/*
* TODO: Document all this keyboard commands
*/
if( e->key() == Key_Control )
ctrlPressed = true;
else if( e->key() == Key_Shift )
shiftPressed = true;
else if( e->key() == Key_Up )
setCurrentItem( currentItem()-1 );
else if( e->key() == Key_Down )
setCurrentItem( currentItem()+1 );
else if( e->key() == Key_Space )
select( item(currentItem()) );
else if( e->key() == Key_Return )
openFile( item(currentItem()) );
else if( e->key() == Key_Delete )
emit deletePressed();
else if( e->key() == Key_A )
for( unsigned int i = 0; i < count(); i++ )
setSelected( i, true );
else if( e->key() == Key_M ) {
moveMode();
return;
} else if( e->key() == Key_N )
for( unsigned int i = 0; i < count(); i++ )
setSelected( i, false );
else if( e->key() == Key_End )
setCurrentItem( count()-1 );
else if( e->key() == Key_Home )
setCurrentItem( 0 );
else
e->ignore();
emit updateCount();
setPreview( KMyListBoxItem::preview() );
emit updatePreview();
}
void KMyListBox::keyReleaseEvent( QKeyEvent* e )
{
if( e->key() == Key_Control )
ctrlPressed = false;
else if( e->key() == Key_Shift )
shiftPressed = false;
}
void KMyListBox::openFile( QListBoxItem* item )
{
if( item ) {
KMyListBoxItem* it = static_cast<KMyListBoxItem*>(item);
KFileItem* fileItem = new KFileItem( KFileItem::Unknown, KFileItem::Unknown, it->url() );
fileItem->run();
delete fileItem;
}
}
void KMyListBox::moveMode()
{
if ( !moving ) {
moving = true;
KApplication::setOverrideCursor( Qt::sizeAllCursor );
}
}
void KMyListBox::select( QListBoxItem* item )
{
if( !ctrlPressed && !shiftPressed )
/* Single click on the list box,
* make all items but the clicked
* one not selected */
for( int i = 0; i < (signed int)count(); i++ )
if( i != index(item) )
setSelected( i, false );
if( shiftPressed ) {
if( currentItem() == -1 ) {
setSelected( item, !isSelected( item ));
setCurrentItem( item );
return;
}
if( currentItem() > index(item) ) {
for( int i = index(item); i <= currentItem(); i++ )
setSelected( i, !isSelected( i ));
setCurrentItem( item );
} else if( currentItem() < index(item) ) { /* Works !*/
for( int i = currentItem()+1; i <= index(item); i++ )
setSelected( i, !isSelected( i ));
} else /* c == index(item) */ /* Works !*/
setSelected( item, !isSelected( item ));
} else {
setSelected( item, !isSelected( item ));
setCurrentItem( item );
}
}
void KMyListBox::preview( KURL::List list )
{
KIO::PreviewJob* job = KIO::filePreview( list, previewSize, previewSize, 0, 100, false, true, 0 );
connect( job, SIGNAL( gotPreview( const KFileItem*, const QPixmap &) ), this, SLOT( previewDone( const KFileItem*, const QPixmap &) ) );
connect( job, SIGNAL( failed( const KFileItem*)), this, SLOT( previewFailed( const KFileItem* ) ));
connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( previewFinished() ) );
KApplication::setOverrideCursor( Qt::waitCursor );
}
void KMyListBox::previewDone( const KFileItem* item, const QPixmap &pixmap )
{
for( unsigned int i = 0; i < count(); i++ )
if( url( i ) == item->url() ) {
KMyListBoxItem* it = static_cast<KMyListBoxItem*>(this->item( i ));
if( it && !pixmap.isNull() ) {
it->setPixmap( pixmap );
//updateItem( i );
}
break;
}
}
void KMyListBox::previewFailed( const KFileItem* item )
{
for( unsigned int i = 0; i < count(); i++ )
if( url( i ) == item->url() ) {
KMyListBoxItem* it = static_cast<KMyListBoxItem*>(this->item( i ));
if( it ) {
it->setPixmap( item->pixmap( getPreviewSize(), KIcon::DefaultState ) );
}
break;
}
}
void KMyListBox::previewFinished()
{
triggerUpdate( true ); //maybe false is enough
KApplication::restoreOverrideCursor();
}
void KMyListBox::setPreview( bool prv )
{
KMyListBoxItem::setPreview( prv );
if( prv ) {
KURL::List list;
for( unsigned int i = 0; i < count(); i++ ) {
KMyListBoxItem* it = static_cast<KMyListBoxItem*>(item( i ) );
if( !it->hasPreview() )
list.append( it->url() );
}
preview( list );
}
}
void KMyListBox::setName( bool name )
{
KMyListBoxItem::setName( name );
setPreview( KMyListBoxItem::preview() );
if( name ) {
setColumnMode( FixedNumber );
} else {
setColumnMode( FitToWidth );
}
}
void KMyListBox::move( int i )
{
KApplication::restoreOverrideCursor();
moving = false;
if( !count() )
return;
int nbSelectedBefore = 0;
for( unsigned int j = 0 ; j < count() ; j++ ) {
if( isSelected( j ) ) {
if( j < (unsigned int)i )
nbSelectedBefore++;
KMyListBoxItem* item = new KMyListBoxItem( static_cast<KMyListBoxItem*>(this->item( j )) );
removeItem( j );
j--;
insertItem( item, i - nbSelectedBefore );
}
}
}
void KMyListBox::moveUp()
{
if( count() == 0 )
return;
unsigned int i = 0;
setUpdatesEnabled( false );
do {
if( isSelected( i ) && i ) {
moveUp( i );
setSelected( i-1, true );
setCurrentItem( i-1 );
}
i++;
} while( i < count() );
setUpdatesEnabled( true );
}
void KMyListBox::moveUp( int i )
{
if( count() == 0 )
return;
KMyListBoxItem* item = new KMyListBoxItem( static_cast<KMyListBoxItem*>(this->item( i )) );
removeItem( i );
insertItem( item, i - 1 );
}
void KMyListBox::moveDown()
{
if( count() == 0 )
return;
unsigned int i = count();
setUpdatesEnabled( false );
do {
i--;
if( isSelected( i ) && (i < count()) ) {
moveDown( i );
setSelected( i+1, true );
setCurrentItem( i+1 );
}
} while( i > 0 );
setUpdatesEnabled( true );
}
void KMyListBox::moveDown( int i )
{
if( count() == 0 )
return;
KMyListBoxItem* item = new KMyListBoxItem( static_cast<KMyListBoxItem*>(this->item( i )) );
removeItem( i );
insertItem( item, i + 1 );
}
bool KMyListBox::isInList( KURL text )
{
// TODO: faster find algorithm
for( unsigned int i = 0; i < count(); i++ ) {
KMyListBoxItem* it = dynamic_cast<KMyListBoxItem*>(item( i ) );
if( it && it->url() == text ) {
return true;
}
}
return false;
}
void KMyListBox::customEvent( QCustomEvent* e )
{
if( e->type() == ThreadedLister::TYPE() )
{
listerDone( (ThreadedLister*)e->data() );
}
}
void KMyListBox::listerDone( ThreadedLister* lister )
{
m_add_mutex.lock();
if( lister )
delete lister;
KApplication::restoreOverrideCursor();
setUpdatesEnabled( false );
setPreview( KMyListBoxItem::preview() );
sortList();
setUpdatesEnabled( true );
emit updateCount();
emit updatePreview();
m_add_mutex.unlock();
}
unsigned int KMyListBox::runningAddListeners()
{
unsigned int u;
m_add_mutex.lock();
u = m_running_lister_counter;
m_add_mutex.unlock();
return u;
}
void KMyListBox::sortAscending()
{
m_sorting = ASCENDING;
sortList();
}
void KMyListBox::sortDescending()
{
m_sorting = DESCENDING;
sortList();
}
void KMyListBox::sortRandom()
{
m_sorting = RANDOM;
sortList();
}
void KMyListBox::sortUnsorted()
{
m_sorting = UNSORTED;
sortList();
}
void KMyListBox::sortNummeric()
{
m_sorting = NUMMERIC;
sortList();
}
void KMyListBox::sortList()
{
KApplication::setOverrideCursor( Qt::WaitCursor );
if( m_sorting == ASCENDING )
sort( true );
else if( m_sorting == DESCENDING )
sort( false );
else if( m_sorting == RANDOM )
{
unsigned int p = 0;
for( unsigned int i = 0;i<count();i++)
{
p = KApplication::random() % count();
if( p != i ) // This prevents the creation of a new ListBoxItem
// on the same position as before. It would not change
// the position of item, but cost a little bit of speed
{
KMyListBoxItem* item = new KMyListBoxItem( static_cast<KMyListBoxItem*>(this->item( i )) );
removeItem( i );
insertItem( item, p );
}
}
}
else if( m_sorting == NUMMERIC )
{
// a very simple bubble sort which sorts filenames by a number inside them.
// if no number is found a lexical comparison is performed
unsigned int z = count();
while( z-- )
for( unsigned int i=1;i<=z;i++)
{
KURL url1 = url( i - 1 );
KURL url2 = url( i );
if( url1.directory() != url2.directory() )
{
// different directory, do a lexical comparison
if( text( i - 1 ).compare( text( i ) ) >= 0 )
moveDown( i - 1 );
}
else
{
if( compareNummeric( url1.filename(), url2.filename() ) >= 0 )
moveDown( i - 1 );
}
}
}
KApplication::restoreOverrideCursor();
}
void KMyListBox::setSorting( int s )
{
switch( s )
{
default:
case UNSORTED:
sortUnsorted();
break;
case ASCENDING:
sortAscending();
break;
case DESCENDING:
sortDescending();
break;
case RANDOM:
sortRandom();
break;
case NUMMERIC:
sortNummeric();
break;
}
emit updatePreview();
}
int KMyListBox::compareNummeric( const QString & s1, const QString & s2 )
{
unsigned int z = 0;
unsigned int max = ( s1.length() > s2.length() ? s1.length() : s2.length() );
QString num1;
QString num2;
for( z=0;z<max;z++)
{
//if( z >= s1.length() || z >= s2.length() )
// break;
if( s1[z] != s2[z] )
{
if( z < s1.length() && s1[z].isDigit() )
num1 = findNumInString( z, s1 );
if( z < s2.length() && s2[z].isDigit() )
num2 = findNumInString( z, s2 );
if( num1.isNull() && num2.isNull() )
break;
int a = num1.toInt();
int b = num2.toInt();
if( a == b )
return s1.compare( s2 );
else
return ( a > b ) ? 1 : -1;
}
}
return s1.compare( s2 );
}
const QString KMyListBox::findNumInString( unsigned int pos, const QString & s )
{
QString num;
for( int i = (int)pos; i >= 0; i-- )
if( s[i].isDigit() )
num.prepend( s[i] );
else
break;
for( unsigned int i = pos + 1; i < s.length(); i++ )
if( s[i].isDigit() )
num.append( s[i] );
else
break;
return num;
}
void KMyListBox::resizeEvent( QResizeEvent* e )
{
KListBox::resizeEvent( e );
positionLabel();
}
void KMyListBox::clear()
{
KListBox::clear();
positionLabel();
}
void KMyListBox::positionLabel()
{
if( count() )
{
label->hide();
}
else
{
int x = (width() - label->minimumSizeHint().width()) / 2;
int y = (height() - label->minimumSizeHint().height()) / 2;
label->setGeometry( x, y, label->minimumSizeHint().width(), label->minimumSizeHint().height() );
label->show();
}
}
void KMyListBox::paintEvent( QPaintEvent* e )
{
// qDebug("Updates=%i", (int)isUpdatesEnabled() );
//if( isUpdatesEnabled() )
KListBox::paintEvent( e );
}
KMyListBoxItem::KMyListBoxItem( const KMyListBoxItem* item )
: QListBoxItem()
{
m_url = item->url();
m_dir = item->dir();
m_has_preview = false;
pm = *item->pixmap();
}
KMyListBoxItem::KMyListBoxItem( const KURL & u, bool b )
: QListBoxItem()
{
m_url = u;
m_dir = b;
m_has_preview = false;
}
void KMyListBoxItem::setPixmap( const QPixmap & pix )
{
KMyListBox* box = static_cast<KMyListBox*>(this->listBox());
pm.resize( box->getPreviewSize(), box->getPreviewSize() );
pm.fill( box->colorGroup().base() );
QPainter painter( &pm );
painter.drawPixmap( (pm.width()-pix.width())/2, (pm.height()-pix.height())/2, pix );
m_has_preview = true;
}
void KMyListBoxItem::setName( bool b )
{
KMyListBoxItem::m_name = b;
}
void KMyListBoxItem::setPreview( bool b )
{
KMyListBoxItem::m_preview = b;
}
void KMyListBoxItem::paint( QPainter *painter )
{
if( !KMyListBoxItem::m_preview ) {
int itemHeight = height( listBox() );
QFontMetrics fm = painter->fontMetrics();
int yPos = ( ( itemHeight - fm.height() ) / 2 ) + fm.ascent();
painter->drawText( 3, yPos, text() );
} else {
int itemHeight = height( listBox() );
int yPos;
if( pm.isNull() ) {
KFileItem item( KFileItem::Unknown, KFileItem::Unknown, m_url );
KMyListBox* box = static_cast<KMyListBox*>(this->listBox());
setPixmap( item.pixmap( box->getPreviewSize(), KIcon::DefaultState ) );
}
yPos = ( itemHeight - pm.height() ) / 2;
if( !isSelected() )
painter->drawPixmap( 3, yPos, pm);
else
{
KPixmap pix = KPixmapEffect::selectedPixmap( pm, listBox()->colorGroup().highlight() );
painter->drawPixmap( 3, yPos, pix );
}
if( KMyListBoxItem::m_name && !m_url.isEmpty() ) {
QFontMetrics fm = painter->fontMetrics();
yPos = ( ( itemHeight - fm.height() ) / 2 ) + fm.ascent();
painter->drawText( pm.width() + 5, yPos, text() );
}
}
}
int KMyListBoxItem::height( const QListBox* lb ) const
{
if( !KMyListBoxItem::m_preview ) {
int h = listBox() ? listBox()->fontMetrics().lineSpacing() + 2 : 0;
return QMAX( h, QApplication::globalStrut().height() );
} else {
int h;
if ( KMyListBoxItem::m_name && !m_url.prettyURL().isEmpty() )
h = pm.height();
else
h = QMAX( pm.height(), lb->fontMetrics().lineSpacing() + 2 );
return QMAX( h, QApplication::globalStrut().height() );
}
}
int KMyListBoxItem::width( const QListBox* ) const
{
if( !KMyListBoxItem::m_preview ) {
int w = listBox() ? listBox()->fontMetrics().width( text() ) + 6 : 0;
return QMAX( w, QApplication::globalStrut().width() );
} else {
if ( m_url.path().isEmpty() || !KMyListBoxItem::m_name)
return QMAX( pm.width() + 6, QApplication::globalStrut().width() );
return QMAX( pm.width() + listBox()->fontMetrics().width( text() ) + 6, QApplication::globalStrut().width() );
}
}
QString KMyListBoxItem::text() const
{
return m_url.prettyURL( 0, m_url.isLocalFile() ? KURL::StripFileProtocol : KURL::NoAdjustements );
}
bool KMyListBoxItem::m_preview = false;
bool KMyListBoxItem::m_name = false;

@ -0,0 +1,186 @@
/***************************************************************************
kmylistbox.h - description
-------------------
begin : Tue Oct 16 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef KMYLISTBOX_H
#define KMYLISTBOX_H
// KDE includes
#include <klistbox.h>
#include <kurl.h>
#include <kfileitem.h>
// Qt includes
#include <qmutex.h>
#include <qstringlist.h>
class ThreadedLister;
class KFileItem;
class KURLLabel;
class QDragObject;
class QPixmap;
class QPainter;
class QPoint;
class KMyListBox : public KListBox {
Q_OBJECT
public:
enum { ASCENDING = 1, DESCENDING = 2, RANDOM = 3, NUMMERIC = 4, UNSORTED = 0 };
KMyListBox(QWidget* parent=0, const char* name=0, WFlags fl=0);
~KMyListBox();
void removeItem( int index );
void addDir( const KURL & dirname, const QString & m_filter, bool m_hidden, bool recursively, bool dirnames = false );
void addDirName( const KURL & dirname, const QString & m_filter, bool m_hidden, bool recursive = false );
void setPreview( bool prv );
inline int sorting() const { return m_sorting; }
void setName( bool name );
void move( int i );
void setPreviewSize( int size );
inline int getPreviewSize() const { return previewSize; }
KURL url( int index ) const;
bool dir( int index ) const;
bool isFile( const KURL & f, bool autoadd = true );
void positionLabel();
void clear();
/**
* returns the number of currently running ThreadedListers for adding files
* or 0 if there is no file adding in progress right now.
*/
unsigned int runningAddListeners();
public slots:
void moveMode();
void moveDown();
void moveDown( int i );
void moveUp();
void moveUp( int i );
void setSorting( int s );
void addFile( const KURL & filename, bool isfile = false );
void addDirName( const KURL & dirname );
signals:
// emited when new item is drag'n'dropped into listobox
// or when files are removed or something similar
void updateCount();
void updatePreview();
void deletePressed();
void addFiles();
void currentlyAddingFiles();
private:
void preview( KURL::List list );
void dropEvent( QDropEvent* e );
void dragEnterEvent( QDragEnterEvent* e );
void viewportMousePressEvent( QMouseEvent* e );
void viewportMouseReleaseEvent( QMouseEvent* e );
void viewportMouseMoveEvent( QMouseEvent* e );
void keyPressEvent( QKeyEvent* e );
void keyReleaseEvent( QKeyEvent* e );
bool isInList( KURL text );
void sortAscending();
void sortDescending();
void sortUnsorted();
void sortRandom();
void sortNummeric();
void sortList();
void setButtonText();
int compareNummeric( const QString & s1, const QString & s2 );
const QString findNumInString( unsigned int pos, const QString & s );
private slots:
void openFile( QListBoxItem* item );
void select( QListBoxItem* item );
void previewDone( const KFileItem* item, const QPixmap &pixmap );
void previewFailed( const KFileItem* item );
void previewFinished();
void listerDone( ThreadedLister* lister );
protected:
void resizeEvent( QResizeEvent* e );
void customEvent( QCustomEvent* e );
void paintEvent( QPaintEvent* e );
bool drag;
bool mousePressed;
bool ctrlPressed;
bool shiftPressed;
bool moving;
int previewSize;
int m_sorting;
unsigned int m_running_lister_counter;
QMutex m_add_mutex;
KURLLabel* label;
QDragObject* drobj;
QPoint presspos;
};
class KMyListBoxItem : public QListBoxItem {
public:
KMyListBoxItem( const KMyListBoxItem* item );
KMyListBoxItem( const KURL&, bool );
bool hasPreview() const { return m_has_preview; }
static void setName( bool b );
static void setPreview( bool b );
void setPixmap( const QPixmap & pix );
static bool preview() { return m_preview; }
static bool name() { return m_name; }
inline bool dir() const { return m_dir; }
inline KURL url() const { return m_url; }
inline const QPixmap* pixmap() const { return &pm; }
private:
QString text() const;
protected:
virtual void paint( QPainter *painter );
virtual int width( const QListBox* ) const;
virtual int height( const QListBox* lb ) const;
private:
KURL m_url;
bool m_dir;
bool m_has_preview;
QPixmap pm;
static bool m_preview;
static bool m_name;
};
#endif

@ -0,0 +1,177 @@
/***************************************************************************
kmylistview.cpp - description
-------------------
begin : Mit M<EFBFBD> 27 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "kmylistview.h"
#include "myinputdialog.h"
// KDE includes
#include <kiconloader.h>
#include <klocale.h>
#include <kpopupmenu.h>
#include <krun.h>
KMyListView::KMyListView( QValueList<manualchanges>* _changes, KMyListBox* _list, QWidget* parent, const char* name )
:KListView(parent, name )
{
changes = _changes;
list = _list;
connect( this, SIGNAL( doubleClicked(QListViewItem*, const QPoint&, int) ),
this, SLOT( changeItem(QListViewItem*, const QPoint&, int) ) );
connect( this, SIGNAL( contextMenuRequested(QListViewItem*, const QPoint&, int) ),
this, SLOT( showContext(QListViewItem*, const QPoint&, int) ) );
setAllColumnsShowFocus( true );
}
KMyListView::~KMyListView()
{ }
void KMyListView::changeItem( QListViewItem* item, const QPoint&, int )
{
if(!item) return;
KURL url = list->url( itemIndex( item ) );
bool revertenable = false;
QValueList<manualchanges>::iterator it;
for ( it = changes->begin(); it != changes->end(); ++it )
if( (*it).url == url ) {
changes->remove( it );
revertenable = true;
break;
}
MyInputDialog i( item->text( 1 ), revertenable );
i.setInputFilename( item->text( 0 ) );
int code = i.exec();
if( code == MyInputDialog::OK ) {
manualchanges tmp = {
url,
i.filename()
};
changes->append( tmp );
emit itemChanged();
} else if( code == MyInputDialog::USE_KRENAME )
emit itemChanged();
}
void KMyListView::showContext( QListViewItem* item, const QPoint& pos, int )
{
KPopupMenu* menu = new KPopupMenu( this );
if(item) {
menu->insertTitle( list->text( itemIndex( item ) ), 0, 0 );
menu->insertItem( i18n("&Change Filename Manually"), this, SLOT( changeCurrentItem() ), Key_F2 );
menu->insertSeparator();
menu->insertItem( BarIcon("exec"), i18n("Open"), this, SLOT( openCurrent() ) );
menu->insertSeparator();
}
menu->insertItem( BarIcon("fileopen"), i18n("&Add..."), this, SLOT( addFiles() ) );
if(item)
menu->insertItem( BarIcon("editdelete"), i18n("&Remove"), this, SLOT( removeCurrentItem() ) );
menu->popup( pos );
}
void KMyListView::removeCurrentItem()
{
int index = itemIndex( currentItem() );
emit removeItem( index );
}
void KMyListView::addFiles()
{
emit addFile();
}
void KMyListView::changeCurrentItem()
{
changeItem( currentItem(), QPoint( 0, 0 ), 0 );
}
void KMyListView::openCurrent()
{
if( currentItem() )
new KRun( list->text( itemIndex( currentItem() ) ) );
}
/////////////////////////////////////////////////////////////
KMyListViewItem::KMyListViewItem(QListView *parent)
: KListViewItem(parent)
{ }
KMyListViewItem::KMyListViewItem(QListViewItem *parent)
: KListViewItem(parent)
{ }
KMyListViewItem::KMyListViewItem(QListView *parent, QListViewItem *after)
: KListViewItem(parent, after)
{ }
KMyListViewItem::KMyListViewItem(QListViewItem *parent, QListViewItem *after)
: KListViewItem(parent, after)
{ }
KMyListViewItem::KMyListViewItem(bool m, QListView *parent,
QString label1, QString label2, QString label3, QString label4,
QString label5, QString label6, QString label7, QString label8)
: KListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
{
modified = m;
}
KMyListViewItem::KMyListViewItem(bool m, QListViewItem *parent,
QString label1, QString label2, QString label3, QString label4,
QString label5, QString label6, QString label7, QString label8)
: KListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
{
modified = m;
}
KMyListViewItem::KMyListViewItem(bool m, QListView *parent, QListViewItem *after,
QString label1, QString label2, QString label3, QString label4,
QString label5, QString label6, QString label7, QString label8)
: KListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
{
modified = m;
}
KMyListViewItem::KMyListViewItem(QListViewItem *parent, QListViewItem *after,
QString label1, QString label2, QString label3, QString label4,
QString label5, QString label6, QString label7, QString label8)
: KListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
{ }
KMyListViewItem::~KMyListViewItem()
{ }
void KMyListViewItem::paintCell( QPainter *p, const QColorGroup &cg,
int column, int width, int alignment )
{
QColorGroup _cg( cg );
QColor c = _cg.text();
if( modified )
_cg.setColor( QColorGroup::Text, Qt::red );
KListViewItem::paintCell( p, _cg, column, width, alignment );
_cg.setColor( QColorGroup::Text, c );
}

@ -0,0 +1,94 @@
/***************************************************************************
kmylistview.h - description
-------------------
begin : Mit M<EFBFBD> 27 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef KMYLISTVIEW_H
#define KMYLISTVIEW_H
#include "batchrenamer.h"
#include "kmylistbox.h"
#include <klistview.h>
#include <qvaluelist.h>
class QMouseEvent;
class KMyListView : public KListView {
Q_OBJECT
public:
KMyListView( QValueList<manualchanges>* _changes, KMyListBox* _list, QWidget* parent=0, const char* name=0 );
~KMyListView();
signals:
void itemChanged();
void removeItem(int);
void addFile();
private slots:
void changeItem( QListViewItem* item, const QPoint&, int );
void showContext( QListViewItem* item, const QPoint& pos, int );
void removeCurrentItem();
void addFiles();
void changeCurrentItem();
void openCurrent();
private:
QValueList<manualchanges>* changes;
KMyListBox* list;
};
/////////////////////////////////////////////////////////////
class QColor;
class QString;
class KMyListViewItem : public KListViewItem {
public:
KMyListViewItem(QListView *parent);
KMyListViewItem(QListViewItem *parent);
KMyListViewItem(QListView *parent, QListViewItem *after);
KMyListViewItem(QListViewItem *parent, QListViewItem *after);
KMyListViewItem(bool m, QListView *parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null);
KMyListViewItem(bool m, QListViewItem *parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null);
KMyListViewItem(bool m, QListView *parent, QListViewItem *after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null);
KMyListViewItem(QListViewItem *parent, QListViewItem *after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null);
virtual ~KMyListViewItem();
void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
private:
bool modified;
};
#endif

@ -0,0 +1,113 @@
/***************************************************************************
krecursivelister.cpp - description
-------------------
begin : Fri Aug 31 2001
copyright : (C) 2001 by Jonathon Sim
email : jonathonsim@iname.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. *
* *
***************************************************************************/
#include <qtimer.h>
#include "krecursivelister.h"
KRecursiveLister::KRecursiveLister(QObject *parent, const char *name ) : QObject(parent,name) {
lister = 0L;
filelist.clear();
dirlist.clear();
dirtree.clear();
allItems.setAutoDelete( true ); // only there to delete all items
m_hidden = false;
m_dirs = false;
m_filter = QString::null;
}
KRecursiveLister::~KRecursiveLister(){
delete lister;
}
void KRecursiveLister::cleanUp()
{
filelist.clear();
dirlist.clear();
}
/** Starts listing the specified url */
void KRecursiveLister::openURL(const KURL& url ){
filelist.clear();
dirlist.clear();
startListing(url);
}
/** Returns the list of fileitems found. */
const KFileItemList & KRecursiveLister::items(){
return filelist;
}
/** handles completion of a listing. */
void KRecursiveLister::slotListingComplete(){
KFileItemList templist=lister->items();
KFileItem * item;
KFileItem * newitem;
for( item = templist.first(); item != 0; item=templist.next() )
{
if (item->isDir()) {
newitem= new KFileItem(*item);
dirlist.append(newitem);//Used for recursing the directories
dirtree.append(newitem);//Returned to user on request.
allItems.append(newitem);
}
else {
newitem= new KFileItem(*item);
filelist.append(newitem);
allItems.append(newitem);
}
}
QTimer::singleShot( 0, this, SLOT( listNextDirectory() ));
}
/** Starts listing the specified url */
void KRecursiveLister::startListing(const KURL& url){
if (!lister) {
lister=new KDirLister(true);
lister->setShowingDotFiles( m_hidden );
lister->setNameFilter( m_filter );
lister->setDirOnlyMode( m_dirs );
connect(lister,SIGNAL(completed()), this, SLOT(slotListingComplete()) );
}
lister->openURL( url, false, false );
}
void KRecursiveLister::listNextDirectory()
{
if ( dirlist.isEmpty() )
emit completed();
else
{
KFileItem * nextdir=dirlist.last();
KURL url = nextdir->url();
dirlist.removeLast();
startListing( url );
}
}
/** Stops the listing */
void KRecursiveLister::stop(){
lister->stop();
}
/** Returns the subdirectories found by the listing */
const KFileItemList& KRecursiveLister::dirs(){
return dirtree;
}
#include "krecursivelister.moc"

@ -0,0 +1,107 @@
/***************************************************************************
krecursivelister.h - description
-------------------
begin : Fri Aug 31 2001
copyright : (C) 2001 by Jonathon Sim
email : jonathonsim@iname.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 KRECURSIVELISTER_H
#define KRECURSIVELISTER_H
#include <qwidget.h>
#include <qobject.h>
#include <kdirlister.h>
#include <kfileitem.h>
#include <qguardedptr.h>
/**A convienience class that recursively lists a directory
*@author Jonathon Sim
*
* Modified by Dominik Seichter to support a name filter,
* dir only mode, support for showing hidden files on demand
* and support for listing directories along with files.
*/
class KRecursiveLister : public QObject {
Q_OBJECT
public:
KRecursiveLister(QObject *parent=0, const char *name=0);
~KRecursiveLister();
/** Returns the list of fileitems found. */
const KFileItemList & items();
/** sets wether hidden files shall be listed */
inline void setShowingDotFiles( bool dotfiles );
/** filter to be used */
inline void setNameFilter( const QString & filter );
/** list only directories */
inline void setDirOnlyMode( bool dirsOnly );
/** Starts listing the specified url */
void openURL(const KURL& url);
/** Stops the listing */
void stop();
/** Returns the subdirectories found by the listing */
const KFileItemList& dirs();
void cleanUp();
signals: // Signals
/** Listing is complete */
void completed();
protected slots: // Protected slots
/** handles completion of a listing. */
void slotListingComplete();
void listNextDirectory();
protected: // Protected methods
/** Starts listing the specified url */
void startListing(const KURL& url);
//Protected variables
KFileItemList filelist; //Files found at url
KFileItemList dirlist; //Dirs remaining to list
KFileItemList dirtree;
KFileItemList allItems;
QGuardedPtr<KDirLister> lister; //The current KDirLister
bool m_hidden;
bool m_dirs;
QString m_filter;
};
void KRecursiveLister::setShowingDotFiles( bool dotfiles )
{
m_hidden = dotfiles;
}
void KRecursiveLister::setNameFilter( const QString & filter )
{
m_filter = filter;
}
void KRecursiveLister::setDirOnlyMode( bool dirsOnly )
{
m_dirs = dirsOnly;
}
#endif

@ -0,0 +1,11 @@
[Desktop Entry]
Type=Application
Exec=krename -caption "%c" %i %m %U
Icon=krename.png
MiniIcon=krename.png
DocPath=krename/index.html
Comment=A batch renamer
Comment[de]=Ein Batch Umbenenner
Terminal=false
Name=KRename
Categories=Qt;KDE;Utility;

@ -0,0 +1,30 @@
/***************************************************************************
krename.h - description
-------------------
begin : Die Mai 15 15:34:19 CEST 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef KRENAME_H
#define KRENAME_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Why the hell am I still using this file ? ;)
// -- Just for config.h and we need a sourcefile
// with KRename in its name, since krename.cpp
// is missing since version 0.1
#endif // KRENAME_H

@ -0,0 +1,12 @@
[Desktop Entry]
Actions=Rename
Encoding=UTF-8
ServiceTypes=inode/directory
[Desktop Action Rename]
Exec=krename -r %U
Name=Rename with KRename
Name[de]=Mit KRename umbenennen
Name[es]=Renombrar con KRename
Name[fr]=Renommer avec KRename
Icon=krename

@ -0,0 +1,11 @@
<!DOCTYPE KRenameProfile>
<krename>
<version version="3.0.3rc1" />
<settings fileplugins="1" wizard="0" />
<filename extension_start="1" extension_enabled="1" extension="$" filename="$" >
<replace/>
<numbering step="1" start="1" skip="" />
</filename>
<destination undoscript="" mode="2" undo="0" overwrite="0" directory="" />
<files names="1" sorting="0" preview="0" />
</krename>

@ -0,0 +1,11 @@
<!DOCTYPE KRenameProfile>
<krename>
<version version="3.0.3rc1" />
<settings fileplugins="1" wizard="1" />
<filename extension_start="1" extension_enabled="1" extension="$" filename="$" >
<replace/>
<numbering step="1" start="1" skip="" />
</filename>
<destination undoscript="" mode="2" undo="0" overwrite="0" directory="" />
<files names="1" sorting="0" preview="0" />
</krename>

@ -0,0 +1,55 @@
/***************************************************************************
krenamedcop.h - description
-------------------
begin : Sat Dec 27 23:54:28 CET 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef KRENAMEDCOP_H
#define KRENAMEDCOP_H
#include <dcopobject.h>
#include <qstringlist.h>
#include <kurl.h>
class KRenameDCOP : virtual public DCOPObject
{
K_DCOP
public:
k_dcop:
virtual void addFileOrDir( const QString & name ) = 0;
virtual void addDir( const QString & name, const QString & filter, bool recursive, bool hidden, bool dirnames ) = 0;
virtual void updatePre() = 0;
virtual void setFileNameTemplate( const QString & t ) = 0;
virtual const QString fileNameTemplate() const = 0;
virtual void setExtensionTemplate( const QString & t ) = 0;
virtual const QString extensionTemplate() const = 0;
virtual void setUseExtension( bool b ) = 0;
virtual bool useExtension() const = 0;
virtual void setCounterStart( int index ) = 0;
virtual int counterStart() const = 0;
virtual void start() = 0;
virtual QStringList tokens() const = 0;
virtual QString parseString( const QString & token, const QString & string ) = 0;
};
#endif /* KRENAMEDCOP_H */

File diff suppressed because it is too large Load Diff

@ -0,0 +1,353 @@
/***************************************************************************
krenameimpl.h - description
-------------------
begin : Die Mai 20 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef KRENAMEIMPL_H
#define KRENAMEIMPL_H
// Own includes
#include "batchrenamer.h"
#include "krenamedcop.h"
class HelpDialog;
class HelpDialogData;
class KAction;
class KComboBox;
class KJanusWidget;
class KMyHistoryCombo;
class KMyListBox;
class KMyListView;
class KMenuBar;
class KPopupMenu;
class KPushButton;
class KToggleAction;
class KURL;
class KURLRequester;
class KIntNumInput;
class MyHelpCombo;
class MyLabel;
class Plugin;
class PluginLoader;
class QButtonGroup;
class QCheckBox;
class QGroupBox;
class QFileInfo;
class QFrame;
class QHBoxLayout;
class QLabel;
class QLineEdit;
class QListView;
class QPushButton;
class QRect;
class QWidgetStack;
class QRadioButton;
class QVBoxLayout;
class QVGroupBox;
class QWidget;
#include <kguiitem.h>
KPushButton* createButton( KGuiItem item, QWidget* parent );
class KRenameImpl : public QObject, public KRenameDCOP {
Q_OBJECT
friend class ProfileManager;
friend class ProfileDlg;
friend class tabs;
public:
KRenameImpl( QWidget* p, KMenuBar* m, QPushButton* finish );
~KRenameImpl();
void setWizardMode( bool mode );
/*
* public because both get called from KRenameImpl::launch()
*/
void updatePre();
void addFileOrDir( const KURL & name );
void setup( bool wizardmode );
void changeParent( QWidget* p, KMenuBar* m, QPushButton* finish, QRect r );
static QWidget* launch( QRect rect, const KURL::List & list, KRenameImpl* impl = 0, bool loadprofile = true );
/** DCOP functions we have to implement
*/
void addFileOrDir( const QString & name );
const QString fileNameTemplate() const;
inline int counterStart() const;
void setExtensionTemplate( const QString & t );
const QString extensionTemplate() const;
void setUseExtension( bool b );
bool useExtension() const;
QStringList tokens() const;
QString parseString( const QString & token, const QString & string );
void addDir( const QString & name, const QString & filter, bool recursive, bool hidden, bool dirnames );
const QString title( int index ) const;
/** @returns true if the user has specified a profile on the commandline
* other wise false is returned
*/
inline bool hasCommandlineProfile() const;
public slots:
void setFileNameTemplate( const QString & t );
void setCounterStart( int index );
signals:
void pageDone( QWidget* page, const QString & title );
void showPage( int page );
void enableFinish( bool b );
private slots:
void about();
void addFile();
bool checkErrors();
void clearList();
void enableControls();
void toggleImagePreview();
void moveUp();
void moveDown();
void help();
void removeFile();
void removeFile( int index );
void preferences();
void replace();
void saveConfig();
void start();
void updateCount();
void undo();
void changeUndoScriptName();
void pluginHelpChanged();
void getCoordinates();
void changeNumbers();
void updateDots();
void updatePreview();
void showTokenHelp();
void toggleName();
void changed();
void loadFilePlugins();
void reloadFilePluginData();
void manageProfiles();
QString easyOptions( KComboBox* combo, KMyHistoryCombo* custom );
void slotEasy1();
void slotEasy2();
void slotEasy3();
void slotEasy4();
/** Update the preview only if the passed
* plugin is enabled for use.
*/
void updatePluginPreview( Plugin* p );
private:
static int numRealTimePreview;
/** Change the GUI mode according to the current setting of m_wizard
*/
void changeGUIMode();
/** Returns COPY if optionCopy is checked, RENAME if optionRename is checked
* ...
*/
int currentRenameMode();
void loadConfig();
void fillStructures( BatchRenamer* b, bool preview );
bool setupBatchRenamer( BatchRenamer* b, bool preview );
void splitFilename( QFileInfo* fi, QString* base, QString* extension );
void setupActions();
void setupPage1();
void setupPage2();
void setupPage3();
void setupPage4();
void setupTab1();
void setupFileTab1();
void setupFileTab2();
void setupPages();
void updateHist();
void parseCommandline();
void addTitle( QWidget* p, QVBoxLayout* layout, QString title );
QValueList<manualchanges> changes;
void refreshColumnMode();
void parseWizardMode();
void getHelpDialogString( QLineEdit* edit );
protected:
QWidget* parent;
KMenuBar* menuBar;
KPopupMenu* mnuSort;
KAction* loadPlugins;
QPushButton* finishButton;
PluginLoader* plugin;
QWidgetStack* fileTab;
QWidget* page_1;
QWidget* page_2;
KJanusWidget* page_3;
QWidget* page_4;
bool m_wizard;
bool m_loadplugins;
bool m_switching;
bool m_autosize;
int m_hist;
int m_index;
int m_step;
bool m_reset;
bool m_hasCommandlineProfile;
KPushButton* buttonUp;
KPushButton* buttonDown;
KPushButton* buttonUp2;
KPushButton* buttonDown2;
KPushButton* buttonAdd;
KPushButton* buttonRemove;
KPushButton* buttonRemoveAll;
KPushButton* buttonReplace;
KPushButton* buttonEasyReplace;
KPushButton* buttonHelp;
KPushButton* buttonMove;
KPushButton* buttonCoord;
KPushButton* buttonNumber;
KPushButton* buttonEasy1;
KPushButton* buttonEasy2;
KPushButton* buttonEasy3;
KPushButton* buttonEasy4;
KComboBox* comboSort;
QLabel* description;
QLabel* description2;
QLabel* description3;
QLabel* description4;
QLabel* labelTemplate;
QLabel* labelHelp;
QLabel* labelCount;
QLabel* labelPoint;
KMyListBox* fileList;
KMyListView* preview;
QButtonGroup* groupOptions;
QRadioButton* optionCopy;
QRadioButton* optionMove;
QRadioButton* optionRename;
QRadioButton* optionLink;
QGroupBox* groupExtension;
QVGroupBox* groupUndo;
KMyHistoryCombo* dirname;
KURLRequester* urlrequester;
KURLRequester* undorequester;
KMyHistoryCombo* filename;
KMyHistoryCombo* extemplate;
QCheckBox* checkName;
QCheckBox* checkExtension;
QCheckBox* checkOverwrite;
QCheckBox* checkPreview;
QCheckBox* checkUndoScript;
KComboBox* comboExtension;
MyHelpCombo* comboHelp;
HelpDialog* helpDialog;
HelpDialogData* helpDialogData;
BatchRenamer* b;
QValueList<int> skip;
QValueList<replacestrings> rep;
// ==========
// Easy mode:
// ==========
KComboBox* comboKRenamePrefix;
KComboBox* comboKRenameSuffix;
KComboBox* comboKRenameFilename;
KComboBox* comboKRenameExtension;
KMyHistoryCombo* comboPrefix;
KMyHistoryCombo* comboSuffix;
KMyHistoryCombo* comboCustom;
KMyHistoryCombo* comboCustomExtension;
KIntNumInput* spinStart;
KIntNumInput* spinNull;
// ===========
// Layout:
// ===========
QHBoxLayout* pageLayout;
QVBoxLayout* pageLayout_2;
QVBoxLayout* pageLayout_3;
QVBoxLayout* pageLayout_4;
QHBoxLayout* tabLayout_0;
QHBoxLayout* tabLayout_1;
QHBoxLayout* tabLayout_2;
QVBoxLayout* tabLayout_3;
QVBoxLayout* groupAdvancedExtensionLayout;
QVBoxLayout* groupOptionsLayout;
QHBoxLayout* groupDirLayout;
QVBoxLayout* groupNumberLayout;
QHBoxLayout* groupExtensionLayout;
// page1
QHBoxLayout* Layout2;
QVBoxLayout* Layout3;
QHBoxLayout* Layout4;
QVBoxLayout* Layout5;
// page4
QVBoxLayout* Layout10;
QHBoxLayout* Layout15;
QVBoxLayout* Layout16;
QHBoxLayout* Layout22;
QVBoxLayout* Layout23;
// tab
QHBoxLayout* Layout100;
QHBoxLayout* Layout101;
};
int KRenameImpl::counterStart() const
{
return m_index;
}
bool KRenameImpl::hasCommandlineProfile() const
{
return m_hasCommandlineProfile;
}
#endif

@ -0,0 +1,16 @@
[Desktop Entry]
Encoding=UTF-8
ServiceTypes=all/allfiles
Actions=Rename
ExcludeServiceTypes=kdedevice/*
[Desktop Action Rename]
Name=Rename with KRename
Name[de]=Mit KRename umbenennen
Name[es]=Renombrar con KRename
Name[fr]=Renommer avec KRename
Name[pt_BR]=Renomear com KRename
Exec=krename %F
Icon=krename

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,148 @@
/***************************************************************************
main.cpp - description
-------------------
begin : Die Mai 15 15:34:19 CEST 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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 your2192 option) any later version. *
* *
***************************************************************************/
// Qt includes
#include <qrect.h>
#include <qwidget.h>
// KDE includes
#include <kapplication.h>
#include <kaboutapplication.h>
#include <kcmdlineargs.h>
#include <kconfig.h>
#include <kimageio.h>
#include <klocale.h>
#include <kmessagebox.h>
// Own includes
#include "wizard.h"
#include "tabs.h"
#include "krenameimpl.h"
#include "firststartdlg.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// OS includes
#include <unistd.h>
#include <sys/types.h>
#ifndef VERSION
#define VERSION "unknown"
#endif
KAboutData aboutData( "krename", I18N_NOOP("KRename"), VERSION, I18N_NOOP(
"KRename is a batch file renamer which can rename a\n"
"list of files based on a set of expressions.\n\n"
"If you like KRename you may want to support it.\n"
"Testing, bug fixes and feature request are as welcome\n"
"as financial support (everybody needs money ;)\nSee help files for details.\n" ),
KAboutData::License_GPL, "KRename Build:" __DATE__ " " __TIME__
, "(c) 2001-2007, Dominik Seichter\n",
"http://www.krename.net", "domseichter@web.de" );
static KCmdLineOptions options[] =
{
{ "+[file]", I18N_NOOP("file will be added to the list of files for renaming"), 0},
{ "r +[dir]", I18N_NOOP("add directory recursively"), 0 },
{ "template +", I18N_NOOP("set a template"), 0 },
{ "extension +", I18N_NOOP("set a template for the file extension"), 0 },
{ "use-plugin +", I18N_NOOP("enable a plugin for use"), 0 },
{ "copy +[dir]", I18N_NOOP("copy files to directory"), 0 },
{ "move +[dir]", I18N_NOOP("move files to directory"), 0 },
{ "profile +[profile]", I18N_NOOP("load the profile named [profile] on startup"), 0 },
{ "start", I18N_NOOP("start renaming immediately"), 0 },
{ "previewitems <num>", I18N_NOOP("only show <num> preview items"), 0 },
KCmdLineLastOption
};
int main(int argc, char *argv[])
{
aboutData.addAuthor("Dominik Seichter", 0, "domseichter@web.de",
"http://www.krename.net" );
aboutData.addAuthor("Stefan \"Stonki\" Onken",
I18N_NOOP("Website, testing, very good ideas and keeping me coding!"),
"support@stonki.de", "http://www.stonki.de" );
aboutData.addCredit("Trevor Semeniuk", I18N_NOOP("Thanks to him for creating RedHat 7.x packages and some other help."),
"semeniuk@ee.ualberta.ca", "http://www.semeniuk.net" );
aboutData.addCredit("Groult Richard", I18N_NOOP("Fixed a bug with startIndex and added the BatchRenamer class\n"
"to his excellent image viewer showimg."),
"rgroult@jalix.org", "http://ric.jalix.org/" );
aboutData.addCredit("Michael Elvers", I18N_NOOP("Fixed a bug that caused krename not closing open files."),
"m_elvers@yahoo.com", "http://come.to/melvers" );
aboutData.addCredit("Andreas Pour", I18N_NOOP("Thanks for his great job at apps.kde.com and help with contributing krename to apps.kde.com."),
"pour@mieterra.com", "http://apps.kde.com" );
aboutData.addCredit("Charles Samuels", I18N_NOOP("Thanks for noatun and the ID3/Ogg Tag code is based on his noatun modules."),
"charles@kde.org", "http://noatun.kde.org/" );
aboutData.addCredit("Franz Schmid", I18N_NOOP("Gave me a good start into writing plugins with his application scribus."),
"Franz.Schmid@altmuehlnet.de", "http://web2.altmuehlnet.de/fschmid/index.html" );
aboutData.addCredit("Rolf Magnus", I18N_NOOP("Parts of the PNG support are copied from his KFile plugin for png support."),
"ramagnus@kde.org" );
aboutData.addCredit("Michael v.Ostheim", I18N_NOOP("Created the Gentoo Ebuild scripts for Krename."),
"MvOstheim@web.de", "http://www.vonostheim.de" );
aboutData.addCredit("Brandon Low", I18N_NOOP("Some GCC 3.1 fixes for Gentoo."),
"lostlogic@gentoo.org", "http://www.gentoo.org" );
aboutData.addCredit("Per <20>vind Karlsen", I18N_NOOP("Thanks for creating the Mandrake RPM"),
"peroyvind@delonic.no" );
aboutData.addCredit("Daniele Medri", I18N_NOOP("Italian translation"), "madrid@linuxmeeting.net" );
aboutData.addCredit("Stephan Johach", I18N_NOOP("Provided a gcc3.x namespace patch"), "lucardus@onlinehome.de" );
aboutData.addCredit("Micha<EFBFBD> Zugaro", I18N_NOOP("Provided the new preview and move features") , "michael.zugaro@college-de-france.fr" );
aboutData.addCredit("Rene Gass", I18N_NOOP("Fixed problems with the spec file and contributed rpms for every SuSE version you can imagine and is also the new Gentoo maintainer for KRename"), "kde-package@gmx.de" );
aboutData.addCredit("Mark Volkert", I18N_NOOP("Provided SuSE RPMs and very good suggestions"), "mark.volkert@rakekniven.de" );
aboutData.addCredit("Jose Rodriguez", I18N_NOOP("Contributed a Spanish translation"), "chmpmi@eresmas.net" );
aboutData.addCredit("Steven P. Ulrick", I18N_NOOP("Provided a RedHat RPM and was big help in improving KRename"), "steve@afolkey2.net" );
aboutData.addCredit("UTUMI Hirosi", I18N_NOOP("Translated KRename to Japanese"), "utuhiro@mx12.freecom.ne.jp" );
aboutData.addCredit("Nicolas Benoit", I18N_NOOP("Translated KRename into French"), "nbenoit@tuxfamily.org" );
aboutData.addCredit("Krzysztof Pawlak", I18N_NOOP("Translated KRename into Polish"), "jmnemonic@gazeta.pl" );
aboutData.addCredit("Ilya Ivkov", I18N_NOOP("Translated KRename into Russian"), "ilya-ivkov@yandex.ru" );
aboutData.addCredit("Asim Husanovic", I18N_NOOP("Translated KRename into Bosnian"), "asim.h@megatel.ba" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineArgs::addCmdLineOptions( options );
KApplication a;
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
KImageIO::registerFormats();
QWidget* krename = KRenameImpl::launch( QRect( 0, 0, 0, 0 ), QStringList() );
/* Check if Krename
* was started from root!
*/
unsigned int uid = geteuid();
if( uid == 0 )
KMessageBox::information( krename, i18n(
"<b>Krename was started from root!</b><br>"
"When started from root, Krename may damage your "
"system if you do not know exactly what you are "
"doing!"
), i18n("Error"), "KrenameRootWarning" );
/*
* Activate this warning message for unstable development releases.
*/
/* KMessageBox::sorry( krename, i18n(
"<b>Warning !</b> This is a development release which may cause damage to your files!"
"<br>Make backups before using KRename." ));
*/
return a.exec();
}

@ -0,0 +1,169 @@
/***************************************************************************
mydirplugin.cpp - description
-------------------
begin : Tue Jan 29 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
// Own includes
#include "mydirplugin.h"
// KDE includes
#include <kapplication.h>
#include <kiconloader.h>
#include <kfiledialog.h>
#include <klocale.h>
// QT includes
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qgroupbox.h>
#include <qspinbox.h>
const QString MyDirPlugin::getName() const
{
return i18n("Dir Plugin");
}
const QString MyDirPlugin::getAccelName() const
{
return i18n("&Dir Plugin");
}
const int MyDirPlugin::type() const
{
return TYPE_FINAL_FILE;
}
bool MyDirPlugin::checkError()
{
return true;
}
const QPixmap MyDirPlugin::getIcon() const
{
return kapp->iconLoader()->loadIcon( "folder", KIcon::Small );
}
void MyDirPlugin::drawInterface( QWidget* w, QVBoxLayout* l )
{
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
QVBoxLayout* LayoutA = new QVBoxLayout( 0, 6, 6 );
QVBoxLayout* LayoutB = new QVBoxLayout( 0, 6, 6 );
m_widget = w;
QLabel* la = new QLabel( w );
la->setText( i18n("<qt>This plugin sorts files after renaming in subdirectories.</qt>") );
l->addWidget( la );
groupNumber = new QGroupBox( w );
groupNumber->setTitle( i18n( "&Options" ) );
groupNumber->setColumnLayout(0, Qt::Vertical );
groupNumber->layout()->setSpacing( 6 );
groupNumber->layout()->setMargin( 11 );
groupNumberLayout = new QHBoxLayout( groupNumber->layout() );
groupNumberLayout->setAlignment( Qt::AlignTop );
QLabel* la2 = new QLabel( groupNumber );
la2->setText( i18n( "Files per directory:" ) );
spinFiles = new QSpinBox( groupNumber );
spinFiles->setRange( 1, 60000 );
spinFiles->setValue( 10 );
QLabel* la3 = new QLabel( groupNumber );
la3->setText( i18n( "Start index:" ) );
spinStart = new QSpinBox( groupNumber );
spinFiles->setRange( 0, 60000 );
LayoutA->addWidget( la2 );
LayoutA->addWidget( la3 );
LayoutB->addWidget( spinFiles );
LayoutB->addWidget( spinStart );
groupNumberLayout->addLayout( LayoutA );
groupNumberLayout->addLayout( LayoutB );
groupNumberLayout->addItem( spacer );
groupOutput = new QGroupBox( w );
groupOutput->setTitle( i18n( "Output &Directory" ) );
groupOutput->setColumnLayout(0, Qt::Vertical );
groupOutput->layout()->setSpacing( 6 );
groupOutput->layout()->setMargin( 11 );
groupOutputLayout = new QHBoxLayout( groupOutput->layout() );
groupOutputLayout->setAlignment( Qt::AlignTop );
outputdir = new QLineEdit( groupOutput );
buttonDir = new QPushButton( groupOutput );
buttonDir->setText( "..." );
groupOutputLayout->addWidget( outputdir );
groupOutputLayout->addWidget( buttonDir );
l->addWidget( groupNumber );
l->addWidget( groupOutput );
l->addItem( spacer2 );
connect( buttonDir, SIGNAL(clicked()), this, SLOT(chooseDir()));
}
void MyDirPlugin::fillStructure()
{
fpd = spinFiles->value();
fpd--;
dir = outputdir->text();
filecounter = 0;
dircounter = spinStart->value();
curdir = dir + QString("/%1/").arg( dircounter );
d = new QDir( dir );
d->mkdir( curdir );
}
QString MyDirPlugin::processFile( BatchRenamer*, int, QString token, int )
{
QString newname;
// token = filename
if( filecounter == fpd ) {
filecounter = 0;
dircounter++;
curdir = dir + QString("/%1/").arg( dircounter );
d->mkdir( curdir );
}
QFileInfo f( token );
newname = curdir + f.fileName();
d->rename( token, newname );
filecounter++;
return QString::null;
}
void MyDirPlugin::finished()
{
filecounter = dircounter = 0;
}
void MyDirPlugin::chooseDir()
{
QString s (KFileDialog::getExistingDirectory ( QString::null ));
if(!s.isEmpty())
outputdir->setText( s );
}

@ -0,0 +1,72 @@
/***************************************************************************
mydirplugin.h - description
-------------------
begin : Tue Jan 29 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef MYDIRPLUGIN_H
#define MYDIRPLUGIN_H
#include "batchrenamer.h"
#include "pluginloader.h"
#include "plugin.h"
#include "helpdialog.h"
class QDir;
class QHBoxLayout;
class QGroupBox;
class QLineEdit;
class QPushButton;
class QSpinBox;
class QString;
class QVBoxLayout;
class QWidget;
class MyDirPlugin : public Plugin {
Q_OBJECT
public:
const QString getName() const;
const QString getAccelName() const;
const int type() const;
bool checkError();
void drawInterface( QWidget* w, QVBoxLayout* l );
void fillStructure();
QString processFile( BatchRenamer*, int, QString token, int );
void finished();
const QPixmap getIcon() const;
private slots:
void chooseDir();
protected:
int fpd; // files per dir
int filecounter;
int dircounter;
QString dir;
QString curdir;
QDir* d;
QLineEdit* outputdir;
QPushButton* buttonDir;
QSpinBox* spinFiles;
QSpinBox* spinStart;
QGroupBox* groupOutput;
QHBoxLayout* groupOutputLayout;
QGroupBox* groupNumber;
QHBoxLayout* groupNumberLayout;
};
#endif

@ -0,0 +1,109 @@
/***************************************************************************
myinputdialog.cpp - description
-------------------
begin : Mit Apr 01 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "myinputdialog.h"
#include <klineedit.h>
#include <kpushbutton.h>
#include <klocale.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qtooltip.h>
MyInputDialog::MyInputDialog( QString filename, bool revertEnabled, QWidget* parent )
: QDialog( parent, 0, true, 0 )
{
// I do not think this has to be translated
setCaption( "KRename" );
MyInputDialogLayout = new QVBoxLayout( this, 11, 6, "MyInputDialogLayout");
Layout = new QHBoxLayout( 0, 0, 6, "Layout");
TextLabel1 = new QLabel( this, "TextLabel1" );
TextLabel1->setText( i18n( "Please input a new filename:" ) );
text = new KLineEdit( this, "text" );
text->setText( filename );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
buttonKrename = new KPushButton( this, "buttonKrename" );
buttonKrename->setText( i18n( "&Revert Changes" ) );
buttonKrename->setEnabled( revertEnabled );
buttonFilename = new KPushButton( this, "buttonFilename" );
buttonFilename->setText( i18n("Use &Input Filename") );
buttonOk = new KPushButton( this, "buttonOk" );
buttonOk->setText( i18n( "&Ok" ) );
buttonOk->setDefault( true );
buttonCancel = new KPushButton( this, "buttonCancel" );
buttonCancel->setText( i18n( "&Cancel" ) );
text->setFocus();
Layout->addWidget( buttonKrename );
Layout->addWidget( buttonFilename );
Layout->addItem( spacer );
Layout->addWidget( buttonOk );
Layout->addWidget( buttonCancel );
MyInputDialogLayout->addWidget( TextLabel1 );
MyInputDialogLayout->addWidget( text );
MyInputDialogLayout->addLayout( Layout );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( buttonKrename, SIGNAL( clicked() ), this, SLOT( krename() ) );
connect( buttonFilename, SIGNAL( clicked() ), this, SLOT( slotFilename() ) );
QToolTip::add( buttonKrename, i18n("Use the filename that is generated by "
"KRename instead of your changes." ) );
}
MyInputDialog::~MyInputDialog()
{ }
QString MyInputDialog::filename() const
{
return text->text();
}
void MyInputDialog::accept()
{
if( text->text().isEmpty() )
reject();
else
done( OK );
}
void MyInputDialog::reject()
{
done( CANCEL );
}
void MyInputDialog::krename()
{
done( USE_KRENAME );
}
void MyInputDialog::slotFilename()
{
text->setText( m_oldfilename );
}

@ -0,0 +1,74 @@
/***************************************************************************
myinputdialog.h - description
-------------------
begin : Mit Apr 01 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef MYINPUTDIALOG_H
#define MYINPUTDIALOG_H
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class KLineEdit;
class KPushButton;
class QLabel;
class QString;
class MyInputDialog : public QDialog
{
Q_OBJECT
public:
MyInputDialog( QString filename, bool revertEnabled = true, QWidget* parent = 0 );
~MyInputDialog();
QString filename() const;
inline void setInputFilename( const QString s );
enum returnCodes {
OK,
CANCEL,
USE_KRENAME
};
private slots:
/** Use the file name generated by KRename....
*/
void krename(); // ????? :-)
void slotFilename();
void accept();
void reject();
private:
QLabel* TextLabel1;
KLineEdit* text;
KPushButton* buttonKrename;
KPushButton* buttonFilename;
KPushButton* buttonOk;
KPushButton* buttonCancel;
QString m_oldfilename;
protected:
QVBoxLayout* MyInputDialogLayout;
QHBoxLayout* Layout;
};
void MyInputDialog::setInputFilename( const QString s )
{
m_oldfilename = s;
}
#endif // MYINPUTDIALOG_H

@ -0,0 +1,171 @@
/***************************************************************************
numberdialog.cpp - description
-------------------
begin : Don Apr 24 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "numberdialog.h"
#include "batchrenamer.h"
// Qt includes
#include <qgroupbox.h>
#include <qlayout.h>
#include <qtooltip.h>
// KDE includes
#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>
#include <kpushbutton.h>
#include <qcheckbox.h>
void KMyIntSpinBox::keyPressEvent( QKeyEvent* e )
{
if( e->key() == Key_Return )
emit returnPressed();
}
NumberDialog::NumberDialog(QValueList<int> & n,QWidget *parent )
: KDialogBase( KDialogBase::Plain, "KRename",
KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent, 0, true, true )
{
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
QVBoxLayout* layout = new QVBoxLayout( plainPage(), 6, 6 );
QGroupBox* group1 = new QGroupBox( plainPage() );
group1->setTitle( i18n("&Numbering") );
group1->setColumnLayout(0, Qt::Vertical );
group1->layout()->setSpacing( 6 );
group1->layout()->setMargin( 11 );
QVBoxLayout* group1Layout = new QVBoxLayout( group1->layout() );
group1Layout->setAlignment( Qt::AlignTop );
spinIndex = new KIntNumInput( group1 );
spinIndex->setMaxValue( SPINMAX );
spinIndex->setLabel( i18n( "Start &index:" ), AlignLeft | AlignVCenter );
spinStep = new KIntNumInput( spinIndex, 1, group1 );
spinStep->setRange( -SPINMAX, SPINMAX, 1, false );
spinStep->setValue( 1 );
spinStep->setLabel( i18n( "Step &by:" ), AlignLeft | AlignVCenter );
checkResetCounter = new QCheckBox( i18n("&Reset counter for every directory"), group1 );
QGroupBox* group2 = new QGroupBox( plainPage() );
group2->setTitle( i18n("S&kip Numbers") );
group2->setColumnLayout(0, Qt::Horizontal );
group2->layout()->setSpacing( 6 );
group2->layout()->setMargin( 11 );
QHBoxLayout* group2Layout = new QHBoxLayout( group2->layout() );
group2Layout->setAlignment( Qt::AlignTop );
listNumbers = new KListBox( group2 );
buttonAdd = new KPushButton( group2 );
buttonAdd->setText( i18n( "&Add Number" ) );
buttonRemove = new KPushButton( group2 );
buttonRemove->setText( i18n( "&Remove Number" ) );
spinNumber = new KMyIntSpinBox( group2 );
spinNumber->setMaxValue( SPINMAX );
spinNumber->setMinValue( -SPINMAX );
spinNumber->setValue( 0 );
spinNumber->setFocus();
QVBoxLayout* layout2 = new QVBoxLayout( 0, 6, 6 );
layout2->addWidget( buttonAdd );
layout2->addWidget( buttonRemove );
layout2->addWidget( spinNumber );
layout2->addItem( spacer );
group1Layout->addWidget( spinIndex );
group1Layout->addWidget( spinStep );
group1Layout->addWidget( checkResetCounter );
group2Layout->addWidget( listNumbers );
group2Layout->addLayout( layout2 );
layout->addWidget( group1 );
layout->addWidget( group2 );
QToolTip::add( spinIndex, i18n( "Number of the first file." ) );
QToolTip::add( spinStep, i18n( "The counter is increased/decreased by this value." ) );
QToolTip::add( listNumbers, i18n("Add all numbers that should be skipped by krename during the rename process.<br>"
"E.g.: If 2 is skipped files will be numbered: file0, file1, file3, ...") );
QToolTip::add( checkResetCounter, i18n("<qt>The counter is set to the start index in every directory. "
"This setting applies to all used counters.</qt>" ) );
connect( buttonAdd, SIGNAL( clicked() ), this, SLOT( addNumber() ) );
connect( buttonRemove,SIGNAL( clicked() ), this, SLOT( removeNumber() ) );
connect( spinNumber, SIGNAL( returnPressed()), this, SLOT( addNumber() ) );
for( unsigned int i = 0; i < n.count(); i++ )
listNumbers->insertItem( QString("%1").arg(n[i]), -1 );
update();
}
NumberDialog::~NumberDialog()
{
}
void NumberDialog::addNumber()
{
QString tmp = QString("%1").arg(spinNumber->value());
for( unsigned int i = 0; i < listNumbers->count(); i++ )
if( listNumbers->text(i) == tmp )
return;
listNumbers->insertItem( tmp, -1 );
sort();
}
void NumberDialog::removeNumber()
{
unsigned int i = 0;
do {
if(listNumbers->isSelected( i )) {
listNumbers->removeItem( i );
listNumbers->setSelected( i-1, true );
return;
} else
i++;
} while( i < listNumbers->count() );
}
QValueList<int> NumberDialog::getList()
{
QValueList<int> skip;
for( unsigned int i = 0; i < listNumbers->count(); i++ )
skip.append( listNumbers->text(i).toInt() );
return skip;
}
void NumberDialog::sort()
{
// Not very fast, but I hope it won't be used on ot big lists ;)
if( listNumbers->count() < 1 )
return;
for( unsigned int i = 0; i < listNumbers->count()-1; i++) {
if( listNumbers->text(i).toInt() > listNumbers->text(i+1).toInt() ) {
QString tmp = listNumbers->text(i);
listNumbers->removeItem(i);
listNumbers->insertItem( tmp, i+1 );
i = 0;
}
}
}

@ -0,0 +1,74 @@
/***************************************************************************
numberdialog.h - description
-------------------
begin : Don Apr 24 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef NUMBERDIALOG_H
#define NUMBERDIALOG_H
#include <qwidget.h>
#include <kdialogbase.h>
#include <qvaluelist.h>
// KDE includes
#include <knuminput.h>
class KMyIntSpinBox : public KIntSpinBox
{
Q_OBJECT
public:
KMyIntSpinBox( QWidget* parent )
: KIntSpinBox( parent )
{ };
~KMyIntSpinBox() { };
private:
void keyPressEvent( QKeyEvent* e );
signals:
void returnPressed();
};
class QCheckBox;
class KIntNumInput;
class KListBox;
class KPushButton;
class NumberDialog : public KDialogBase {
Q_OBJECT
public:
NumberDialog(QValueList<int> & n,QWidget *parent=0);
~NumberDialog();
// TODO: bad object oriented design!!!
// make them accessible by members
KIntNumInput* spinIndex;
KIntNumInput* spinStep;
QCheckBox* checkResetCounter;
QValueList<int> getList();
private slots:
void addNumber();
void removeNumber();
private:
void sort();
KListBox* listNumbers;
KPushButton* buttonAdd;
KPushButton* buttonRemove;
KMyIntSpinBox* spinNumber;
};
#endif

@ -0,0 +1,329 @@
/***************************************************************************
permission.cpp - description
-------------------
begin : Sun Jan 13 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "permission.h"
// QT includes
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
// KDE includes
#include <kapplication.h>
#include <kcombobox.h>
#include <kiconloader.h>
#include <klocale.h>
// OS includes
#include <stdio.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <grp.h>
#include <unistd.h>
const QString MyPermPlugin::getName() const
{
return i18n("Permissions");
}
const QString MyPermPlugin::getAccelName() const
{
return i18n("&Permissions");
}
const int MyPermPlugin::type() const
{
return TYPE_FINAL_FILE;
}
bool MyPermPlugin::checkError()
{
return true;
}
void MyPermPlugin::drawInterface( QWidget* w, QVBoxLayout* l )
{
int i;
unsigned int uid; // Maybe this must be signed int ?
struct passwd *user;
struct group *ge;
QLabel *la, *cl[3];
QGridLayout *gl;
QString strOwner;
m_widget = w;
l->setResizeMode( QLayout::FreeResize );
w->setMinimumSize( QSize( 100, 100 ) );
Layout0 = new QVBoxLayout( 0, 0, 6 );
groupPermission = new QGroupBox ( i18n("Access permissions"), w );
groupPermission->setEnabled( FALSE );
gl = new QGridLayout (groupPermission, 6, 6, 15);
gl->addRowSpacing(0, 10);
checkPermissions = new QCheckBox( i18n("Change &Permissions"), w );
la = new QLabel(i18n("Class"), groupPermission);
gl->addWidget(la, 1, 0);
la = new QLabel( i18n("Read"), groupPermission );
gl->addWidget (la, 1, 1);
la = new QLabel( i18n("Write"), groupPermission );
gl->addWidget (la, 1, 2);
la = new QLabel( i18n("Exec"), groupPermission );
QSize size = la->sizeHint();
size.setWidth(size.width() + 15);
la->setFixedSize(size);
gl->addWidget (la, 1, 3);
la = new QLabel( i18n("Special"), groupPermission );
gl->addMultiCellWidget(la, 1, 1, 4, 5);
cl[0] = new QLabel( i18n("User"), groupPermission );
gl->addWidget (cl[0], 2, 0);
cl[1] = new QLabel( i18n("Group"), groupPermission );
gl->addWidget (cl[1], 3, 0);
cl[2] = new QLabel( i18n("Others"), groupPermission );
gl->addWidget (cl[2], 4, 0);
la = new QLabel(i18n("UID"), groupPermission);
gl->addWidget(la, 2, 5);
la = new QLabel(i18n("GID"), groupPermission);
gl->addWidget(la, 3, 5);
la = new QLabel(i18n("Sticky"), groupPermission);
gl->addWidget(la, 4, 5);
for (int row = 0; row < 3 ; ++row) {
for (int col = 0; col < 4; ++col) {
QCheckBox *cb = new QCheckBox(groupPermission);
permBox[row][col] = cb;
gl->addWidget (permBox[row][col], row+2, col+1);
permBox[row][0]->setChecked( TRUE );
}
}
permBox[0][1]->setChecked( TRUE );
gl->setColStretch(6, 10);
checkOwner = new QCheckBox( i18n("Change &Owner"), w );
groupOwner = new QGroupBox ( i18n("Ownership"), w );
groupOwner->setEnabled( FALSE );
groupOwner->setColumnLayout(0, Qt::Vertical );
groupOwner->layout()->setSpacing( 6 );
groupOwner->layout()->setMargin( 11 );
groupOwnerLayout = new QVBoxLayout( groupOwner->layout() );
groupOwnerLayout->setAlignment( Qt::AlignTop );
Layout2 = new QHBoxLayout( 0, 0, 6 );
Layout3 = new QHBoxLayout( 0, 0, 6 );
Layout4 = new QHBoxLayout( 0, 0, 6 );
la = new QLabel( i18n("User:"), groupOwner );
Layout2->addWidget( la );
la = new QLabel( i18n("Group:"), groupOwner );
Layout3->addWidget( la );
username = new KComboBox( groupOwner );
uid = geteuid();
setpwent();
for (i=0; ((user = getpwent()) != 0L) && (i < MAXENTRIES); i++) {
if( uid == 0 )
username->insertItem(QString::fromLatin1(user->pw_name));
else
if( user->pw_uid == uid )
username->insertItem(QString::fromLatin1(user->pw_name));
}
endpwent();
groupname = new KComboBox( groupOwner );
user = getpwuid(geteuid());
QString strUser = user->pw_name;
setgrent();
for (i=0; ((ge = getgrent()) != 0L) && (i < MAXENTRIES); i++) {
if( uid == 0 ) {
groupname->insertItem(QString::fromLatin1(ge->gr_name));
} else {
char ** members = ge->gr_mem;
char * member;
while ((member = *members) != 0L) {
if (strUser == member) {
groupname->insertItem(QString::fromLatin1(ge->gr_name));
break;
}
++members;
}
}
}
endgrent();
/* add the users group */
ge = getgrgid (getegid());
if (ge) {
QString name = QString::fromLatin1(ge->gr_name);
if (name.isEmpty())
name.setNum(ge->gr_gid);
groupname->insertItem( name );
}
// make the users group visible
groupname->setCurrentItem( groupname->count() );
QSpacerItem* spacer8 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
QSpacerItem* spacer9 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
Layout2->addWidget( username );
Layout2->addItem( spacer8 );
Layout3->addWidget( groupname );
Layout3->addItem( spacer9 );
groupOwnerLayout->addLayout( Layout2 );
groupOwnerLayout->addLayout( Layout3 );
QSpacerItem* spacer10 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
Layout4->addWidget( checkPermissions );
Layout4->addWidget( checkOwner );
l->addLayout( Layout4 );
l->addWidget( groupPermission );
l->addWidget( groupOwner );
l->addItem( spacer10 );
connect( checkOwner, SIGNAL(clicked()), this, SLOT(enableControls()) );
connect( checkPermissions, SIGNAL(clicked()), this, SLOT(enableControls()) );
}
void MyPermPlugin::fillStructure()
{
perm.changeOwner = checkOwner->isChecked();
perm.changePermissions = checkPermissions->isChecked();
if( perm.changeOwner ) {
perm.group = groupname->currentText();
perm.owner = username->currentText();
}
if( perm.changePermissions )
perm.newPermission = getPermissions();
}
QString MyPermPlugin::processFile( BatchRenamer* b, int i, QString, int )
{
QString filename = b->files()[i].dst.name;
if( perm.changePermissions )
if( chmod( (const char *)filename, (mode_t)perm.newPermission ) == -1 )
return QString( i18n("Can't chmod %1.") ).arg(filename);
if( perm.changeOwner )
if( chown( (const char*)filename, getUid( perm.owner), getGid( perm.group )))
return QString( i18n("Can't chown %1.") ).arg(filename);
return QString::null;
}
void MyPermPlugin::finished()
{
// We don't care about this event!
return;
}
int MyPermPlugin::getPermissions()
{
int fperm[3][4] = {
{S_IRUSR, S_IWUSR, S_IXUSR, S_ISUID},
{S_IRGRP, S_IWGRP, S_IXGRP, S_ISGID},
{S_IROTH, S_IWOTH, S_IXOTH, S_ISVTX}
};
int permissions = 0, mask = 0;
for (int row = 0;row < 3; ++row)
for (int col = 0; col < 4; ++col)
{
switch (permBox[row][col]->state())
{
case QCheckBox::On:
permissions |= fperm[row][col];
//fall through
case QCheckBox::Off:
mask |= fperm[row][col];
break;
default:
break;
}
}
return permissions;
}
int MyPermPlugin::getGid( QString group )
{
int i, r;
struct group *ge;
setgrent();
for (i=0; ((ge = getgrent()) != 0L) && (i < MAXENTRIES); i++)
if( !strcmp( ge->gr_name, (const char *)group ) )
break;
r = ge->gr_gid;
endgrent();
return r;
}
int MyPermPlugin::getUid( QString owner )
{
int i, r;
struct passwd *user;
setpwent();
for (i=0; ((user = getpwent()) != 0L) && (i < MAXENTRIES); i++)
if( !strcmp(user->pw_name, (const char *)owner) )
break;
r = user->pw_uid;
endpwent();
return r;
}
void MyPermPlugin::enableControls()
{
groupOwner->setEnabled( checkOwner->isChecked() );
groupPermission->setEnabled( checkPermissions->isChecked() );
}
const QPixmap MyPermPlugin::getIcon() const
{
return kapp->iconLoader()->loadIcon( "clanbomber", KIcon::Small );
}

@ -0,0 +1,90 @@
/***************************************************************************
permission.h - description
-------------------
begin : Sun Jan 13 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef PERMISSION_H
#define PERMISSION_H
/*
* This two includes are required, because you have to use
* krenames internal structures and enums.
*/
#include "batchrenamer.h"
#include "pluginloader.h"
#include "plugin.h"
#include "helpdialog.h"
#include <stdio.h>
class KComboBox;
class QCheckBox;
class QGroupBox;
class QVBoxLayout;
class QHBoxLayout;
class QString;
class QWidget;
// Plugin class starts here
class MyPermPlugin: public Plugin {
Q_OBJECT
public:
const QString getName() const;
const QString getAccelName() const;
const int type() const;
bool checkError();
void drawInterface( QWidget* w, QVBoxLayout* l );
void fillStructure();
QString processFile( BatchRenamer* b, int, QString token, int );
void finished();
const QPixmap getIcon() const;
private:
int getPermissions();
int getGid( QString group );
int getUid( QString owner );
struct pervals {
bool changePermissions;
bool changeOwner;
QString owner; // name of owner
QString group; // name of group
int newPermission; // Permissions
}perm;
private slots:
void enableControls();
protected:
QGroupBox* groupPermission;
QGroupBox* groupOwner;
QCheckBox* checkPermissions;
QCheckBox* checkOwner;
QCheckBox* permBox[3][4];
KComboBox* username;
KComboBox* groupname;
QVBoxLayout* groupOwnerLayout;
QVBoxLayout* Layout0;
QHBoxLayout* Layout2;
QHBoxLayout* Layout3;
QHBoxLayout* Layout4;
};
#endif

@ -0,0 +1,98 @@
/***************************************************************************
pictureplugin.cpp - description
-------------------
begin : Son Apr 14 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "pictureplugin.h"
// QT includes
#include <qimage.h>
// KDE includes
#include <kapplication.h>
#include <klocale.h>
PicturePlugin::PicturePlugin()
: FilePlugin( 0 )
{
keys.append( "resolution" );
keys.append( "xres" );
keys.append( "yres" );
keys.append( "bitdepth" );
setupKeys();
m_icon = "image";
}
const QString PicturePlugin::getName() const
{
return i18n("Picture Plugin");
}
const QString PicturePlugin::getAccelName() const
{
return i18n("P&icture Plugin");
}
const QString PicturePlugin::getPattern() const
{
return "pic";
}
QString PicturePlugin::processFile( BatchRenamer* b, int i, QString token, int )
{
QString resolution;
QString xres;
QString yres;
QString bitdepth;
QString filename = BatchRenamer::buildFilename( &b->files()[i].src );
token = token.lower();
/*
* Check if we have something cached for this file
*/
if( cache.contains( filename + "::" + token ) )
return cache[filename + "::" + token ];
QImage img( filename );
if( img.isNull() )
return QString::null;
resolution = QString( "%1x%2" ).arg(img.width()).arg(img.height());
xres = QString::number( img.width() );
yres = QString::number( img.height() );
bitdepth = QString::number( img.depth() );
if( cache.count() >= CACHE_MAX )
cache.remove( cache.begin() );
QString ret = QString::null;
if( token == getPattern() + "resolution" )
ret = resolution;
else if( token == getPattern() + "xres" )
ret = xres;
else if( token == getPattern() + "yres" )
ret = yres;
else if( token == getPattern() + "bitdepth" )
ret = bitdepth;
cache.insert( filename + "::" + token, ret );
return ret;
}

@ -0,0 +1,40 @@
/***************************************************************************
pictureplugin.h - description
-------------------
begin : Son Apr 14 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef PICTUREPLUGIN_H
#define PICTUREPLUGIN_H
#include "batchrenamer.h"
#include "pluginloader.h"
#include "fileplugin.h"
class QVBoxLayout;
class QHBoxLayout;
class QString;
class QWidget;
class PicturePlugin : public FilePlugin {
Q_OBJECT
public:
PicturePlugin();
const QString getName() const;
const QString getAccelName() const;
const QString getPattern() const;
QString processFile( BatchRenamer* b, int i, QString token, int );
};
#endif

@ -0,0 +1,62 @@
/***************************************************************************
plugin.cpp - description
-------------------
begin : Sun Dec 30 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "plugin.h"
#include "helpdialog.h"
#include <qpixmap.h>
Plugin::Plugin()
{
m_widget = NULL;
}
Plugin::~Plugin()
{
delete m_widget;
}
void Plugin::addHelp( HelpDialogData* ) { }
void Plugin::removeHelp( HelpDialogData* data )
{
data->remove( getName() );
}
bool Plugin::alwaysUsed() const
{
return false;
}
const QStringList Plugin::getKeys() const
{
return QStringList();
}
const QString Plugin::getPattern() const
{
return QString::null;
};
const QPixmap Plugin::getIcon() const
{
return QPixmap();
}
void Plugin::clearCache()
{
// do nothing...
}

@ -0,0 +1,72 @@
/***************************************************************************
plugin.h - description
-------------------
begin : Sun Dec 30 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef PLUGIN_H
#define PLUGIN_H
#include "batchrenamer.h"
#include <qobject.h>
class HelpDialogData;
class QString;
class QStringList;
class QWidget;
class QVBoxLayout;
class Plugin : public QObject {
Q_OBJECT
public:
Plugin();
virtual ~Plugin();
virtual const QString getName() const = 0;
virtual const QString getAccelName() const = 0;
virtual const QString getPattern() const;
virtual const int type() const = 0;
virtual bool alwaysUsed() const;
virtual bool checkError() = 0;
virtual void drawInterface( QWidget* w, QVBoxLayout* l ) = 0;
virtual void fillStructure() { }
virtual QString processFile( BatchRenamer* b, int i, QString token, int mode ) = 0;
virtual void finished() { }
virtual void addHelp( HelpDialogData* data );
virtual void removeHelp( HelpDialogData* data );
virtual void clearCache();
virtual const QPixmap getIcon() const;
virtual const QStringList getKeys() const;
signals:
void previewChanged( Plugin* plugin );
protected slots:
// call this method when your plugin settings changed
// in a way, that KRename should update its preview
void updatePreview()
{
emit previewChanged( this );
}
protected:
QWidget* m_widget;
};
#endif

@ -0,0 +1,179 @@
/***************************************************************************
pluginloader.cpp - description
-------------------
begin : Sun Dec 30 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
/*
* Parts of this code are copied from
* Franz Schmid's <Franz.Schmid@altmuehlnet.de>
* Scribus.
*/
// Own includes
#include "pluginloader.h"
#include "fileplugin.h"
#include "datetime.h"
#include "mydirplugin.h"
#include "permission.h"
#include "pictureplugin.h"
#include "commandplugin.h"
#include "dateplugin.h"
#include "encodingplugin.h"
#include "translitplugin.h"
// QT includes
#include <qregexp.h>
#include <qstringlist.h>
// KDE includes
#include <kapplication.h>
#include <kservice.h>
/* use a prime number here */
#define DICT_SIZE 43
#define BRACKET_CACHE_COUNT 19
PluginLoader::PluginLoader()
{
libs.setAutoDelete( true );
m_loaded = false;
m_file = false;
}
PluginLoader::~PluginLoader()
{ }
PluginLoader* PluginLoader::instance()
{
if( !m_plugin )
m_plugin = new PluginLoader();
return m_plugin;
}
PluginLoader* PluginLoader::m_plugin = NULL;
void PluginLoader::loadPlugins( bool fileplugins )
{
int i;
// make sure all plugins with display
// get deleted and the GUI is rebuild
if( m_loaded )
{
for( i=0;i<NUM_INTERNAL_PLUGINS;i++ )
{
for( unsigned int z=0;z<libs.count();z++ )
if( libs.at(z)->plugin == m_internal_plugins[i] )
{
libs.remove( z );
break;
}
}
}
m_loaded = true;
m_internal_plugins[0] = new CommandPlugin();
m_internal_plugins[1] = new MyPermPlugin();
m_internal_plugins[2] = new MyDatePlugin();
m_internal_plugins[3] = new MyDirPlugin();
m_internal_plugins[4] = new PicturePlugin();
m_internal_plugins[5] = new EncodingPlugin();
m_internal_plugins[6] = new DatePlugin();
m_internal_plugins[7] = new TranslitPlugin();
for( i=0;i<NUM_INTERNAL_PLUGINS;i++ )
addPlugin( m_internal_plugins[i] );
if( fileplugins && !m_file )
loadFilePlugins();
m_bracket_map.clear();
QPtrListIterator<PluginLoader::PluginLibrary> it( libs );
for( ; it.current(); ++it ) {
if( (*it)->plugin->type() == TYPE_BRACKET ) {
const QStringList list = (*it)->plugin->getKeys();
for( unsigned int i = 0; i < list.count(); i++ )
m_bracket_map.insert( list[i].lower(), (*it)->plugin );
}
}
}
void PluginLoader::clearCache()
{
QPtrListIterator<PluginLoader::PluginLibrary> it( libs );
for( ; it.current(); ++it )
(*it)->plugin->clearCache();
}
Plugin* PluginLoader::findPlugin( const QString & token )
{
// Optimize a little bit for speed and convert only once to lower()
QString lower = token.lower();
if( m_bracket_cache.contains( lower ) )
return m_bracket_cache[lower];
/* The new version is slower than the old one :-(
*/
QMap<QString,Plugin*>::Iterator it;
for ( it = m_bracket_map.begin(); it != m_bracket_map.end(); ++it )
{
if( QRegExp( it.key() ).exactMatch( lower ) )
{
m_bracket_cache.insert( lower, it.data(), true );
if( m_bracket_cache.count() > BRACKET_CACHE_COUNT )
m_bracket_cache.remove( m_bracket_cache.begin() );
return it.data();
}
}
// add typos to the cache, too:
// So that we find immediately that this key is not supported.
m_bracket_cache.insert( lower, NULL, true );
if( m_bracket_cache.count() > BRACKET_CACHE_COUNT )
m_bracket_cache.remove( m_bracket_cache.begin() );
return NULL;
}
void PluginLoader::addPlugin( Plugin* plugin )
{
PluginLibrary* listitem=new PluginLibrary;
listitem->plugin = plugin;
listitem->check = NULL;
listitem->usePlugin = plugin->alwaysUsed();
libs.append( listitem );
}
void PluginLoader::loadFilePlugins()
{
KService::List list = KService::allServices();
for( unsigned int i = 0; i < list.count(); i++ ) {
KService* s = (KService*)list[i];
if( !s->terminal() && s->type() == "Service" && s->hasServiceType( "KFilePlugin" ) ) {
FilePlugin* kfileplugin = new FilePlugin( s );
if( kfileplugin->isValid() ) {
addPlugin( kfileplugin );
kapp->processEvents();
} else
delete kfileplugin;
}
}
m_file = true;
}

@ -0,0 +1,92 @@
/***************************************************************************
pluginloader.h - description
-------------------
begin : Sun Dec 30 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef PLUGINLOADER_H
#define PLUGINLOADER_H
// Own includes
#include "batchrenamer.h"
#include "plugin.h"
#include <qmap.h>
#include <qptrlist.h>
class QCheckBox;
class QVBoxLayout;
class QString;
class QWidget;
#define NUM_INTERNAL_PLUGINS 8
enum pluginType {
TYPE_BRACKET = 2, // Plugin argument is in brackets like [artist] or [1-2]
TYPE_TOKEN = 4, // Plugin has its own reserved token like ,& or /
TYPE_FINAL_FILE = 8, // Plugin does something with the final file
// i.e. that is not changing its name but its permission or similar!
TYPE_FINAL_FILENAME = 16 // Plugin changes the final filename before renaming
};
class PluginLoader {
public:
// For RedHat :)
struct PluginLibrary {
Plugin *plugin;
bool usePlugin;
/* access this member only
* from within KRenameImpl
* when the GUI is already constructed!
*/
QCheckBox* check;
};
static PluginLoader* instance();
void loadPlugins( bool fileplugins );
QPtrList<PluginLoader::PluginLibrary> libs;
Plugin* findPlugin( const QString & token );
inline bool filePluginsLoaded() const;
void clearCache();
private:
PluginLoader();
~PluginLoader();
void addPlugin( Plugin* plugin );
void loadFilePlugins();
private:
Plugin* m_internal_plugins[NUM_INTERNAL_PLUGINS];
static PluginLoader* m_plugin;
QMap<QString,Plugin*> m_bracket_map;
QMap<QString,Plugin*> m_bracket_cache;
bool m_loaded;
bool m_file;
};
bool PluginLoader::filePluginsLoaded() const
{
return m_file;
}
#endif

@ -0,0 +1,602 @@
/***************************************************************************
profiledlg.cpp - description
-------------------
begin : Sat Nov 20 2004
copyright : (C) 2004 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "profiledlg.h"
#include "krenameimpl.h"
#include "kmyhistorycombo.h"
#include "pluginloader.h"
#include "kmylistbox.h"
#include <kapplication.h>
#include <kcombobox.h>
#include <kconfig.h>
#include <kiconloader.h>
#include <kinputdialog.h>
#include <klistbox.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kpushbutton.h>
#include <kstandarddirs.h>
#include <kurlrequester.h>
#include <qcheckbox.h>
#include <qdom.h>
#include <qfile.h>
#include <qlayout.h>
#include <qpainter.h>
#include <qradiobutton.h>
#include <qtooltip.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef VERSION
#define VERSION "unknown"
#endif
#define PROFILE_WIZARD_INDEX 0
#define PROFILE_TABBED_INDEX 1
#define PROFILE_WIZARD_NAME i18n("KRename: Wizard default profile")
#define PROFILE_TABBED_NAME i18n("KRename: Tabbed default profile")
class ProfileListBoxText : public QListBoxText {
public:
ProfileListBoxText( const QString & text = QString::null )
: QListBoxText( text )
{
m_default = false;
}
inline bool isDefault() const {
return m_default;
}
inline void setDefault( const bool b ) {
m_default = b;
}
protected:
void paint( QPainter* painter )
{
QFont f = painter->font();
f.setBold( m_default );
painter->setFont( f );
QListBoxText::paint( painter );
}
private:
bool m_default;
};
ProfileManager::ProfileManager( KRenameImpl* krename )
: m_krename( krename )
{
}
const QString ProfileManager::readProfilePath( const QString & name )
{
QString path;
KConfig* conf = kapp->config();
conf->setGroup( "Profiles" );
path = conf->readEntry( name, QString::null );
return path;
}
const QString ProfileManager::getProfilePath( const QString & name )
{
QStringList list;
if( name == PROFILE_WIZARD_NAME )
return locate( "data", "krename/krename_system_default_wizard.xml" );
else if( name == PROFILE_TABBED_NAME )
return locate( "data", "krename/krename_system_default_tabbed.xml" );
QString path = locateLocal( "data", QString( "krename/%1.xml" ).arg( name ) );
KConfig* conf = kapp->config();
conf->setGroup( "ProfilesHeader" );
list = conf->readListEntry( "list" );
if( !list.contains( name ) )
list.append( name );
conf->writeEntry( "list", list );
conf->setGroup( "Profiles" );
conf->writeEntry( name, path );
conf->sync();
return path;
}
void ProfileManager::writeXML( const QString & name )
{
QString path = getProfilePath( name );
QFile file( path );
if( !file.open( IO_WriteOnly ) )
{
qDebug("Cannot write to: %s", path.latin1() );
return;
}
QDomDocument doc( "KRenameProfile" );
QDomElement root = doc.createElement( "krename" );
doc.appendChild( root );
QDomElement v = doc.createElement( "version" );
v.setAttribute( "version", VERSION );
root.appendChild( v );
// General settings of Krename
QDomElement settings = doc.createElement( "settings" );
settings.setAttribute( "wizard", m_krename->m_wizard );
settings.setAttribute( "fileplugins", m_krename->plugin->filePluginsLoaded() );
root.appendChild( settings );
// Filename settings
QDomElement filename = doc.createElement( "filename" );
filename.setAttribute( "filename", m_krename->filename->text() );
filename.setAttribute( "extension", m_krename->extemplate->text() );
filename.setAttribute( "extension_enabled", m_krename->checkExtension->isChecked() );
filename.setAttribute( "extension_start", m_krename->comboExtension->currentItem() );
QDomElement numbering = doc.createElement( "numbering" );
numbering.setAttribute( "start", m_krename->m_index );
numbering.setAttribute( "step", m_krename->m_step );
numbering.setAttribute( "skip", listToString( m_krename->skip ) );
numbering.setAttribute( "reset", m_krename->m_reset );
QDomElement replace = doc.createElement( "replace" );
for( unsigned int i=0;i<m_krename->rep.count();i++)
{
QDomElement r = doc.createElement( "item" );
r.setAttribute( "find", m_krename->rep[i].find );
r.setAttribute( "replace", m_krename->rep[i].replace );
r.setAttribute( "reg", m_krename->rep[i].reg );
replace.appendChild( r );
}
// destination settings
QDomElement dest = doc.createElement( "destination" );
dest.setAttribute( "mode", m_krename->currentRenameMode() );
dest.setAttribute( "overwrite", QString::number( m_krename->checkOverwrite->isChecked() ) );
dest.setAttribute( "directory", m_krename->dirname->text() );
dest.setAttribute( "undo", QString::number( m_krename->checkUndoScript->isChecked() ) );
dest.setAttribute( "undoscript", m_krename->undorequester->url() );
// file adding settings
QDomElement files = doc.createElement( "files" );
files.setAttribute( "sorting", QString::number( m_krename->comboSort->currentItem() ) );
files.setAttribute( "preview", QString::number( m_krename->checkPreview->isChecked() ) );
files.setAttribute( "names", QString::number( m_krename->checkName->isChecked() ) );
filename.appendChild( replace );
filename.appendChild( numbering );
root.appendChild( settings );
root.appendChild( filename );
root.appendChild( dest );
root.appendChild( files );
QCString xml = doc.toCString();
file.writeBlock( xml, xml.length() );
file.close();
}
bool ProfileManager::loadXML( const QString & path )
{
QFile file( path );
if( !file.open( IO_ReadOnly ) )
{
qDebug("Cannot read from: %s", path.latin1() );
return false;
}
QDomDocument doc( "KRenameProfile" );
if ( !doc.setContent( &file ) )
{
file.close();
return false;
}
QDomNode n = doc.documentElement().firstChild();
while( !n.isNull() )
{
QDomElement e = n.toElement(); // try to convert the node to an element.
if( !e.isNull() )
{
if( e.tagName() == "settings" )
{
bool wiz, plug;
wiz = (bool)e.attribute( "wizard",
QString( "%1" ).arg( m_krename->m_wizard ) ).toInt();
m_krename->setWizardMode( wiz );
// if( wiz != m_krename->m_wizard )
{
m_krename->m_wizard = wiz;
m_krename->changeGUIMode();
}
plug = (bool)e.attribute( "fileplugins",
QString( "%1" ).arg( m_krename->plugin->filePluginsLoaded() ) ).toInt();
if( plug && !m_krename->plugin->filePluginsLoaded() )
m_krename->plugin->loadPlugins( true );
}
else if( e.tagName() == "filename" )
{
m_krename->filename->setText( e.attribute("filename", m_krename->filename->text() ) );
m_krename->extemplate->setText( e.attribute("extension", m_krename->extemplate->text() ) );
m_krename->checkExtension->setChecked(
(bool)e.attribute("extension_enabled",
QString("%1").arg(m_krename->checkExtension->isChecked() ) ).toInt() );
m_krename->comboExtension->setCurrentItem(
e.attribute("extension_start",
QString::number( m_krename->comboExtension->currentItem() ) ).toInt() );
QDomNode n = e.firstChild();
while( !n.isNull() )
{
QDomElement e = n.toElement(); // try to convert the node to an element.
if( !e.isNull() )
{
if( e.tagName() == "numbering" )
{
m_krename->m_index = e.attribute( "start", QString::number( m_krename->m_index ) ).toInt();
m_krename->m_step = e.attribute( "step", QString::number( m_krename->m_step ) ).toInt();
m_krename->skip = stringToList( e.attribute("skip", listToString( m_krename->skip ) ) );
m_krename->m_reset = (bool)e.attribute( "reset", QString::number( (int)m_krename->m_reset ) ).toInt();
}
else if( e.tagName() == "replace" )
{
m_krename->rep.clear();
QDomNode n = e.firstChild();
while( !n.isNull() )
{
QDomElement e = n.toElement(); // try to convert the node to an element.
if( !e.isNull() && e.tagName() == "item" )
{
replacestrings r;
r.find = e.attribute( "find", QString::null );
r.replace = e.attribute( "replace", QString::null );
r.reg = (bool)e.attribute( "reg", "0" ).toInt();
m_krename->rep.append( r );
}
n = n.nextSibling();
}
}
}
n = n.nextSibling();
}
}
else if( e.tagName() == "destination" )
{
int mode = e.attribute( "mode", QString::number( m_krename->currentRenameMode() ) ).toInt();
m_krename->optionRename->setChecked( false );
m_krename->optionCopy->setChecked( false );
m_krename->optionMove->setChecked( false );
m_krename->optionLink->setChecked( false );
switch( mode )
{
default:
case RENAME:
m_krename->optionRename->setChecked( true ); break;
case COPY:
m_krename->optionCopy->setChecked( true ); break;
case MOVE:
m_krename->optionMove->setChecked( true ); break;
case LINK:
m_krename->optionLink->setChecked( true ); break;
}
m_krename->checkOverwrite->setChecked( e.attribute( "overwrite",
QString::number( m_krename->checkOverwrite->isChecked() ) ).toInt() );
m_krename->dirname->setText( e.attribute( "directory", m_krename->dirname->text() ) );
m_krename->checkUndoScript->setChecked( e.attribute( "undo",
QString::number( m_krename->checkUndoScript->isChecked() ) ).toInt() );
m_krename->undorequester->setURL( e.attribute( "undoscript", m_krename->undorequester->url() ) );
}
else if( e.tagName() == "files" )
{
m_krename->comboSort->setCurrentItem( e.attribute( "sorting",
QString::number( m_krename->comboSort->currentItem() ) ).toInt() );
m_krename->checkPreview->setChecked( e.attribute( "preview",
QString::number( m_krename->checkPreview->isChecked() ) ).toInt() );
m_krename->checkName->setChecked( e.attribute( "names",
QString::number( m_krename->checkName->isChecked() ) ).toInt() );
}
}
n = n.nextSibling();
}
if( m_krename->m_wizard )
m_krename->parseWizardMode();
file.close();
return true;
}
const QString ProfileManager::listToString( QValueList<int> & list )
{
QString data;
for( unsigned int i = 0; i < list.count(); i++ )
data += QString( "%1;" ).arg( list[i] );
return data;
}
const QValueList<int> ProfileManager::stringToList( const QString & data )
{
QValueList<int> list;
int c = data.contains( ";" );
if( c > 0 )
{
for( int i = 0;i<c;i++)
list.append( data.section( ';', i, i ).toInt() );
}
return list;
}
bool ProfileManager::hasDefaultProfile()
{
KConfig* conf = kapp->config();
conf->setGroup( "ProfilesHeader" );
QString def = conf->readEntry( "defprofile", QString::null );
return (!def.isEmpty());
}
void ProfileManager::loadDefaultProfile( KRenameImpl* krename )
{
KConfig* conf = kapp->config();
conf->setGroup( "ProfilesHeader" );
QString def = conf->readEntry( "defprofile", QString::null );
if( !def.isEmpty() )
ProfileManager::loadProfile( def, krename );
}
void ProfileManager::loadProfile( const QString & name, KRenameImpl* krename )
{
ProfileManager manager( krename );
manager.loadXML( manager.getProfilePath( name ) );
}
///////////////////////////////////////////////////////////////////////////////
ProfileDlg::ProfileDlg(KRenameImpl* krename, QWidget *parent, const char *name)
: KDialogBase( KDialogBase::Plain, i18n("Profiles"),
KDialogBase::Close, KDialogBase::Close, parent, name, true, true ), ProfileManager( krename )
{
int i;
QHBoxLayout* layout = new QHBoxLayout( plainPage(), 6, 6 );
QVBoxLayout* button = new QVBoxLayout( 0, 6, 6 );
profiles = new KListBox( plainPage() );
profiles->insertItem( new ProfileListBoxText( PROFILE_WIZARD_NAME ), PROFILE_WIZARD_INDEX );
profiles->insertItem( new ProfileListBoxText( PROFILE_TABBED_NAME ), PROFILE_TABBED_INDEX );
createProfile = new KPushButton( i18n("&Save As Profile..."), plainPage() );
loadProfile = new KPushButton( i18n("&Load Profile"), plainPage() );
deleteProfile = new KPushButton( i18n("&Delete Profile"), plainPage() );
checkDefault = new QCheckBox( i18n("&Use as default profile on startup"), plainPage() );
createProfile->setIconSet( SmallIconSet( "filesaveas") );
loadProfile->setIconSet( SmallIconSet( "fileopen" ) );
deleteProfile->setIconSet( SmallIconSet( "edittrash" ) );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
button->addWidget( createProfile );
button->addWidget( loadProfile );
button->addWidget( deleteProfile );
button->addItem( spacer );
button->addWidget( checkDefault );
layout->addWidget( profiles );
layout->addLayout( button );
layout->setStretchFactor( profiles, 2 );
QToolTip::add( createProfile, i18n("<qt>Save KRename's current settings as a new profile. "
"The settings are saved and can be restored with Load Profile later.</qt>" ) );
QToolTip::add( loadProfile, i18n("<qt>Load all settings stored in this profile.</qt>") );
enableControls();
connect( createProfile, SIGNAL( clicked() ), this, SLOT( slotCreateProfile() ) );
connect( loadProfile, SIGNAL( clicked() ), this, SLOT( slotLoadProfile() ) );
connect( deleteProfile, SIGNAL( clicked() ), this, SLOT( slotDeleteProfile() ) );
connect( profiles, SIGNAL( selectionChanged () ), this, SLOT( enableControls() ) );
connect( checkDefault, SIGNAL( clicked() ), this, SLOT( slotSetDefault() ) );
connect( this, SIGNAL( hidden() ), this, SLOT( slotHidden() ) );
KConfig* conf = kapp->config();
conf->setGroup( "ProfilesHeader" );
ProfileListBoxText* item;
QStringList list = conf->readListEntry( "list" );
QString def = conf->readEntry( "defprofile", QString::null );
for( i=0;i<(int)list.count();i++ )
profiles->insertItem( new ProfileListBoxText( list[i] ) );
for( i=0;i<(int)profiles->count();i++ )
{
item = static_cast<ProfileListBoxText*>(profiles->item(i));
if( item->text() == def )
{
item->setDefault( true);
break;
}
}
profiles->repaintContents();
}
ProfileDlg::~ProfileDlg()
{
}
void ProfileDlg::enableControls()
{
ProfileListBoxText* item;
loadProfile->setEnabled( profiles->selectedItem() );
// Do not allow to delete the two default profiles
deleteProfile->setEnabled( profiles->selectedItem() &&
profiles->currentItem() != PROFILE_TABBED_INDEX && profiles->currentItem() != PROFILE_WIZARD_INDEX );
checkDefault->setEnabled( profiles->selectedItem() );
item = static_cast<ProfileListBoxText*>(profiles->selectedItem());
checkDefault->setChecked( item && item->isDefault() );
}
void ProfileDlg::slotSetDefault()
{
int i;
ProfileListBoxText* item;
for( i=0;i<(int)profiles->count();i++ )
{
item = static_cast<ProfileListBoxText*>(profiles->item( i ));
item->setDefault( false );
}
item = static_cast<ProfileListBoxText*>(profiles->selectedItem());
if( item )
item->setDefault( checkDefault->isChecked() );
profiles->repaintContents();
}
void ProfileDlg::slotLoadProfile()
{
QString profile = profiles->currentText();
QString msg = QString( i18n("Do you really want to load the profile and overwrite the current settings: %1") ).arg( profile );
QString path = getProfilePath( profile );
if( path.isEmpty() )
{
KMessageBox::error( this, i18n("The profile \"%1\" could not be found.").arg( profile ) );
return;
}
if( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
{
if( loadXML( path ) )
this->close();
enableControls();
m_krename->enableControls();
m_krename->updatePre();
}
}
void ProfileDlg::slotCreateProfile()
{
bool ok = false;
const char* mask = "xXXXXXXXXXXXXXXXXXXX"; // allows for 20 characters
QString name = KInputDialog::getText( i18n("Profile Name"), i18n("Please enter a name for the new profile:"),
"KRename", &ok, this, 0, 0, mask );
if( !ok )
return;
if( profiles->findItem( name, Qt::ExactMatch ) )
{
KMessageBox::error( this, i18n("This profile does already exist. Please choose another name.") );
slotCreateProfile();
return;
}
profiles->insertItem( new ProfileListBoxText( name ) );
writeXML( name );
enableControls();
}
void ProfileDlg::slotDeleteProfile()
{
if( profiles->currentItem() == PROFILE_WIZARD_INDEX || profiles->currentItem() == PROFILE_TABBED_INDEX )
{
KMessageBox::error( this, i18n("You cannot delete default profiles!") );
return;
}
QString profile = profiles->currentText();
QString msg = QString( i18n("Do you really want to delete the profile: %1") ).arg( profile );
if( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
{
QString path = readProfilePath( profile );
QFile::remove( path );
QListBoxItem* item = profiles->findItem( profile, Qt::ExactMatch );
if( item )
delete item;
KConfig* conf = kapp->config();
conf->setGroup( "ProfilesHeader" );
QStringList list = conf->readListEntry( "list" );
list.remove( profile );
conf->writeEntry( "list", list );
conf->sync();
enableControls();
}
}
void ProfileDlg::slotHidden()
{
int i;
KConfig* conf = kapp->config();
QString def = QString::null;
ProfileListBoxText* item;
for( i=0;i<(int)profiles->count();i++ )
{
item = static_cast<ProfileListBoxText*>(profiles->item( i ));
if( item->isDefault() )
{
def = profiles->text( i );
break;
}
}
conf->setGroup( "ProfilesHeader" );
conf->writeEntry( "defprofile", def );
conf->sync();
}
#include "profiledlg.moc"

@ -0,0 +1,79 @@
/***************************************************************************
profiledlg.h - description
-------------------
begin : Sat Nov 20 2004
copyright : (C) 2004 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef PROFILEDLG_H
#define PROFILEDLG_H
#include <kdialogbase.h>
class KListBox;
class KPushButton;
class KRenameImpl;
class QCheckBox;
class ProfileManager {
public:
ProfileManager( KRenameImpl* krename );
static void loadDefaultProfile( KRenameImpl* krename );
static void loadProfile( const QString & name, KRenameImpl* krename );
static bool hasDefaultProfile();
protected:
const QString getProfilePath( const QString & name );
const QString readProfilePath( const QString & name );
const QString listToString( QValueList<int> & list );
const QValueList<int> stringToList( const QString & );
void writeXML( const QString & name );
bool loadXML( const QString & path );
protected:
KRenameImpl* m_krename;
};
/**
@author Dominik Seichter
*/
class ProfileDlg : public KDialogBase, public ProfileManager
{
Q_OBJECT
public:
ProfileDlg(KRenameImpl* krename, QWidget *parent = 0, const char *name = 0);
~ProfileDlg();
private slots:
void enableControls();
void slotLoadProfile();
void slotCreateProfile();
void slotDeleteProfile();
void slotSetDefault();
void slotHidden();
private:
KListBox* profiles;
QCheckBox* checkDefault;
KPushButton* createProfile;
KPushButton* loadProfile;
KPushButton* deleteProfile;
};
#endif

@ -0,0 +1,257 @@
/***************************************************************************
replacedialog.cpp - description
-------------------
begin : Sat Aug 18 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
// Own includes
#include "replacedialog.h"
// QT includes
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qlayout.h>
#include <qregexp.h>
// KDE includes
#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>
#include <klistview.h>
#include <kmessagebox.h>
#include <kparts/componentfactory.h>
#include <kpushbutton.h>
#include <kregexpeditorinterface.h>
ReplaceDialog::ReplaceDialog( QValueList<replacestrings> & r, QWidget* parent )
: KDialogBase( KDialogBase::Plain, i18n( "Find and Replace" ),
KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent, 0, true, true )
{
ReplaceDialogLayout = new QGridLayout( plainPage(), 11, 6);
list = new KListView( plainPage() );
list->addColumn( i18n("Find") );
list->addColumn( i18n("Replace With") );
list->addColumn( i18n("Regular Expression") );
list->addColumn( "regexp" ); // no i18n, because not user visible
// list->setColumnWidthMode( 0, QListView::Manual );
// list->setColumnWidthMode( 1, QListView::Manual );
// list->setColumnWidthMode( 2, QListView::Manual );
list->setColumnWidthMode( 3, QListView::Manual );
list->setColumnWidth( 3, 0 );
list->setSorting( -1 );
list->setAllColumnsShowFocus( true );
TextLabel1 = new QLabel( plainPage() );
TextLabel1->setText( i18n( "Find:" ) );
TextLabel2 = new QLabel( plainPage() );
TextLabel2->setText( i18n( "Replace with:" ) );
text1 = new QLineEdit( plainPage() );
text2 = new QLineEdit( plainPage() );
checkReg = new QCheckBox( i18n("&Regular expression"), plainPage() );
buttonRegEdit = new KPushButton( plainPage() );
buttonRegEdit->setText( i18n( "&Edit..." ) );
buttonRegEdit->setEnabled( false );
buttonAdd = new KPushButton( plainPage() );
buttonAdd->setText( i18n( "&Add" ) );
buttonEdit = new KPushButton( plainPage() );
buttonEdit->setText( i18n("&Edit") );
buttonRemove = new KPushButton( plainPage() );
buttonRemove->setText( i18n( "&Remove" ) );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
ReplaceDialogLayout->addWidget( TextLabel1, 0, 0 );
ReplaceDialogLayout->addWidget( text1, 0, 1 );
ReplaceDialogLayout->addWidget( TextLabel2, 0, 3 );
ReplaceDialogLayout->addWidget( text2, 0, 4 );
ReplaceDialogLayout->addWidget( checkReg, 1, 0 );
ReplaceDialogLayout->addWidget( buttonRegEdit, 1, 1 );
ReplaceDialogLayout->addWidget( buttonAdd, 0, 6 );
ReplaceDialogLayout->addWidget( buttonEdit, 1, 6 );
ReplaceDialogLayout->addWidget( buttonRemove, 2, 6 );
ReplaceDialogLayout->addItem( spacer, 0, 5 );
ReplaceDialogLayout->addItem( spacer, 0, 2 );
ReplaceDialogLayout->addMultiCellWidget( list, 3, 3, 0, 4 );
text1->setFocus();
connect( buttonAdd, SIGNAL( clicked() ), this, SLOT( add() ) );
connect( buttonRemove, SIGNAL( clicked() ), this, SLOT( remove() ) );
connect( list, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( enableControls() ) );
connect( list, SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( slotEdit() ) );
connect( text2, SIGNAL( returnPressed() ), this, SLOT( add() ) );
connect( text1, SIGNAL( returnPressed() ), this, SLOT( moveFocus() ) );
connect( buttonRegEdit, SIGNAL( clicked() ), this, SLOT( invokeRegEdit() ) );
connect( checkReg, SIGNAL( clicked() ), this, SLOT( enableControls() ) );
connect( buttonEdit, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
for( unsigned int i = 0; i < r.count(); i++ ) {
replacestrings rs = r[i];
BatchRenamer::unEscape( rs.find );
KListViewItem* item = new KListViewItem( list );
item->setText( 0, encode( rs.find ) );
item->setText( 1, encode( rs.replace ) );
item->setText( 2, rs.reg ? i18n("yes") : i18n("no") );
item->setText( 3, QString::number( rs.reg ) );
list->insertItem( item );
}
enableControls();
}
ReplaceDialog::~ReplaceDialog()
{ }
void ReplaceDialog::add()
{
if( text1->text().isEmpty() ) {
KMessageBox::sorry( this, i18n( "Add a text that should be replaced." ) );
return;
}
QListViewItem* it = list->firstChild();
while( it ) {
if( it->text( 0 ) == text1->text() ) {
KMessageBox::sorry( this, i18n( "You can't replace the same text twice." ) );
return;
}
it = it->nextSibling();
}
KListViewItem* item = new KListViewItem( list, i18n("Regular expression") );
item->setText( 0, encode( text1->text() ) );
item->setText( 1, encode( text2->text() ) );
item->setText( 2, checkReg->isChecked() ? i18n("yes") : i18n("no") );
item->setText( 3, QString::number( checkReg->isChecked() ) );
list->insertItem( item );
reset();
enableControls();
}
void ReplaceDialog::remove()
{
if( list->selectedItem() ) {
QListViewItem* item = list->selectedItem();
list->takeItem( item );
delete item;
}
enableControls();
}
QValueList<replacestrings> ReplaceDialog::getList()
{
QValueList<replacestrings> r;
QListViewItem* item = list->firstChild();
while( item ) {
replacestrings n;
n.find = decode( item->text( 0 ) );
n.replace = decode( item->text( 1 ) );
n.reg = item->text( 3 ).toInt();
BatchRenamer::doEscape( n.find );
r.append( n );
item = item->nextSibling();
}
return r;
}
void ReplaceDialog::moveFocus()
{
text2->setFocus();
}
void ReplaceDialog::invokeRegEdit()
{
QDialog* regExpDialog = KParts::ComponentFactory::createInstanceFromQuery<QDialog>( "KRegExpEditor/KRegExpEditor", QString::null, this );
KRegExpEditorInterface *iface = static_cast<KRegExpEditorInterface *>( regExpDialog->qt_cast( "KRegExpEditorInterface" ) );
if ( !iface )
return;
iface->setRegExp( text1->text() );
bool ok = regExpDialog->exec();
if ( ok )
text1->setText( iface->regExp() );
}
QString ReplaceDialog::encode( QString s )
{
s.append("\"");
s.prepend("\"");
return s;
}
QString ReplaceDialog::decode( QString s )
{
if( s[0] == '"' )
s.remove( 0, 1 );
if( s[s.length()-1] == '"' )
s.remove( s.length()-1, 1 );
return s;
}
void ReplaceDialog::resizeEvent( QResizeEvent* e )
{
QDialog::resizeEvent( e );
// list->setColumnWidth( 0, TextLabel1->width() + text1->width() );
// list->setColumnWidth( 1, TextLabel2->width() + text2->width() );
}
void ReplaceDialog::reset()
{
text1->clear();
text2->clear();
checkReg->setChecked( false );
text1->setFocus();
}
void ReplaceDialog::enableControls()
{
buttonRemove->setEnabled( list->selectedItem() );
buttonRegEdit->setEnabled( checkReg->isChecked() && !KTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() );
buttonEdit->setEnabled( list->selectedItem() );
}
void ReplaceDialog::slotEdit()
{
text1->setText( decode( list->selectedItem()->text( 0 ) ) );
text2->setText( decode( list->selectedItem()->text( 1 ) ) );
checkReg->setChecked( list->selectedItem()->text( 3 ).toInt() );
QListViewItem* item = list->selectedItem();
list->takeItem( item );
delete item;
text1->setFocus();
enableControls();
}

@ -0,0 +1,78 @@
/***************************************************************************
replacedialog.h - description
-------------------
begin : Sat Aug 18 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef REPLACEDIALOG_H
#define REPLACEDIALOG_H
// QT includes
#include <kdialogbase.h>
#include <qvaluelist.h>
// Own includes
#include "batchrenamer.h"
class QCheckBox;
class QGridLayout;
class QGridLayout;
class QLabel;
class QLineEdit;
class KPushButton;
class QListViewItem;
class KListView;
class ReplaceDialog : public KDialogBase
{
Q_OBJECT
public:
ReplaceDialog( QValueList<replacestrings> & r, QWidget* parent = 0 );
~ReplaceDialog();
QValueList<replacestrings> getList();
private slots:
void add();
void moveFocus();
void remove();
void invokeRegEdit();
void enableControls();
void slotEdit();
private:
void reset();
QLabel* TextLabel1;
QLineEdit* text2;
QLabel* TextLabel2;
QLineEdit* text1;
KListView* list;
QCheckBox* checkReg;
KPushButton* buttonAdd;
KPushButton* buttonRemove;
KPushButton* buttonEdit;
KPushButton* buttonRegEdit;
QString encode( QString s );
QString decode( QString s );
protected:
void resizeEvent( QResizeEvent* e );
QGridLayout* ReplaceDialogLayout;
};
#endif // REPLACEDIALOG_H

File diff suppressed because one or more lines are too long

@ -0,0 +1,120 @@
/***************************************************************************
tabs.cpp - description
-------------------
begin : Die Mai 20 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "tabs.h"
#include "krenameimpl.h"
#include "kmyhistorycombo.h"
// Qt includes
#include <qlayout.h>
#include <qsizepolicy.h>
#include <qtabwidget.h>
// KDE includes
#include <kapplication.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kmenubar.h>
#include <kmessagebox.h>
#include <kpushbutton.h>
#include <kstartupinfo.h>
tabs::tabs(KRenameImpl* impl, QRect r, QWidget *parent, const char *name )
: QDialog(parent,name)
{
setIcon( BarIcon( "krename" ) );
QVBoxLayout* layout = new QVBoxLayout( this, 6, 6 );
QHBoxLayout* buttons = new QHBoxLayout( 0, 6, 6 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
tab = new QTabWidget( this );
finishButton = new KPushButton( i18n("&Finish"), this );
finishButton->setIconSet( SmallIconSet( "finish" ) );
finishButton->setDefault( true );
cancelButton = new KPushButton( i18n("&Cancel"), this );
cancelButton->setIconSet( SmallIconSet( "button_cancel" ) );
buttons->addItem( spacer );
buttons->addWidget( finishButton );
buttons->addWidget( cancelButton );
layout->addWidget( tab );
layout->addLayout( buttons );
layout->setStretchFactor( tab, 2 );
menuBar = new KMenuBar( this );
layout->setMenuBar( menuBar );
connect( cancelButton, SIGNAL( clicked() ), this, SLOT( close() ) );
krename = impl ? impl : new KRenameImpl( this, menuBar, finishButton );
connect( krename, SIGNAL( pageDone( QWidget*, const QString & ) ), this, SLOT( slotAddPage( QWidget*, const QString & ) ) );
connect( krename, SIGNAL( showPage( int ) ), this, SLOT( slotShowPage( int ) ) );
connect( krename, SIGNAL( enableFinish( bool ) ), this, SLOT( slotEnableFinish( bool ) ) );
connect( tab, SIGNAL( currentChanged( QWidget* ) ), this, SLOT( slotTabChanged() ) );
if( impl )
{
krename->changeParent( this, menuBar, finishButton, r );
krename->setWizardMode( false );
} else
krename->setup( false );
// Tell KStartupInfo that KRename has been loaded completly
KStartupInfoId id;
id.initId( kapp->startupId() );
KStartupInfo::sendFinish( id );
}
tabs::~tabs()
{
}
void tabs::slotAddPage( QWidget* page, const QString & title )
{
tab->addTab( page, title );
}
void tabs::slotShowPage( int page )
{
tab->setCurrentPage( page - 1 );
}
void tabs::slotEnableFinish( bool b )
{
finishButton->setEnabled( b );
}
void tabs::slotTabChanged()
{
if( tab->currentPageIndex() == tab->count() - 1 )
{
krename->filename->setFocus();
krename->filename->lineEdit()->selectAll();
}
}
void tabs::keyPressEvent( QKeyEvent *e )
{
// ESC should not close KRename
if( e->key() == Qt::Key_Escape )
e->accept();
else
e->ignore();
}

@ -0,0 +1,57 @@
/***************************************************************************
tabs.h - description
-------------------
begin : Die Mai 20 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef TABS_H
#define TABS_H
#include <qwidget.h>
#include <qdialog.h>
class KMenuBar;
class KRenameImpl;
class KPushButton;
class QCloseEvent;
class QRect;
class QString;
class QTabWidget;
class tabs : public QDialog {
Q_OBJECT
public:
tabs(KRenameImpl* impl, QRect r, QWidget *parent=0, const char *name=0);
~tabs();
inline KRenameImpl* getKRename() { return krename; }
private slots:
void slotAddPage( QWidget* page, const QString & title );
void slotShowPage( int page );
void slotEnableFinish( bool b );
void slotTabChanged();
protected:
virtual void keyPressEvent( QKeyEvent *e );
protected:
KRenameImpl* krename;
KPushButton* finishButton;
KPushButton* cancelButton;
KMenuBar* menuBar;
QTabWidget* tab;
};
#endif

@ -0,0 +1,162 @@
/***************************************************************************
threadedlister.cpp - description
-------------------
begin : Tue Feb 01 2005
copyright : (C) 2005 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "threadedlister.h"
#include "kmylistbox.h"
#include "krecursivelister.h"
#include <kapplication.h>
#include <qmutex.h>
ThreadedLister::ThreadedLister( QMutex* mutex, unsigned int* counter, KMyListBox* list )
: QObject(), QThread(), m_mutex( mutex ), m_counter( counter ), m_list( list )
{
m_mutex->lock();
++(*m_counter);
m_mutex->unlock();
m_reclister = NULL;
m_lister = NULL;
m_internal = NULL;
m_hidden = false;
m_recursive = false;
m_dirnames = false;
m_dironly = false;
}
ThreadedLister::~ThreadedLister()
{
if( m_reclister )
delete m_reclister;
if( m_lister )
delete m_lister;
if( m_internal )
delete m_internal;
}
void ThreadedLister::run()
{
m_internal = new QMutex();
m_internal->lock();
if( m_recursive )
{
m_reclister = new KRecursiveLister();
m_reclister->setShowingDotFiles( m_hidden );
m_reclister->setNameFilter( m_filter );
m_reclister->setDirOnlyMode( m_dironly );
connect( m_reclister, SIGNAL( completed() ), this, SLOT( reclisterFinished() ) );
m_reclister->openURL( m_dirname );
} else {
m_lister = new KDirLister();
m_lister->setAutoUpdate( false );
m_lister->setShowingDotFiles( m_hidden );
m_lister->setNameFilter( m_filter );
connect( m_lister, SIGNAL( completed() ), this, SLOT( listerFinished() ) );
m_lister->openURL( m_dirname, false, false );
}
// try to lock the mutex.
// This will block run as long as *listerFinished()
// does not unlock the mutex.
m_internal->lock();
m_internal->unlock();
KApplication::postEvent( m_list, new QCustomEvent( (QEvent::Type)ThreadedLister::TYPE(), (void*)this ) );
}
void ThreadedLister::reclisterFinished()
{
KFileItemList l = m_reclister->items();
FileList list = l;
if( m_dirnames )
{
FileList dirs = m_reclister->dirs();
KFileItem* item;
for( item = dirs.first(); item; item = dirs.next() )
list.append( item );
}
list.sort();
m_mutex->lock();
m_list->setUpdatesEnabled( false );
if( m_dirnames )
{
QString name = m_dirname.fileName();
if( !m_hidden && name.right( 1 ) != QString::fromLatin1(".") )
m_list->addDirName( m_dirname );
}
KFileItem* item;
for( item = list.first(); item; item = list.next() )
if( item->isFile() )
m_list->addFile( item->url(), true );
else if( item->isDir() )
m_list->addDirName( item->url() );
m_mutex->unlock();
m_list->setUpdatesEnabled( true );
m_internal->unlock();
}
void ThreadedLister::listerFinished()
{
if( m_lister->isFinished() ) {
FileList list = m_lister->items( KDirLister::FilteredItems );
list.sort();
m_mutex->lock();
m_list->setUpdatesEnabled( false );
if( m_dirnames )
{
QString name = m_dirname.fileName();
if( !m_hidden && name.right( 1 ) != QString::fromLatin1(".") )
m_list->addDirName( m_dirname );
}
KFileItem* item;
for( item = list.first(); item; item = list.next() )
if( item->isFile() )
m_list->addFile( item->url(), true );
--(*m_counter);
m_mutex->unlock();
m_list->setUpdatesEnabled( true );
m_internal->unlock();
}
}
#include "threadedlister.moc"

@ -0,0 +1,158 @@
/***************************************************************************
threadedlister.h - description
-------------------
begin : Tue Feb 01 2005
copyright : (C) 2005 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef THREADEDLISTER_H
#define THREADEDLISTER_H
#include <qobject.h>
#include <qthread.h>
#include <kfileitem.h>
class KDirLister;
class KRecursiveLister;
class KMyListBox;
class QMutex;
class FileList : public QPtrList<KFileItem> {
public:
FileList() : QPtrList<KFileItem>() {}
FileList( KFileItemList list )
: QPtrList<KFileItem>() {
KFileItem* it;
for( it = list.first(); it; it = list.next() )
this->append( it );
}
protected:
int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 ) {
return static_cast<KFileItem*>(item1)->url().url().compare( static_cast<KFileItem*>(item2)->url().url() );
}
};
class ThreadedLister : public QObject, public QThread
{
Q_OBJECT
public:
ThreadedLister( QMutex* mutex, unsigned int* counter, KMyListBox* list );
~ThreadedLister();
static int TYPE() { return 51984; }
inline FileList* items();
inline const KURL & dirname();
inline bool dirnames();
inline const QString & filter();
inline bool hidden();
inline void setDirname( const KURL & dirname );
inline void setDirnames( bool names );
inline void setFilter( const QString & filter );
inline void setHidden( bool h );
inline void setRecursive( bool r );
inline void setRecursiveDirOnlyMode( bool m );
signals:
void listerDone( ThreadedLister* );
protected:
void run();
private slots:
void reclisterFinished();
void listerFinished();
private:
QMutex* m_mutex;
QMutex* m_internal;
unsigned int* m_counter;
FileList m_files;
KURL m_dirname;
QString m_filter;
bool m_hidden;
bool m_recursive;
bool m_dirnames;
bool m_dironly;
KDirLister* m_lister;
KRecursiveLister* m_reclister;
KMyListBox* m_list;
};
void ThreadedLister::setDirname( const KURL & dirname )
{
m_dirname = dirname;
}
void ThreadedLister::setDirnames( bool names )
{
m_dirnames = names;
}
void ThreadedLister::setFilter( const QString & filter )
{
m_filter = filter;
}
void ThreadedLister::setHidden( bool h )
{
m_hidden = h;
}
void ThreadedLister::setRecursive( bool r )
{
m_recursive = r;
}
void ThreadedLister::setRecursiveDirOnlyMode( bool m )
{
m_dironly = m;
}
FileList* ThreadedLister::items()
{
return &m_files;
}
const KURL & ThreadedLister::dirname()
{
return m_dirname;
}
bool ThreadedLister::dirnames()
{
return m_dirnames;
}
const QString & ThreadedLister::filter()
{
return m_filter;
}
bool ThreadedLister::hidden()
{
return m_hidden;
}
#endif

@ -0,0 +1,106 @@
//
// C++ Implementation: translitplugin
//
// Description:
//
//
// Author: Dominik Seichter <domseichter@web.de>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "translitplugin.h"
#include "translitplugin.moc"
const QString TranslitPlugin::m_strUtf8[] = {"а","б","в","г","д","е","ё","ж","з","и",
"й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ","ъ","ы","ь",
"э","ю","я",
"А","Б","В","Г","Д","Е","Ё","Ж","З","И","Й","К","Л","М","Н","О","П",
"Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я",
"á","ä","č","ď","é","ě","í","ľ","ĺ","ň","ó","ô","ř","ŕ","š","ť","ú","ů","ý","ž",
"Á","Ä","Č","Ď","É","Ě","Í","Ľ","Ĺ","Ň","Ó","Ô","Ř","Ŕ","Š","Ť","Ú","Ů","Ý","Ž",QString::null};
const QString TranslitPlugin::m_strEngl[]= {"a","b","v","g","d","e","yo","zh","z","i",
"j","k","l","m","n","o","p","r","s","t","u","f","h","c","ch","sh","sh","","y","",
"e","yu","ya",
"A","B","V","G","D","E","Yo","Zh","Z","I","J","K","L","M","N","O","P",
"R","S","T","U","F","H","C","Ch","Sh","Sh","","Y","","E","Yu","Ya",
"a","a","c","d","e","e","i","l","l","n","o","o","r","r","s","t","u","u","y","z",
"A","A","C","D","E","E","I","L","L","N","O","O","R","R","S","T","U","U","Y","Z",QString::null};
const QString TranslitPlugin::getName() const
{
return i18n("Transliteration Plugin");
}
const QString TranslitPlugin::getAccelName() const
{
return i18n("&Transliteration Plugin");
}
const QPixmap TranslitPlugin::getIcon() const
{
return kapp->iconLoader()->loadIcon( "fonts", KIcon::Small );
}
const int TranslitPlugin::type() const
{
return TYPE_FINAL_FILENAME;
}
void TranslitPlugin::drawInterface( QWidget* w, QVBoxLayout* l )
{
QLabel* label = new QLabel(
i18n("<qt>This plugin transliterates names written with non-english characters.</qt>"), w );
l->addWidget( label );
label = new QLabel( "<qt><b>WARNING! THIS PLUGIN IS EXPERIMENTAL AND MIGHT CAUSE LOSS OF DATA!</b></qt>", w );
l->addWidget( label );
}
void TranslitPlugin::finished()
{
}
void TranslitPlugin::fillStructure()
{
}
bool TranslitPlugin::checkError()
{
return true;
}
QString TranslitPlugin::processFile( BatchRenamer*, int, QString token, int )
{
QString output = translit( token );
return output; // no error
}
QString TranslitPlugin::translit(const QString & unicoded)
{
int i;
QString transed = "";
for (i=0; i<(int)unicoded.length(); i++) {
QString charIn = unicoded.mid(i, 1);
if (m_mapFromUTF8[charIn.utf8()]) {
QString charTrans = m_mapFromUTF8[charIn.utf8()];
transed.append(charTrans);
} else {
transed.append(charIn);
}
}
return transed;
}
TranslitPlugin::TranslitPlugin() {
// Initialize transliteration map
int i;
for (i=0; m_strUtf8[i]!=QString::null; i++) {
QString src = m_strUtf8[i];
QString dst = m_strEngl[i];
m_mapFromUTF8[src] = dst;
}
}

@ -0,0 +1,59 @@
//
// C++ Interface: translitplugin
//
// Description:
//
//
// Author: Dominik Seichter <domseichter@web.de>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef TRANSLITPLUGIN_H
#define TRANSLITPLUGIN_H
#include "plugin.h"
#include "pluginloader.h"
#include "batchrenamer.h"
// QT includes
#include <qlabel.h>
#include <qlayout.h>
#include <qtextcodec.h>
#include <qvgroupbox.h>
#include <qcheckbox.h>
// KDE includes
#include <kapplication.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kcombobox.h>
// #include <kdebug.h>
/**
@author Dominik Seichter
*/
class TranslitPlugin : public Plugin {
Q_OBJECT
public:
const QString getName() const;
const QString getAccelName() const;
const int type() const;
const QPixmap getIcon() const;
void drawInterface( QWidget* w, QVBoxLayout* l );
void finished();
bool checkError();
void fillStructure();
QString processFile( BatchRenamer*, int, QString token, int );
TranslitPlugin();
protected:
QString translit(const QString &);
typedef QMap<QString, QString> TranslitMap;
TranslitMap m_mapFromUTF8;
static const QString m_strUtf8[];
static const QString m_strEngl[];
};
#endif

@ -0,0 +1,136 @@
/***************************************************************************
undodialog.cpp - description
-------------------
begin : Mon Mai 27 20:08:19 CEST 2002
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#include "undodialog.h"
// Qt includes
#include <qlabel.h>
#include <qlayout.h>
// KDE includes
#include <kfiledialog.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kprocess.h>
#include <ktextbrowser.h>
#include <kurlrequester.h>
UndoDialog::UndoDialog( QWidget* parent )
: KDialogBase( KDialogBase::Plain, i18n("Undo Renaming"),
KDialogBase::User1 | KDialogBase::Close, KDialogBase::User1, parent, 0, false, true )
{
UndoDialogLayout = new QVBoxLayout( plainPage(), 11, 6, "UndoDialogLayout");
TextLabel1 = new QLabel( plainPage(), "TextLabel1" );
TextLabel1->setText( i18n( "Undo script:" ) );
UndoDialogLayout->addWidget( TextLabel1 );
scriptname = new KURLRequester( plainPage(), "KURLRequester1" );
scriptname->setMode( KFile::File | KFile::LocalOnly );
scriptname->fileDialog()->setOperationMode( KFileDialog::Opening );
scriptname->setFilter( i18n("*.krename|KRename undo scripts (*.krename)\n"
"*|All Files (*)") );
UndoDialogLayout->addWidget( scriptname );
TextLabel2 = new QLabel( plainPage(), "TextLabel2" );
TextLabel2->setText( i18n( "<qt>Undo Scripts are normal shell scripts which can also be executed manually from the command line.</qt>" ) );
UndoDialogLayout->addWidget( TextLabel2 );
browser = new KTextBrowser( plainPage());
browser->setWordWrap( QTextEdit::NoWrap );
browser->setTextFormat( Qt::RichText );
UndoDialogLayout->addWidget( browser );
setButtonText( KDialogBase::User1, i18n( "&Start" ) );
connect( this, SIGNAL( user1Clicked() ), this, SLOT( start() ) );
connect( scriptname, SIGNAL( textChanged( const QString & ) ), this, SLOT( enableControls() ) );
enableControls();
}
UndoDialog::~UndoDialog()
{ }
void UndoDialog::start()
{
if( scriptname->url().right( 8 ) != ".krename" ) // EXTENSION
if( KMessageBox::warningContinueCancel( this, i18n("This script does not seem "
"to be a Krename undo script. Execution of this "
"script can be dangerous. Continue ?") )
== KMessageBox::Cancel )
return;
KProcess *proc = new KProcess;
*proc << scriptname->url() << "--krename";
enableButton( KDialogBase::User1, false );
if( !proc->start( KProcess::NotifyOnExit, KProcess::AllOutput ) ) {
KMessageBox::sorry( this, i18n("Unable to start the given undo script!") );
enableButton( KDialogBase::User1, true );
delete proc;
return;
}
proc->resume();
connect( proc, SIGNAL( receivedStdout( KProcess*, char*, int) ), this, SLOT( receive( KProcess*, char*, int ) ) );
connect( proc, SIGNAL( receivedStderr( KProcess*, char*, int) ), this, SLOT( receiveErr( KProcess*, char*, int ) ) );
connect( proc, SIGNAL( processExited( KProcess* ) ), this, SLOT( finished( KProcess* ) ) );
}
void UndoDialog::receive( KProcess*, char* buffer, int len )
{
QString text;
for( int i = 0; i < len; i++ )
text.append( buffer[i] );
browser->setText( browser->text() + text + "<br>");
}
void UndoDialog::receiveErr( KProcess*, char* buffer, int len )
{
QString text = "<b>";
for( int i = 0; i < len; i++ )
text.append( buffer[i] );
browser->setText( browser->text() + text + "</b><br>");
}
void UndoDialog::finished( KProcess* p )
{
delete p;
KMessageBox::information( this, i18n("Finished successfully") );
enableControls();
}
void UndoDialog::enableControls()
{
QFileInfo fi( scriptname->url() );
bool b = !scriptname->url().isEmpty() && fi.exists() && fi.isExecutable();
enableButton( KDialogBase::User1, b );
}
void UndoDialog::setUndoScript( const QString & filename )
{
scriptname->setURL( filename );
}

@ -0,0 +1,59 @@
/**************************************************************************
undodialog.h - description
-------------------
begin : Mon Mai 27 20:08:19 CEST 2002
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef UNDODIALOG_H
#define UNDODIALOG_H
#include <kdialogbase.h>
class KPushButton;
class KProcess;
class KTextBrowser;
class KURLRequester;
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QLabel;
class UndoDialog : public KDialogBase
{
Q_OBJECT
public:
UndoDialog( QWidget* parent = 0 );
~UndoDialog();
void setUndoScript( const QString & filename );
public slots:
void start();
private slots:
void receive( KProcess*, char* buffer, int len );
void receiveErr( KProcess*, char* buffer, int len );
void finished( KProcess* p );
void enableControls();
private:
QLabel* TextLabel1;
KURLRequester* scriptname;
QLabel* TextLabel2;
KTextBrowser* browser;
protected:
QVBoxLayout* UndoDialogLayout;
};
#endif // UNDODIALOG_H

@ -0,0 +1,106 @@
/***************************************************************************
wizard.cpp - description
-------------------
begin : Die Mai 15 15:34:19 CEST 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
// Own includes
#include "wizard.h"
#include "krenameimpl.h"
// KDE includes
#include <kapplication.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kmenubar.h>
#include <kmessagebox.h>
#include <kstartupinfo.h>
// Qt includes
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qsizepolicy.h>
#include <qvbox.h>
wizard::wizard( KRenameImpl* impl, QRect r, QWidget* parent, const char* name )
: KWizard( parent, name )
{
setIcon( BarIcon( "krename" ) );
menuBar = new KMenuBar(this);
krename = impl ? impl : new KRenameImpl( this, menuBar, this->finishButton() );
connect( krename, SIGNAL( pageDone( QWidget*, const QString & ) ), this, SLOT( slotAddPage( QWidget*, const QString & ) ) );
connect( krename, SIGNAL( showPage( int ) ), this, SLOT( slotShowPage( int ) ) );
connect( krename, SIGNAL( enableFinish( bool ) ), this, SLOT( slotEnableFinish( bool ) ) );
if( impl )
{
krename->changeParent( this, menuBar, this->finishButton(), r );
krename->setWizardMode( true );
} else
krename->setup( true );
// Tell KStartupInfo that KRename has been loaded completly
KStartupInfoId id;
id.initId( kapp->startupId() );
KStartupInfo::sendFinish( id );
// Disable ESC key
cancelButton()->setAccel( QKeySequence() );
}
wizard::~wizard()
{
}
void wizard::slotAddPage( QWidget* page, const QString & title )
{
// exclude page 3 from wizard
if( krename->title( 2 ) == title )
{
page->hide();
return;
}
QString t = title + i18n(" - Step %1 of %2").arg( pageCount()+1 ).arg( 3 );
QVBox* layout = new QVBox( this );
new QLabel( QString( t ).remove( title.find( "&" ), 1 ), layout );
QFrame* hbar1 = new QFrame( layout, "<hr>", 0 );
hbar1->setFrameStyle( QFrame::Sunken + QFrame::HLine );
page->reparent( layout, QPoint( 0, 0 ) );
addPage( layout, t );
setHelpEnabled( layout, false );
}
void wizard::slotShowPage( int page )
{
showPage( this->page( page - 1 ) );
}
void wizard::slotEnableFinish( bool b )
{
setFinishEnabled( page( pageCount() - 1), b );
}
void wizard::accept()
{
/** do nothing */
}

@ -0,0 +1,54 @@
/***************************************************************************
wizard.h - description
-------------------
begin : Die Mai 15 15:34:19 CEST 2001
copyright : (C) 2001 by Dominik Seichter
email : domseichter@web.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. *
* *
***************************************************************************/
#ifndef WIZARD_H
#define WIZARD_H
// KDE includes
#include <kwizard.h>
class QCloseEvent;
class KRenameImpl;
class KMenuBar;
class QCloseEvent;
class QHBoxLayout;
class QRect;
class QString;
class QVBoxLayout;
class QWidget;
class wizard : public KWizard
{
Q_OBJECT
public:
wizard( KRenameImpl* impl, QRect r, QWidget* parent = 0, const char* name = 0 );
~wizard();
inline KRenameImpl* getKRename() { return krename; }
private slots:
void slotAddPage( QWidget* page, const QString & title );
void slotShowPage( int page );
void slotEnableFinish( bool b );
protected:
void accept();
KMenuBar* menuBar;
KRenameImpl* krename;
};
#endif // WIZARD_H

@ -0,0 +1,8 @@
####### kdevelop will overwrite this part!!! (begin)##########
EXTRA_DIST = krename.pot
####### kdevelop will overwrite this part!!! (end)############
POFILES = AUTO

1474
po/bs.po

File diff suppressed because it is too large Load Diff

1451
po/de.po

File diff suppressed because it is too large Load Diff

1462
po/es.po

File diff suppressed because it is too large Load Diff

1483
po/fr.po

File diff suppressed because it is too large Load Diff

1447
po/hu.po

File diff suppressed because it is too large Load Diff

1459
po/it.po

File diff suppressed because it is too large Load Diff

1432
po/ja.po

File diff suppressed because it is too large Load Diff

1482
po/nl.po

File diff suppressed because it is too large Load Diff

1450
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1448
po/ru.po

File diff suppressed because it is too large Load Diff

1443
po/sl.po

File diff suppressed because it is too large Load Diff

1442
po/sv.po

File diff suppressed because it is too large Load Diff

1454
po/tr.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,3 @@
doc
krename
po
Loading…
Cancel
Save