mirror of
https://invent.kde.org/utilities/filelight
synced 2024-06-29 05:54:26 +00:00
inital import of the kde4 version of filelight
svn path=/trunk/playground/utils/filelight/; revision=920321
This commit is contained in:
parent
5007410642
commit
6458153e9b
2
AUTHORS
Normal file
2
AUTHORS
Normal file
|
@ -0,0 +1,2 @@
|
|||
Martin Sandsmark <sandsmark@samfundet.no>
|
||||
Max Howell <max.howell@methylblue.com>
|
33
CMakeLists.txt
Normal file
33
CMakeLists.txt
Normal file
|
@ -0,0 +1,33 @@
|
|||
#######################################################################
|
||||
# Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License or (at your option) version 3 or any later version
|
||||
# accepted by the membership of KDE e.V. (or its successor approved
|
||||
# by the membership of KDE e.V.), which shall act as a proxy
|
||||
# defined in Section 14 of version 3 of the license.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
|
||||
find_package(KDE4 REQUIRED)
|
||||
|
||||
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS} -fPIC)
|
||||
|
||||
include(KDE4Defaults)
|
||||
|
||||
include(MacroLibrary)
|
||||
|
||||
include_directories(src/ ${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(misc)
|
||||
|
848
COPYING
848
COPYING
|
@ -1,285 +1,626 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
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
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. 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.
|
||||
them 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.
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
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.
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. 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.
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
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.
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
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.
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
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".
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
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.
|
||||
0. Definitions.
|
||||
|
||||
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.
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
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.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
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:
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
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.
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
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.
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
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.
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
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.
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
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:
|
||||
1. Source Code.
|
||||
|
||||
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,
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
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,
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
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 "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
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.
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
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.
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
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.
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
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
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
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
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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.
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying 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.
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
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.
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
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.
|
||||
14. Revised Versions 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
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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.
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public 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.
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
NO WARRANTY
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
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.
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
|
@ -287,15 +628,15 @@ free software which everyone can redistribute and change under these terms.
|
|||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
|
@ -304,37 +645,30 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA
|
||||
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
1.0.1
|
||||
Added the Amarok crash-handler, which I wrote, in case you were wondering
|
||||
Made the fixes suggested at http://www.englishbreakfastnetwork.org/
|
||||
Deletes remove the segment deleted and re-render the map as expected rather than require a rescan, this wasn't trivial to do due to poor design on my part.. ;)
|
||||
|
||||
1.0
|
||||
Added copy to clipboard function to segment context menus
|
||||
Accepts URLs from drag and drop
|
||||
|
|
68
INSTALL
68
INSTALL
|
@ -1,36 +1,32 @@
|
|||
|
||||
Filelight INSTALL
|
||||
===================
|
||||
|
||||
Simply:
|
||||
|
||||
$ ./configure && make && su -c "make install"
|
||||
|
||||
But, I recommend:
|
||||
|
||||
$ CXXFLAGS="-O3" ./configure --enable-final --disable-debug \
|
||||
&& make && su -c "make install"
|
||||
|
||||
|
||||
Troubleshooting
|
||||
=================
|
||||
|
||||
Check you have the kde development packages installed, they'll be named
|
||||
something like:
|
||||
|
||||
kde-devel
|
||||
|
||||
This should pull in a lot of other development packages (unless they are already
|
||||
installed) like:
|
||||
|
||||
x11-devel
|
||||
qt-devel
|
||||
|
||||
If you get stuck, please email me the config.log file with any information you
|
||||
can provide. I will get back to you! Compile issues suck, I know this full well.
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
I hope you enjoy using Filelight!
|
||||
|
||||
Max Howell <max.howell@methylblue.com>
|
||||
|
||||
Filelight INSTALL
|
||||
===================
|
||||
|
||||
Simply:
|
||||
|
||||
$ mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
&& make && sudo make install
|
||||
|
||||
Troubleshooting
|
||||
=================
|
||||
|
||||
Check you have the kde development packages installed, they'll be named
|
||||
something like:
|
||||
|
||||
kde-devel
|
||||
|
||||
This should pull in a lot of other development packages (unless they are already
|
||||
installed) like:
|
||||
|
||||
x11-devel
|
||||
qt-devel
|
||||
|
||||
If you get stuck, please email me with any relevant information you can
|
||||
provide. I will get back to you! Compile issues suck, I know this full well.
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
We hope you enjoy using Filelight!
|
||||
|
||||
Martin Sandsmark <sandsmark@samfundet.no>
|
||||
Max Howell <max.howell@methylblue.com>
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
AUTOMAKE_OPTIONS = foreign
|
||||
SUBDIRS = src misc
|
||||
|
||||
messages: rc.cpp
|
||||
$(EXTRACTRC) `find . -name "*.rc" -o -name "*.ui"` >> rc.cpp
|
||||
LIST=`find src -name \*.h -o -name \*.cpp` ;\
|
||||
if test -n "$$LIST"; then \
|
||||
$(XGETTEXT) rc.cpp $$LIST -o $(podir)/filelight.pot; \
|
||||
fi
|
18
README
18
README
|
@ -3,17 +3,17 @@
|
|||
==================
|
||||
|
||||
Filelight allows you to understand exactly where your diskspace is being used by
|
||||
graphically representing your file system as a set of concentric
|
||||
graphically representating your filesystem as a set of concentric
|
||||
segmented-rings.
|
||||
|
||||
README last updated with respect to 1.0
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Dependencies
|
||||
==============
|
||||
|
||||
Filelight depends on KDElibs >= 3.2 and therefore Qt >= 3.2.
|
||||
Filelight works on KDElibs >= 4.2 and therefore Qt >= 4.4 (lower versions may
|
||||
work, but no guarantees).
|
||||
|
||||
|
||||
Usage Tips
|
||||
|
@ -26,14 +26,13 @@ Filelight depends on KDElibs >= 3.2 and therefore Qt >= 3.2.
|
|||
* Increase the window size to see more detail
|
||||
* Hover over segments to find out more information
|
||||
* Available as a view-KPart in Konqueror
|
||||
* You can specify a directory to scan on startup from the command line, for
|
||||
example:
|
||||
* You can specify a directory to scan on startup from the command line, eg:
|
||||
|
||||
$ filelight /home/mxcl
|
||||
|
||||
|
||||
Install
|
||||
=========
|
||||
Installation
|
||||
==============
|
||||
|
||||
See the accompanying file; INSTALL.
|
||||
|
||||
|
@ -41,10 +40,11 @@ See the accompanying file; INSTALL.
|
|||
Bugs
|
||||
======
|
||||
|
||||
There are less bugs everyday! Please report bugs to filelight@methylblue.com
|
||||
There are less bugs everyday! Please report bugs to sandsmark@samfundet.no
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
I hope you enjoy using Filelight!
|
||||
We hope you enjoy using Filelight!
|
||||
|
||||
Martin Sandsmark <sandsmark@samfundet.no>
|
||||
Max Howell <max.howell@methylblue.com>
|
||||
|
|
9
TODO
9
TODO
|
@ -22,15 +22,6 @@
|
|||
support other mouse actions for central circle (ie middle click, right click)
|
||||
write caches for all scans, so if crash or something that root scan that took 20 mins is not lost
|
||||
|
||||
1.0.1
|
||||
Check we are reporting same sizes as du, --> get du source code
|
||||
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=230849
|
||||
Make first run for users at summary screen explain what is going on
|
||||
* more click targets for showing that partition
|
||||
* non intrusive help message of some kind
|
||||
* explain why we look like a browser
|
||||
Verify the part version is new enough
|
||||
|
||||
MAYBE
|
||||
flicking mouse wheel shows different information in tooltip, and there's an off setting, show temp status message to reflect info box
|
||||
ideally, eventually show which labels are children of which by grouping them with a coloured square or something
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
# -*-shell-script-*-
|
||||
|
||||
[Meta]
|
||||
RootName: @methylblue.com/filelight:$SOFTWAREVERSION
|
||||
DisplayName: Filelight
|
||||
ShortName: filelight
|
||||
Maintainer: Max Howell <max.howell@filelight.com>
|
||||
Packager: Max Howell <max.howell@filelight.com>
|
||||
Summary: Graphical disk-usage information
|
||||
URL: http://www.methyblue.com/filelight/
|
||||
License: GNU General Public License, Version 2
|
||||
SoftwareVersion: 1.0.1
|
||||
AutopackageTarget: 1.2
|
||||
|
||||
# Only uncomment InterfaceVersion if your package exposes interfaces to other software,
|
||||
# for instance if it includes DSOs or python/perl modules. See the developer guide for more info,
|
||||
# or ask on autopackage-dev if you don't understand interface versioning in autopackage.
|
||||
#
|
||||
# InterfaceVersion: 0.0
|
||||
|
||||
[Prepare]
|
||||
requireAtLeast @kde.org/kdelibs:3.2
|
||||
|
||||
[Description]
|
||||
Filelight allows you to understand exactly where your diskspace is being used by graphically
|
||||
representating your filesystem as a set of concentric, segmented-rings.
|
||||
|
||||
[BuildPrepare]
|
||||
echo "Do not build with unsermake! You must rebuild the Makefiles thus:"
|
||||
echo " $ UNSERMAKE=no make -f Makefile.cvs"
|
||||
echo
|
||||
|
||||
prepareBuild() --enable-final --disable-debug --without-arts
|
||||
|
||||
[BuildUnprepare]
|
||||
unprepareBuild()
|
||||
|
||||
[Imports]
|
||||
cd filelight
|
||||
echo '*' | import
|
||||
|
||||
[Install]
|
||||
PREFIX=getKdePrefix
|
||||
|
||||
# Put your installation script here
|
||||
installExe bin/*
|
||||
installLib lib/kde3/*
|
||||
|
||||
installDesktop share/applications/kde/filelight.desktop
|
||||
installIcon share/icons/crystalsvg
|
||||
installConfig share/config/filelightrc
|
||||
|
||||
copyFiles filelightui.rc filelight_partui.rc $PREFIX/share/apps/filelight/
|
||||
|
||||
[Uninstall]
|
||||
# Usually just the following line is enough to uninstall everything
|
||||
uninstallFromLog
|
|
@ -1,2 +0,0 @@
|
|||
KDE_DOCS = filelight
|
||||
KDE_LANG = en
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
|
@ -1,422 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.1.2-Based Variant V1.0//EN" "dtd/kdex.dtd" [
|
||||
<!ENTITY kappname "&filelight;">
|
||||
<!ENTITY filelight "<application>Filelight</application>">
|
||||
<!ENTITY % addindex "IGNORE">
|
||||
<!ENTITY % English "INCLUDE"><!-- change language only here -->
|
||||
]>
|
||||
|
||||
<book lang="&language;">
|
||||
|
||||
<bookinfo>
|
||||
<title>The &filelight; Handbook</title>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<firstname>Max</firstname>
|
||||
<surname>Howell</surname>
|
||||
<affiliation><address><email>max.howell@methylblue.com</email></address></affiliation>
|
||||
</author>
|
||||
<!-- TRANS:ROLES_OF_TRANSLATORS -->
|
||||
</authorgroup>
|
||||
<copyright><year>2006</year><holder>Max Howell</holder></copyright>
|
||||
<!-- Translators: put here the copyright notice of the translation -->
|
||||
<legalnotice>&FDLNotice;</legalnotice>
|
||||
<date>14/09/2006</date>
|
||||
<releaseinfo>3</releaseinfo>
|
||||
<abstract><para>&filelight; creates an interactive map of concentric segmented-rings that helps visualise disk usage on your computer.</para></abstract>
|
||||
<!-- These may be used by search engines -->
|
||||
<keywordset>
|
||||
<keyword>KDE</keyword>
|
||||
<keyword>Filelight</keyword>
|
||||
<keyword>du</keyword>
|
||||
<keyword>disk usage</keyword>
|
||||
</keywordset>
|
||||
</bookinfo>
|
||||
|
||||
|
||||
<chapter id="introduction">
|
||||
<title>Introduction</title>
|
||||
<screenshot>
|
||||
<screeninfo>&filelight; 1.0 Screenshot</screeninfo>
|
||||
<mediaobject>
|
||||
<imageobject><imagedata fileref="radial_map.png" format="PNG"/></imageobject>
|
||||
<textobject><phrase>Screenshot</phrase></textobject>
|
||||
</mediaobject>
|
||||
</screenshot>
|
||||
<para>&filelight; allows you to quickly understand exactly where your diskspace is being used by graphically representing your file system as a set of concentric segmented-rings. You can use it to locate hotspots of disk usage and then manipulate those areas using &konqueror;.</para>
|
||||
</chapter>
|
||||
|
||||
|
||||
<chapter id="configuring">
|
||||
<title>Configuring &filelight;</title>
|
||||
|
||||
<para>The &filelight; settings dialog has two tabs for configuring the &filelight; options. The two tabs are <guimenuitem>Scanning</guimenuitem> and <guimenuitem>Appearance</guimenuitem>. Below is a description of the settings tabs. The &filelight; settings dialog can be found by clicking <menuchoice><guimenu>Settings</guimenu><guimenuitem>Configure Filelight</guimenuitem></menuchoice>.</para>
|
||||
|
||||
<sect1 id="scanning">
|
||||
<title>Scanning</title>
|
||||
|
||||
<screenshot>
|
||||
<screeninfo>Scanning Screenshot</screeninfo>
|
||||
<mediaobject>
|
||||
<imageobject><imagedata fileref="config_scan.png" format="PNG"/></imageobject>
|
||||
<textobject><phrase>Screenshot</phrase></textobject>
|
||||
</mediaobject>
|
||||
</screenshot>
|
||||
|
||||
<para>The scanning tab allows you to configure how &filelight; scans folders. The <guimenuitem> Don't scan these folders:</guimenuitem> is used to excluded certain folders from your scan. This option is very useful for skipping folders that you may not have permissions to read, or folders that are part of a virtual filesystem, such as /proc. To add a folder to the list, click the <guibutton>Add...</guibutton> button, this will start a dialog where you can choose the folder of your choice from a tree view. To remove a folder simply select the folder of your choice and click the <guibutton>Remove</guibutton> button.</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="appearance">
|
||||
<title>Appearance</title>
|
||||
|
||||
<screenshot>
|
||||
<screeninfo>Appearance Screenshot</screeninfo>
|
||||
<mediaobject>
|
||||
<imageobject><imagedata fileref="config_appear.png" format="PNG"/></imageobject>
|
||||
<textobject><phrase>Screenshot</phrase></textobject>
|
||||
</mediaobject>
|
||||
</screenshot>
|
||||
|
||||
<para>The <guimenuitem>Appearance</guimenuitem> tab allows you to configure the way &filelight; looks.</para>
|
||||
<para>The <guimenuitem>Scheme</guimenuitem> section is used to choose a color scheme for &filelight;. The color schemes are Rainbow, &kde; Colours, and High Contrast. There is also a <guimenuitem>Contrast:</guimenuitem> slider to adjust the contrast of the ring segments for easier viewing.</para>
|
||||
<para>The <guimenuitem>Use anti-aliasing</guimenuitem> check box is used to enable the use of anti-aliasing in the &filelight; view. Selected, this option makes the ring segments have a much cleaner look.</para>
|
||||
<para>The <guimenuitem>Vary label font sizes</guimenuitem> check box is useful when you have files or folders with long names. This option will change the size of the font to allow it to fit in the view better. When this option is enabled a <guimenuitem>Minimum font size:</guimenuitem> spinbox becomes available for choosing the smallest size font to scale to.</para>
|
||||
<para>The <guimenuitem>Show small files</guimenuitem> option is disabled by default as small files tend to clutter the &filelight; view. Enable this option if you would like to have your small files included in the &filelight; view.</para>
|
||||
|
||||
</sect1>
|
||||
</chapter>
|
||||
|
||||
|
||||
<chapter id="using">
|
||||
<title>Using &filelight;</title>
|
||||
|
||||
<sect1 id="starting">
|
||||
<title>Starting &filelight;</title>
|
||||
<para>&filelight; can be started from the K-Menu, or from the command-line</para>
|
||||
|
||||
<sect2 id="starting-from-the-menu">
|
||||
<title>From the K-Menu</title>
|
||||
<para>
|
||||
Open the &kde; program menu by clicking on the
|
||||
<guiicon>big K</guiicon> icon on your
|
||||
panel. This will raise the <guimenu>program menu</guimenu>. Move your
|
||||
cursor up the menu to the <guimenu>Utilities</guimenu> menu item. Choose
|
||||
<guimenuitem>&filelight;</guimenuitem>.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="starting-from-the-command-line">
|
||||
<title>From the Command Line</title>
|
||||
<para>
|
||||
You can start &filelight; by typing its name on the command line.
|
||||
If you give it a folder name, as in the example below, it will scan that folder.
|
||||
</para>
|
||||
<informalexample>
|
||||
<screen>
|
||||
<prompt>%</prompt><userinput><command>filelight</command> <option><replaceable>/home</replaceable></option></userinput>
|
||||
</screen>
|
||||
</informalexample>
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="scanning-folders">
|
||||
<title>Scanning folders</title>
|
||||
<para>
|
||||
Scanning a folder shows it's contents as a filemap. To scan a folder, use the scan menu, or type a url straight into the location bar.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="exploring-filemaps">
|
||||
<title>Exploring Filemaps</title>
|
||||
<para>
|
||||
Once a scan has completed you will be presented with a filemap that represents the folder you scanned. The filemap is a series of segmented-rings that expand from the center. Brightly coloured segments are folders, grey segments are files. Segments are sized in proportion to their filesize. Segments can be nested, so for example, /home/mxcl will be one level outwards and within the bounds of the segment representing /home. Segments are labeled and hovering the mouse over segments will give you more details of that segment and its child segments.
|
||||
</para>
|
||||
<screenshot>
|
||||
<screeninfo>Filemap Screenshot</screeninfo>
|
||||
<mediaobject>
|
||||
<imageobject><imagedata fileref="radial_map.png" format="PNG"/></imageobject>
|
||||
<textobject><phrase>Screenshot</phrase></textobject>
|
||||
</mediaobject>
|
||||
</screenshot>
|
||||
<para>
|
||||
You can open folders with &konqueror; or &konsole; using the context menu for that segment. Middle clicks open files by mimetype, so images with Kuickshow. You can right click the central circle to get a context menu for the scanned folder. Left clicking segments will re-center the map on that segment.
|
||||
</para>
|
||||
<para>
|
||||
If you want to improve the documentation, I'll happily accept patches :) Thanks.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
||||
|
||||
<chapter id="commands">
|
||||
<title>Menu and Command Reference</title>
|
||||
|
||||
<sect1 id="scan_menu">
|
||||
<title>The Scan Menu</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<shortcut>
|
||||
<keycombo><keycap>Ctrl</keycap><keycap>o</keycap></keycombo>
|
||||
</shortcut>
|
||||
<guimenu>Scan</guimenu>
|
||||
<guimenuitem>Scan folder..</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Offers a folder selection dialog so you can choose a folder to scan.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<shortcut>
|
||||
<keycombo><keycap>Ctrl</keycap><keycap>Home</keycap></keycombo>
|
||||
</shortcut>
|
||||
<guimenu>Scan</guimenu>
|
||||
<guimenuitem>Scan Home folder</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Starts a scan of the user's home folder.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Scan</guimenu>
|
||||
<guimenuitem>Scan Root folder</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Starts a scan of the root folder.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Scan</guimenu>
|
||||
<guimenuitem>Recent Scans</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Provides a list of your most recent scanned folders allowing quick access to these folders.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<shortcut>
|
||||
<keycap>F5</keycap>
|
||||
</shortcut>
|
||||
<guimenu>Scan</guimenu>
|
||||
<guimenuitem>Rescan</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Starts a new scan of the current working folder, this is useful when changes have been made to the filesystem.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<shortcut>
|
||||
<keycap>Esc</keycap>
|
||||
</shortcut>
|
||||
<guimenu>Scan</guimenu>
|
||||
<guimenuitem>Stop</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Stops the current scan.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<shortcut>
|
||||
<keycombo><keycap>Ctrl</keycap><keycap>q</keycap></keycombo>
|
||||
</shortcut>
|
||||
<guimenu>Scan</guimenu>
|
||||
<guimenuitem>Quit</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Quits &filelight;.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="go_menu">
|
||||
<title>The Go Menu</title>
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<shortcut>
|
||||
<keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
|
||||
</shortcut>
|
||||
<guimenu>Go</guimenu>
|
||||
<guimenuitem>Up</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Moves you up once in the filesystem.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<shortcut>
|
||||
<keycombo><keycap>Alt</keycap><keycap>Left</keycap></keycombo>
|
||||
</shortcut>
|
||||
<guimenu>Go</guimenu>
|
||||
<guimenuitem>Back</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Moves you one step back in your browsing of the filesystem.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<shortcut>
|
||||
<keycombo><keycap>Alt</keycap><keycap>Right</keycap></keycombo>
|
||||
</shortcut>
|
||||
<guimenu>Go</guimenu>
|
||||
<guimenuitem>Forward</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Moves you one step forward in your browsing of the filesystem.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="settings_menu">
|
||||
<title>The Settings Menu</title>
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Settings</guimenu>
|
||||
<guisubmenu>Toolbars</guisubmenu>
|
||||
<guimenuitem>Show Main Toolbar</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Enables or disable the main application toolbar.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Settings</guimenu>
|
||||
<guisubmenu>Toolbars</guisubmenu>
|
||||
<guimenuitem>Show Location Toolbar</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Enables or disable the location toolbar.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Settings</guimenu>
|
||||
<guimenuitem>Configure Shortcuts...</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Allows you to configure the &filelight; shortcuts.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Settings</guimenu>
|
||||
<guimenuitem>Configure Toolbars...</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Allows you to configure the &filelight; toolbar options.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Settings</guimenu>
|
||||
<guimenuitem>Configure Filelight...</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Starts the Configure &filelight; dialog.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="help_menu">
|
||||
<title>The Help Menu</title>
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Help</guimenu>
|
||||
<guimenuitem>Filelight Handbook</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Opens this help document.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<shortcut>
|
||||
<keycombo><keycap>Shift</keycap><keycap>F1</keycap></keycombo>
|
||||
</shortcut>
|
||||
<guimenu>Help</guimenu>
|
||||
<guimenuitem>What's This?</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Activates the "What's This?" mouse cursor allowing you to click an object to get a "What's this?" tooltip.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Help</guimenu>
|
||||
<guimenuitem>Report Bug...</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Starts the bug report tool dialog window.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Help</guimenu>
|
||||
<guimenuitem>About Filelight</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Starts the About &filelight; dialog window.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><menuchoice>
|
||||
<guimenu>Help</guimenu>
|
||||
<guimenuitem>About KDE</guimenuitem>
|
||||
</menuchoice></term>
|
||||
<listitem><para><action>Starts the About &kde; dialog window.</action></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
||||
|
||||
<chapter id="credits">
|
||||
<title>Credits and License</title>
|
||||
<sect1 id="kapp">
|
||||
<title>&filelight;</title>
|
||||
<para>Program copyright 2003 Max B. Howell <email>max.howell@methylblue.com</email></para>
|
||||
&underGPL;
|
||||
</sect1>
|
||||
<sect1 id="Documentation">
|
||||
<title>Documentation</title>
|
||||
<para>Documentation copyright 2003 Max B. Howell <email>max.howell@methylblue.com</email></para>
|
||||
<!-- TRANS:CREDIT_FOR_TRANSLATORS -->
|
||||
&underFDL;
|
||||
</sect1>
|
||||
</chapter>
|
||||
|
||||
|
||||
<appendix id="installation">
|
||||
<title>Installation</title>
|
||||
<sect1 id="getting-filelight">
|
||||
<title>How to obtain &filelight;</title>
|
||||
<para>&filelight; is not yet part of the &kde; project, it can be found at <ulink url="http://www.methylblue.com/filelight/">www.methylblue.com/filelight/</ulink>.</para>
|
||||
</sect1>
|
||||
<sect1 id="compilation">
|
||||
<title>Compilation and Installation</title>
|
||||
<para>In order to compile and install &filelight; on your system, type the following in the base folder of the &filelight; distribution:</para>
|
||||
<screen width="40">
|
||||
<prompt>%</prompt> <userinput>./configure --prefix=`kde-config --prefix`</userinput>
|
||||
<prompt>%</prompt> <userinput>make</userinput>
|
||||
<prompt>%</prompt> <userinput>make install</userinput>
|
||||
</screen>
|
||||
<para>Since &filelight; uses autoconf and automake you should have not trouble compiling it. Should you run into problems please report them to filelight@methylblue.com or the &filelight; Forums.</para>
|
||||
</sect1>
|
||||
</appendix>
|
||||
|
||||
&documentation.index;
|
||||
|
||||
</book>
|
||||
|
||||
<!--
|
||||
Local Variables:
|
||||
mode: sgml
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-general-insert-case:lower
|
||||
sgml-indent-step:0
|
||||
sgml-indent-data:nil
|
||||
End:
|
||||
-->
|
Binary file not shown.
Before Width: | Height: | Size: 40 KiB |
|
@ -1,10 +1,10 @@
|
|||
Begin3
|
||||
Title: Filelight
|
||||
Version: 1.0.1
|
||||
title: Filelight
|
||||
Version: 1.0
|
||||
Entered-date: 5/9/2003
|
||||
Description: Graphical disk usage information
|
||||
Keywords: kde disk usage du filesystem diskspace
|
||||
Author: Max Howell <max.howell@methylblue.com>
|
||||
author: Max Howell <max.howell@methylblue.com>
|
||||
Maintained-by: Max Howell <max.howell@methylblue.com>
|
||||
Home-page: http://www.methylblue.com/filelight/
|
||||
Platform: unix
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
export VERSION=??
|
||||
svn co https://svn.kde.org/home/kde/trunk/extragear/utils
|
||||
pushd utils
|
||||
svn up admin
|
||||
rm -rf `find -name .svn`
|
||||
export UNSERMAKE=no
|
||||
export AUTOMAKE=/usr/bin/automake-1.6
|
||||
make -f Makefile.cvs
|
||||
rm -rf autom4te.cache config.h config.log configure.files configure.in.in
|
||||
find -exec touch --date=010806 {} \;
|
||||
popd
|
||||
mv utils filelight-$VERSION
|
||||
tar cjf filelight-$VERSION.tar.bz2 filelight-$VERSION
|
||||
md5sum filelight-$VERSION.tar.bz2
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
All files are touched to a time in the past to ensure we aren't bitten by an
|
||||
automake bug where people in the future (think timezones ahead of yours) can't
|
||||
build the tarball until 24 hours after release.
|
||||
|
||||
The MD5 should be posted with the tarball.
|
||||
|
||||
Add a new tag for the release in /tags/filelight/$VERSION
|
||||
|
||||
Adjust the stable branch to point at the new tag
|
||||
svn delete /branches/stable/extragear/utils/filelight
|
||||
svn cp /tags/filelight/$VERSION /branches/stable/extragear/utils/filelight
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Ensure user-strings of versions are up to date.
|
||||
Ensure README, ChangeLog are up to date.
|
||||
Test it builds using the lines in the README.
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Create the i18n tarball using the make-i18n-dist.ruby script.
|
|
@ -1,146 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# adopted from release_amarok.rb
|
||||
|
||||
#===============================================================================
|
||||
# edit these to customise behaviour
|
||||
#===============================================================================
|
||||
branch = 'trunk'
|
||||
user = 'mhowell'
|
||||
protocol = 'https'
|
||||
category = 'utils'
|
||||
product = 'filelight'
|
||||
#===============================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# header
|
||||
#===============================================================================
|
||||
|
||||
def mkdir( dirname )
|
||||
begin
|
||||
Dir.mkdir dirname
|
||||
rescue Errno::EEXIST
|
||||
# ignore error if directory exists
|
||||
end
|
||||
|
||||
return Dir.new( dirname )
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# checkout and generate build system
|
||||
#===============================================================================
|
||||
|
||||
# create our root directory
|
||||
mkdir( "#{product}-#{version}-i18n-#{Date.today.chomp '-'}" ).chdir()
|
||||
|
||||
# get the vital buildsystem bits
|
||||
`svn co #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/extragear/#{category}/Makefile.cvs`
|
||||
`svn co #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/extragear/#{category}/configure.in`
|
||||
`svn co #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/l10n/COPYING`
|
||||
`svn co #{protocol}://#{user}@svn.kde.org/home/kde/branches/KDE/3.5/kde-common/admin`
|
||||
|
||||
# make some more subdirectorries
|
||||
mkdir( "doc" )
|
||||
mkdir( "po" )
|
||||
mkdir( "l10n" ).chdir();
|
||||
|
||||
|
||||
# list of available languages
|
||||
languages = `svn cat #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/l10n/subdirs`
|
||||
|
||||
|
||||
# docs
|
||||
for lang in languages
|
||||
lang.chomp!()
|
||||
`rm -rf #{product}`
|
||||
dirname = "l10n/#{lang}/docs/extragear-#{category}/#{product}"
|
||||
`svn co -q #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/#{dirname} > /dev/null 2>&1`
|
||||
next unless FileTest.exists?( product )
|
||||
|
||||
print "Copying #{product} documentation for #{lang}... "
|
||||
`cp -R #{product}/ ../doc/#{lang}`
|
||||
|
||||
# we don't want KDE_DOCS = AUTO, because that makes the
|
||||
# build system assume that the product of the app is the
|
||||
# same as the product of the dir the Makefile.am is in.
|
||||
# Instead, we explicitly pass the product..
|
||||
makefile = File.new( "../doc/#{lang}/Makefile.am", File::CREAT | File::RDWR | File::TRUNC )
|
||||
makefile << "KDE_LANG = #{lang}\n"
|
||||
makefile << "KDE_DOCS = #{product}\n"
|
||||
makefile.close()
|
||||
|
||||
puts "done"
|
||||
end
|
||||
|
||||
|
||||
Dir.chdir( ".." )
|
||||
puts "\n"
|
||||
|
||||
|
||||
# po
|
||||
for lang in languages
|
||||
lang.chomp!()
|
||||
filename = "l10n/#{lang}/messages/extragear-#{category}/#{product}.po"
|
||||
`svn cat #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/#{filename} 2> /dev/null | tee l10n/#{product}.po`
|
||||
next if FileTest.size( "l10n/#{product}.po" ) == 0
|
||||
|
||||
dest = "po/#{lang}"
|
||||
Dir.mkdir( dest )
|
||||
print "Copying #{product}.po for #{lang}... "
|
||||
`mv l10n/#{product}.po #{dest}`
|
||||
|
||||
makefile = File.new( "#{dest}/Makefile.am", File::CREAT | File::RDWR | File::TRUNC )
|
||||
makefile << "KDE_LANG = #{lang}\n"
|
||||
makefile << "SUBDIRS = $(AUTODIRS)\n"
|
||||
makefile << "POFILES = AUTO\n"
|
||||
makefile.close()
|
||||
|
||||
puts "done"
|
||||
end
|
||||
|
||||
|
||||
# create crucial Makefile.am files
|
||||
for dir in [po doc]
|
||||
makefile = File.new( "#{dir}/Makefile.am", File::CREAT | File::RDWR | File::TRUNC )
|
||||
makefile << "SUBDIRS = $(AUTODIRS)\n"
|
||||
makefile.close()make
|
||||
end
|
||||
|
||||
makefile = File.new( "Makefile.am", File::CREAT | File::RDWR | File::TRUNC )
|
||||
makefile << "AUTOMAKE_OPTIONS = foreign"
|
||||
makefile << "SUBDIRS = doc po\n"
|
||||
makefile.close()
|
||||
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# cleanup
|
||||
#===============================================================================
|
||||
|
||||
`mkdir delete_me`
|
||||
`mv po/xx delete_me`
|
||||
`mv l10n delete_me/#{product}.l10n.backup.#{Date.today.to_s}`
|
||||
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# autoconf/automake and finalise
|
||||
#===============================================================================
|
||||
|
||||
dot_svn = `find -name .svn -exec`
|
||||
`rm -rf #{dot_svn}`
|
||||
ENV["UNSERMAKE"] = 'no'
|
||||
ENV["AUTOMAKE"] = '/usr/bin/automake-1.6'
|
||||
# we could avoid these if we could use automake --foreign
|
||||
#`touch COPYING README NEWS AUTHORS INSTALL ChangeLog`
|
||||
`make -f Makefile.cvs`
|
||||
`rm -rf autom4te.cache stamp.h.in Makefile.cvs`
|
||||
yesterday = Date.today - 1
|
||||
`find -exec touch --date=#{yesterday.to_s} {} \;`
|
28
misc/CMakeLists.txt
Normal file
28
misc/CMakeLists.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
#######################################################################
|
||||
# Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License or (at your option) version 3 or any later version
|
||||
# accepted by the membership of KDE e.V. (or its successor approved
|
||||
# by the membership of KDE e.V.), which shall act as a proxy
|
||||
# defined in Section 14 of version 3 of the license.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
|
||||
include_directories(${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
|
||||
|
||||
install(FILES filelight_part.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install(FILES filelight.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}/kde)
|
||||
install(FILES filelightrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/config)
|
||||
install(FILES filelight_partui.rc filelightui.rc DESTINATION ${DATA_INSTALL_DIR}/filelight)
|
||||
|
||||
kde4_install_icons(${ICON_INSTALL_DIR})
|
|
@ -1,12 +0,0 @@
|
|||
KDE_ICON = AUTO
|
||||
|
||||
rcdir = $(kde_datadir)/filelight
|
||||
rc_DATA = filelight_partui.rc filelightui.rc
|
||||
|
||||
configdir = $(kde_confdir)
|
||||
config_DATA = filelightrc
|
||||
|
||||
xdg_apps_DATA = filelight.desktop
|
||||
|
||||
partdesktopdir = $(kde_servicesdir)
|
||||
partdesktop_DATA = filelight_part.desktop
|
|
@ -3,32 +3,11 @@
|
|||
Encoding=UTF-8
|
||||
Name=Filelight
|
||||
Name[xx]=xxFilelightxx
|
||||
GenericName=Disk Usage Information
|
||||
GenericName[bg]=Информация за използване на диска
|
||||
GenericName[cs]=Informace o využití disku
|
||||
GenericName[da]=Information om diskbrug
|
||||
GenericName[el]=Πληροφορίες χρήσης δίσκου
|
||||
GenericName[es]=Información del uso del disco
|
||||
GenericName[et]=Kettakasutuse info
|
||||
GenericName[ga]=Faisnéis maidir le húsáid diosca
|
||||
GenericName[it]=Informazioni sull'uso dei dischi
|
||||
GenericName[ja]=ディスクの使用状況
|
||||
GenericName[ms]=Maklumat Penggunaan Cakera
|
||||
GenericName[nl]=Informatie over schijfgebruik
|
||||
GenericName[pt]=Informações de Utilização do Disco
|
||||
GenericName[pt_BR]=Informações de Utilização do Disco
|
||||
GenericName[sk]=Informácie o využití disku
|
||||
GenericName[sr]=Подаци о заузетости диска
|
||||
GenericName[sr@Latn]=Podaci o zauzetosti diska
|
||||
GenericName[sv]=Information om diskanvändning
|
||||
GenericName[tr]=Disk Kullanım Bilgileri
|
||||
GenericName[uk]=Перегляд використання диска
|
||||
GenericName[xx]=xxDisk Usage Informationxx
|
||||
Generic Name=Disk Usage Statistics
|
||||
Type=Application
|
||||
Exec=filelight %f
|
||||
Icon=filelight.png
|
||||
Comment=View disk usage information
|
||||
Comment[ar]=عرض معلومات حول استعمال القرص
|
||||
Comment[bg]=Информация за използване на диска
|
||||
Comment[cs]=Zobrazení využití disku
|
||||
Comment[da]=Vis information om diskforbrug
|
||||
|
@ -42,18 +21,16 @@ Comment[gl]=Informazón do uso do disco
|
|||
Comment[it]=Visualizza informazioni sull'uso dei dischi
|
||||
Comment[ja]=ディスクの使用状況を見る
|
||||
Comment[ka]=დისკის გამოყენების ინფორმაციის ხილვა
|
||||
Comment[ms]=Papar maklumat penggunaan cakera
|
||||
Comment[nb]=Vis informasjon om diskforbruk
|
||||
Comment[nl]=Informatie over schijfgebruik
|
||||
Comment[pa]=ਡਿਸਕ ਵਰਤੋਂ ਦੀ ਜਾਣਕਾਰੀ ਵੇਖੋ
|
||||
Comment[pt]=Ver informações de utilização do disco
|
||||
Comment[pt_BR]=Ver informações de utilização do disco
|
||||
Comment[ru]=Нагладное представление файловой системы
|
||||
Comment[sk]=Pohľad na informácie o využití disku
|
||||
Comment[sr]=Погледајте податке о заузетости диска
|
||||
Comment[sr@Latn]=Pogledajte podatke o zauzetosti diska
|
||||
Comment[sr]=Приказује податке о заузетости диска
|
||||
Comment[sr@Latn]=Prikazuje podatke o zauzetosti diska
|
||||
Comment[sv]=Visa information om diskanvändning
|
||||
Comment[tr]=Disk kullanım bilgilerini göster
|
||||
Comment[tr]=Disk kullanım bilgisini görmek için
|
||||
Comment[uk]=Перегляд використання диска
|
||||
Comment[xx]=xxView disk usage informationxx
|
||||
Comment[zh_CN]=查看磁盘使用信息
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=RadialMap View
|
||||
Name[ar]=عرض RadialMap
|
||||
Name[bg]=Изглед "радиална карта"
|
||||
Name[cs]=Pohled s kruhovou mapou
|
||||
Name[da]=Radialkort-visning
|
||||
|
@ -9,25 +8,24 @@ Name[de]=Radialansicht
|
|||
Name[el]=Προβολή κυκλικού χάρτη
|
||||
Name[es]=Vista en mapa radial
|
||||
Name[et]=Radiaalse kaardi vaade
|
||||
Name[ga]=Mapa Gathach
|
||||
Name[gl]=Vista en Mapa Radial
|
||||
Name[it]=Vista a mappa radiale
|
||||
Name[ja]=放射状グラフ表示
|
||||
Name[ka]=RadialMap ხედი
|
||||
Name[ms]=Paparan Peta Radial
|
||||
Name[nb]=RadialMap-visning
|
||||
Name[nl]=Radiale weergave
|
||||
Name[pa]=RadialMap ਵੇਖੋ
|
||||
Name[pt]=Vista em Mapa Radial
|
||||
Name[pt_BR]=Visualização em Mapa Radial
|
||||
Name[sk]=RadialMap pohľad
|
||||
Name[sr]=Приказ кружне мапе
|
||||
Name[sr@Latn]=Prikaz kružne mape
|
||||
Name[sv]=Radiell avbildningsvy
|
||||
Name[tr]=RadyalHarita Görünümü
|
||||
Name[uk]=Перегляд RadialMap
|
||||
Name[xx]=xxRadialMap Viewxx
|
||||
MimeType=inode/directory
|
||||
MimeType=inode/directory;
|
||||
ServiceTypes=KParts/ReadOnlyPart
|
||||
X-KDE-Library=libfilelight
|
||||
X-KDE-Library=filelightpart
|
||||
# X-KDE-PluginKeyword=filelightpart
|
||||
Type=Service
|
||||
Icon=view_filelight
|
||||
|
|
24
src/CMakeLists.txt
Normal file
24
src/CMakeLists.txt
Normal file
|
@ -0,0 +1,24 @@
|
|||
#######################################################################
|
||||
# Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License or (at your option) version 3 or any later version
|
||||
# accepted by the membership of KDE e.V. (or its successor approved
|
||||
# by the membership of KDE e.V.), which shall act as a proxy
|
||||
# defined in Section 14 of version 3 of the license.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
|
||||
include_directories($ {KDE4_INCLUDES} $ {KDE4_INCLUDE_DIR} $ {QT_INCLUDES} )
|
||||
|
||||
add_subdirectory(app)
|
||||
add_subdirectory(part)
|
|
@ -1,3 +0,0 @@
|
|||
SUBDIRS = app part
|
||||
INCLUDES = $(all_includes)
|
||||
METASOURCES = AUTO
|
29
src/app/CMakeLists.txt
Normal file
29
src/app/CMakeLists.txt
Normal file
|
@ -0,0 +1,29 @@
|
|||
#######################################################################
|
||||
# Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License or (at your option) version 3 or any later version
|
||||
# accepted by the membership of KDE e.V. (or its successor approved
|
||||
# by the membership of KDE e.V.), which shall act as a proxy
|
||||
# defined in Section 14 of version 3 of the license.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/filelight/src ${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES})
|
||||
|
||||
set(filelight_SRCS historyAction.cpp mainWindow.cpp main.cpp)
|
||||
|
||||
kde4_add_executable(filelight ${filelight_SRCS})
|
||||
|
||||
target_link_libraries(filelight ${KDE4_KDECORE_LIBS} ${KDE4_KPARTS_LIBS} ${KDE4_KDEUI_LIBS})
|
||||
|
||||
install(TARGETS filelight ${INSTALL_TARGETS_DEFAULT_ARGS})
|
|
@ -1,8 +0,0 @@
|
|||
INCLUDES = $(all_includes) -I$(top_srcdir)/filelight/src
|
||||
METASOURCES = AUTO
|
||||
|
||||
# Application
|
||||
bin_PROGRAMS = filelight
|
||||
filelight_SOURCES = historyAction.cpp mainWindow.cpp main.cpp crashHandler.cpp
|
||||
filelight_LDADD = $(LIB_KPARTS) $(LIB_KDEUI)
|
||||
filelight_LDFLAGS = $(all_libraries) $(KDE_RPATH)
|
|
@ -1,184 +0,0 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
|
||||
#include <cstdio> //popen, fread
|
||||
#include "crashHandler.h"
|
||||
#include "define.h"
|
||||
#include <iostream>
|
||||
#include <kapplication.h> //invokeMailer()
|
||||
#include <kdebug.h> //kdBacktrace()
|
||||
#include <kdeversion.h>
|
||||
#include <klocale.h>
|
||||
#include <ktempfile.h>
|
||||
#include <qregexp.h>
|
||||
#include <qglobal.h> //qVersion()
|
||||
#include <sys/types.h> //pid_t
|
||||
#include <sys/wait.h> //waitpid
|
||||
#include <unistd.h> //write, getpid
|
||||
|
||||
|
||||
static QString
|
||||
run_command( const QCString &command )
|
||||
{
|
||||
static const uint SIZE = 40960; //40 KiB
|
||||
static char buf[ SIZE ] = { 0 };
|
||||
|
||||
std::cout << "Running: " << command << std::endl;
|
||||
|
||||
FILE *process = ::popen( command, "r" );
|
||||
if (process) {
|
||||
int const n = std::fread( (void*)buf, sizeof(char), SIZE-1, process );
|
||||
buf[ n ] = '\0';
|
||||
::pclose( process );
|
||||
}
|
||||
|
||||
return QString::fromLocal8Bit( buf );
|
||||
}
|
||||
|
||||
void
|
||||
mxcl::crashHandler( int /*signal*/ )
|
||||
{
|
||||
// we need to fork to be able to get a semi-decent bt - I dunno why
|
||||
pid_t const pid = ::fork();
|
||||
|
||||
if (pid < 0) {
|
||||
std::cout << "Filelight has crashed...\n" << "fork() failed\n";
|
||||
_exit( 1 );
|
||||
}
|
||||
else if (pid != 0) {
|
||||
// we are the process that crashed
|
||||
::alarm( 0 );
|
||||
::waitpid( pid, NULL, 0 ); // wait for child to exit
|
||||
::_exit( 253 );
|
||||
}
|
||||
else {
|
||||
// we are the child process - the result of the fork()
|
||||
|
||||
std::cout << "Filelight has crashed...\n";
|
||||
|
||||
//TODO -fomit-frame-pointer buggers up the backtrace, so detect it
|
||||
//TODO -O optimization can rearrange execution and stuff so show a warning for the developer
|
||||
//TODO pass the CXXFLAGS used with the email
|
||||
|
||||
QString subject = APP_VERSION " ";
|
||||
|
||||
/// obtain the backtrace with gdb
|
||||
|
||||
KTempFile temp;
|
||||
temp.setAutoDelete( true );
|
||||
|
||||
QCString const gdb_command =
|
||||
"bt\n"
|
||||
"echo\\n\\n\n"
|
||||
"echo ==== (gdb) bt full ================\n"
|
||||
"bt full\n"
|
||||
"echo\\n\\n\n"
|
||||
"echo ==== (gdb) thread apply all bt ====\n"
|
||||
"thread apply all bt\n";
|
||||
|
||||
int const handle = temp.handle();
|
||||
|
||||
::write( handle, gdb_command, gdb_command.length() );
|
||||
::fsync( handle );
|
||||
|
||||
// so we can read stderr too
|
||||
::dup2( fileno( stdout ), fileno( stderr ) );
|
||||
|
||||
QCString gdb;
|
||||
gdb = "gdb --nw -n --batch -x ";
|
||||
gdb += temp.name().latin1();
|
||||
gdb += " filelight ";
|
||||
gdb += QCString().setNum( ::getppid() );
|
||||
|
||||
QString bt = run_command( gdb );
|
||||
|
||||
/// clean up
|
||||
bt.remove( "(no debugging symbols found)..." );
|
||||
bt.remove( "(no debugging symbols found)\n" );
|
||||
//bt.replace( QRegExp("\n{2,}"), "\n" ); //clean up multiple \n characters
|
||||
bt.stripWhiteSpace();
|
||||
|
||||
/// analyze usefulness
|
||||
bool useful = true;
|
||||
|
||||
if (bt.isEmpty())
|
||||
useful = false;
|
||||
else {
|
||||
const int invalidFrames = bt.contains( QRegExp("\n#[0-9]+\\s+0x[0-9A-Fa-f]+ in \\?\\?") );
|
||||
const int validFrames = bt.contains( QRegExp("\n#[0-9]+\\s+0x[0-9A-Fa-f]+ in [^?]") );
|
||||
const int totalFrames = invalidFrames + validFrames;
|
||||
|
||||
if (totalFrames > 0) {
|
||||
double const validity = double(validFrames) / totalFrames;
|
||||
subject += QString("[validity: %1]").arg( validity, 0, 'f', 2 );
|
||||
if (validity <= 0.3)
|
||||
useful = false;
|
||||
}
|
||||
subject += QString("[frames: %1]").arg( totalFrames, 3 /*padding*/ );
|
||||
|
||||
if (bt.find( QRegExp(" at \\w*\\.cpp:\\d+\n") ) >= 0)
|
||||
subject += "[line numbers]";
|
||||
}
|
||||
|
||||
/// determine if stripped
|
||||
const QString file_out = run_command( "file `which filelight`" );
|
||||
|
||||
if (file_out.find( "not stripped", false ) == -1)
|
||||
subject += "[___stripped]"; //same length as below
|
||||
else
|
||||
subject += "[NOTstripped]";
|
||||
|
||||
std::cout << subject.latin1() << std::endl;
|
||||
|
||||
if (useful) {
|
||||
QString body = i18n(
|
||||
"Filelight has crashed! :(\n\n"
|
||||
|
||||
"But, all is not lost! Information about the crash is embedded in this "
|
||||
"mail, so just click send, and we'll do what we can to fix the crash.\n\n"
|
||||
|
||||
"Many thanks :)\n\n\n\n\n\n\n\n" ) +
|
||||
|
||||
"------------------------------------------------------------------------\n" + i18n(
|
||||
"The information below is to help the developers identify the problem, "
|
||||
"please do not modify it.\n\n" );
|
||||
|
||||
|
||||
|
||||
body += "==== Build Information ===========\n"
|
||||
"Version: " APP_VERSION "\n"
|
||||
"Build date: " __DATE__ "\n"
|
||||
"CC version: " __VERSION__ "\n" //assuming we're using GCC
|
||||
"KDElibs: " KDE_VERSION_STRING "\n"
|
||||
"Qt: " + QString(qVersion()) + '\n' +
|
||||
#ifdef NDEBUG
|
||||
"Debug: false"
|
||||
#else
|
||||
"Debug: true"
|
||||
#endif
|
||||
"\n\n\n";
|
||||
|
||||
body += "==== file `which filelight` =======\n";
|
||||
body += file_out + "\n\n";
|
||||
body += "==== (gdb) bt =====================\n";
|
||||
body += bt + "\n\n";
|
||||
body += "==== kdBacktrace() ================\n";
|
||||
body += kdBacktrace();
|
||||
|
||||
//TODO startup notification
|
||||
kapp->invokeMailer(
|
||||
/*to*/ "backtraces@methylblue.com",
|
||||
/*cc*/ QString(),
|
||||
/*bcc*/ QString(),
|
||||
/*subject*/ subject,
|
||||
/*body*/ body,
|
||||
/*messageFile*/ QString(),
|
||||
/*attachURLs*/ QStringList(),
|
||||
/*startup_id*/ "" );
|
||||
}
|
||||
|
||||
//_exit() exits immediately, otherwise this
|
||||
//function is called repeatedly ad finitum
|
||||
::_exit( 255 );
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright 2003-6 Max Howell <max.howell@methylblue.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 CRASH_H
|
||||
#define CRASH_H
|
||||
|
||||
#include <kcrash.h> //for main.cpp
|
||||
|
||||
|
||||
/**
|
||||
* @author Max Howell
|
||||
* @short The Amarok crash-handler
|
||||
*
|
||||
* I'm not entirely sure why this had to be inside a class, but it
|
||||
* wouldn't work otherwise *shrug*
|
||||
*/
|
||||
struct mxcl
|
||||
{
|
||||
static void crashHandler( int signal );
|
||||
|
||||
private:
|
||||
mxcl();
|
||||
mxcl( mxcl& );
|
||||
mxcl &operator=( mxcl& );
|
||||
bool operator==( mxcl& );
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,95 +1,109 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "historyAction.h"
|
||||
|
||||
#include <kaccel.h>
|
||||
#include <kconfig.h>
|
||||
#include <klocale.h>
|
||||
#include <KAction>
|
||||
#include <KConfig>
|
||||
#include <KLocale>
|
||||
#include <KActionCollection>
|
||||
#include <KStandardShortcut>
|
||||
#include <KConfigGroup>
|
||||
|
||||
|
||||
inline
|
||||
HistoryAction::HistoryAction( const QString &text, const char *icon, const KShortcut &cut, KActionCollection *ac, const char *name )
|
||||
: KAction( text, icon, cut, 0, 0, ac, name )
|
||||
, m_text( text )
|
||||
inline HistoryAction::HistoryAction(const QString &text, KActionCollection *ac)
|
||||
: KAction(text, ac)
|
||||
, m_text(text)
|
||||
{
|
||||
// ui files make this false, but we can't rely on UI file as it isn't compiled in :(
|
||||
KAction::setEnabled( false );
|
||||
// .ui files make this false, but we can't rely on UI file as it isn't compiled in :(
|
||||
KAction::setEnabled(false);
|
||||
}
|
||||
|
||||
void
|
||||
HistoryAction::push( const QString &path )
|
||||
void HistoryAction::push(const QString &path)
|
||||
{
|
||||
if( !path.isEmpty() && m_list.last() != path )
|
||||
if (!path.isEmpty() && !m_list.isEmpty() && m_list.last() != path)
|
||||
{
|
||||
m_list.append( path );
|
||||
setActionMenuTextOnly( this, path );
|
||||
KAction::setEnabled( true );
|
||||
m_list.append(path);
|
||||
setActionMenuTextOnly(this, path);
|
||||
KAction::setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
HistoryAction::pop()
|
||||
QString HistoryAction::pop()
|
||||
{
|
||||
const QString s = m_list.last();
|
||||
m_list.pop_back();
|
||||
setActionMenuTextOnly( this, m_list.last() );
|
||||
setActionMenuTextOnly(this, m_list.last());
|
||||
setEnabled();
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HistoryCollection::HistoryCollection( KActionCollection *ac, QObject *parent, const char *name )
|
||||
: QObject( parent, name )
|
||||
, m_b( new HistoryAction( i18n( "Back" ), "back", KStdAccel::back(), ac, "go_back" ) )
|
||||
, m_f( new HistoryAction( i18n( "Forward" ), "forward", KStdAccel::forward(), ac, "go_forward" ) )
|
||||
, m_receiver( 0 )
|
||||
HistoryCollection::HistoryCollection(KActionCollection *ac, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_b(new HistoryAction(i18n("Back"), ac))
|
||||
, m_f(new HistoryAction(i18n("Forward"), ac))
|
||||
, m_receiver(0)
|
||||
{
|
||||
connect( m_b, SIGNAL(activated()), SLOT(pop()) );
|
||||
connect( m_f, SIGNAL(activated()), SLOT(pop()) );
|
||||
connect(m_b, SIGNAL(activated()), SLOT(pop()));
|
||||
connect(m_f, SIGNAL(activated()), SLOT(pop()));
|
||||
}
|
||||
|
||||
void
|
||||
HistoryCollection::push( const KURL &url ) //slot
|
||||
void HistoryCollection::push(const KUrl &url) //slot
|
||||
{
|
||||
if( !url.isEmpty() )
|
||||
if (!url.isEmpty())
|
||||
{
|
||||
if( !m_receiver )
|
||||
if (!m_receiver)
|
||||
{
|
||||
m_f->clear();
|
||||
m_receiver = m_b;
|
||||
}
|
||||
|
||||
m_receiver->push( url.path( 1 ) );
|
||||
m_receiver->push(url.path(KUrl::AddTrailingSlash));
|
||||
}
|
||||
m_receiver = 0;
|
||||
}
|
||||
|
||||
void
|
||||
HistoryCollection::pop() //slot
|
||||
void HistoryCollection::pop() //slot
|
||||
{
|
||||
KURL url;
|
||||
KUrl url;
|
||||
const QString path = ((HistoryAction*)sender())->pop(); //FIXME here we remove the constness
|
||||
url.setPath( path );
|
||||
url.setPath(path);
|
||||
|
||||
m_receiver = (sender() == m_b) ? m_f : m_b;
|
||||
|
||||
emit activated( url );
|
||||
emit activated(url);
|
||||
}
|
||||
|
||||
void
|
||||
HistoryCollection::save( KConfig *config )
|
||||
void HistoryCollection::save(KConfigGroup &configgroup)
|
||||
{
|
||||
config->writePathEntry( "backHistory", m_b->m_list );
|
||||
config->writePathEntry( "forwardHistory", m_f->m_list );
|
||||
configgroup.writePathEntry("backHistory", m_b->m_list);
|
||||
configgroup.writePathEntry("forwardHistory", m_f->m_list);
|
||||
}
|
||||
|
||||
void
|
||||
HistoryCollection::restore( KConfig *config )
|
||||
void HistoryCollection::restore(const KConfigGroup &configgroup)
|
||||
{
|
||||
m_b->m_list = config->readPathListEntry( "backHistory" );
|
||||
m_f->m_list = config->readPathListEntry( "forwardHistory" );
|
||||
m_b->m_list = configgroup.readPathEntry("backHistory", QStringList());
|
||||
m_f->m_list = configgroup.readPathEntry("forwardHistory", QStringList());
|
||||
//TODO texts are not updated - no matter
|
||||
}
|
||||
|
||||
|
|
|
@ -1,35 +1,59 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef HISTORY_ACTION_H
|
||||
#define HISTORY_ACTION_H
|
||||
#ifndef HISTORYACTION_H
|
||||
#define HISTORYACTION_H
|
||||
|
||||
#include <kaction.h>
|
||||
#include <kurl.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
class KConfig;
|
||||
class KConfigGroup;
|
||||
class KActionCollection;
|
||||
|
||||
|
||||
/// defined in mainWindow.cpp
|
||||
void setActionMenuTextOnly( KAction *a, QString const &suffix );
|
||||
void setActionMenuTextOnly(KAction *a, QString const &suffix);
|
||||
|
||||
|
||||
class HistoryAction : KAction
|
||||
{
|
||||
HistoryAction( const QString &text, const char *icon, const KShortcut &cut, KActionCollection *ac, const char *name );
|
||||
HistoryAction(const QString &text, KActionCollection *ac);
|
||||
|
||||
friend class HistoryCollection;
|
||||
|
||||
public:
|
||||
virtual void setEnabled( bool b = true ) { KAction::setEnabled( b ? !m_list.isEmpty() : false ); }
|
||||
virtual void setEnabled(bool b = true) {
|
||||
KAction::setEnabled(b ? !m_list.isEmpty() : false);
|
||||
}
|
||||
|
||||
void clear() { m_list.clear(); KAction::setText( m_text ); }
|
||||
void clear() {
|
||||
m_list.clear();
|
||||
KAction::setText(m_text);
|
||||
}
|
||||
|
||||
private:
|
||||
void setText();
|
||||
|
||||
void push( const QString &path );
|
||||
void push(const QString &path);
|
||||
QString pop();
|
||||
|
||||
const QString m_text;
|
||||
|
@ -39,20 +63,22 @@ private:
|
|||
|
||||
class HistoryCollection : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HistoryCollection( KActionCollection *ac, QObject *parent, const char *name );
|
||||
HistoryCollection(KActionCollection *ac, QObject *parent);
|
||||
|
||||
void save( KConfig *config );
|
||||
void restore( KConfig *config );
|
||||
void save(KConfigGroup &configgroup);
|
||||
void restore(const KConfigGroup &configgroup);
|
||||
|
||||
public slots:
|
||||
void push( const KURL& );
|
||||
void stop() { m_receiver = 0; }
|
||||
void push(const KUrl&);
|
||||
void stop() {
|
||||
m_receiver = 0;
|
||||
}
|
||||
|
||||
signals:
|
||||
void activated( const KURL& );
|
||||
void activated(const KUrl&);
|
||||
|
||||
private slots:
|
||||
void pop();
|
||||
|
|
|
@ -1,59 +1,75 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "crashHandler.h"
|
||||
#include "define.h"
|
||||
#include "mainWindow.h"
|
||||
|
||||
#include <kaboutdata.h>
|
||||
#include <kapplication.h>
|
||||
#include <kcmdlineargs.h>
|
||||
#include <klocale.h>
|
||||
#include <kurl.h>
|
||||
#include "mainWindow.h"
|
||||
|
||||
|
||||
static const KCmdLineOptions options[] =
|
||||
{
|
||||
{ "+[path]", I18N_NOOP( "Scan 'path'" ), 0 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static KAboutData about(
|
||||
APP_NAME, I18N_NOOP( APP_PRETTYNAME ), APP_VERSION,
|
||||
I18N_NOOP("Graphical disk-usage information"), KAboutData::License_GPL_V2,
|
||||
I18N_NOOP("(C) 2006 Max Howell"), 0,
|
||||
"http://www.methylblue.com/filelight/", "filelight@methylblue.com" );
|
||||
APP_NAME,
|
||||
0,
|
||||
ki18n(APP_PRETTYNAME),
|
||||
APP_VERSION,
|
||||
ki18n("Graphical disk-usage information"),
|
||||
KAboutData::License_GPL_V2,
|
||||
ki18n("(C) 2006 Max Howell\n(C) 2008 Martin Sandsmark"),
|
||||
ki18n("You like it, you buy it!"),
|
||||
"http://www.methylblue.com/filelight/");
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
using Filelight::MainWindow;
|
||||
|
||||
about.addAuthor( "Max Howell", I18N_NOOP("Author, maintainer"), "max.howell@methylblue.com", "http://www.methylblue.com/" );
|
||||
about.addAuthor( "Mike Diehl", I18N_NOOP("Documentation"), 0, 0 );
|
||||
about.addCredit( "Steffen Gerlach", I18N_NOOP("Inspiration"), 0, "http://www.steffengerlach.de/" );
|
||||
about.addCredit( "André Somers", I18N_NOOP("Internationalization") );
|
||||
about.addCredit( "Stephanie James", I18N_NOOP("Testing") );
|
||||
about.addCredit( "Marcus Camen", I18N_NOOP("Bravery in the face of unreadable code") );
|
||||
about.addAuthor(ki18n("Martin Sandsmark"), ki18n("Maintainer"), "sandsmark@iskrembilen.com", "http://iskrembilen.com/");
|
||||
about.addAuthor(ki18n("Max Howell"), ki18n("Original author"), "max.howell@methylblue.com", "http://www.methylblue.com/");
|
||||
about.addAuthor(ki18n("Mike Diehl"), ki18n("Documentation"), 0, 0);
|
||||
about.addCredit(ki18n("Steffen Gerlach"), ki18n("Inspiration"), 0, "http://www.steffengerlach.de/");
|
||||
about.addCredit(ki18n("André Somers"), ki18n("Internationalization"));
|
||||
about.addCredit(ki18n("Stephanie James"), ki18n("Testing"));
|
||||
about.addCredit(ki18n("Marcus Camen"), ki18n("Bravery in the face of unreadable code"));
|
||||
|
||||
KCmdLineArgs::init( argc, argv, &about );
|
||||
KCmdLineArgs::addCmdLineOptions( options );
|
||||
KCmdLineArgs::init(argc, argv, &about);
|
||||
|
||||
KCmdLineOptions options;
|
||||
options.add("+[path]", ki18n("Scan 'path'"));
|
||||
KCmdLineArgs::addCmdLineOptions(options);
|
||||
|
||||
KApplication app;
|
||||
|
||||
KCrash::setCrashHandler( mxcl::crashHandler );
|
||||
|
||||
if (!app.isRestored()) {
|
||||
if (!app.isSessionRestored()) {
|
||||
MainWindow *mw = new MainWindow();
|
||||
app.setMainWidget( mw );
|
||||
|
||||
KCmdLineArgs* const args = KCmdLineArgs::parsedArgs();
|
||||
if (args->count() > 0 ) mw->scan( args->url( 0 ));
|
||||
if (args->count() > 0) mw->scan(args->url(0));
|
||||
args->clear();
|
||||
|
||||
mw->show();
|
||||
}
|
||||
else
|
||||
RESTORE( MainWindow );
|
||||
else RESTORE(MainWindow);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -1,236 +1,288 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "historyAction.h"
|
||||
#include "mainWindow.h"
|
||||
#include "part/part.h"
|
||||
#include "historyAction.h"
|
||||
|
||||
#include <cstdlib> //std::exit()
|
||||
#include <kaccel.h> //KStdAccel namespace
|
||||
#include <kaction.h>
|
||||
#include <kapplication.h> //setupActions()
|
||||
#include <kcombobox.h> //locationbar
|
||||
#include <kconfig.h>
|
||||
#include <kdirselectdialog.h> //slotScanDirectory
|
||||
#include <kedittoolbar.h> //for editToolbar dialog
|
||||
#include <kkeydialog.h>
|
||||
#include <klibloader.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kshell.h>
|
||||
#include <kstatusbar.h>
|
||||
#include <ktoolbar.h>
|
||||
#include <kurl.h>
|
||||
#include <kurlcompletion.h> //locationbar
|
||||
#include <qobjectlist.h>
|
||||
#include <qpopupmenu.h>
|
||||
#include <qtooltip.h>
|
||||
|
||||
|
||||
#include <KApplication> //setupActions()
|
||||
#include <KComboBox> //locationbar
|
||||
#include <KHistoryComboBox>
|
||||
#include <KRecentFilesAction>
|
||||
#include <KConfig>
|
||||
#include <KDirSelectDialog> //slotScanDirectory
|
||||
#include <KEditToolBar> //for editToolbar dialog
|
||||
#include <QLineEdit>
|
||||
#include <KStandardShortcut>
|
||||
#include <KFileDialog>
|
||||
#include <KLibLoader>
|
||||
#include <KLocale>
|
||||
#include <KMessageBox>
|
||||
#include <KShell>
|
||||
#include <KStatusBar>
|
||||
#include <KToolBar>
|
||||
#include <KUrl>
|
||||
#include <KUrlCompletion> //locationbar
|
||||
#include <QObject>
|
||||
#include <QToolTip>
|
||||
#include <KGlobal>
|
||||
#include <KConfigGroup>
|
||||
#include <KShortcutsDialog>
|
||||
#include <KSharedConfig>
|
||||
#include <KStandardAction>
|
||||
#include <KActionCollection>
|
||||
|
||||
namespace Filelight {
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: KParts::MainWindow()
|
||||
, m_part( 0 )
|
||||
MainWindow::MainWindow() : KParts::MainWindow(), m_part(0)
|
||||
{
|
||||
KLibFactory *factory = KLibLoader::self()->factory( "libfilelight" );
|
||||
setXMLFile("filelightui.rc");
|
||||
KPluginFactory *factory = KPluginLoader("filelightpart").factory();
|
||||
|
||||
if (!factory) {
|
||||
KMessageBox::error( this, i18n("KDE could not find the Filelight Part, or the Filelight Part could not be started. Did you make install?") );
|
||||
//exit() seems to not exist inside the std namespace for some users!
|
||||
using namespace std;
|
||||
exit( 1 ); //don't use QApplication::exit() - it causes a crash
|
||||
KMessageBox::error(this, i18n("Unable to load the Filelight Part.\nPlease make sure Filelight was correctly installed."));
|
||||
std::exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
m_part = (Part *)factory->create( this, "part", "KParts::ReadOnlyPart" );
|
||||
m_part = static_cast<Part *>(factory->create<KParts::ReadOnlyPart>(this));
|
||||
|
||||
setCentralWidget( m_part->widget() );
|
||||
setStandardToolBarMenuEnabled( true );
|
||||
setupActions();
|
||||
createGUI( m_part );
|
||||
if (m_part) {
|
||||
setStandardToolBarMenuEnabled(true);
|
||||
setupActions();
|
||||
createGUI(m_part);
|
||||
setCentralWidget(m_part->widget());
|
||||
|
||||
stateChanged( "scan_failed" ); //bah! doesn't affect the parts' actions, should I add them to the actionCollection here?
|
||||
stateChanged("scan_failed"); //bah! doesn't affect the parts' actions, should I add them to the actionCollection here?
|
||||
|
||||
QObjectList *buttons = toolBar()->queryList( "KToolBarButton" );
|
||||
if (buttons->isEmpty())
|
||||
KMessageBox::error( this, i18n(
|
||||
"Filelight doesn't seem to be installed properly, "
|
||||
"consequently its menus and toolbars will appear reduced or even empty") );
|
||||
delete buttons;
|
||||
//QList<QObject *> buttons = toolBar()->findChildren<QObject *>("KToolBarButton"); //FIXME
|
||||
//if (buttons.isEmpty())
|
||||
// KMessageBox::error(this, i18n("Filelight is not installed properly, consequently its menus and toolbars will appear reduced or even empty"));
|
||||
//delete &buttons;
|
||||
|
||||
connect( m_part, SIGNAL(started( KIO::Job* )), SLOT(scanStarted()) );
|
||||
connect( m_part, SIGNAL(completed()), SLOT(scanCompleted()) );
|
||||
connect( m_part, SIGNAL(canceled( const QString& )), SLOT(scanFailed()) );
|
||||
connect(m_part, SIGNAL(started(KIO::Job*)), SLOT(scanStarted()));
|
||||
connect(m_part, SIGNAL(completed()), SLOT(scanCompleted()));
|
||||
connect(m_part, SIGNAL(canceled(const QString&)), SLOT(scanFailed()));
|
||||
|
||||
//TODO test these
|
||||
connect( m_part, SIGNAL(canceled( const QString& )), m_histories, SLOT(stop()) );
|
||||
connect( BrowserExtension::childObject( m_part ), SIGNAL(openURLNotify()), SLOT(urlAboutToChange()) );
|
||||
//TODO test these
|
||||
connect(m_part, SIGNAL(canceled(const QString&)), m_histories, SLOT(stop()));
|
||||
connect(BrowserExtension::childObject(m_part), SIGNAL(openURLNotify()), SLOT(urlAboutToChange()));
|
||||
|
||||
KConfig* const config = KGlobal::config();
|
||||
config->setGroup( "general" );
|
||||
m_combo->setHistoryItems( config->readPathListEntry( "comboHistory" ) );
|
||||
applyMainWindowSettings( config, "window" );
|
||||
const KConfigGroup config = KGlobal::config()->group("general");
|
||||
m_combo->setHistoryItems(config.readPathEntry("comboHistory", QStringList()));
|
||||
applyMainWindowSettings(config, "window");
|
||||
} else {
|
||||
KMessageBox::error(this, i18n("Unable to create part widget."));
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
MainWindow::setupActions() //singleton function
|
||||
inline void MainWindow::setupActions() //singleton function
|
||||
{
|
||||
KActionCollection *const ac = actionCollection();
|
||||
|
||||
m_combo = new KHistoryCombo( this, "history_combo" );
|
||||
m_combo->setCompletionObject( new KURLCompletion( KURLCompletion::DirCompletion ) );
|
||||
m_combo->setAutoDeleteCompletionObject( true );
|
||||
m_combo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
|
||||
m_combo->setDuplicatesEnabled( false );
|
||||
m_combo = new KHistoryComboBox(this);
|
||||
m_combo->setCompletionObject(new KUrlCompletion(KUrlCompletion::DirCompletion));
|
||||
m_combo->setAutoDeleteCompletionObject(true);
|
||||
m_combo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
m_combo->setDuplicatesEnabled(false);
|
||||
|
||||
KStdAction::open( this, SLOT(slotScanDirectory()), ac, "scan_directory" );
|
||||
KStdAction::quit( this, SLOT(close()), ac );
|
||||
KStdAction::up( this, SLOT(slotUp()), ac );
|
||||
KStdAction::configureToolbars(this, SLOT(configToolbars()), ac);
|
||||
KStdAction::keyBindings(this, SLOT(configKeys()), ac);
|
||||
KStandardAction::open(this, SLOT(slotScanDirectory()), ac);
|
||||
KStandardAction::quit(this, SLOT(close()), ac);
|
||||
KStandardAction::up(this, SLOT(slotUp()), ac);
|
||||
KStandardAction::configureToolbars(this, SLOT(configToolbars()), ac);
|
||||
KStandardAction::keyBindings(this, SLOT(configKeys()), ac);
|
||||
|
||||
new KAction( i18n( "Scan &Home Directory" ), "folder_home", CTRL+Key_Home, this, SLOT(slotScanHomeDirectory()), ac, "scan_home" );
|
||||
new KAction( i18n( "Scan &Root Directory" ), "folder_red", 0, this, SLOT(slotScanRootDirectory()), ac, "scan_root" );
|
||||
new KAction( i18n( "Rescan" ), "reload", KStdAccel::reload(), m_part, SLOT(rescan()), ac, "scan_rescan" );
|
||||
new KAction( i18n( "Stop" ), "stop", Qt::Key_Escape, this, SLOT(slotAbortScan()), ac, "scan_stop" );
|
||||
new KAction( i18n( "Clear Location Bar" ), KApplication::reverseLayout() ? "clear_left" : "locationbar_erase", 0, m_combo, SLOT(clearEdit()), ac, "clear_location" );
|
||||
new KAction( i18n( "Go" ), "key_enter", 0, m_combo, SIGNAL(returnPressed()), ac, "go" );
|
||||
KAction* action;
|
||||
|
||||
KWidgetAction *combo = new KWidgetAction( m_combo, i18n( "Location Bar" ), 0, 0, 0, ac, "location_bar" );
|
||||
m_recentScans = new KRecentFilesAction( i18n( "&Recent Scans" ), 0, ac, "scan_recent", 8 );
|
||||
m_histories = new HistoryCollection( ac, this, "history_collection" );
|
||||
//KAction(KIcon("folder_home"), i18n("Scan &Home Directory"), this, SLOT(slotScanHomeDirectory()), ac, "scan_home")
|
||||
action = ac->addAction("scan_home", this, SLOT(slotScanHomeDirectory()));
|
||||
action->setText(i18n("Scan &Home Directory"));
|
||||
action->setIcon(KIcon("user-home"));
|
||||
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Home));
|
||||
|
||||
ac->action( "scan_directory" )->setText( i18n( "&Scan Directory..." ) );
|
||||
m_recentScans->loadEntries( KGlobal::config() );
|
||||
combo->setAutoSized( true ); //FIXME what does this do?
|
||||
//new KAction(i18n("Scan &Root Directory"), "folder_red", 0, this, SLOT(slotScanRootDirectory()), ac, "scan_root");
|
||||
action = ac->addAction("scan_root", this, SLOT(slotScanRootDirectory()));
|
||||
action->setText(i18n("Scan &Root Directory"));
|
||||
action->setIcon(KIcon("folder-red"));
|
||||
|
||||
connect( m_recentScans, SIGNAL(urlSelected( const KURL& )), SLOT(slotScanUrl( const KURL& )) );
|
||||
connect( m_combo, SIGNAL(returnPressed()), SLOT(slotComboScan()) );
|
||||
connect( m_histories, SIGNAL(activated( const KURL& )), SLOT(slotScanUrl( const KURL& )) );
|
||||
//new KAction(i18n("Rescan"), "reload", KStandardShortcut::reload(), m_part, SLOT(rescan()), ac, "scan_rescan");
|
||||
action = ac->addAction("scan_rescan", m_part, SLOT(rescan()));
|
||||
action->setText(i18n("Rescan"));
|
||||
action->setIcon(KIcon("view-refresh"));
|
||||
action->setShortcut(KStandardShortcut::reload());
|
||||
|
||||
|
||||
//new KAction(i18n("Stop"), "stop", Qt::Key_Escape, this, SLOT(slotAbortScan()), ac, "scan_stop");
|
||||
action = ac->addAction("scan_stop", this, SLOT(slotAbortScan()));
|
||||
action->setText(i18n("Stop"));
|
||||
action->setIcon(KIcon("process-stop"));
|
||||
action->setShortcut(Qt::Key_Escape);
|
||||
|
||||
//new KAction(i18n("Clear Location Bar"), KApplication::reverseLayout() ? "clear_left" : "locationbar_erase", 0, m_combo, SLOT(clearEdit()), ac, "clear_location");
|
||||
|
||||
//new KAction(i18n("Go"), "key_enter", 0, m_combo, SIGNAL(returnPressed()), ac, "go");
|
||||
action = ac->addAction("go", m_combo, SIGNAL(returnPressed()));
|
||||
action->setText(i18n("Go"));
|
||||
action->setIcon(KIcon("go-jump-locationbar"));
|
||||
|
||||
// K3WidgetAction *combo = new K3WidgetAction(m_combo, i18n("Location Bar"), 0, 0, 0, ac, "location_bar"); //TODO: Wtf was this good for?
|
||||
action = ac->addAction("location_bar", 0, 0);
|
||||
action->setText(i18n("Location Bar"));
|
||||
action->setDefaultWidget(m_combo);
|
||||
|
||||
action = ac->addAction("scan_directory", this, SLOT(slotScanDirectory()));
|
||||
action->setText(i18n("Scan Directory"));
|
||||
action->setIcon(KIcon("folder"));
|
||||
|
||||
//m_recentScans = new KRecentFilesAction(i18n("&Recent Scans"), 0, ac, "scan_recent", 8);
|
||||
m_recentScans = new KRecentFilesAction(i18n("&Recent Scans"), ac);
|
||||
m_recentScans->setMaxItems(8);
|
||||
|
||||
m_histories = new HistoryCollection(ac, this);
|
||||
|
||||
// ac->action("scan_directory")->setText(i18n("&Scan Directory...")); TODO: Uncomment this, and fix.
|
||||
m_recentScans->loadEntries(KGlobal::config()->group(""));
|
||||
//combo->setAutoSized(true); //FIXME what does this do?
|
||||
|
||||
connect(m_recentScans, SIGNAL(urlSelected(const KUrl&)), SLOT(slotScanUrl(const KUrl&)));
|
||||
connect(m_combo, SIGNAL(returnPressed()), SLOT(slotComboScan()));
|
||||
connect(m_histories, SIGNAL(activated(const KUrl&)), SLOT(slotScanUrl(const KUrl&)));
|
||||
}
|
||||
|
||||
bool
|
||||
MainWindow::queryExit()
|
||||
bool MainWindow::queryExit()
|
||||
{
|
||||
if( !m_part ) //apparently std::exit() still calls this function, and abort() causes a crash..
|
||||
return true;
|
||||
if (!m_part) //apparently std::exit() still calls this function, and abort() causes a crash..
|
||||
return true;
|
||||
|
||||
KConfig* const config = KGlobal::config();
|
||||
KConfigGroup config = KGlobal::config()->group("general");
|
||||
|
||||
saveMainWindowSettings( config, "window" );
|
||||
m_recentScans->saveEntries( config );
|
||||
config->setGroup( "general" );
|
||||
config->writePathEntry( "comboHistory", m_combo->historyItems() );
|
||||
config->sync();
|
||||
saveMainWindowSettings(KGlobal::config()->group("window"));
|
||||
m_recentScans->saveEntries(config);
|
||||
config.writePathEntry("comboHistory", m_combo->historyItems());
|
||||
config.sync();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void
|
||||
MainWindow::configToolbars() //slot
|
||||
inline void MainWindow::configToolbars() //slot
|
||||
{
|
||||
KEditToolbar dialog( factory(), this );
|
||||
dialog.showButtonApply( false );
|
||||
KEditToolBar dialog(factory(), this);
|
||||
// dialog.showButtonApply(false); //TODO: Is this still needed?
|
||||
|
||||
if( dialog.exec() )
|
||||
if (dialog.exec())
|
||||
{
|
||||
createGUI( m_part );
|
||||
applyMainWindowSettings( kapp->config(), "window" );
|
||||
createGUI(m_part);
|
||||
applyMainWindowSettings(KGlobal::config()->group("window"));
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
MainWindow::configKeys() //slot
|
||||
inline void MainWindow::configKeys() //slot
|
||||
{
|
||||
KKeyDialog::configure( actionCollection(), this );
|
||||
KShortcutsDialog::configure(actionCollection(), KShortcutsEditor::LetterShortcutsAllowed, this, true);
|
||||
}
|
||||
|
||||
inline void
|
||||
MainWindow::slotScanDirectory()
|
||||
inline void MainWindow::slotScanDirectory()
|
||||
{
|
||||
slotScanUrl( KDirSelectDialog::selectDirectory( m_part->url().path(), false, this ) );
|
||||
slotScanUrl(KFileDialog::getExistingDirectoryUrl(m_part->url(), this, QString("Select directory to scan...")));
|
||||
}
|
||||
|
||||
inline void MainWindow::slotScanHomeDirectory() { slotScanPath( getenv( "HOME" ) ); }
|
||||
inline void MainWindow::slotScanRootDirectory() { slotScanPath( "/" ); }
|
||||
inline void MainWindow::slotUp() { slotScanUrl( m_part->url().upURL() ); }
|
||||
|
||||
inline void
|
||||
MainWindow::slotComboScan()
|
||||
{
|
||||
const QString path = KShell::tildeExpand(m_combo->lineEdit()->text());
|
||||
if (slotScanPath( path ))
|
||||
m_combo->addToHistory( path );
|
||||
inline void MainWindow::slotScanHomeDirectory() {
|
||||
slotScanPath(getenv("HOME"));
|
||||
}
|
||||
inline void MainWindow::slotScanRootDirectory() {
|
||||
slotScanPath("/");
|
||||
}
|
||||
inline void MainWindow::slotUp() {
|
||||
slotScanUrl(m_part->url().upUrl());
|
||||
}
|
||||
|
||||
inline bool
|
||||
MainWindow::slotScanPath( const QString &path )
|
||||
inline void MainWindow::slotComboScan()
|
||||
{
|
||||
return slotScanUrl( KURL::fromPathOrURL( path ) );
|
||||
const QString path = KShell::tildeExpand(m_combo->lineEdit()->text());
|
||||
if (slotScanPath(path))
|
||||
m_combo->addToHistory(path);
|
||||
}
|
||||
|
||||
bool
|
||||
MainWindow::slotScanUrl( const KURL &url )
|
||||
inline bool MainWindow::slotScanPath(const QString &path)
|
||||
{
|
||||
const KURL oldUrl = m_part->url();
|
||||
const bool b = m_part->openURL( url );
|
||||
|
||||
if (b) {
|
||||
m_histories->push( oldUrl );
|
||||
action( "go_back" )->KAction::setEnabled( false ); } //FIXME
|
||||
|
||||
return b;
|
||||
return slotScanUrl(KUrl::KUrl(path));
|
||||
}
|
||||
|
||||
inline void
|
||||
MainWindow::slotAbortScan()
|
||||
bool MainWindow::slotScanUrl(const KUrl &url)
|
||||
{
|
||||
if( m_part->closeURL() ) action( "scan_stop" )->setEnabled( false );
|
||||
const KUrl oldUrl = m_part->url();
|
||||
const bool b = m_part->openURL(url);
|
||||
|
||||
if (b) {
|
||||
m_histories->push(oldUrl);
|
||||
//action("go_back")->setEnabled(false); //FIXME
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
inline void
|
||||
MainWindow::scanStarted()
|
||||
inline void MainWindow::slotAbortScan()
|
||||
{
|
||||
stateChanged( "scan_started" );
|
||||
if (m_part->closeURL()) action("scan_stop")->setEnabled(false);
|
||||
}
|
||||
|
||||
inline void MainWindow::scanStarted()
|
||||
{
|
||||
stateChanged("scan_started");
|
||||
m_combo->clearFocus();
|
||||
}
|
||||
|
||||
inline void
|
||||
MainWindow::scanFailed()
|
||||
inline void MainWindow::scanFailed()
|
||||
{
|
||||
stateChanged( "scan_failed" );
|
||||
setActionMenuTextOnly( action( "go_up" ), QString::null );
|
||||
stateChanged("scan_failed");
|
||||
setActionMenuTextOnly(qobject_cast<KAction *>(action("go_up")), QString());
|
||||
m_combo->lineEdit()->clear();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::scanCompleted()
|
||||
void MainWindow::scanCompleted()
|
||||
{
|
||||
KAction *goUp = action( "go_up" );
|
||||
const KURL url = m_part->url();
|
||||
KAction *goUp = qobject_cast<KAction *>(action("go_up"));
|
||||
const KUrl url = m_part->url();
|
||||
|
||||
stateChanged( "scan_complete" );
|
||||
stateChanged("scan_complete");
|
||||
|
||||
m_combo->lineEdit()->setText( m_part->prettyURL() );
|
||||
m_combo->lineEdit()->setText(m_part->prettyUrl());
|
||||
|
||||
if ( url.path( 1 ) == "/") {
|
||||
goUp->setEnabled( false );
|
||||
setActionMenuTextOnly( goUp, QString() );
|
||||
if (url.path(KUrl::LeaveTrailingSlash) == "/") {
|
||||
goUp->setEnabled(false);
|
||||
setActionMenuTextOnly(goUp, QString());
|
||||
}
|
||||
else
|
||||
setActionMenuTextOnly( goUp, url.upURL().path( 1 ) );
|
||||
setActionMenuTextOnly(goUp, url.upUrl().path(KUrl::LeaveTrailingSlash));
|
||||
|
||||
m_recentScans->addURL( url ); //FIXME doesn't set the tick
|
||||
m_recentScans->addUrl(url); //FIXME doesn't set the tick
|
||||
}
|
||||
|
||||
inline void
|
||||
MainWindow::urlAboutToChange()
|
||||
inline void MainWindow::urlAboutToChange()
|
||||
{
|
||||
//called when part's URL is about to change internally
|
||||
//the part will then create the Map and emit completed()
|
||||
//called when part's URL is about to change internally
|
||||
//the part will then create the Map and emit completed()
|
||||
|
||||
m_histories->push( m_part->url() );
|
||||
m_histories->push(m_part->url());
|
||||
}
|
||||
|
||||
|
||||
|
@ -238,18 +290,16 @@ MainWindow::urlAboutToChange()
|
|||
SESSION MANAGEMENT
|
||||
**********************************************/
|
||||
|
||||
void
|
||||
MainWindow::saveProperties( KConfig *config ) //virtual
|
||||
void MainWindow::saveProperties(KConfigGroup &configgroup) //virtual
|
||||
{
|
||||
m_histories->save( config );
|
||||
config->writeEntry( "currentMap", m_part->url().path() );
|
||||
m_histories->save(configgroup);
|
||||
configgroup.writeEntry("currentMap", m_part->url().path());
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::readProperties( KConfig *config ) //virtual
|
||||
void MainWindow::readProperties(const KConfigGroup &configgroup) //virtual
|
||||
{
|
||||
m_histories->restore( config );
|
||||
slotScanPath( config->readEntry( "currentMap", QString::null ) );
|
||||
m_histories->restore(configgroup);
|
||||
slotScanPath(configgroup.group("General").readEntry("currentMap", QString()));
|
||||
}
|
||||
|
||||
} //namespace Filelight
|
||||
|
@ -258,23 +308,24 @@ MainWindow::readProperties( KConfig *config ) //virtual
|
|||
|
||||
/// declared in historyAction.h
|
||||
|
||||
void setActionMenuTextOnly( KAction *a, QString const &suffix )
|
||||
void setActionMenuTextOnly(KAction *a, QString const &suffix)
|
||||
{
|
||||
QString const menu_text = suffix.isEmpty()
|
||||
? a->text()
|
||||
: i18n( "&Up: /home/mxcl", "%1: %2" ).arg( a->text(), suffix );
|
||||
? a->text()
|
||||
: i18nc("&Up: /home/mxcl", "%1: %2").arg(a->text(), suffix);
|
||||
|
||||
for (int i = 0; i < a->containerCount(); ++i) {
|
||||
QWidget *w = a->container( i );
|
||||
int const id = a->itemId( i );
|
||||
for (int i = 0; i < a->associatedWidgets().count(); ++i) {
|
||||
QWidget *w = a->associatedWidgets().value(i);
|
||||
// int const id = a->itemId(i);
|
||||
|
||||
if (w->inherits( "QPopupMenu" ))
|
||||
static_cast<QPopupMenu*>(w)->changeItem( id, menu_text );
|
||||
/*if (w->inherits("QPopupMenu")) //FIXME: This was probably here for a reason!
|
||||
static_cast<Q3PopupMenu*>(w)->changeItem(id, menu_text);
|
||||
|
||||
else if (w->inherits( "KToolBar" )) {
|
||||
QWidget *button = static_cast<KToolBar*>(w)->getWidget( id );
|
||||
if (button->inherits( "KToolBarButton" ))
|
||||
QToolTip::add( button, suffix );
|
||||
else */
|
||||
if (w->inherits("KToolBar")) {
|
||||
QWidget *button = static_cast<KToolBar*>(w);
|
||||
if (button->inherits("KToolBarButton"))
|
||||
button->setToolTip(suffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,31 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef MAIN_WINDOW_H
|
||||
#define MAIN_WINDOW_H
|
||||
#ifndef FILELIGHT_H
|
||||
#define FILELIGHT_H
|
||||
|
||||
#include <kparts/mainwindow.h>
|
||||
|
||||
class KSqueezedTextLabel;
|
||||
class KHistoryCombo;
|
||||
class KHistoryComboBox;
|
||||
class KAction;
|
||||
class KRecentFilesAction;
|
||||
|
||||
|
@ -21,21 +39,23 @@ class Part;
|
|||
|
||||
class MainWindow : public KParts::MainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
void scan( const KURL &u ) { slotScanUrl( u ); }
|
||||
void scan(const KUrl &u) {
|
||||
slotScanUrl(u);
|
||||
}
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void slotUp();
|
||||
void slotComboScan();
|
||||
void slotScanDirectory();
|
||||
void slotScanHomeDirectory();
|
||||
void slotScanRootDirectory();
|
||||
bool slotScanUrl( const KURL& );
|
||||
bool slotScanPath( const QString& );
|
||||
bool slotScanUrl(const KUrl&);
|
||||
bool slotScanPath(const QString&);
|
||||
void slotAbortScan();
|
||||
|
||||
void configToolbars();
|
||||
|
@ -47,16 +67,16 @@ class MainWindow : public KParts::MainWindow
|
|||
|
||||
void urlAboutToChange();
|
||||
|
||||
protected:
|
||||
virtual void saveProperties( KConfig * );
|
||||
virtual void readProperties( KConfig * );
|
||||
protected:
|
||||
virtual void saveProperties(KConfigGroup&);
|
||||
virtual void readProperties(const KConfigGroup&);
|
||||
virtual bool queryExit();
|
||||
|
||||
private:
|
||||
private:
|
||||
Filelight::Part *m_part;
|
||||
|
||||
KSqueezedTextLabel *m_status[2];
|
||||
KHistoryCombo *m_combo;
|
||||
KHistoryComboBox *m_combo;
|
||||
HistoryCollection *m_histories;
|
||||
KRecentFilesAction *m_recentScans;
|
||||
|
||||
|
|
27
src/define.h
27
src/define.h
|
@ -1,17 +1,36 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#ifndef DEFINE_H
|
||||
#define DEFINE_H
|
||||
|
||||
#include "config.h"
|
||||
#include "part/Config.h"
|
||||
|
||||
#undef VERSION
|
||||
#undef PACKAGE
|
||||
#undef PRETTYNAME
|
||||
|
||||
#define APP_NAME "filelight"
|
||||
#define APP_VERSION "1.0.1"
|
||||
#define APP_VERSION "1.9"
|
||||
#define APP_PRETTYNAME "Filelight"
|
||||
|
||||
#endif
|
||||
|
|
49
src/part/CMakeLists.txt
Normal file
49
src/part/CMakeLists.txt
Normal file
|
@ -0,0 +1,49 @@
|
|||
#######################################################################
|
||||
# Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License or (at your option) version 3 or any later version
|
||||
# accepted by the membership of KDE e.V. (or its successor approved
|
||||
# by the membership of KDE e.V.), which shall act as a proxy
|
||||
# defined in Section 14 of version 3 of the license.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/filelight/src ${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
|
||||
|
||||
add_subdirectory(radialMap)
|
||||
|
||||
set(filelight_PART_SRCS
|
||||
part.cpp
|
||||
scan.cpp
|
||||
progressBox.cpp
|
||||
Config.cpp
|
||||
settingsDialog.cpp
|
||||
fileTree.cpp
|
||||
localLister.cpp
|
||||
remoteLister.cpp
|
||||
summaryWidget.cpp)
|
||||
|
||||
kde4_add_ui_files(filelight_PART_SRCS dialog.ui)
|
||||
|
||||
kde4_add_plugin(filelightpart ${filelight_PART_SRCS})
|
||||
|
||||
target_link_libraries(filelightpart radialmap
|
||||
${KDE4_KDECORE_LIBS}
|
||||
${KDE4_KPARTS_LIBS}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${KDE4_KDE3SUPPORT_LIBS}
|
||||
${KDE4_KIO_LIBS}
|
||||
${KDE4_KFILE_LIBS}
|
||||
qimageblitz)
|
||||
|
||||
install(TARGETS filelightpart DESTINATION ${PLUGIN_INSTALL_DIR})
|
|
@ -1,9 +1,32 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#include "Config.h"
|
||||
#include <kconfig.h>
|
||||
#include <kglobal.h>
|
||||
|
||||
#include <KConfig>
|
||||
#include <KConfigGroup>
|
||||
#include <KGlobal>
|
||||
#include <KSharedConfig>
|
||||
#include <KSharedPtr>
|
||||
|
||||
|
||||
bool Config::scanAcrossMounts;
|
||||
|
@ -18,30 +41,21 @@ uint Config::defaultRingDepth;
|
|||
Filelight::MapScheme Config::scheme;
|
||||
QStringList Config::skipList;
|
||||
|
||||
|
||||
inline KConfig&
|
||||
Filelight::Config::kconfig()
|
||||
{
|
||||
KConfig *config = KGlobal::config();
|
||||
config->setGroup( "filelight_part" );
|
||||
return *config;
|
||||
}
|
||||
|
||||
void
|
||||
Filelight::Config::read()
|
||||
{
|
||||
const KConfig &config = kconfig();
|
||||
const KConfigGroup config = KGlobal::config()->group("filelight_part");
|
||||
|
||||
scanAcrossMounts = config.readBoolEntry( "scanAcrossMounts", false );
|
||||
scanRemoteMounts = config.readBoolEntry( "scanRemoteMounts", false );
|
||||
scanRemovableMedia = config.readBoolEntry( "scanRemovableMedia", false );
|
||||
varyLabelFontSizes = config.readBoolEntry( "varyLabelFontSizes", true );
|
||||
showSmallFiles = config.readBoolEntry( "showSmallFiles", false );
|
||||
contrast = config.readNumEntry( "contrast", 75 );
|
||||
antiAliasFactor = config.readNumEntry( "antiAliasFactor", 2 );
|
||||
minFontPitch = config.readNumEntry( "minFontPitch", QFont().pointSize() - 3);
|
||||
scheme = (MapScheme) config.readNumEntry( "scheme", 0 );
|
||||
skipList = config.readPathListEntry( "skipList" );
|
||||
scanAcrossMounts = config.readEntry("scanAcrossMounts", false);
|
||||
scanRemoteMounts = config.readEntry("scanRemoteMounts", false);
|
||||
scanRemovableMedia = config.readEntry("scanRemovableMedia", false);
|
||||
varyLabelFontSizes = config.readEntry("varyLabelFontSizes", true);
|
||||
showSmallFiles = config.readEntry("showSmallFiles", false);
|
||||
contrast = config.readEntry("contrast", 75);
|
||||
antiAliasFactor = config.readEntry("antiAliasFactor", 2);
|
||||
minFontPitch = config.readEntry("minFontPitch", QFont().pointSize() - 3);
|
||||
scheme = (MapScheme) config.readEntry("scheme", 0);
|
||||
skipList = config.readEntry("skipList", QStringList());
|
||||
|
||||
defaultRingDepth = 4;
|
||||
}
|
||||
|
@ -49,16 +63,17 @@ Filelight::Config::read()
|
|||
void
|
||||
Filelight::Config::write()
|
||||
{
|
||||
KConfig &config = kconfig();
|
||||
KConfigGroup config = KGlobal::config()->group("filelight_part");
|
||||
|
||||
config.writeEntry( "scanAcrossMounts", scanAcrossMounts );
|
||||
config.writeEntry( "scanRemoteMounts", scanRemoteMounts );
|
||||
config.writeEntry( "scanRemovableMedia", scanRemovableMedia );
|
||||
config.writeEntry( "varyLabelFontSizes", varyLabelFontSizes );
|
||||
config.writeEntry( "showSmallFiles", showSmallFiles);
|
||||
config.writeEntry( "contrast", contrast );
|
||||
config.writeEntry( "antiAliasFactor", antiAliasFactor );
|
||||
config.writeEntry( "minFontPitch", minFontPitch );
|
||||
config.writeEntry( "scheme", scheme );
|
||||
config.writePathEntry( "skipList", skipList );
|
||||
config.writeEntry("scanAcrossMounts", scanAcrossMounts);
|
||||
config.writeEntry("scanRemoteMounts", scanRemoteMounts);
|
||||
config.writeEntry("scanRemovableMedia", scanRemovableMedia);
|
||||
config.writeEntry("varyLabelFontSizes", varyLabelFontSizes);
|
||||
config.writeEntry("showSmallFiles", showSmallFiles);
|
||||
config.writeEntry("contrast", contrast);
|
||||
config.writeEntry("antiAliasFactor", antiAliasFactor);
|
||||
config.writeEntry("minFontPitch", minFontPitch);
|
||||
config.writeEntry("scheme", (int)scheme); // TODO: make the enum belong to a qwidget,
|
||||
//and use magic macros to make it save this properly
|
||||
config.writePathEntry("skipList", skipList);
|
||||
}
|
||||
|
|
|
@ -1,41 +1,59 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef Config_H
|
||||
#define Config_H
|
||||
|
||||
#include <qstringlist.h>
|
||||
#include <QStringList>
|
||||
|
||||
class KConfig;
|
||||
|
||||
|
||||
namespace Filelight
|
||||
{
|
||||
enum MapScheme { Rainbow, HighContrast, KDE, FileDensity, ModTime };
|
||||
enum MapScheme { Rainbow, HighContrast, KDE, FileDensity, ModTime };
|
||||
|
||||
class Config
|
||||
{
|
||||
static KConfig& kconfig();
|
||||
class Config
|
||||
{
|
||||
static KConfig& kconfig();
|
||||
|
||||
public:
|
||||
static void read();
|
||||
static void write();
|
||||
public:
|
||||
static void read();
|
||||
static void write();
|
||||
|
||||
//keep everything positive, avoid using DON'T, NOT or NO
|
||||
//keep everything positive, avoid using DON'T, NOT or NO
|
||||
|
||||
static bool scanAcrossMounts;
|
||||
static bool scanRemoteMounts;
|
||||
static bool scanRemovableMedia;
|
||||
static bool varyLabelFontSizes;
|
||||
static bool showSmallFiles;
|
||||
static uint contrast;
|
||||
static uint antiAliasFactor;
|
||||
static uint minFontPitch;
|
||||
static uint defaultRingDepth;
|
||||
static bool scanAcrossMounts;
|
||||
static bool scanRemoteMounts;
|
||||
static bool scanRemovableMedia;
|
||||
static bool varyLabelFontSizes;
|
||||
static bool showSmallFiles;
|
||||
static uint contrast;
|
||||
static uint antiAliasFactor;
|
||||
static uint minFontPitch;
|
||||
static uint defaultRingDepth;
|
||||
|
||||
static MapScheme scheme;
|
||||
static QStringList skipList;
|
||||
};
|
||||
static MapScheme scheme;
|
||||
static QStringList skipList;
|
||||
};
|
||||
}
|
||||
|
||||
using Filelight::Config;
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
SUBDIRS = radialMap
|
||||
INCLUDES = $(all_includes) -I$(top_srcdir)/filelight/src
|
||||
METASOURCES = AUTO
|
||||
|
||||
#Part
|
||||
kde_module_LTLIBRARIES = libfilelight.la
|
||||
libfilelight_la_LIBADD = ./radialMap/libradialmap.la $(LIB_KFILE) $(LIB_KPARTS) $(LIB_KDEUI) $(LIB_QT)
|
||||
libfilelight_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
|
||||
libfilelight_la_SOURCES = \
|
||||
dialog.ui \
|
||||
part.cpp \
|
||||
scan.cpp \
|
||||
progressBox.cpp \
|
||||
Config.cpp \
|
||||
settingsDialog.cpp \
|
||||
fileTree.cpp \
|
||||
localLister.cpp \
|
||||
remoteLister.cpp \
|
||||
summaryWidget.cpp
|
179
src/part/debug.h
179
src/part/debug.h
|
@ -1,179 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
|
||||
** Copyright (C) 2006 Max Howell <max.howell@methylblue.com>
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** This file may be used under the terms of the GNU General Public
|
||||
** License version 2.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of
|
||||
** this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
** http://www.trolltech.com/products/qt/opensource.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** review the following information:
|
||||
** http://www.trolltech.com/products/qt/licensing.html or contact the
|
||||
** sales department at sales@trolltech.com.
|
||||
**
|
||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/// Quite a lot modified by Max Howell so it works with Qt3
|
||||
|
||||
|
||||
#ifndef QDEBUG_H
|
||||
#define QDEBUG_H
|
||||
|
||||
#include <qstringlist.h>
|
||||
|
||||
|
||||
struct ForEachHelper
|
||||
{
|
||||
QStringList::ConstIterator const end;
|
||||
QStringList::ConstIterator it;
|
||||
|
||||
bool m_break;
|
||||
|
||||
ForEachHelper( QStringList const &list )
|
||||
: end( list.end() )
|
||||
, it( list.begin() )
|
||||
, m_break( true )
|
||||
{}
|
||||
};
|
||||
|
||||
#define foreach( var, list ) \
|
||||
for (ForEachHelper h( list ); h.it != h.end; ++h.it, h.m_break = true) \
|
||||
for (var = *h.it; h.m_break; h.m_break = false)
|
||||
|
||||
|
||||
#ifdef QT_NO_DEBUG
|
||||
#define NDEBUG
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
#include <qcstring.h>
|
||||
#include <qtextstream.h>
|
||||
#include <kdebug.h>
|
||||
#include <kurl.h>
|
||||
|
||||
|
||||
class QDebug
|
||||
{
|
||||
friend class QDebugBlock;
|
||||
|
||||
static QString indent;
|
||||
|
||||
struct Stream {
|
||||
Stream(QtMsgType t) : ts(&buffer, IO_WriteOnly), ref(1), type(t), space(true){}
|
||||
QTextStream ts;
|
||||
QString buffer;
|
||||
int ref;
|
||||
QtMsgType type;
|
||||
bool space;
|
||||
} *stream;
|
||||
|
||||
public:
|
||||
inline QDebug( QtMsgType t ) : stream( new Stream( t ) ) {}
|
||||
inline QDebug( const QDebug &o ) : stream( o.stream ) { ++stream->ref; }
|
||||
inline ~QDebug()
|
||||
{
|
||||
if (!--stream->ref) {
|
||||
stream->ts << "\n";
|
||||
switch (stream->type) {
|
||||
default:
|
||||
case QtDebugMsg: kdDebug() << indent << stream->buffer; break;
|
||||
case QtWarningMsg: kdWarning() << indent << stream->buffer; break;
|
||||
}
|
||||
delete stream;
|
||||
}
|
||||
}
|
||||
|
||||
inline QDebug &space() { stream->space = true; stream->ts << " "; return *this; }
|
||||
inline QDebug &nospace() { stream->space = false; return *this; }
|
||||
inline QDebug &maybeSpace() { if (stream->space) stream->ts << " "; return *this; }
|
||||
|
||||
inline QDebug &operator<<(QChar t) { stream->ts << "\'" << t << "\'"; return maybeSpace(); }
|
||||
inline QDebug &operator<<(bool t) { stream->ts << (t ? "true" : "false"); return maybeSpace(); }
|
||||
inline QDebug &operator<<(char t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(signed short t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(unsigned short t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(signed int t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(unsigned int t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(signed long t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(unsigned long t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(float t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(double t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(const char* t) { stream->ts << t; return maybeSpace(); }
|
||||
inline QDebug &operator<<(const QString & t) { stream->ts << "\"" << t << "\""; return maybeSpace(); }
|
||||
|
||||
inline QDebug &operator<<(const QStringList &list)
|
||||
{
|
||||
stream->ts << "(";
|
||||
foreach (QString s, list)
|
||||
stream->ts << s << ", ";
|
||||
stream->ts << ")";
|
||||
return maybeSpace();
|
||||
}
|
||||
|
||||
//NOTE added by mxcl
|
||||
inline QDebug &operator<<(const KURL &url) { stream->ts << '"' << url.prettyURL() << '"'; return maybeSpace(); }
|
||||
inline QDebug &operator<<(const QCString &s) { stream->ts << '"' << s << '"'; return maybeSpace(); }
|
||||
};
|
||||
|
||||
inline QDebug qDebug() { return QDebug( QtDebugMsg ); }
|
||||
inline QDebug qWarning() { return QDebug( QtWarningMsg ); }
|
||||
inline QDebug qError() { return QDebug( QtWarningMsg ); }
|
||||
|
||||
class QDebugBlock
|
||||
{
|
||||
const char *m_title;
|
||||
|
||||
public:
|
||||
QDebugBlock( const char *title )
|
||||
: m_title( title )
|
||||
{
|
||||
qDebug() << "BEGIN:" << title;
|
||||
QDebug::indent += " ";
|
||||
}
|
||||
|
||||
~QDebugBlock()
|
||||
{
|
||||
QDebug::indent.truncate( QDebug::indent.length() - 2 );
|
||||
qDebug() << "END__:" << m_title;
|
||||
}
|
||||
};
|
||||
|
||||
#define Q_DEBUG_BLOCK QDebugBlock q_debug_block( __PRETTY_FUNCTION__ );
|
||||
|
||||
#else // NDEBUG
|
||||
|
||||
class QNoDebug
|
||||
{
|
||||
public:
|
||||
inline QNoDebug() {}
|
||||
inline QNoDebug( const QNoDebug& ) {}
|
||||
inline ~QNoDebug() {}
|
||||
|
||||
inline QNoDebug &space() { return *this; }
|
||||
inline QNoDebug &nospace() { return *this; }
|
||||
inline QNoDebug &maybeSpace() { return *this; }
|
||||
|
||||
template<typename T> inline QNoDebug &operator<<( const T& ) { return *this; }
|
||||
};
|
||||
|
||||
inline QNoDebug qDebug() { return QNoDebug(); }
|
||||
inline QNoDebug qWarning() { return QNoDebug(); }
|
||||
inline QNoDebug qError() { return QNoDebug(); }
|
||||
|
||||
#define Q_DEBUG_BLOCK
|
||||
|
||||
#endif
|
||||
|
||||
#define DEBUG_ANNOUNCE qDebug() << ">>" << __PRETTY_FUNCTION__;
|
||||
|
||||
#endif // QDEBUG_H
|
1096
src/part/dialog.ui
1096
src/part/dialog.ui
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,30 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "fileTree.h"
|
||||
#include <kglobal.h>
|
||||
#include <klocale.h>
|
||||
#include <qfile.h>
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KLocale>
|
||||
|
||||
#include <QFile>
|
||||
|
||||
|
||||
//static definitions
|
||||
|
@ -13,55 +33,55 @@ static const char PREFIX[4] = { 'K', 'M', 'G', 'T' };
|
|||
|
||||
|
||||
QString
|
||||
File::fullPath( const Directory *root /*= 0*/ ) const
|
||||
File::fullPath(const Directory *root /*= 0*/) const
|
||||
{
|
||||
QString path;
|
||||
QString path;
|
||||
|
||||
if( root == this )
|
||||
root = 0; //prevent returning empty string when there is something we could return
|
||||
if (root == this)
|
||||
root = 0; //prevent returning empty string when there is something we could return
|
||||
|
||||
for( const Directory *d = (Directory*)this; d != root && d; d = d->parent() )
|
||||
path.prepend( d->name() );
|
||||
for (const Directory *d = (Directory*)this; d != root && d; d = d->parent())
|
||||
path.prepend(d->name());
|
||||
|
||||
return path;
|
||||
return path;
|
||||
}
|
||||
|
||||
QString
|
||||
File::humanReadableSize( UnitPrefix key /*= mega*/ ) const //FIXME inline
|
||||
File::humanReadableSize(UnitPrefix key /*= mega*/) const //FIXME inline
|
||||
{
|
||||
return humanReadableSize( m_size, key );
|
||||
return humanReadableSize(m_size, key);
|
||||
}
|
||||
|
||||
QString
|
||||
File::humanReadableSize( uint size, UnitPrefix key /*= mega*/ ) //static
|
||||
File::humanReadableSize(uint size, UnitPrefix key /*= mega*/) //static
|
||||
{
|
||||
if( size == 0 )
|
||||
return "0 B";
|
||||
if (size == 0)
|
||||
return "0 B";
|
||||
|
||||
QString s;
|
||||
double prettySize = (double)size / (double)DENOMINATOR[key];
|
||||
const KLocale &locale = *KGlobal::locale();
|
||||
QString s;
|
||||
double prettySize = (double)size / (double)DENOMINATOR[key];
|
||||
const KLocale &locale = *KGlobal::locale();
|
||||
|
||||
if( prettySize >= 0.01 )
|
||||
{
|
||||
//use three significant figures
|
||||
if( prettySize < 1 ) s = locale.formatNumber( prettySize, 2 );
|
||||
else if( prettySize < 100 ) s = locale.formatNumber( prettySize, 1 );
|
||||
else s = locale.formatNumber( prettySize, 0 );
|
||||
if (prettySize >= 0.01)
|
||||
{
|
||||
//use three significant figures
|
||||
if (prettySize < 1) s = locale.formatNumber(prettySize, 2);
|
||||
else if (prettySize < 100) s = locale.formatNumber(prettySize, 1);
|
||||
else s = locale.formatNumber(prettySize, 0);
|
||||
|
||||
s += ' ';
|
||||
s += PREFIX[key];
|
||||
s += 'B';
|
||||
}
|
||||
s += ' ';
|
||||
s += PREFIX[key];
|
||||
s += 'B';
|
||||
}
|
||||
|
||||
if( prettySize < 0.1 )
|
||||
{
|
||||
s += " (";
|
||||
s += locale.formatNumber( size / DENOMINATOR[key - 1], 0 );
|
||||
s += ' ';
|
||||
s += PREFIX[key - 1];
|
||||
s += "B)";
|
||||
}
|
||||
if (prettySize < 0.1)
|
||||
{
|
||||
s += " (";
|
||||
s += locale.formatNumber(size / DENOMINATOR[key - 1], 0);
|
||||
s += ' ';
|
||||
s += PREFIX[key - 1];
|
||||
s += "B)";
|
||||
}
|
||||
|
||||
return s;
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,30 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef FILE_TREE_H
|
||||
#define FILE_TREE_H
|
||||
#ifndef FILETREE_H
|
||||
#define FILETREE_H
|
||||
|
||||
#include <Q3CString> //qstrdup
|
||||
#include <QFile> //decodeName()
|
||||
|
||||
#include <qcstring.h> //qstrdup
|
||||
#include <qfile.h> //decodeName()
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
@ -24,25 +43,32 @@ template <class T>
|
|||
class Link
|
||||
{
|
||||
public:
|
||||
Link( T* const t ) : prev( this ), next( this ), data( t ) {}
|
||||
Link() : prev( this ), next( this ), data( 0 ) {}
|
||||
Link(T* const t) : prev(this), next(this), data(t) {}
|
||||
Link() : prev(this), next(this), data(0) {}
|
||||
|
||||
//TODO unlinking is slow and you don't use it very much in this context.
|
||||
// ** Perhaps you can make a faster deletion system that doesn't bother tidying up first
|
||||
// ** and then you MUST call some kind of detach() function when you remove elements otherwise
|
||||
~Link() { delete data; unlink(); }
|
||||
~Link() {
|
||||
delete data;
|
||||
unlink();
|
||||
}
|
||||
|
||||
friend class Iterator<T>;
|
||||
friend class ConstIterator<T>;
|
||||
friend class Chain<T>;
|
||||
friend class Iterator<T>;
|
||||
friend class ConstIterator<T>;
|
||||
friend class Chain<T>;
|
||||
|
||||
private:
|
||||
void unlink() { prev->next = next; next->prev = prev; prev = next = this; }
|
||||
void unlink() {
|
||||
prev->next = next;
|
||||
next->prev = prev;
|
||||
prev = next = this;
|
||||
}
|
||||
|
||||
Link<T>* prev;
|
||||
Link<T>* next;
|
||||
Link<T>* prev;
|
||||
Link<T>* next;
|
||||
|
||||
T* data; //ensure only iterators have access to this
|
||||
T* data; //ensure only iterators have access to this
|
||||
};
|
||||
|
||||
|
||||
|
@ -50,40 +76,56 @@ template <class T>
|
|||
class Iterator
|
||||
{
|
||||
public:
|
||||
Iterator() : link( 0 ) { } //**** remove this, remove this REMOVE THIS!!! dangerous as your implementation doesn't test for null links, always assumes they can be derefenced
|
||||
Iterator( Link<T> *p ) : link( p ) { }
|
||||
Iterator() : link(0) { } //**** remove this, remove this REMOVE THIS!!! dangerous as your implementation doesn't test for null links, always assumes they can be derefenced
|
||||
Iterator(Link<T> *p) : link(p) { }
|
||||
|
||||
bool operator==( const Iterator<T>& it ) const { return link == it.link; }
|
||||
bool operator!=( const Iterator<T>& it ) const { return link != it.link; }
|
||||
bool operator!=( const Link<T> *p ) const { return p != link; }
|
||||
bool operator==(const Iterator<T>& it) const {
|
||||
return link == it.link;
|
||||
}
|
||||
bool operator!=(const Iterator<T>& it) const {
|
||||
return link != it.link;
|
||||
}
|
||||
bool operator!=(const Link<T> *p) const {
|
||||
return p != link;
|
||||
}
|
||||
|
||||
//here we have a choice, really I should make two classes one const the other not
|
||||
const T* operator*() const { return link->data; }
|
||||
T* operator*() { return link->data; }
|
||||
//here we have a choice, really I should make two classes one const the other not
|
||||
const T* operator*() const {
|
||||
return link->data;
|
||||
}
|
||||
T* operator*() {
|
||||
return link->data;
|
||||
}
|
||||
|
||||
Iterator<T>& operator++() { link = link->next; return *this; } //**** does it waste time returning in places where we don't use the retval?
|
||||
Iterator<T>& operator++() {
|
||||
link = link->next; //**** does it waste time returning in places where we don't use the retval?
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool isNull() const { return (link == 0); } //REMOVE WITH ABOVE REMOVAL you don't want null iterators to be possible
|
||||
bool isNull() const {
|
||||
return (link == 0); //REMOVE WITH ABOVE REMOVAL you don't want null iterators to be possible
|
||||
}
|
||||
|
||||
void transferTo( Chain<T> &chain )
|
||||
{
|
||||
chain.append( remove() );
|
||||
}
|
||||
void transferTo(Chain<T> &chain)
|
||||
{
|
||||
chain.append(remove());
|
||||
}
|
||||
|
||||
T* const remove() //remove from list, delete Link, data is returned NOT deleted
|
||||
{
|
||||
T* const d = link->data;
|
||||
Link<T>* const p = link->prev;
|
||||
T* remove() //remove from list, delete Link, data is returned NOT deleted
|
||||
|
||||
link->data = 0;
|
||||
delete link;
|
||||
link = p; //make iterator point to previous element, YOU must check this points to an element
|
||||
{
|
||||
T* const d = link->data;
|
||||
Link<T>* const p = link->prev;
|
||||
|
||||
return d;
|
||||
}
|
||||
link->data = 0;
|
||||
delete link;
|
||||
link = p; //make iterator point to previous element, YOU must check this points to an element
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
private:
|
||||
Link<T> *link;
|
||||
Link<T> *link;
|
||||
};
|
||||
|
||||
|
||||
|
@ -91,18 +133,29 @@ template <class T>
|
|||
class ConstIterator
|
||||
{
|
||||
public:
|
||||
ConstIterator( Link<T> *p ) : link( p ) { }
|
||||
ConstIterator(Link<T> *p) : link(p) { }
|
||||
|
||||
bool operator==( const Iterator<T>& it ) const { return link == it.link; }
|
||||
bool operator!=( const Iterator<T>& it ) const { return link != it.link; }
|
||||
bool operator!=( const Link<T> *p ) const { return p != link; }
|
||||
bool operator==(const Iterator<T>& it) const {
|
||||
return link == it.link;
|
||||
}
|
||||
bool operator!=(const Iterator<T>& it) const {
|
||||
return link != it.link;
|
||||
}
|
||||
bool operator!=(const Link<T> *p) const {
|
||||
return p != link;
|
||||
}
|
||||
|
||||
const T* operator*() const { return link->data; }
|
||||
const T* operator*() const {
|
||||
return link->data;
|
||||
}
|
||||
|
||||
ConstIterator<T>& operator++() { link = link->next; return *this; }
|
||||
ConstIterator<T>& operator++() {
|
||||
link = link->next;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
const Link<T> *link;
|
||||
const Link<T> *link;
|
||||
};
|
||||
|
||||
|
||||
|
@ -110,45 +163,59 @@ template <class T>
|
|||
class Chain
|
||||
{
|
||||
public:
|
||||
virtual ~Chain() { empty(); }
|
||||
virtual ~Chain() {
|
||||
empty();
|
||||
}
|
||||
|
||||
void append( T* const data )
|
||||
{
|
||||
Link<T>* const link = new Link<T>( data );
|
||||
void append(T* const data)
|
||||
{
|
||||
Link<T>* const link = new Link<T>(data);
|
||||
|
||||
link->prev = head.prev;
|
||||
link->next = &head;
|
||||
link->prev = head.prev;
|
||||
link->next = &head;
|
||||
|
||||
head.prev->next = link;
|
||||
head.prev = link;
|
||||
}
|
||||
head.prev->next = link;
|
||||
head.prev = link;
|
||||
}
|
||||
|
||||
void transferTo( Chain &c )
|
||||
{
|
||||
if( isEmpty() ) return;
|
||||
void transferTo(Chain &c)
|
||||
{
|
||||
if (isEmpty()) return;
|
||||
|
||||
Link<T>* const first = head.next;
|
||||
Link<T>* const last = head.prev;
|
||||
Link<T>* const first = head.next;
|
||||
Link<T>* const last = head.prev;
|
||||
|
||||
head.unlink();
|
||||
head.unlink();
|
||||
|
||||
first->prev = c.head.prev;
|
||||
c.head.prev->next = first;
|
||||
first->prev = c.head.prev;
|
||||
c.head.prev->next = first;
|
||||
|
||||
last->next = &c.head;
|
||||
c.head.prev = last;
|
||||
}
|
||||
last->next = &c.head;
|
||||
c.head.prev = last;
|
||||
}
|
||||
|
||||
void empty() { while( head.next != &head ) { delete head.next; } }
|
||||
void empty() {
|
||||
while (head.next != &head) {
|
||||
delete head.next;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<T> iterator() const { return Iterator<T>( head.next ); }
|
||||
ConstIterator<T> constIterator() const { return ConstIterator<T>( head.next ); }
|
||||
const Link<T> *end() const { return &head; }
|
||||
bool isEmpty() const { return head.next == &head; }
|
||||
Iterator<T> iterator() const {
|
||||
return Iterator<T>(head.next);
|
||||
}
|
||||
ConstIterator<T> constIterator() const {
|
||||
return ConstIterator<T>(head.next);
|
||||
}
|
||||
const Link<T> *end() const {
|
||||
return &head;
|
||||
}
|
||||
bool isEmpty() const {
|
||||
return head.next == &head;
|
||||
}
|
||||
|
||||
private:
|
||||
Link<T> head;
|
||||
void operator=( const Chain& );
|
||||
Link<T> head;
|
||||
void operator=(const Chain&);
|
||||
};
|
||||
|
||||
|
||||
|
@ -158,94 +225,98 @@ class QString;
|
|||
class File
|
||||
{
|
||||
public:
|
||||
friend class Directory;
|
||||
friend class Directory;
|
||||
|
||||
enum UnitPrefix { kilo, mega, giga, tera };
|
||||
enum UnitPrefix { kilo, mega, giga, tera };
|
||||
|
||||
static const uint DENOMINATOR[4];
|
||||
static const uint DENOMINATOR[4];
|
||||
|
||||
public:
|
||||
File( const char *name, FileSize size ) : m_parent( 0 ), m_name( qstrdup( name ) ), m_size( size ) {}
|
||||
virtual ~File() { delete [] m_name; }
|
||||
File(const char *name, FileSize size) : m_parent(0), m_name(qstrdup(name)), m_size(size) {}
|
||||
virtual ~File() {
|
||||
delete [] m_name;
|
||||
}
|
||||
|
||||
Directory *parent() const { return m_parent; }
|
||||
const char *name8Bit() const { return m_name; }
|
||||
const FileSize size() const { return m_size; }
|
||||
QString name() const { return QFile::decodeName( m_name ); }
|
||||
const Directory *parent() const {
|
||||
return m_parent;
|
||||
}
|
||||
const char *name8Bit() const {
|
||||
return m_name;
|
||||
}
|
||||
FileSize size() const {
|
||||
return m_size;
|
||||
}
|
||||
QString name() const {
|
||||
return QFile::decodeName(m_name);
|
||||
}
|
||||
|
||||
virtual bool isDirectory() const { return false; }
|
||||
virtual bool isDirectory() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString fullPath( const Directory* = 0 ) const;
|
||||
QString humanReadableSize( UnitPrefix key = mega ) const;
|
||||
QString fullPath(const Directory* = 0) const;
|
||||
QString humanReadableSize(UnitPrefix key = mega) const;
|
||||
|
||||
public:
|
||||
static QString humanReadableSize( uint size, UnitPrefix Key = mega );
|
||||
static QString humanReadableSize(uint size, UnitPrefix Key = mega);
|
||||
|
||||
protected:
|
||||
File( const char *name, FileSize size, Directory *parent ) : m_parent( parent ), m_name( qstrdup( name ) ), m_size( size ) {}
|
||||
File(const char *name, FileSize size, Directory *parent) : m_parent(parent), m_name(qstrdup(name)), m_size(size) {}
|
||||
|
||||
Directory *m_parent; //0 if this is treeRoot
|
||||
char *m_name;
|
||||
FileSize m_size; //in units of KiB
|
||||
Directory *m_parent; //0 if this is treeRoot
|
||||
char *m_name;
|
||||
FileSize m_size; //in units of KiB
|
||||
|
||||
private:
|
||||
File( const File& );
|
||||
void operator=( const File& );
|
||||
File(const File&);
|
||||
void operator=(const File&);
|
||||
};
|
||||
|
||||
|
||||
class Directory : public Chain<File>, public File
|
||||
{
|
||||
public:
|
||||
Directory( const char *name ) : File( name, 0 ), m_children( 0 ) {} //DON'T pass the full path!
|
||||
Directory(const char *name) : File(name, 0), m_children(0) {} //DON'T pass the full path!
|
||||
|
||||
uint children() const { return m_children; }
|
||||
virtual bool isDirectory() const { return true; }
|
||||
uint children() const {
|
||||
return m_children;
|
||||
}
|
||||
virtual bool isDirectory() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
///appends a Directory
|
||||
void append( Directory *d, const char *name=0 )
|
||||
{
|
||||
if( name ) {
|
||||
delete [] d->m_name;
|
||||
d->m_name = qstrdup( name ); } //directories that had a fullpath copy just their names this way
|
||||
///appends a Directory
|
||||
void append(Directory *d, const char *name=0)
|
||||
{
|
||||
if (name) {
|
||||
delete [] d->m_name;
|
||||
d->m_name = qstrdup(name);
|
||||
} //directories that had a fullpath copy just their names this way
|
||||
|
||||
m_children += d->children(); //doesn't include the dir itself
|
||||
d->m_parent = this;
|
||||
append( (File*)d ); //will add 1 to filecount for the dir itself
|
||||
}
|
||||
m_children += d->children(); //doesn't include the dir itself
|
||||
d->m_parent = this;
|
||||
append((File*)d); //will add 1 to filecount for the dir itself
|
||||
}
|
||||
|
||||
///appends a File
|
||||
void append( const char *name, FileSize size )
|
||||
{
|
||||
append( new File( name, size, this ) );
|
||||
}
|
||||
|
||||
void remove( const File *f )
|
||||
{
|
||||
for (Iterator<File> it = iterator(); it != end(); ++it)
|
||||
if (*it == f) {
|
||||
if (f->isDirectory())
|
||||
m_children -= ((Directory*)f)->children();
|
||||
|
||||
m_size -= f->size();
|
||||
|
||||
delete it.remove();
|
||||
}
|
||||
}
|
||||
///appends a File
|
||||
void append(const char *name, FileSize size)
|
||||
{
|
||||
append(new File(name, size, this));
|
||||
}
|
||||
|
||||
private:
|
||||
void append( File *p )
|
||||
{
|
||||
m_children++;
|
||||
m_size += p->size();
|
||||
Chain<File>::append( p );
|
||||
}
|
||||
void append(File *p)
|
||||
{
|
||||
m_children++;
|
||||
m_size += p->size();
|
||||
Chain<File>::append(p);
|
||||
}
|
||||
|
||||
uint m_children;
|
||||
uint m_children;
|
||||
|
||||
private:
|
||||
Directory( const Directory& ); //undefined
|
||||
void operator=( const Directory& ); //undefined
|
||||
Directory(const Directory&); //undefined
|
||||
void operator=(const Directory&); //undefined
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,16 +1,38 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "Config.h"
|
||||
#include "debug.h"
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include "fileTree.h"
|
||||
#include <fstab.h>
|
||||
#include "localLister.h"
|
||||
#include <qapplication.h> //postEvent()
|
||||
#include <qfile.h>
|
||||
#include "fileTree.h"
|
||||
#include "scan.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <KMessageBox>
|
||||
|
||||
#include <QApplication> //postEvent()
|
||||
#include <QFile>
|
||||
#include <Q3CString>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fstab.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
@ -19,275 +41,321 @@
|
|||
#include <mntent.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace Filelight
|
||||
{
|
||||
QStringList LocalLister::s_remote_mounts;
|
||||
QStringList LocalLister::s_local_mounts;
|
||||
QStringList LocalLister::s_remoteMounts;
|
||||
QStringList LocalLister::s_localMounts;
|
||||
|
||||
LocalLister::LocalLister( const QString &path, Chain<Directory> *cachedTrees, QObject *parent )
|
||||
: QThread()
|
||||
, m_path( path )
|
||||
, m_trees( cachedTrees )
|
||||
, m_parent( parent )
|
||||
{
|
||||
//add empty directories for any mount points that are in the path
|
||||
//TODO empty directories is not ideal as adds to fileCount incorrectly
|
||||
LocalLister::LocalLister(const QString &path, Chain<Directory> *cachedTrees, QObject *parent)
|
||||
: QThread()
|
||||
, m_path(path)
|
||||
, m_trees(cachedTrees)
|
||||
, m_parent(parent)
|
||||
{
|
||||
//add empty directories for any mount points that are in the path
|
||||
//TODO empty directories is not ideal as adds to fileCount incorrectly
|
||||
|
||||
QStringList list( Config::skipList );
|
||||
if (!Config::scanAcrossMounts) list += s_local_mounts;
|
||||
if (!Config::scanRemoteMounts) list += s_remote_mounts;
|
||||
QStringList list(Config::skipList);
|
||||
if (!Config::scanAcrossMounts) list += s_localMounts;
|
||||
if (!Config::scanRemoteMounts) list += s_remoteMounts;
|
||||
|
||||
for( QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it )
|
||||
if( (*it).startsWith( path ) )
|
||||
for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it)
|
||||
if ((*it).startsWith(path))
|
||||
//prevent scanning of these directories
|
||||
m_trees->append( new Directory( (*it).local8Bit() ) );
|
||||
m_trees->append(new Directory((*it).toLocal8Bit()));
|
||||
|
||||
start();
|
||||
}
|
||||
start();
|
||||
}
|
||||
|
||||
void
|
||||
LocalLister::run()
|
||||
{
|
||||
//recursively scan the requested path
|
||||
const QCString path = QFile::encodeName( m_path );
|
||||
Directory *tree = scan( path, path );
|
||||
void
|
||||
LocalLister::run()
|
||||
{
|
||||
//recursively scan the requested path
|
||||
const Q3CString path = QFile::encodeName(m_path);
|
||||
Directory *tree = scan(path, path);
|
||||
|
||||
//delete the list of trees useful for this scan,
|
||||
//in a sucessful scan the contents would now be transfered to 'tree'
|
||||
delete m_trees;
|
||||
//delete the list of trees useful for this scan,
|
||||
//in a sucessful scan the contents would now be transfered to 'tree'
|
||||
delete m_trees;
|
||||
|
||||
if( ScanManager::s_abort ) //scan was cancelled
|
||||
{
|
||||
qDebug() << "Scan successfully aborted";
|
||||
delete tree;
|
||||
tree = 0;
|
||||
}
|
||||
if (ScanManager::s_abort) //scan was cancelled
|
||||
{
|
||||
kDebug() << "Scan succesfully aborted";
|
||||
delete tree;
|
||||
tree = 0;
|
||||
}
|
||||
emit branchCompleted(tree, false);
|
||||
}
|
||||
|
||||
QCustomEvent *e = new QCustomEvent( 1000 );
|
||||
e->setData( tree );
|
||||
QApplication::postEvent( m_parent, e );
|
||||
}
|
||||
// from system.h in GNU coreutils package
|
||||
/* Extract or fake data from a `struct stat'.
|
||||
ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes.
|
||||
ST_NBLOCKS: Number of blocks in the file, including indirect blocks.
|
||||
ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS. */
|
||||
#ifndef HAVE_STRUCT_STAT_ST_BLOCKS
|
||||
#define ST_BLKSIZE(statbuf) DEV_BSIZE
|
||||
#if defined _POSIX_SOURCE || !defined BSIZE /* fileblocks.c uses BSIZE. */
|
||||
#define ST_NBLOCKS(statbuf) ((statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 0))
|
||||
#else /* !_POSIX_SOURCE && BSIZE */
|
||||
#define ST_NBLOCKS(statbuf) (S_ISREG ((statbuf).st_mode) || S_ISDIR ((statbuf).st_mode) ? st_blocks ((statbuf).st_size) : 0)
|
||||
#endif /* !_POSIX_SOURCE && BSIZE */
|
||||
#else /* HAVE_STRUCT_STAT_ST_BLOCKS */
|
||||
/* Some systems, like Sequents, return st_blksize of 0 on pipes.
|
||||
Also, when running `rsh hpux11-system cat any-file', cat would
|
||||
determine that the output stream had an st_blksize of 2147421096.
|
||||
So here we arbitrarily limit the `optimal' block size to 4MB.
|
||||
If anyone knows of a system for which the legitimate value for
|
||||
st_blksize can exceed 4MB, please report it as a bug in this code. */
|
||||
#define ST_BLKSIZE(statbuf) ((0 < (statbuf).st_blksize && (statbuf).st_blksize <= (1 << 22)) /* 4MiB */ ? (statbuf).st_blksize : DEV_BSIZE)
|
||||
#if defined hpux || defined __hpux__ || defined __hpux
|
||||
/* HP-UX counts st_blocks in 1024-byte units.
|
||||
This loses when mixing HP-UX and BSD filesystems with NFS. */
|
||||
#define ST_NBLOCKSIZE 1024
|
||||
#else /* !hpux */
|
||||
#if defined _AIX && defined _I386
|
||||
/* AIX PS/2 counts st_blocks in 4K units. */
|
||||
#define ST_NBLOCKSIZE (4 * 1024)
|
||||
#else /* not AIX PS/2 */
|
||||
#if defined _CRAY
|
||||
#define ST_NBLOCKS(statbuf) (S_ISREG ((statbuf).st_mode) || S_ISDIR ((statbuf).st_mode) ? (statbuf).st_blocks * ST_BLKSIZE(statbuf)/ST_NBLOCKSIZE : 0)
|
||||
#endif /* _CRAY */
|
||||
#endif /* not AIX PS/2 */
|
||||
#endif /* !hpux */
|
||||
#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
|
||||
|
||||
// from system.h in GNU coreutils package
|
||||
/* Extract or fake data from a `struct stat'.
|
||||
ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes.
|
||||
ST_NBLOCKS: Number of blocks in the file, including indirect blocks.
|
||||
ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS. */
|
||||
#ifndef HAVE_STRUCT_STAT_ST_BLOCKS
|
||||
#define ST_BLKSIZE(statbuf) DEV_BSIZE
|
||||
#if defined _POSIX_SOURCE || !defined BSIZE /* fileblocks.c uses BSIZE. */
|
||||
#define ST_NBLOCKS(statbuf) ((statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 0))
|
||||
#else /* !_POSIX_SOURCE && BSIZE */
|
||||
#define ST_NBLOCKS(statbuf) (S_ISREG ((statbuf).st_mode) || S_ISDIR ((statbuf).st_mode) ? st_blocks ((statbuf).st_size) : 0)
|
||||
#endif /* !_POSIX_SOURCE && BSIZE */
|
||||
#else /* HAVE_STRUCT_STAT_ST_BLOCKS */
|
||||
/* Some systems, like Sequents, return st_blksize of 0 on pipes.
|
||||
Also, when running `rsh hpux11-system cat any-file', cat would
|
||||
determine that the output stream had an st_blksize of 2147421096.
|
||||
So here we arbitrarily limit the `optimal' block size to 4MB.
|
||||
If anyone knows of a system for which the legitimate value for
|
||||
st_blksize can exceed 4MB, please report it as a bug in this code. */
|
||||
#define ST_BLKSIZE(statbuf) ((0 < (statbuf).st_blksize && (statbuf).st_blksize <= (1 << 22)) /* 4MiB */ ? (statbuf).st_blksize : DEV_BSIZE)
|
||||
#if defined hpux || defined __hpux__ || defined __hpux
|
||||
/* HP-UX counts st_blocks in 1024-byte units.
|
||||
This loses when mixing HP-UX and BSD filesystems with NFS. */
|
||||
#define ST_NBLOCKSIZE 1024
|
||||
#else /* !hpux */
|
||||
#if defined _AIX && defined _I386
|
||||
/* AIX PS/2 counts st_blocks in 4K units. */
|
||||
#define ST_NBLOCKSIZE (4 * 1024)
|
||||
#else /* not AIX PS/2 */
|
||||
#if defined _CRAY
|
||||
#define ST_NBLOCKS(statbuf) (S_ISREG ((statbuf).st_mode) || S_ISDIR ((statbuf).st_mode) ? (statbuf).st_blocks * ST_BLKSIZE(statbuf)/ST_NBLOCKSIZE : 0)
|
||||
#endif /* _CRAY */
|
||||
#endif /* not AIX PS/2 */
|
||||
#endif /* !hpux */
|
||||
#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
|
||||
#ifndef ST_NBLOCKS
|
||||
#define ST_NBLOCKS(statbuf) ((statbuf).st_blocks)
|
||||
#endif
|
||||
|
||||
#ifndef ST_NBLOCKS
|
||||
#define ST_NBLOCKS(statbuf) ((statbuf).st_blocks)
|
||||
#endif
|
||||
|
||||
#ifndef ST_NBLOCKSIZE
|
||||
#define ST_NBLOCKSIZE 512
|
||||
#endif
|
||||
#ifndef ST_NBLOCKSIZE
|
||||
#define ST_NBLOCKSIZE 512
|
||||
#endif
|
||||
|
||||
//some GNU systems don't support big files for some reason
|
||||
#ifdef __USE_LARGEFILE64 //see dirent.h
|
||||
#define dirent dirent64
|
||||
#define scandir scandir64
|
||||
#define stat stat64
|
||||
#define statstruct stat64
|
||||
#define lstat lstat64
|
||||
#define readdir readdir64
|
||||
#define dirent dirent64
|
||||
#define scandir scandir64
|
||||
#define stat stat64
|
||||
#define statstruct stat64
|
||||
#define lstat lstat64
|
||||
#define readdir readdir64
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
outputError( QCString path )
|
||||
{
|
||||
///show error message that stat or opendir may give
|
||||
#include <errno.h>
|
||||
static void
|
||||
outputError(Q3CString path)
|
||||
{
|
||||
///show error message that stat or opendir may give
|
||||
|
||||
#define out( s ) qError() << s ": " << path; break
|
||||
#define out(s) kError() << s ": " << path; break
|
||||
|
||||
switch( errno ) {
|
||||
case EACCES:
|
||||
out( "Inadequate access permissions" );
|
||||
case EMFILE:
|
||||
out( "Too many file descriptors in use by Filelight" );
|
||||
case ENFILE:
|
||||
out( "Too many files are currently open in the system" );
|
||||
case ENOENT:
|
||||
out( "A component of the path does not exist, or the path is an empty string" );
|
||||
case ENOMEM:
|
||||
out( "Insufficient memory to complete the operation" );
|
||||
case ENOTDIR:
|
||||
out( "A component of the path is not a directory" );
|
||||
case EBADF:
|
||||
out( "Bad file descriptor" );
|
||||
case EFAULT:
|
||||
out( "Bad address" );
|
||||
case ELOOP: //NOTE shouldn't ever happen
|
||||
out( "Too many symbolic links encountered while traversing the path" );
|
||||
case ENAMETOOLONG:
|
||||
out( "File name too long" );
|
||||
}
|
||||
switch (errno) {
|
||||
case EACCES:
|
||||
out("Inadequate access permisions");
|
||||
case EMFILE:
|
||||
out("Too many file descriptors in use by Filelight");
|
||||
case ENFILE:
|
||||
out("Too many files are currently open in the system");
|
||||
case ENOENT:
|
||||
out("A component of the path does not exist, or the path is an empty string");
|
||||
case ENOMEM:
|
||||
out("Insufficient memory to complete the operation");
|
||||
case ENOTDIR:
|
||||
out("A component of the path is not a directory");
|
||||
case EBADF:
|
||||
out("Bad file descriptor");
|
||||
case EFAULT:
|
||||
out("Bad address");
|
||||
case ELOOP: //NOTE shouldn't ever happen
|
||||
out("Too many symbolic links encountered while traversing the path");
|
||||
case ENAMETOOLONG:
|
||||
out("File name too long");
|
||||
}
|
||||
|
||||
#undef out
|
||||
}
|
||||
#undef out
|
||||
}
|
||||
|
||||
Directory*
|
||||
LocalLister::scan( const QCString &path, const QCString &dirname )
|
||||
{
|
||||
Directory *cwd = new Directory( dirname );
|
||||
DIR *dir = opendir( path );
|
||||
Directory*
|
||||
LocalLister::scan(const Q3CString &path, const Q3CString &dirname)
|
||||
{
|
||||
Directory *cwd = new Directory(dirname);
|
||||
DIR *dir = opendir(path);
|
||||
|
||||
if( !dir ) {
|
||||
outputError( path );
|
||||
return cwd;
|
||||
}
|
||||
if (!dir) {
|
||||
outputError(path);
|
||||
return cwd;
|
||||
}
|
||||
|
||||
struct stat statbuf;
|
||||
dirent *ent;
|
||||
while ((ent = readdir( dir )))
|
||||
{
|
||||
if( ScanManager::s_abort )
|
||||
struct stat statbuf;
|
||||
dirent *ent;
|
||||
while ((ent = readdir(dir)))
|
||||
{
|
||||
if (ScanManager::s_abort)
|
||||
return cwd;
|
||||
|
||||
if( qstrcmp( ent->d_name, "." ) == 0 || qstrcmp( ent->d_name, ".." ) == 0 )
|
||||
if (qstrcmp(ent->d_name, ".") == 0 || qstrcmp(ent->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
QCString new_path = path; new_path += ent->d_name;
|
||||
Q3CString new_path = path;
|
||||
new_path += ent->d_name;
|
||||
|
||||
//get file information
|
||||
if( lstat( new_path, &statbuf ) == -1 ) {
|
||||
outputError( new_path );
|
||||
//get file information
|
||||
if (lstat(new_path, &statbuf) == -1) {
|
||||
outputError(new_path);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (S_ISLNK( statbuf.st_mode ) ||
|
||||
S_ISCHR( statbuf.st_mode ) ||
|
||||
S_ISBLK( statbuf.st_mode ) ||
|
||||
S_ISFIFO( statbuf.st_mode ) ||
|
||||
S_ISSOCK( statbuf.st_mode ))
|
||||
if (S_ISLNK(statbuf.st_mode) ||
|
||||
S_ISCHR(statbuf.st_mode) ||
|
||||
S_ISBLK(statbuf.st_mode) ||
|
||||
S_ISFIFO(statbuf.st_mode)||
|
||||
S_ISSOCK(statbuf.st_mode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (S_ISREG( statbuf.st_mode )) /// i.e. a normal file
|
||||
// we use units of KiB because in bytes uint32_t only will go to
|
||||
// 4GiB and we should avoid the expense of int64_t if possible
|
||||
cwd->append( ent->d_name, (ST_NBLOCKS( statbuf ) * ST_NBLOCKSIZE) / 1024 );
|
||||
if (S_ISREG(statbuf.st_mode)) //file
|
||||
//using units of KiB as 32bit max is 4GiB and 64bit ints are expensive
|
||||
cwd->append(ent->d_name, (ST_NBLOCKS(statbuf) * ST_NBLOCKSIZE) / 1024);
|
||||
|
||||
else if (S_ISDIR( statbuf.st_mode ))
|
||||
{
|
||||
else if (S_ISDIR(statbuf.st_mode)) //directory
|
||||
{
|
||||
Directory *d = 0;
|
||||
QCString new_dirname = ent->d_name;
|
||||
Q3CString new_dirname = ent->d_name;
|
||||
new_dirname += '/';
|
||||
new_path += '/';
|
||||
|
||||
//check to see if we've scanned this section already
|
||||
|
||||
for( Iterator<Directory> it = m_trees->iterator(); it != m_trees->end(); ++it )
|
||||
for (Iterator<Directory> it = m_trees->iterator(); it != m_trees->end(); ++it)
|
||||
{
|
||||
if( new_path == (*it)->name8Bit() )
|
||||
{
|
||||
qDebug() << "Tree pre-completed: " << (*it)->name();
|
||||
d = it.remove();
|
||||
ScanManager::s_files += d->children();
|
||||
//**** ideally don't have this redundant extra somehow
|
||||
cwd->append( d, new_dirname );
|
||||
}
|
||||
if (new_path == (*it)->name8Bit())
|
||||
{
|
||||
kDebug() << "Tree pre-completed: " << (*it)->name();
|
||||
d = it.remove();
|
||||
ScanManager::s_files += d->children();
|
||||
//**** ideally don't have this redundant extra somehow
|
||||
cwd->append(d, new_dirname);
|
||||
}
|
||||
}
|
||||
|
||||
if( !d ) //then scan
|
||||
if ((d = scan( new_path, new_dirname ))) //then scan was successful
|
||||
cwd->append( d );
|
||||
}
|
||||
if (!d) //then scan
|
||||
if ((d = scan(new_path, new_dirname))) //then scan was successful
|
||||
cwd->append(d);
|
||||
}
|
||||
|
||||
++ScanManager::s_files;
|
||||
}
|
||||
++ScanManager::s_files;
|
||||
}
|
||||
|
||||
closedir( dir );
|
||||
closedir(dir);
|
||||
|
||||
return cwd;
|
||||
}
|
||||
|
||||
void
|
||||
LocalLister::readMounts()
|
||||
{
|
||||
Q_DEBUG_BLOCK
|
||||
|
||||
//FIXME
|
||||
// * no removable media detection
|
||||
// * no updates if mounts change
|
||||
// * you want a KDE extension that handles this for you really
|
||||
|
||||
QValueList<QCString> remote_types; remote_types
|
||||
<< "smbfs"
|
||||
<< "sshfs"
|
||||
#ifdef MNTTYPE_NFS
|
||||
<< MNTTYPE_NFS
|
||||
#else
|
||||
<< "nfs";
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MNTENT_H
|
||||
#define SET_ENT setfsent()
|
||||
#define GET_ENT getfsent()
|
||||
#define MOUNT_PATH fs_file
|
||||
#define FS_TYPE fs_vfstype
|
||||
#define END_ENT endfsent()
|
||||
#else
|
||||
#ifndef _PATH_MOUNTED
|
||||
#define _PATH_MOUNTED "/etc/mtab"
|
||||
#endif
|
||||
|
||||
#define SET_ENT setmntent( _PATH_MOUNTED, "r" )
|
||||
#define GET_ENT getmntent( fp )
|
||||
#define MOUNT_PATH mnt_dir
|
||||
#define FS_TYPE mnt_type
|
||||
#define END_ENT endmntent( fp )
|
||||
|
||||
FILE *fp;
|
||||
#endif
|
||||
|
||||
if (SET_ENT) {
|
||||
struct fstab *ent;
|
||||
while ((ent = GET_ENT) != NULL ) {
|
||||
QString path = QFile::decodeName( ent->MOUNT_PATH );
|
||||
if (path == "/")
|
||||
continue;
|
||||
path += '/';
|
||||
|
||||
if (remote_types.contains( ent->FS_TYPE ))
|
||||
s_remote_mounts += path;
|
||||
else
|
||||
s_local_mounts += path;
|
||||
|
||||
qDebug() << "Found mount point: " << ent->MOUNT_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
END_ENT;
|
||||
}
|
||||
return cwd;
|
||||
}
|
||||
|
||||
bool
|
||||
LocalLister::readMounts()
|
||||
{
|
||||
#define INFO_PARTITIONS "/proc/partitions"
|
||||
#define INFO_MOUNTED_PARTITIONS "/etc/mtab" /* on Linux... */
|
||||
|
||||
////////////
|
||||
//BIG FAT TODO TODO TODO
|
||||
// Use Solid for this
|
||||
|
||||
//**** SHAMBLES
|
||||
// ** mtab should have priority as mount points don't have to follow fstab
|
||||
// ** no removable media detection
|
||||
// ** no updates if mounts change
|
||||
// ** you want a KDE extension that handles this for you really
|
||||
|
||||
struct fstab *fstab_ent;
|
||||
#ifdef HAVE_MNTENT_H
|
||||
struct mntent *mnt_ent;
|
||||
#endif
|
||||
QString str;
|
||||
|
||||
|
||||
#ifdef HAVE_MNTENT_H
|
||||
FILE *fp;
|
||||
if (setfsent() == 0 || !(fp = setmntent(INFO_MOUNTED_PARTITIONS, "r")))
|
||||
#else
|
||||
if (setfsent() == 0)
|
||||
#endif
|
||||
return false;
|
||||
|
||||
#define FS_NAME fstab_ent->fs_spec // device-name
|
||||
#define FS_FILE fstab_ent->fs_file // mount-point
|
||||
#define FS_TYPE fstab_ent->fs_vfstype // fs-type
|
||||
#define FS_MNTOPS fstab_ent->fs_mntops // mount-options
|
||||
|
||||
QStringList remoteFsTypes;
|
||||
remoteFsTypes << "smbfs" ;
|
||||
#ifdef MNTTYPE_NFS
|
||||
remoteFsTypes << MNTTYPE_NFS;
|
||||
#else
|
||||
remoteFsTypes << "nfs";
|
||||
#endif
|
||||
// What about afs?
|
||||
|
||||
while ((fstab_ent = getfsent()) != NULL)
|
||||
{
|
||||
str = QString(FS_FILE);
|
||||
if (str == "/") continue;
|
||||
str += '/';
|
||||
|
||||
if (remoteFsTypes.contains(FS_TYPE))
|
||||
s_remoteMounts.append(str); //**** NO! can't be sure won't have trailing slash, need to do a check first dummy!!
|
||||
|
||||
else
|
||||
s_localMounts.append(str); //**** NO! can't be sure won't have trailing slash, need to do a check first dummy!!
|
||||
|
||||
kDebug() << "FSTAB: " << FS_TYPE << "\n";
|
||||
}
|
||||
|
||||
endfsent(); /* close fstab.. */
|
||||
|
||||
#undef FS_NAME
|
||||
#undef FS_FILE
|
||||
#undef FS_TYPE
|
||||
#undef FS_MNTOPS
|
||||
|
||||
#define FS_NAME mnt_ent->mnt_fsname // device-name
|
||||
#define FS_FILE mnt_ent->mnt_dir // mount-point
|
||||
#define FS_TYPE mnt_ent->mnt_type // fs-type
|
||||
#define FS_MNTOPS mnt_ent->mnt_opts // mount-options
|
||||
|
||||
//scan mtab, **** mtab should take priority, but currently it isn't
|
||||
|
||||
#ifdef HAVE_MNTENT_H
|
||||
while ((mnt_ent = getmntent(fp)) != NULL)
|
||||
{
|
||||
bool b = false;
|
||||
|
||||
str = QString(FS_FILE);
|
||||
if (str == "/") continue;
|
||||
str += "/";
|
||||
|
||||
if (remoteFsTypes.contains(FS_TYPE))
|
||||
if (b = !s_remoteMounts.contains(str))
|
||||
s_remoteMounts.append(str); //**** NO! can't be sure won't have trailing slash, need to do a check first dummy!!
|
||||
|
||||
else if (b = !s_localMounts.contains(str))
|
||||
s_localMounts.append(str); //**** NO! can't be sure won't have trailing slash, need to do a check first dummy!!
|
||||
|
||||
if (b) kDebug() << "MTAB: " << FS_TYPE << "\n";
|
||||
}
|
||||
|
||||
endmntent(fp); /* Close mtab. */
|
||||
#endif
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#include "localLister.moc"
|
||||
|
|
|
@ -1,35 +1,59 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef LOCAL_LISTER_H
|
||||
#define LOCAL_LISTER_H
|
||||
#ifndef LOCALLISTER_H
|
||||
#define LOCALLISTER_H
|
||||
|
||||
#include <qthread.h>
|
||||
#include <QThread>
|
||||
#include <Q3CString>
|
||||
|
||||
class Directory;
|
||||
template<class T> class Chain;
|
||||
|
||||
namespace Filelight
|
||||
{
|
||||
class LocalLister : public QThread
|
||||
{
|
||||
public:
|
||||
LocalLister( const QString &path, Chain<Directory> *cachedTrees, QObject *parent );
|
||||
class LocalLister : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
static void readMounts();
|
||||
public:
|
||||
LocalLister(const QString &path, Chain<Directory> *cachedTrees, QObject *parent);
|
||||
|
||||
private:
|
||||
QString m_path;
|
||||
Chain<Directory> *m_trees;
|
||||
QObject *m_parent;
|
||||
static bool readMounts();
|
||||
|
||||
private:
|
||||
virtual void run();
|
||||
Directory *scan( const QCString&, const QCString& );
|
||||
signals:
|
||||
void branchCompleted(Directory* tree, bool finished);
|
||||
|
||||
private:
|
||||
static QStringList s_local_mounts, s_remote_mounts; //TODO namespace
|
||||
};
|
||||
private:
|
||||
QString m_path;
|
||||
Chain<Directory> *m_trees;
|
||||
QObject *m_parent;
|
||||
|
||||
private:
|
||||
virtual void run();
|
||||
Directory *scan(const Q3CString&, const Q3CString&);
|
||||
|
||||
private:
|
||||
static QStringList s_localMounts, s_remoteMounts; //TODO namespace
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,25 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "Config.h"
|
||||
#include "debug.h"
|
||||
#include "define.h"
|
||||
#include "fileTree.h"
|
||||
#include "part.h"
|
||||
|
@ -12,163 +29,177 @@
|
|||
#include "settingsDialog.h"
|
||||
#include "summaryWidget.h"
|
||||
|
||||
#include <kaboutdata.h> //::createAboutData()
|
||||
#include <kaction.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h> //::start()
|
||||
//#include <konq_operations.h>
|
||||
#include <kparts/genericfactory.h>
|
||||
#include <kstatusbar.h>
|
||||
#include <kstdaction.h>
|
||||
#include <qfile.h> //encodeName()
|
||||
#include <qtimer.h> //postInit() hack
|
||||
#include <qvbox.h>
|
||||
#include <unistd.h> //access()
|
||||
#include <KAboutData> //::createAboutData()
|
||||
#include <KAction>
|
||||
#include <KActionCollection>
|
||||
#include <KLocale>
|
||||
#include <KMessageBox> //::start()
|
||||
#include <KParts/BrowserExtension>
|
||||
#include <KParts/GenericFactory>
|
||||
#include <KStatusBar>
|
||||
#include <KStandardAction>
|
||||
|
||||
#include <QFile> //encodeName()
|
||||
#include <QTimer> //postInit() hack
|
||||
#include <Q3VBox>
|
||||
#include <Q3CString>
|
||||
#include <QPixmap>
|
||||
|
||||
#include <unistd.h> //access()
|
||||
#include <iostream>
|
||||
|
||||
namespace Filelight {
|
||||
|
||||
K_PLUGIN_FACTORY(filelightPartFactory, registerPlugin<Part>();) // produce a factory
|
||||
K_EXPORT_PLUGIN(filelightPartFactory("filelightpart"))
|
||||
|
||||
typedef KParts::GenericFactory<Filelight::Part> Factory;
|
||||
K_EXPORT_COMPONENT_FACTORY( libfilelight, Filelight::Factory )
|
||||
|
||||
|
||||
BrowserExtension::BrowserExtension( Part *parent, const char *name )
|
||||
: KParts::BrowserExtension( parent, name )
|
||||
BrowserExtension::BrowserExtension(Part *parent)
|
||||
: KParts::BrowserExtension(parent)
|
||||
{}
|
||||
|
||||
|
||||
Part::Part( QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, const QStringList& )
|
||||
: ReadOnlyPart( parent, name )
|
||||
, m_ext( new BrowserExtension( this ) )
|
||||
, m_statusbar( new StatusBarExtension( this ) )
|
||||
, m_map( 0 )
|
||||
, m_manager( new ScanManager( this ) )
|
||||
, m_started( false )
|
||||
Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
|
||||
: ReadOnlyPart(parent)
|
||||
, m_ext(new BrowserExtension(this))
|
||||
, m_statusbar(new StatusBarExtension(this))
|
||||
, m_map(0)
|
||||
, m_manager(new ScanManager(this))
|
||||
, m_started(false)
|
||||
{
|
||||
QPixmap::setDefaultOptimization( QPixmap::BestOptim );
|
||||
|
||||
Config::read();
|
||||
KGlobal::locale()->insertCatalog("filelight");
|
||||
setComponentData(filelightPartFactory::componentData());
|
||||
setXMLFile("filelight_partui.rc");
|
||||
// we need an instance
|
||||
|
||||
setInstance( Factory::instance() );
|
||||
setWidget( new QVBox( parentWidget, widgetName ) );
|
||||
setXMLFile( "filelight_partui.rc" );
|
||||
|
||||
m_map = new RadialMap::Widget( widget() );
|
||||
// setInstance(mainComponent());
|
||||
setWidget(new QWidget(parentWidget));
|
||||
|
||||
m_layout = new QVBoxLayout(widget());
|
||||
widget()->setLayout(m_layout);
|
||||
|
||||
m_map = new RadialMap::Widget(widget());
|
||||
m_map->hide();
|
||||
|
||||
KStdAction::zoomIn( m_map, SLOT(zoomIn()), actionCollection() );
|
||||
KStdAction::zoomOut( m_map, SLOT(zoomOut()), actionCollection() );
|
||||
KStdAction::preferences( this, SLOT(configFilelight()), actionCollection(), "configure_filelight" )->setText( i18n( "Configure Filelight..." ) );
|
||||
KStandardAction::zoomIn(m_map, SLOT(zoomIn()), actionCollection());
|
||||
KStandardAction::zoomOut(m_map, SLOT(zoomOut()), actionCollection());
|
||||
KAction *showPreferences = KStandardAction::preferences(this, SLOT(configFilelight()), actionCollection());
|
||||
showPreferences->setText(i18n("Configure Filelight..."));
|
||||
showPreferences->setObjectName("configure_filelight");
|
||||
|
||||
connect( m_map, SIGNAL(created( const Directory* )), SIGNAL(completed()) );
|
||||
connect( m_map, SIGNAL(created( const Directory* )), SLOT(mapChanged( const Directory* )) );
|
||||
connect( m_map, SIGNAL(activated( const KURL& )), SLOT(updateURL( const KURL& )) );
|
||||
connect(m_map, SIGNAL(created(const Directory*)), SIGNAL(completed()));
|
||||
connect(m_map, SIGNAL(created(const Directory*)), SLOT(mapChanged(const Directory*)));
|
||||
connect(m_map, SIGNAL(activated(const KUrl&)), SLOT(updateURL(const KUrl&)));
|
||||
|
||||
// TODO make better system
|
||||
connect( m_map, SIGNAL(giveMeTreeFor( const KURL& )), SLOT(updateURL( const KURL& )) );
|
||||
connect( m_map, SIGNAL(giveMeTreeFor( const KURL& )), SLOT(openURL( const KURL& )) );
|
||||
connect(m_map, SIGNAL(giveMeTreeFor(const KUrl&)), SLOT(updateURL(const KUrl&)));
|
||||
connect(m_map, SIGNAL(giveMeTreeFor(const KUrl&)), SLOT(openURL(const KUrl&)));
|
||||
|
||||
connect( m_manager, SIGNAL(completed( Directory* )), SLOT(scanCompleted( Directory* )) );
|
||||
connect( m_manager, SIGNAL(aboutToEmptyCache()), m_map, SLOT(invalidate()) );
|
||||
connect(m_manager, SIGNAL(completed(Directory*)), SLOT(scanCompleted(Directory*)));
|
||||
connect(m_manager, SIGNAL(aboutToEmptyCache()), m_map, SLOT(invalidate()));
|
||||
|
||||
QTimer::singleShot( 0, this, SLOT(postInit()) );
|
||||
QTimer::singleShot(0, this, SLOT(postInit()));
|
||||
}
|
||||
|
||||
void
|
||||
Part::postInit()
|
||||
{
|
||||
if( m_url.isEmpty() ) //if url is not empty openURL() has been called immediately after ctor, which happens
|
||||
{
|
||||
QWidget *summary = new SummaryWidget( widget(), "summaryWidget" );
|
||||
connect( summary, SIGNAL(activated( const KURL& )), SLOT(openURL( const KURL& )) );
|
||||
summary->show();
|
||||
if (url().isEmpty()) //if url is not empty openURL() has been called immediately after ctor, which happens
|
||||
{
|
||||
QWidget *summary = new SummaryWidget(widget());
|
||||
summary->setObjectName("summaryWidget");
|
||||
connect(summary, SIGNAL(activated(const KUrl&)), SLOT(openURL(const KUrl&)));
|
||||
summary->show();
|
||||
m_layout->addWidget(summary);
|
||||
|
||||
//FIXME KXMLGUI is b0rked, it should allow us to set this
|
||||
//BEFORE createGUI is called but it doesn't
|
||||
stateChanged( "scan_failed" );
|
||||
}
|
||||
//FIXME KXMLGUI is b0rked, it should allow us to set this
|
||||
//BEFORE createGUI is called but it doesn't
|
||||
stateChanged("scan_failed");
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Part::openURL( const KURL &u )
|
||||
Part::openURL(const KUrl &u)
|
||||
{
|
||||
//we don't want to be using the summary screen anymore
|
||||
delete widget()->child( "summaryWidget" );
|
||||
m_map->show();
|
||||
//we don't want to be using the summary screen anymore
|
||||
delete widget()->findChild<SummaryWidget *>("summaryWidget");
|
||||
|
||||
//TODO everyone hates dialogs, instead render the text in big fonts on the Map
|
||||
//TODO should have an empty KURL until scan is confirmed successful
|
||||
//TODO probably should set caption to QString::null while map is unusable
|
||||
m_map->show();
|
||||
m_layout->addWidget(m_map);
|
||||
|
||||
#define KMSG( s ) KMessageBox::information( widget(), s )
|
||||
//TODO everyone hates dialogs, instead render the text in big fonts on the Map
|
||||
//TODO should have an empty KUrl until scan is confirmed successful
|
||||
//TODO probably should set caption to QString::null while map is unusable
|
||||
|
||||
KURL url = u;
|
||||
url.cleanPath( true );
|
||||
const QString path = url.path( 1 );
|
||||
const QCString path8bit = QFile::encodeName( path );
|
||||
const bool isLocal = url.protocol() == "file";
|
||||
#define KMSG(s) KMessageBox::information(widget(), s)
|
||||
|
||||
if( url.isEmpty() )
|
||||
{
|
||||
//do nothing, chances are the user accidently pressed ENTER
|
||||
}
|
||||
else if( !url.isValid() )
|
||||
{
|
||||
KMSG( i18n( "The entered URL cannot be parsed; it is invalid." ) );
|
||||
}
|
||||
else if( path[0] != '/' )
|
||||
{
|
||||
KMSG( i18n( "Filelight only accepts absolute paths, eg. /%1" ).arg( path ) );
|
||||
}
|
||||
else if( isLocal && access( path8bit, F_OK ) != 0 ) //stat( path, &statbuf ) == 0
|
||||
{
|
||||
KMSG( i18n( "Directory not found: %1" ).arg( path ) );
|
||||
}
|
||||
else if( isLocal && access( path8bit, R_OK | X_OK ) != 0 )
|
||||
{
|
||||
KMSG( i18n( "Unable to enter: %1\nYou do not have access rights to this location." ).arg( path ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( url == m_url )
|
||||
m_manager->emptyCache(); //same as rescan()
|
||||
KUrl uri = u;
|
||||
uri.cleanPath(KUrl::SimplifyDirSeparators);
|
||||
const QString path = uri.path(KUrl::AddTrailingSlash);
|
||||
const Q3CString path8bit = QFile::encodeName(path);
|
||||
const bool isLocal = uri.protocol() == "file";
|
||||
|
||||
return start( url );
|
||||
}
|
||||
if (uri.isEmpty())
|
||||
{
|
||||
//do nothing, chances are the user accidently pressed ENTER
|
||||
}
|
||||
else if (!uri.isValid())
|
||||
{
|
||||
KMSG(i18n("The entered URL cannot be parsed; it is invalid."));
|
||||
}
|
||||
else if (path[0] != '/')
|
||||
{
|
||||
KMSG(i18n("Filelight only accepts absolute paths, eg. /%1").arg(path));
|
||||
}
|
||||
else if (isLocal && access(path8bit, F_OK) != 0) //stat(path, &statbuf) == 0
|
||||
{
|
||||
KMSG(i18n("Directory not found: %1").arg(path));
|
||||
}
|
||||
else if (isLocal && access(path8bit, R_OK | X_OK) != 0)
|
||||
{
|
||||
KMSG(i18n("Unable to enter: %1\nYou do not have access rights to this location.").arg(path));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uri == url())
|
||||
m_manager->emptyCache(); //same as rescan()
|
||||
|
||||
return false;
|
||||
return start(uri);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
Part::closeURL()
|
||||
{
|
||||
if( m_manager->abort() )
|
||||
statusBar()->message( i18n( "Aborting Scan..." ) );
|
||||
if (m_manager->abort())
|
||||
statusBar()->showMessage(i18n("Aborting Scan..."));
|
||||
|
||||
m_url = KURL();
|
||||
setUrl(KUrl());
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Part::updateURL( const KURL &u )
|
||||
Part::updateURL(const KUrl &u)
|
||||
{
|
||||
//the map has changed internally, update the interface to reflect this
|
||||
emit m_ext->openURLNotify(); //must be done first
|
||||
emit m_ext->setLocationBarURL( u.prettyURL() );
|
||||
//the map has changed internally, update the interface to reflect this
|
||||
emit m_ext->openUrlNotify(); //must be done first
|
||||
emit m_ext->setLocationBarUrl(u.prettyUrl());
|
||||
|
||||
//do this last, or it breaks Konqi location bar
|
||||
m_url = u;
|
||||
//do this last, or it breaks Konqi location bar
|
||||
setUrl(u);
|
||||
}
|
||||
|
||||
void
|
||||
Part::configFilelight()
|
||||
{
|
||||
QWidget *dialog = new SettingsDialog( widget(), "settings_dialog" );
|
||||
QWidget *dialog = new SettingsDialog(widget());
|
||||
|
||||
connect( dialog, SIGNAL(canvasIsDirty( int )), m_map, SLOT(refresh( int )) );
|
||||
connect( dialog, SIGNAL(mapIsInvalid()), m_manager, SLOT(emptyCache()) );
|
||||
connect(dialog, SIGNAL(canvasIsDirty(int)), m_map, SLOT(refresh(int)));
|
||||
connect(dialog, SIGNAL(mapIsInvalid()), m_manager, SLOT(emptyCache()));
|
||||
|
||||
dialog->show(); //deletes itself
|
||||
}
|
||||
|
@ -176,84 +207,89 @@ Part::configFilelight()
|
|||
KAboutData*
|
||||
Part::createAboutData()
|
||||
{
|
||||
return new KAboutData( APP_NAME, I18N_NOOP( APP_PRETTYNAME ), APP_VERSION );
|
||||
return new KAboutData(
|
||||
"filelight",
|
||||
0,
|
||||
ki18n("Filelight"),
|
||||
APP_VERSION,
|
||||
ki18n("Displays file usage in an easy to understand way."),
|
||||
KAboutData::License_GPL,
|
||||
ki18n("(c) 2002-2004 Max Howell\n\
|
||||
(c) 2008 Martin T. Sandsmark"),
|
||||
ki18n("Please report bugs."),
|
||||
"http://iskrembilen.com/",
|
||||
"sandsmark@iskrembilen.com");
|
||||
}
|
||||
|
||||
bool
|
||||
Part::start( const KURL &url )
|
||||
Part::start(const KUrl &url)
|
||||
{
|
||||
if( !m_started ) {
|
||||
m_statusbar->addStatusBarItem( new ProgressBox( statusBar(), this ), 0, true );
|
||||
connect( m_map, SIGNAL(mouseHover( const QString& )), statusBar(), SLOT(message( const QString& )) );
|
||||
connect( m_map, SIGNAL(created( const Directory* )), statusBar(), SLOT(clear()) );
|
||||
m_started = true;
|
||||
}
|
||||
if (!m_started) {
|
||||
m_statusbar->addStatusBarItem(new ProgressBox(statusBar(), this), 0, true);
|
||||
connect(m_map, SIGNAL(mouseHover(const QString&)), statusBar(), SLOT(message(const QString&)));
|
||||
connect(m_map, SIGNAL(created(const Directory*)), statusBar(), SLOT(clear()));
|
||||
m_started = true;
|
||||
}
|
||||
|
||||
if( m_manager->start( url ) ) {
|
||||
m_url = url;
|
||||
if (m_manager->start(url)) {
|
||||
setUrl(url);
|
||||
|
||||
const QString s = i18n( "Scanning: %1" ).arg( prettyURL() );
|
||||
stateChanged( "scan_started" );
|
||||
emit started( 0 ); //as a Part, we have to do this
|
||||
emit setWindowCaption( s );
|
||||
statusBar()->message( s );
|
||||
m_map->invalidate(); //to maintain ui consistency
|
||||
const QString s = i18n("Scanning: %1", prettyUrl());
|
||||
stateChanged("scan_started");
|
||||
emit started(0); //as a Part, we have to do this
|
||||
emit setWindowCaption(s);
|
||||
statusBar()->showMessage(s);
|
||||
m_map->invalidate(); //to maintain ui consistency
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
Part::rescan()
|
||||
{
|
||||
//FIXME we have to empty the cache because otherwise rescan picks up the old tree..
|
||||
m_manager->emptyCache(); //causes canvas to invalidate
|
||||
start( m_url );
|
||||
//FIXME we have to empty the cache because otherwise rescan picks up the old tree..
|
||||
m_manager->emptyCache(); //causes canvas to invalidate
|
||||
start(url());
|
||||
}
|
||||
|
||||
void
|
||||
Part::scanCompleted( Directory *tree )
|
||||
Part::scanCompleted(Directory *tree)
|
||||
{
|
||||
if( tree ) {
|
||||
statusBar()->message( i18n( "Scan completed, generating map..." ) );
|
||||
if (tree) {
|
||||
statusBar()->showMessage(i18n("Scan completed, generating map..."));
|
||||
|
||||
m_map->create( tree );
|
||||
m_map->create(tree);
|
||||
|
||||
//do after creating map
|
||||
stateChanged( "scan_complete" );
|
||||
}
|
||||
else {
|
||||
stateChanged( "scan_failed" );
|
||||
emit canceled( i18n( "Scan failed: %1" ).arg( prettyURL() ) );
|
||||
emit setWindowCaption( QString::null );
|
||||
//do after creating map
|
||||
stateChanged("scan_complete");
|
||||
}
|
||||
else {
|
||||
stateChanged("scan_failed");
|
||||
emit canceled(i18n("Scan failed: %1").arg(prettyUrl()));
|
||||
emit setWindowCaption(QString::null);
|
||||
|
||||
statusBar()->clear();
|
||||
// QTimer::singleShot( 2000, statusBar(), SLOT(clear()) );
|
||||
statusBar()->clearMessage();
|
||||
|
||||
m_url = KURL();
|
||||
}
|
||||
setUrl(KUrl());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Part::mapChanged( const Directory *tree )
|
||||
Part::mapChanged(const Directory *tree)
|
||||
{
|
||||
//IMPORTANT -> m_url has already been set
|
||||
//IMPORTANT -> url() has already been set
|
||||
|
||||
emit setWindowCaption( prettyURL() );
|
||||
emit setWindowCaption(prettyUrl());
|
||||
|
||||
ProgressBox *progress = static_cast<ProgressBox *>(statusBar()->child( "ProgressBox" ));
|
||||
ProgressBox *progress = statusBar()->findChild<ProgressBox *>();
|
||||
|
||||
if( progress )
|
||||
progress->setText( tree->children() );
|
||||
if (progress)
|
||||
progress->setText(tree->children());
|
||||
}
|
||||
|
||||
} //namespace Filelight
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
QString QDebug::indent; //see debug.h
|
||||
#endif
|
||||
|
||||
#include "part.moc"
|
||||
|
|
115
src/part/part.h
115
src/part/part.h
|
@ -1,71 +1,98 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef FILELIGHT_PART_H
|
||||
#define FILELIGHT_PART_H
|
||||
#ifndef FILELIGHTPART_H
|
||||
#define FILELIGHTPART_H
|
||||
|
||||
#include <kparts/browserextension.h>
|
||||
#include <kparts/statusbarextension.h>
|
||||
#include <kparts/part.h>
|
||||
#include <kurl.h>
|
||||
#include <KParts/BrowserExtension>
|
||||
#include <KParts/StatusBarExtension>
|
||||
#include <KParts/Part>
|
||||
#include <KUrl>
|
||||
|
||||
class KAboutData;
|
||||
using KParts::StatusBarExtension;
|
||||
namespace RadialMap { class Widget; }
|
||||
namespace RadialMap {
|
||||
class Widget;
|
||||
}
|
||||
class Directory;
|
||||
|
||||
|
||||
namespace Filelight
|
||||
{
|
||||
class Part;
|
||||
class Part;
|
||||
|
||||
class BrowserExtension : public KParts::BrowserExtension
|
||||
{
|
||||
public:
|
||||
explicit BrowserExtension( Part*, const char * = 0 );
|
||||
};
|
||||
class BrowserExtension : public KParts::BrowserExtension
|
||||
{
|
||||
public:
|
||||
BrowserExtension(Part*);
|
||||
};
|
||||
|
||||
|
||||
class Part : public KParts::ReadOnlyPart
|
||||
{
|
||||
Q_OBJECT
|
||||
class Part : public KParts::ReadOnlyPart
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Part( QWidget *, const char *, QObject *, const char *, const QStringList& );
|
||||
public:
|
||||
Part(QWidget *, QObject *, const QList<QVariant>&);
|
||||
|
||||
virtual bool openFile() { return false; } //pure virtual in base class
|
||||
virtual bool closeURL();
|
||||
virtual bool openFile() {
|
||||
return false; //pure virtual in base class
|
||||
}
|
||||
virtual bool closeURL();
|
||||
|
||||
QString prettyURL() const { return m_url.protocol() == "file" ? m_url.path() : m_url.prettyURL(); }
|
||||
QString prettyUrl() const {
|
||||
return url().protocol() == "file" ? url().path() : url().prettyUrl();
|
||||
}
|
||||
|
||||
static KAboutData *createAboutData();
|
||||
static KAboutData *createAboutData();
|
||||
|
||||
public slots:
|
||||
virtual bool openURL( const KURL& );
|
||||
void configFilelight();
|
||||
void rescan();
|
||||
public slots:
|
||||
virtual bool openURL(const KUrl&);
|
||||
void configFilelight();
|
||||
void rescan();
|
||||
|
||||
private slots:
|
||||
void postInit();
|
||||
void scanCompleted( Directory* );
|
||||
void mapChanged( const Directory* );
|
||||
private slots:
|
||||
void postInit();
|
||||
void scanCompleted(Directory*);
|
||||
void mapChanged(const Directory*);
|
||||
|
||||
private:
|
||||
KStatusBar *statusBar() { return m_statusbar->statusBar(); }
|
||||
private:
|
||||
KStatusBar *statusBar() {
|
||||
return m_statusbar->statusBar();
|
||||
}
|
||||
|
||||
BrowserExtension *m_ext;
|
||||
StatusBarExtension *m_statusbar;
|
||||
RadialMap::Widget *m_map;
|
||||
class ScanManager *m_manager;
|
||||
QLayout *m_layout;
|
||||
BrowserExtension *m_ext;
|
||||
StatusBarExtension *m_statusbar;
|
||||
RadialMap::Widget *m_map;
|
||||
class ScanManager *m_manager;
|
||||
|
||||
bool m_started;
|
||||
bool m_started;
|
||||
|
||||
private:
|
||||
bool start( const KURL& );
|
||||
private:
|
||||
bool start(const KUrl&);
|
||||
|
||||
private slots:
|
||||
void updateURL( const KURL & );
|
||||
};
|
||||
private slots:
|
||||
void updateURL(const KUrl &);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,65 +1,87 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
|
||||
#include <kglobal.h>
|
||||
#include <kglobalsettings.h>
|
||||
#include <kio/job.h>
|
||||
#include <klocale.h>
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "scan.h"
|
||||
#include "progressBox.h"
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KGlobalSettings>
|
||||
#include <KIO/Job>
|
||||
#include <KLocale>
|
||||
|
||||
ProgressBox::ProgressBox( QWidget *parent, QObject *part )
|
||||
: QLabel( parent, "ProgressBox" )
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
ProgressBox::ProgressBox(QWidget *parent, QObject *part)
|
||||
: QLabel(parent)
|
||||
{
|
||||
hide();
|
||||
hide();
|
||||
|
||||
setAlignment( Qt::AlignCenter );
|
||||
setFont( KGlobalSettings::fixedFont() );
|
||||
setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
|
||||
setObjectName("ProgressBox");
|
||||
|
||||
setText( 999999 );
|
||||
setMinimumWidth( sizeHint().width() );
|
||||
setAlignment(Qt::AlignCenter);
|
||||
setFont(KGlobalSettings::fixedFont());
|
||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||
|
||||
connect( &m_timer, SIGNAL(timeout()), SLOT(report()) );
|
||||
connect( part, SIGNAL(started( KIO::Job* )), SLOT(start()) );
|
||||
connect( part, SIGNAL(completed()), SLOT(stop()) );
|
||||
connect( part, SIGNAL(canceled( const QString& )), SLOT(halt()) );
|
||||
setText(999999);
|
||||
setMinimumWidth(sizeHint().width());
|
||||
|
||||
connect(&m_timer, SIGNAL(timeout()), SLOT(report()));
|
||||
connect(part, SIGNAL(started(KIO::Job*)), SLOT(start()));
|
||||
connect(part, SIGNAL(completed()), SLOT(stop()));
|
||||
connect(part, SIGNAL(canceled(const QString&)), SLOT(halt()));
|
||||
}
|
||||
|
||||
void
|
||||
ProgressBox::start() //slot
|
||||
{
|
||||
m_timer.start( 50 ); //20 times per second - very smooth
|
||||
report();
|
||||
show();
|
||||
m_timer.start(50); //20 times per second - very smooth
|
||||
report();
|
||||
show();
|
||||
}
|
||||
|
||||
void
|
||||
ProgressBox::report() //slot
|
||||
{
|
||||
setText( Filelight::ScanManager::files() );
|
||||
setText(Filelight::ScanManager::files());
|
||||
}
|
||||
|
||||
void
|
||||
ProgressBox::stop()
|
||||
{
|
||||
m_timer.stop();
|
||||
m_timer.stop();
|
||||
}
|
||||
|
||||
void
|
||||
ProgressBox::halt()
|
||||
{
|
||||
// canceled by stop button
|
||||
m_timer.stop();
|
||||
QTimer::singleShot( 2000, this, SLOT(hide()) );
|
||||
// canceled by stop button
|
||||
m_timer.stop();
|
||||
QTimer::singleShot(2000, this, SLOT(hide()));
|
||||
}
|
||||
|
||||
void
|
||||
ProgressBox::setText( int files )
|
||||
ProgressBox::setText(int files)
|
||||
{
|
||||
QLabel::setText( i18n("%n File", "%n Files", files) );
|
||||
QLabel::setText(i18np("%1 File", "%1 Files", files));
|
||||
}
|
||||
|
||||
#include "progressBox.moc"
|
||||
|
|
|
@ -1,23 +1,43 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef PROGRESS_BOX_H
|
||||
#define PROGRESS_BOX_H
|
||||
#ifndef PROGRESSBOX_H
|
||||
#define PROGRESSBOX_H
|
||||
|
||||
#include <qlabel.h>
|
||||
#include <qtimer.h>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
|
||||
namespace KIO { class Job; }
|
||||
namespace KIO {
|
||||
class Job;
|
||||
}
|
||||
|
||||
|
||||
class ProgressBox : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ProgressBox( QWidget*, QObject* );
|
||||
ProgressBox(QWidget*, QObject*);
|
||||
|
||||
void setText( int );
|
||||
void setText(int);
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
|
|
33
src/part/radialMap/CMakeLists.txt
Normal file
33
src/part/radialMap/CMakeLists.txt
Normal file
|
@ -0,0 +1,33 @@
|
|||
#######################################################################
|
||||
# Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License or (at your option) version 3 or any later version
|
||||
# accepted by the membership of KDE e.V. (or its successor approved
|
||||
# by the membership of KDE e.V.), which shall act as a proxy
|
||||
# defined in Section 14 of version 3 of the license.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/filelight/src/part ${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
|
||||
|
||||
set(radialmap_STAT_SRCS
|
||||
widget.cpp
|
||||
builder.cpp
|
||||
map.cpp
|
||||
widgetEvents.cpp
|
||||
labels.cpp
|
||||
segmentTip.cpp)
|
||||
|
||||
kde4_add_library(radialmap STATIC ${radialmap_STAT_SRCS} )
|
||||
find_package(Blitz REQUIRED)
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
INCLUDES = -I$(top_srcdir)/filelight/src/part $(all_includes)
|
||||
METASOURCES = AUTO
|
||||
noinst_LTLIBRARIES = libradialmap.la
|
||||
libradialmap_la_SOURCES = \
|
||||
widget.cpp \
|
||||
builder.cpp \
|
||||
map.cpp \
|
||||
widgetEvents.cpp \
|
||||
labels.cpp \
|
||||
segmentTip.cpp \
|
||||
deleteDialog.cpp
|
|
@ -1,9 +1,27 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "builder.h"
|
||||
#include "Config.h"
|
||||
#include "fileTree.h"
|
||||
#include "part/Config.h"
|
||||
#include "part/fileTree.h"
|
||||
#include <kglobal.h> //locale object
|
||||
#include <klocale.h>
|
||||
#include "widget.h"
|
||||
|
@ -13,23 +31,23 @@
|
|||
//**** add some angle bounds checking (possibly in Segment ctor? can I delete in a ctor?)
|
||||
//**** this class is a mess
|
||||
|
||||
RadialMap::Builder::Builder( RadialMap::Map *m, const Directory* const d, bool fast )
|
||||
: m_map( m )
|
||||
, m_root( d )
|
||||
, m_minSize( static_cast<unsigned int>((d->size() * 3) / (PI * m->height() - m->MAP_2MARGIN )) )
|
||||
, m_depth( &m->m_visibleDepth )
|
||||
RadialMap::Builder::Builder(RadialMap::Map *m, const Directory* const d, bool fast)
|
||||
: m_map(m)
|
||||
, m_root(d)
|
||||
, m_minSize(static_cast<unsigned int>((d->size() * 3) / (PI * m->height() - m->MAP_2MARGIN)))
|
||||
, m_depth(&m->m_visibleDepth)
|
||||
{
|
||||
m_signature = new Chain<Segment> [*m_depth + 1];
|
||||
|
||||
if( !fast )//|| *m_depth == 0 ) //depth 0 is special case usability-wise //**** WHY?!
|
||||
if (!fast)//|| *m_depth == 0) //depth 0 is special case usability-wise //**** WHY?!
|
||||
{
|
||||
//determine depth rather than use old one
|
||||
findVisibleDepth( d ); //sets m_depth
|
||||
findVisibleDepth(d); //sets m_depth
|
||||
}
|
||||
|
||||
m_map->setRingBreadth();
|
||||
setLimits( m_map->m_ringBreadth );
|
||||
build( d );
|
||||
setLimits(m_map->m_ringBreadth);
|
||||
build(d);
|
||||
|
||||
m_map->m_signature = m_signature;
|
||||
|
||||
|
@ -38,7 +56,7 @@ RadialMap::Builder::Builder( RadialMap::Map *m, const Directory* const d, bool f
|
|||
|
||||
|
||||
void
|
||||
RadialMap::Builder::findVisibleDepth( const Directory* const dir, const unsigned int depth )
|
||||
RadialMap::Builder::findVisibleDepth(const Directory* const dir, const unsigned int depth)
|
||||
{
|
||||
//**** because I don't use the same minimumSize criteria as in the visual function
|
||||
// this can lead to incorrect visual representation
|
||||
|
@ -51,60 +69,60 @@ RadialMap::Builder::findVisibleDepth( const Directory* const dir, const unsigned
|
|||
|
||||
static uint stopDepth = 0;
|
||||
|
||||
if( dir == m_root )
|
||||
if (dir == m_root)
|
||||
{
|
||||
stopDepth = *m_depth;
|
||||
*m_depth = 0;
|
||||
}
|
||||
|
||||
if( *m_depth < depth ) *m_depth = depth;
|
||||
if( *m_depth >= stopDepth ) return;
|
||||
if (*m_depth < depth) *m_depth = depth;
|
||||
if (*m_depth >= stopDepth) return;
|
||||
|
||||
for( ConstIterator<File> it = dir->constIterator(); it != dir->end(); ++it )
|
||||
if( (*it)->isDirectory() && (*it)->size() > m_minSize )
|
||||
findVisibleDepth( (Directory *)*it, depth + 1 ); //if no files greater than min size the depth is still recorded
|
||||
for (ConstIterator<File> it = dir->constIterator(); it != dir->end(); ++it)
|
||||
if ((*it)->isDirectory() && (*it)->size() > m_minSize)
|
||||
findVisibleDepth((Directory *)*it, depth + 1); //if no files greater than min size the depth is still recorded
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Builder::setLimits( const uint &b ) //b = breadth?
|
||||
RadialMap::Builder::setLimits(const uint &b) //b = breadth?
|
||||
{
|
||||
double size3 = m_root->size() * 3;
|
||||
double pi2B = PI * 2 * b;
|
||||
|
||||
m_limits = new uint [*m_depth + 1]; //FIXME delete!
|
||||
|
||||
for( unsigned int d = 0; d <= *m_depth; ++d )
|
||||
for (unsigned int d = 0; d <= *m_depth; ++d)
|
||||
m_limits[d] = (uint)(size3 / (double)(pi2B * (d + 1))); //min is angle that gives 3px outer diameter for that depth
|
||||
}
|
||||
|
||||
|
||||
//**** segments currently overlap at edges (i.e. end of first is start of next)
|
||||
bool
|
||||
RadialMap::Builder::build( const Directory* const dir, const unsigned int depth, unsigned int a_start, const unsigned int a_end )
|
||||
RadialMap::Builder::build(const Directory* const dir, const unsigned int depth, unsigned int a_start, const unsigned int a_end)
|
||||
{
|
||||
//first iteration: dir == m_root
|
||||
|
||||
if( dir->children() == 0 ) //we do fileCount rather than size to avoid chance of divide by zero later
|
||||
if (dir->children() == 0) //we do fileCount rather than size to avoid chance of divide by zero later
|
||||
return false;
|
||||
|
||||
uint hiddenSize = 0, hiddenFileCount = 0;
|
||||
|
||||
for( ConstIterator<File> it = dir->constIterator(); it != dir->end(); ++it )
|
||||
for (ConstIterator<File> it = dir->constIterator(); it != dir->end(); ++it)
|
||||
{
|
||||
if( (*it)->size() > m_limits[depth] )
|
||||
if ((*it)->size() > m_limits[depth])
|
||||
{
|
||||
unsigned int a_len = (unsigned int)(5760 * ((double)(*it)->size() / (double)m_root->size()));
|
||||
|
||||
Segment *s = new Segment( *it, a_start, a_len );
|
||||
Segment *s = new Segment(*it, a_start, a_len);
|
||||
|
||||
(m_signature + depth)->append( s );
|
||||
(m_signature + depth)->append(s);
|
||||
|
||||
if( (*it)->isDirectory() )
|
||||
if ((*it)->isDirectory())
|
||||
{
|
||||
if( depth != *m_depth )
|
||||
if (depth != *m_depth)
|
||||
{
|
||||
//recurse
|
||||
s->m_hasHiddenChildren = build( (Directory*)*it, depth + 1, a_start, a_start + a_len );
|
||||
s->m_hasHiddenChildren = build((Directory*)*it, depth + 1, a_start, a_start + a_len);
|
||||
}
|
||||
else s->m_hasHiddenChildren = true;
|
||||
}
|
||||
|
@ -115,27 +133,27 @@ RadialMap::Builder::build( const Directory* const dir, const unsigned int depth,
|
|||
|
||||
hiddenSize += (*it)->size();
|
||||
|
||||
if( (*it)->isDirectory() ) //**** considered virtual, but dir wouldn't count itself!
|
||||
if ((*it)->isDirectory()) //**** considered virtual, but dir wouldn't count itself!
|
||||
hiddenFileCount += static_cast<const Directory*>(*it)->children(); //need to add one to count the dir as well
|
||||
|
||||
++hiddenFileCount;
|
||||
}
|
||||
}
|
||||
|
||||
if( hiddenFileCount == dir->children() && !Config::showSmallFiles )
|
||||
return true;
|
||||
if (hiddenFileCount == dir->children() && !Config::showSmallFiles)
|
||||
return true;
|
||||
|
||||
else if( (Config::showSmallFiles && hiddenSize > m_limits[depth]) || (depth == 0 && (hiddenSize > dir->size()/8)) /*|| > size() * 0.75*/ )
|
||||
{
|
||||
//append a segment for unrepresented space - a "fake" segment
|
||||
else if ((Config::showSmallFiles && hiddenSize > m_limits[depth]) || (depth == 0 && (hiddenSize > dir->size()/8)) /*|| > size() * 0.75*/)
|
||||
{
|
||||
//append a segment for unrepresented space - a "fake" segment
|
||||
|
||||
// I dunno how to i18n this
|
||||
const QString s = i18n( "There cannot ever be only 1 file", "%1 files, each about %2" )
|
||||
.arg( hiddenFileCount )
|
||||
.arg( File::humanReadableSize( hiddenSize/hiddenFileCount ) );
|
||||
// I dunno how to i18n this
|
||||
const QString s = i18np("There can't ever be only 1 file", "%1 files, each about %2",
|
||||
hiddenFileCount,
|
||||
File::humanReadableSize(hiddenSize/hiddenFileCount));
|
||||
|
||||
(m_signature + depth)->append( new Segment( new File( s.local8Bit(), hiddenSize ), a_start, a_end - a_start, true ) );
|
||||
}
|
||||
(m_signature + depth)->append(new Segment(new File(s.toLocal8Bit(), hiddenSize), a_start, a_end - a_start, true));
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,23 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef BUILDER_H
|
||||
#define BUILDER_H
|
||||
|
@ -12,27 +30,27 @@ class Directory;
|
|||
|
||||
namespace RadialMap
|
||||
{
|
||||
class Map;
|
||||
class Map;
|
||||
|
||||
//temporary class that builds the Map signature
|
||||
//temporary class that builds the Map signature
|
||||
|
||||
class Builder
|
||||
{
|
||||
public:
|
||||
Builder( Map*, const Directory* const, bool fast=false );
|
||||
class Builder
|
||||
{
|
||||
public:
|
||||
Builder(Map*, const Directory* const, bool fast=false);
|
||||
|
||||
private:
|
||||
void findVisibleDepth( const Directory* const dir, const uint=0 );
|
||||
void setLimits( const uint& );
|
||||
bool build( const Directory* const, const uint=0, uint=0, const uint=5760 );
|
||||
private:
|
||||
void findVisibleDepth(const Directory* const dir, const uint=0);
|
||||
void setLimits(const uint&);
|
||||
bool build(const Directory* const, const uint=0, uint=0, const uint=5760);
|
||||
|
||||
Map *m_map;
|
||||
const Directory* const m_root;
|
||||
const uint m_minSize;
|
||||
uint *m_depth;
|
||||
Chain<Segment> *m_signature;
|
||||
uint *m_limits;
|
||||
};
|
||||
Map *m_map;
|
||||
const Directory* const m_root;
|
||||
const uint m_minSize;
|
||||
uint *m_depth;
|
||||
Chain<Segment> *m_signature;
|
||||
uint *m_limits;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
|
||||
#include "debug.h"
|
||||
#include "deleteDialog.h"
|
||||
#include <kcursor.h>
|
||||
#include <kglobal.h>
|
||||
#include <kio/job.h>
|
||||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
#include <kpushbutton.h>
|
||||
#include <qapplication.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlayout.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qprogressbar.h>
|
||||
|
||||
|
||||
DeleteDialog::DeleteDialog( const KURL &url, bool is_dir, QWidget *parent )
|
||||
: QDialog( parent )
|
||||
, m_url( url )
|
||||
, m_job( 0 )
|
||||
{
|
||||
QString message = is_dir
|
||||
? i18n("The directory and its contents will be <b>recursively</b> and <b>permanently</b> deleted.")
|
||||
: i18n("The file will be <b>permanently</b> deleted.");
|
||||
|
||||
message += "<p><a href='#'>";
|
||||
message += url.protocol() == "file" ? url.path() : url.prettyURL();
|
||||
|
||||
//////
|
||||
QLabel *icon = 0;
|
||||
KGuiItem const del = KGuiItem( i18n("&Delete"), "editdelete" );
|
||||
|
||||
QBoxLayout *h1 = new QHBoxLayout;
|
||||
h1->addWidget( icon = new QLabel( this ) );
|
||||
h1->addItem( new QSpacerItem( 6, 6, QSizePolicy::Fixed ) );
|
||||
h1->addWidget( new QLabel( message, this ) );
|
||||
|
||||
QBoxLayout *h2 = new QHBoxLayout;
|
||||
h2->addWidget( m_bar = new QProgressBar( this ) );
|
||||
h2->addItem( new QSpacerItem( 0, 6 ) );
|
||||
h2->addWidget( m_ok = new KPushButton( del, this ) );
|
||||
h2->addWidget( m_cancel = new KPushButton( KStdGuiItem::cancel(), this ) );
|
||||
|
||||
QBoxLayout *v = new QVBoxLayout( this );
|
||||
v->setSpacing( 8 );
|
||||
v->setMargin( 8 );
|
||||
v->addLayout( h1 );
|
||||
v->addItem( new QSpacerItem( 6, 18 ) );
|
||||
v->addLayout( h2 );
|
||||
|
||||
m_bar->hide();
|
||||
m_bar->setCenterIndicator( true );
|
||||
icon->setPixmap( KGlobal::iconLoader()->loadIcon( "messagebox_warning", KIcon::NoGroup, KIcon::SizeLarge, KIcon::DefaultState, 0, true ) );
|
||||
icon->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
m_ok->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
m_cancel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
|
||||
connect( m_cancel, SIGNAL(clicked()), SLOT(reject()) );
|
||||
connect( m_ok, SIGNAL(clicked()), SLOT(accept()) );
|
||||
|
||||
//////
|
||||
setFixedSize( QSize( 4 * m_ok->sizeHint().width(), sizeHint().height() ) );
|
||||
setCaption( i18n("Delete Confirmation") );
|
||||
}
|
||||
|
||||
DeleteDialog::~DeleteDialog()
|
||||
{
|
||||
if (m_job) {
|
||||
m_job->kill();
|
||||
delete m_job;
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeleteDialog::accept()
|
||||
{
|
||||
Q_DEBUG_BLOCK
|
||||
|
||||
m_job = KIO::del( m_url ); //, false /*shred*/, false /*show fugly progress window*/ );
|
||||
//m_job->setWindow( this );
|
||||
|
||||
connect( m_job, SIGNAL(result( KIO::Job* )), SLOT(result( KIO::Job* )) );
|
||||
connect( m_job, SIGNAL(percent( KIO::Job*, unsigned long )), SLOT(percent( KIO::Job*, unsigned long )) );
|
||||
|
||||
m_cancel->setText( i18n("&Abort") );
|
||||
m_ok->setEnabled( false );
|
||||
m_bar->show();
|
||||
|
||||
QApplication::setOverrideCursor( KCursor::workingCursor() );
|
||||
}
|
||||
|
||||
void
|
||||
DeleteDialog::result( KIO::Job *j )
|
||||
{
|
||||
Q_DEBUG_BLOCK
|
||||
|
||||
hide();
|
||||
|
||||
if (j->error()) {
|
||||
j->showErrorDialog( parentWidget() );
|
||||
done( IndeterminateResult );
|
||||
}
|
||||
else
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void
|
||||
DeleteDialog::percent( KIO::Job*, const unsigned long percent )
|
||||
{
|
||||
Q_DEBUG_BLOCK
|
||||
|
||||
m_bar->setProgress( percent );
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
|
||||
#ifndef DELETE_DIALOG_H
|
||||
#define DELETE_DIALOG_H
|
||||
|
||||
#include <qdialog.h>
|
||||
#include <kurl.h>
|
||||
namespace KIO { class Job; }
|
||||
class QProgressBar;
|
||||
class QPushButton;
|
||||
|
||||
|
||||
class DeleteDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
KURL const m_url;
|
||||
KIO::Job *m_job;
|
||||
|
||||
QProgressBar *m_bar;
|
||||
QPushButton *m_cancel, *m_ok;
|
||||
|
||||
virtual void accept();
|
||||
|
||||
public:
|
||||
DeleteDialog( const KURL&, bool is_dir, QWidget *parent );
|
||||
~DeleteDialog();
|
||||
|
||||
enum Result { IndeterminateResult = 1000 };
|
||||
|
||||
private slots:
|
||||
/// I'm sorry, but KIO signals lack elegance, so great job there
|
||||
void percent( KIO::Job *job, unsigned long percent );
|
||||
void result( KIO::Job *job );
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,14 +1,34 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include <kstringhandler.h>
|
||||
#include <qfont.h>
|
||||
#include <qfontmetrics.h>
|
||||
#include <qpainter.h>
|
||||
#include <qptrlist.h>
|
||||
#include <q3ptrlist.h>
|
||||
//Added by qt3to4:
|
||||
#include <Q3PtrCollection>
|
||||
|
||||
#include "Config.h"
|
||||
#include "fileTree.h"
|
||||
#include "part/Config.h"
|
||||
#include "part/fileTree.h"
|
||||
#include "radialMap.h"
|
||||
#include "sincos.h"
|
||||
#include "widget.h"
|
||||
|
@ -17,311 +37,314 @@
|
|||
|
||||
namespace RadialMap
|
||||
{
|
||||
struct Label
|
||||
{
|
||||
Label( const RadialMap::Segment *s, int l ) : segment( s ), lvl( l ), a( segment->start() + (segment->length() / 2) ) { }
|
||||
struct Label
|
||||
{
|
||||
Label(const RadialMap::Segment *s, int l) : segment(s), lvl(l), a(segment->start() + (segment->length() / 2)) { }
|
||||
|
||||
bool tooClose( const int &aa ) const { return ( a > aa - LABEL_ANGLE_MARGIN && a < aa + LABEL_ANGLE_MARGIN ); }
|
||||
bool tooClose(const int &aa) const {
|
||||
return (a > aa - LABEL_ANGLE_MARGIN && a < aa + LABEL_ANGLE_MARGIN);
|
||||
}
|
||||
|
||||
const RadialMap::Segment *segment;
|
||||
const unsigned int lvl;
|
||||
const int a;
|
||||
const RadialMap::Segment *segment;
|
||||
const unsigned int lvl;
|
||||
const int a;
|
||||
|
||||
int x1, y1, x2, y2, x3;
|
||||
int tx, ty;
|
||||
int x1, y1, x2, y2, x3;
|
||||
int tx, ty;
|
||||
|
||||
QString qs;
|
||||
};
|
||||
QString qs;
|
||||
};
|
||||
|
||||
class LabelList : public QPtrList<Label>
|
||||
{
|
||||
protected:
|
||||
int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 )
|
||||
{
|
||||
//you add 1440 to work round the fact that later you want the circle split vertically
|
||||
//and as it is you start at 3 o' clock. It's to do with rightPrevY, stops annoying bug
|
||||
class LabelList : public Q3PtrList<Label>
|
||||
{
|
||||
protected:
|
||||
int compareItems(Q3PtrCollection::Item item1, Q3PtrCollection::Item item2)
|
||||
{
|
||||
//you add 1440 to work round the fact that later you want the circle split vertically
|
||||
//and as it is you start at 3 o' clock. It's to do with rightPrevY, stops annoying bug
|
||||
|
||||
int a1 = ((Label*)item1)->a + 1440;
|
||||
int a2 = ((Label*)item2)->a + 1440;
|
||||
int a1 = ((Label*)item1)->a + 1440;
|
||||
int a2 = ((Label*)item2)->a + 1440;
|
||||
|
||||
if( a1 == a2 )
|
||||
if (a1 == a2)
|
||||
return 0;
|
||||
|
||||
if( a1 > 5760 ) a1 -= 5760;
|
||||
if( a2 > 5760 ) a2 -= 5760;
|
||||
if (a1 > 5760) a1 -= 5760;
|
||||
if (a2 > 5760) a2 -= 5760;
|
||||
|
||||
if( a1 > a2 )
|
||||
if (a1 > a2)
|
||||
return 1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RadialMap::Widget::paintExplodedLabels( QPainter &paint ) const
|
||||
RadialMap::Widget::paintExplodedLabels(QPainter &paint) const
|
||||
{
|
||||
//we are a friend of RadialMap::Map
|
||||
//we are a friend of RadialMap::Map
|
||||
|
||||
LabelList list; list.setAutoDelete( true );
|
||||
QPtrListIterator<Label> it( list );
|
||||
unsigned int startLevel = 0;
|
||||
LabelList list;
|
||||
list.setAutoDelete(true);
|
||||
Q3PtrListIterator<Label> it(list);
|
||||
unsigned int startLevel = 0;
|
||||
|
||||
|
||||
//1. Create list of labels sorted in the order they will be rendered
|
||||
//1. Create list of labels sorted in the order they will be rendered
|
||||
|
||||
if( m_focus && m_focus->file() != m_tree ) //separate behavior for selected vs unselected segments
|
||||
{
|
||||
//don't bother with files
|
||||
if( m_focus->file() && !m_focus->file()->isDirectory() )
|
||||
return;
|
||||
if (m_focus && m_focus->file() != m_tree) //separate behavior for selected vs unselected segments
|
||||
{
|
||||
//don't bother with files
|
||||
if (m_focus->file() && !m_focus->file()->isDirectory())
|
||||
return;
|
||||
|
||||
//find the range of levels we will be potentially drawing labels for
|
||||
//startLevel is the level above whatever m_focus is in
|
||||
for( const Directory *p = (const Directory*)m_focus->file(); p != m_tree; ++startLevel )
|
||||
p = p->parent();
|
||||
//find the range of levels we will be potentially drawing labels for
|
||||
//startLevel is the level above whatever m_focus is in
|
||||
for (const Directory *p = (const Directory*)m_focus->file(); p != m_tree; ++startLevel)
|
||||
p = p->parent();
|
||||
|
||||
//range=2 means 2 levels to draw labels for
|
||||
//range=2 means 2 levels to draw labels for
|
||||
|
||||
unsigned int a1, a2, minAngle;
|
||||
unsigned int a1, a2, minAngle;
|
||||
|
||||
a1 = m_focus->start();
|
||||
a2 = m_focus->end(); //boundary angles
|
||||
minAngle = int(m_focus->length() * LABEL_MIN_ANGLE_FACTOR);
|
||||
a1 = m_focus->start();
|
||||
a2 = m_focus->end(); //boundry angles
|
||||
minAngle = int(m_focus->length() * LABEL_MIN_ANGLE_FACTOR);
|
||||
|
||||
|
||||
#define segment (*it)
|
||||
#define ring (m_map.m_signature + i)
|
||||
#define segment (*it)
|
||||
#define ring (m_map.m_signature + i)
|
||||
|
||||
//**** Levels should be on a scale starting with 0
|
||||
//**** range is a useless parameter
|
||||
//**** keep a topblock var which is the lowestLevel OR startLevel for identation purposes
|
||||
for( unsigned int i = startLevel; i <= m_map.m_visibleDepth; ++i )
|
||||
for( Iterator<Segment> it = ring->iterator(); it != ring->end(); ++it )
|
||||
if( segment->start() >= a1 && segment->end() <= a2 )
|
||||
if( segment->length() > minAngle )
|
||||
list.inSort( new Label( segment, i ) );
|
||||
//**** Levels should be on a scale starting with 0
|
||||
//**** range is a useless parameter
|
||||
//**** keep a topblock var which is the lowestLevel OR startLevel for identation purposes
|
||||
for (unsigned int i = startLevel; i <= m_map.m_visibleDepth; ++i)
|
||||
for (Iterator<Segment> it = ring->iterator(); it != ring->end(); ++it)
|
||||
if (segment->start() >= a1 && segment->end() <= a2)
|
||||
if (segment->length() > minAngle)
|
||||
list.inSort(new Label(segment, i));
|
||||
|
||||
#undef ring
|
||||
#undef segment
|
||||
#undef ring
|
||||
#undef segment
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
#define ring m_map.m_signature
|
||||
#define ring m_map.m_signature
|
||||
|
||||
for( Iterator<Segment> it = ring->iterator(); it != ring->end(); ++it )
|
||||
if( (*it)->length() > 288 )
|
||||
list.inSort( new Label( (*it), 0 ) );
|
||||
for (Iterator<Segment> it = ring->iterator(); it != ring->end(); ++it)
|
||||
if ((*it)->length() > 288)
|
||||
list.inSort(new Label((*it), 0));
|
||||
|
||||
#undef ring
|
||||
#undef ring
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//2. Check to see if any adjacent labels are too close together
|
||||
// if so, remove the least significant labels
|
||||
//2. Check to see if any adjacent labels are too close together
|
||||
// if so, remove the least significant labels
|
||||
|
||||
it.toFirst();
|
||||
QPtrListIterator<Label> jt( it );
|
||||
++jt;
|
||||
it.toFirst();
|
||||
Q3PtrListIterator<Label> jt(it);
|
||||
++jt;
|
||||
|
||||
while( jt ) //**** no need to check _it_ as jt will be NULL if _it_ was too
|
||||
{
|
||||
//this method is fairly efficient
|
||||
while (jt) //**** no need to check _it_ as jt will be NULL if _it_ was too
|
||||
{
|
||||
//this method is fairly efficient
|
||||
|
||||
if( (*it)->tooClose( (*jt)->a ) ) {
|
||||
if( (*it)->lvl > (*jt)->lvl ) {
|
||||
list.remove( *it );
|
||||
it = jt;
|
||||
}
|
||||
else
|
||||
list.remove( *jt );
|
||||
}
|
||||
else
|
||||
++it;
|
||||
|
||||
jt = it;
|
||||
++jt;
|
||||
}
|
||||
|
||||
//used in next two steps
|
||||
bool varySizes;
|
||||
//**** should perhaps use doubles
|
||||
int *sizes = new int [ m_map.m_visibleDepth + 1 ]; //**** make sizes an array of floats I think instead (or doubles)
|
||||
|
||||
do
|
||||
{
|
||||
//3. Calculate font sizes
|
||||
|
||||
{
|
||||
//determine current range of levels to draw for
|
||||
uint range = 0;
|
||||
|
||||
for( it.toFirst(); it != 0; ++it )
|
||||
{
|
||||
uint lvl = (*it)->lvl;
|
||||
if( lvl > range )
|
||||
range = lvl;
|
||||
|
||||
//**** better way would just be to assign if nothing is range
|
||||
}
|
||||
|
||||
range -= startLevel; //range 0 means 1 level of labels
|
||||
|
||||
varySizes = Config::varyLabelFontSizes && (range != 0);
|
||||
|
||||
if( varySizes )
|
||||
{
|
||||
//create an array of font sizes for various levels
|
||||
//will exceed normal font pitch automatically if necessary, but not minPitch
|
||||
//**** this needs to be checked lots
|
||||
|
||||
//**** what if this is negative (min size gtr than default size)
|
||||
uint step = (paint.font().pointSize() - Config::minFontPitch) / range;
|
||||
if( step == 0 )
|
||||
step = 1;
|
||||
|
||||
for( uint x = range + startLevel, y = Config::minFontPitch; x >= startLevel; y += step, --x )
|
||||
sizes[x] = y;
|
||||
}
|
||||
}
|
||||
|
||||
//4. determine label co-ordinates
|
||||
|
||||
int x1, y1, x2, y2, x3, tx, ty; //coords
|
||||
double sinra, cosra, ra; //angles
|
||||
|
||||
int cx = m_map.width() / 2 + m_offset.x(); //center relative to canvas
|
||||
int cy = m_map.height() / 2 + m_offset.y();
|
||||
|
||||
int spacer, preSpacer = int(m_map.m_ringBreadth * 0.5) + m_map.m_innerRadius;
|
||||
int fullStrutLength = ( m_map.width() - m_map.MAP_2MARGIN ) / 2 + LABEL_MAP_SPACER; //full length of a strut from map center
|
||||
|
||||
int prevLeftY = 0;
|
||||
int prevRightY = height();
|
||||
|
||||
bool rightSide;
|
||||
|
||||
QFont font;
|
||||
|
||||
for( it.toFirst(); it != 0; ++it )
|
||||
{
|
||||
//** bear in mind that text is drawn with QPoint param as BOTTOM left corner of text box
|
||||
QString qs = (*it)->segment->file()->name();
|
||||
if( varySizes )
|
||||
font.setPointSize( sizes[(*it)->lvl] );
|
||||
QFontMetrics fm( font );
|
||||
int fmh = fm.height(); //used to ensure label texts don't overlap
|
||||
int fmhD4 = fmh / 4;
|
||||
|
||||
fmh += LABEL_TEXT_VMARGIN;
|
||||
|
||||
rightSide = ( (*it)->a < 1440 || (*it)->a > 4320 );
|
||||
|
||||
ra = M_PI/2880 * (*it)->a; //convert to radians
|
||||
sincos( ra, &sinra, &cosra );
|
||||
|
||||
|
||||
spacer = preSpacer + m_map.m_ringBreadth * (*it)->lvl;
|
||||
|
||||
x1 = cx + (int)(cosra * spacer);
|
||||
y1 = cy - (int)(sinra * spacer);
|
||||
y2 = y1 - (int)(sinra * (fullStrutLength - spacer));
|
||||
|
||||
if( rightSide ) { //righthand side, going upwards
|
||||
if( y2 > prevRightY /*- fmh*/ ) //then it is too low, needs to be drawn higher
|
||||
y2 = prevRightY /*- fmh*/;
|
||||
}
|
||||
else //lefthand side, going downwards
|
||||
if( y2 < prevLeftY/* + fmh*/ ) //then we're too high, need to be drawn lower
|
||||
y2 = prevLeftY /*+ fmh*/;
|
||||
|
||||
x2 = x1 - int(double(y2 - y1) / tan( ra ));
|
||||
ty = y2 + fmhD4;
|
||||
|
||||
|
||||
if( rightSide ) {
|
||||
if( x2 > width() || ty < fmh || x2 < x1 ) {
|
||||
//skip this strut
|
||||
//**** don't duplicate this code
|
||||
list.remove( *it ); //will delete the label and set it to list.current() which _should_ be the next ptr
|
||||
break;
|
||||
if ((*it)->tooClose((*jt)->a)) {
|
||||
if ((*it)->lvl > (*jt)->lvl) {
|
||||
list.remove(*it);
|
||||
it = jt;
|
||||
}
|
||||
else
|
||||
list.remove(*jt);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
|
||||
prevRightY = ty - fmh - fmhD4; //must be after above's "continue"
|
||||
jt = it;
|
||||
++jt;
|
||||
}
|
||||
|
||||
qs = KStringHandler::cPixelSqueeze( qs, fm, width() - x2 );
|
||||
//used in next two steps
|
||||
bool varySizes;
|
||||
//**** should perhaps use doubles
|
||||
int *sizes = new int [ m_map.m_visibleDepth + 1 ]; //**** make sizes an array of floats I think instead (or doubles)
|
||||
|
||||
x3 = width() - fm.width( qs )
|
||||
- LABEL_HMARGIN //outer margin
|
||||
- LABEL_TEXT_HMARGIN //margin between strut and text
|
||||
//- ((*it)->lvl - startLevel) * LABEL_HMARGIN; //indentation
|
||||
;
|
||||
if( x3 < x2 ) x3 = x2;
|
||||
tx = x3 + LABEL_TEXT_HMARGIN;
|
||||
do
|
||||
{
|
||||
//3. Calculate font sizes
|
||||
|
||||
} else {
|
||||
{
|
||||
//determine current range of levels to draw for
|
||||
uint range = 0;
|
||||
|
||||
if( x2 < 0 || ty > height() || x2 > x1 )
|
||||
for (it.toFirst(); it != 0; ++it)
|
||||
{
|
||||
//skip this strut
|
||||
list.remove( *it ); //will delete the label and set it to list.current() which _should_ be the next ptr
|
||||
break;
|
||||
uint lvl = (*it)->lvl;
|
||||
if (lvl > range)
|
||||
range = lvl;
|
||||
|
||||
//**** better way would just be to assign if nothing is range
|
||||
}
|
||||
|
||||
prevLeftY = ty + fmh - fmhD4;
|
||||
range -= startLevel; //range 0 means 1 level of labels
|
||||
|
||||
qs = KStringHandler::cPixelSqueeze( qs, fm, x2 );
|
||||
varySizes = Config::varyLabelFontSizes && (range != 0);
|
||||
|
||||
//**** needs a little tweaking:
|
||||
if (varySizes)
|
||||
{
|
||||
//create an array of font sizes for various levels
|
||||
//will exceed normal font pitch automatically if necessary, but not minPitch
|
||||
//**** this needs to be checked lots
|
||||
|
||||
//**** what if this is negative (min size gtr than default size)
|
||||
uint step = (paint.font().pointSize() - Config::minFontPitch) / range;
|
||||
if (step == 0)
|
||||
step = 1;
|
||||
|
||||
for (uint x = range + startLevel, y = Config::minFontPitch; x >= startLevel; y += step, --x)
|
||||
sizes[x] = y;
|
||||
}
|
||||
}
|
||||
|
||||
//4. determine label co-ordinates
|
||||
|
||||
int x1, y1, x2, y2, x3, tx, ty; //coords
|
||||
double sinra, cosra, ra; //angles
|
||||
|
||||
int cx = m_map.width() / 2 + m_offset.x(); //centre relative to canvas
|
||||
int cy = m_map.height() / 2 + m_offset.y();
|
||||
|
||||
int spacer, preSpacer = int(m_map.m_ringBreadth * 0.5) + m_map.m_innerRadius;
|
||||
int fullStrutLength = (m_map.width() - m_map.MAP_2MARGIN) / 2 + LABEL_MAP_SPACER; //full length of a strut from map center
|
||||
|
||||
int prevLeftY = 0;
|
||||
int prevRightY = height();
|
||||
|
||||
bool rightSide;
|
||||
|
||||
QFont font;
|
||||
|
||||
for (it.toFirst(); it != 0; ++it)
|
||||
{
|
||||
//** bear in mind that text is drawn with QPoint param as BOTTOM left corner of text box
|
||||
QString qs = (*it)->segment->file()->name();
|
||||
if (varySizes)
|
||||
font.setPointSize(sizes[(*it)->lvl]);
|
||||
QFontMetrics fm(font);
|
||||
int fmh = fm.height(); //used to ensure label texts don't overlap
|
||||
int fmhD4 = fmh / 4;
|
||||
|
||||
fmh += LABEL_TEXT_VMARGIN;
|
||||
|
||||
rightSide = ((*it)->a < 1440 || (*it)->a > 4320);
|
||||
|
||||
ra = M_PI/2880 * (*it)->a; //convert to radians
|
||||
sincos(ra, &sinra, &cosra);
|
||||
|
||||
|
||||
spacer = preSpacer + m_map.m_ringBreadth * (*it)->lvl;
|
||||
|
||||
x1 = cx + (int)(cosra * spacer);
|
||||
y1 = cy - (int)(sinra * spacer);
|
||||
y2 = y1 - (int)(sinra * (fullStrutLength - spacer));
|
||||
|
||||
if (rightSide) { //righthand side, going upwards
|
||||
if (y2 > prevRightY /*- fmh*/) //then it is too low, needs to be drawn higher
|
||||
y2 = prevRightY /*- fmh*/;
|
||||
}
|
||||
else //lefthand side, going downwards
|
||||
if (y2 < prevLeftY/* + fmh*/) //then we're too high, need to be drawn lower
|
||||
y2 = prevLeftY /*+ fmh*/;
|
||||
|
||||
x2 = x1 - int(double(y2 - y1) / tan(ra));
|
||||
ty = y2 + fmhD4;
|
||||
|
||||
|
||||
if (rightSide) {
|
||||
if (x2 > width() || ty < fmh || x2 < x1) {
|
||||
//skip this strut
|
||||
//**** don't duplicate this code
|
||||
list.remove(*it); //will delete the label and set it to list.current() which _should_ be the next ptr
|
||||
break;
|
||||
}
|
||||
|
||||
prevRightY = ty - fmh - fmhD4; //must be after above's "continue"
|
||||
|
||||
qs = fm.elidedText(qs, Qt::ElideMiddle, width() - x2);
|
||||
|
||||
x3 = width() - fm.width(qs)
|
||||
- LABEL_HMARGIN //outer margin
|
||||
- LABEL_TEXT_HMARGIN //margin between strut and text
|
||||
//- ((*it)->lvl - startLevel) * LABEL_HMARGIN; //indentation
|
||||
;
|
||||
if (x3 < x2) x3 = x2;
|
||||
tx = x3 + LABEL_TEXT_HMARGIN;
|
||||
|
||||
tx = fm.width( qs ) + LABEL_HMARGIN/* + ((*it)->lvl - startLevel) * LABEL_HMARGIN*/;
|
||||
if( tx > x2 ) { //text is too long
|
||||
tx = LABEL_HMARGIN + x2 - tx; //some text will be lost from sight
|
||||
x3 = x2; //no text margin (right side of text here)
|
||||
} else {
|
||||
x3 = tx + LABEL_TEXT_HMARGIN;
|
||||
tx = LABEL_HMARGIN /*+ ((*it)->lvl - startLevel) * LABEL_HMARGIN*/;
|
||||
|
||||
if (x2 < 0 || ty > height() || x2 > x1)
|
||||
{
|
||||
//skip this strut
|
||||
list.remove(*it); //will delete the label and set it to list.current() which _should_ be the next ptr
|
||||
break;
|
||||
}
|
||||
|
||||
prevLeftY = ty + fmh - fmhD4;
|
||||
|
||||
qs = fm.elidedText(qs, Qt::ElideMiddle, x2);
|
||||
|
||||
//**** needs a little tweaking:
|
||||
|
||||
tx = fm.width(qs) + LABEL_HMARGIN/* + ((*it)->lvl - startLevel) * LABEL_HMARGIN*/;
|
||||
if (tx > x2) { //text is too long
|
||||
tx = LABEL_HMARGIN + x2 - tx; //some text will be lost from sight
|
||||
x3 = x2; //no text margin (right side of text here)
|
||||
} else {
|
||||
x3 = tx + LABEL_TEXT_HMARGIN;
|
||||
tx = LABEL_HMARGIN /*+ ((*it)->lvl - startLevel) * LABEL_HMARGIN*/;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(*it)->x1 = x1;
|
||||
(*it)->y1 = y1;
|
||||
(*it)->x2 = x2;
|
||||
(*it)->y2 = y2;
|
||||
(*it)->x3 = x3;
|
||||
(*it)->tx = tx;
|
||||
(*it)->ty = ty;
|
||||
(*it)->qs = qs;
|
||||
}
|
||||
(*it)->x1 = x1;
|
||||
(*it)->y1 = y1;
|
||||
(*it)->x2 = x2;
|
||||
(*it)->y2 = y2;
|
||||
(*it)->x3 = x3;
|
||||
(*it)->tx = tx;
|
||||
(*it)->ty = ty;
|
||||
(*it)->qs = qs;
|
||||
}
|
||||
|
||||
//if an element is deleted at this stage, we need to do this whole
|
||||
//iteration again, thus the following loop
|
||||
//**** in rare case that deleted label was last label in top level
|
||||
// and last in labelList too, this will not work as expected (not critical)
|
||||
//if an element is deleted at this stage, we need to do this whole
|
||||
//iteration again, thus the following loop
|
||||
//**** in rare case that deleted label was last label in top level
|
||||
// and last in labelList too, this will not work as expected (not critical)
|
||||
|
||||
} while( it != 0 );
|
||||
} while (it != 0);
|
||||
|
||||
|
||||
//5. Render labels
|
||||
//5. Render labels
|
||||
|
||||
paint.setPen( QPen( Qt::black, 1 ) );
|
||||
paint.setPen(QPen(Qt::black, 1));
|
||||
|
||||
for( it.toFirst(); it != 0; ++it )
|
||||
{
|
||||
if( varySizes ) {
|
||||
//**** how much overhead in making new QFont each time?
|
||||
// (implicate sharing remember)
|
||||
QFont font = paint.font();
|
||||
font.setPointSize( sizes[(*it)->lvl] );
|
||||
paint.setFont( font );
|
||||
}
|
||||
for (it.toFirst(); it != 0; ++it)
|
||||
{
|
||||
if (varySizes) {
|
||||
//**** how much overhead in making new QFont each time?
|
||||
// (implicate sharing remember)
|
||||
QFont font = paint.font();
|
||||
font.setPointSize(sizes[(*it)->lvl]);
|
||||
paint.setFont(font);
|
||||
}
|
||||
|
||||
paint.drawEllipse( (*it)->x1 - 3, (*it)->y1 - 3, 7, 7 ); //**** CPU intensive! better to use a pixmap
|
||||
paint.drawLine( (*it)->x1, (*it)->y1, (*it)->x2, (*it)->y2 );
|
||||
paint.drawLine( (*it)->x2, (*it)->y2, (*it)->x3, (*it)->y2);
|
||||
paint.drawText( (*it)->tx, (*it)->ty, (*it)->qs );
|
||||
}
|
||||
paint.drawEllipse((*it)->x1 - 3, (*it)->y1 - 3, 7, 7); //**** CPU intensive! better to use a pixmap
|
||||
paint.drawLine((*it)->x1, (*it)->y1, (*it)->x2, (*it)->y2);
|
||||
paint.drawLine((*it)->x2, (*it)->y2, (*it)->x3, (*it)->y2);
|
||||
paint.drawText((*it)->tx, (*it)->ty, (*it)->qs);
|
||||
}
|
||||
|
||||
delete [] sizes;
|
||||
delete [] sizes;
|
||||
}
|
||||
|
|
|
@ -1,268 +1,277 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include <kcursor.h> //make()
|
||||
#include <kglobalsettings.h> //kdeColours
|
||||
#include <kimageeffect.h> //desaturate()
|
||||
#include <qapplication.h> //make()
|
||||
#include <qimage.h> //make() & paint()
|
||||
#include <qfont.h> //ctor
|
||||
#include <qfontmetrics.h> //ctor
|
||||
#include <qpainter.h>
|
||||
#include <KCursor> //make()
|
||||
#include <KDebug>
|
||||
#include <KGlobalSettings> //kdeColours
|
||||
#include <qimageblitz/qimageblitz.h> //desaturate()
|
||||
#include <QApplication> //make()
|
||||
#include <QImage> //make() & paint()
|
||||
#include <QFont> //ctor
|
||||
#include <QFontMetrics> //ctor
|
||||
#include <QPainter>
|
||||
#include <Q3PointArray>
|
||||
|
||||
#include "builder.h"
|
||||
#include "Config.h"
|
||||
#include "debug.h"
|
||||
#include "fileTree.h"
|
||||
#include "part/Config.h"
|
||||
#include "part/fileTree.h"
|
||||
#define SINCOS_H_IMPLEMENTATION (1)
|
||||
#include "sincos.h"
|
||||
#include "widget.h"
|
||||
|
||||
#define COLOR_GREY QColor( 0, 0, 140, QColor::Hsv )
|
||||
|
||||
|
||||
RadialMap::Map::Map()
|
||||
: m_signature( 0 )
|
||||
, m_ringBreadth( MIN_RING_BREADTH )
|
||||
, m_innerRadius( 0 )
|
||||
, m_visibleDepth( DEFAULT_RING_DEPTH )
|
||||
: m_signature(0)
|
||||
, m_visibleDepth(DEFAULT_RING_DEPTH)
|
||||
, m_pixmap()
|
||||
, m_ringBreadth(MIN_RING_BREADTH)
|
||||
, m_innerRadius(0)
|
||||
{
|
||||
//FIXME this is all broken. No longer is a maximum depth!
|
||||
const int fmh = QFontMetrics( QFont() ).height();
|
||||
const int fmh = QFontMetrics(QFont()).height();
|
||||
const int fmhD4 = fmh / 4;
|
||||
MAP_2MARGIN = 2 * ( fmh - (fmhD4 - LABEL_MAP_SPACER) ); //margin is dependent on fitting in labels at top and bottom
|
||||
MAP_2MARGIN = 2 * (fmh - (fmhD4 - LABEL_MAP_SPACER)); //margin is dependent on fitting in labels at top and bottom
|
||||
}
|
||||
|
||||
RadialMap::Map::~Map()
|
||||
{
|
||||
delete [] m_signature;
|
||||
delete [] m_signature;
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Map::invalidate( const bool desaturateTheImage )
|
||||
void RadialMap::Map::invalidate(const bool desaturateTheImage)
|
||||
{
|
||||
DEBUG_ANNOUNCE
|
||||
delete [] m_signature;
|
||||
m_signature = 0;
|
||||
|
||||
delete [] m_signature;
|
||||
m_signature = 0;
|
||||
if (desaturateTheImage)
|
||||
{
|
||||
QImage img = m_pixmap.toImage();
|
||||
|
||||
if( desaturateTheImage )
|
||||
{
|
||||
QImage img = this->convertToImage();
|
||||
Blitz::desaturate(img, 0.7);
|
||||
Blitz::grayscale(img, true);
|
||||
|
||||
KImageEffect::desaturate( img, 0.7 );
|
||||
KImageEffect::toGray( img, true );
|
||||
m_pixmap.fromImage(img);
|
||||
}
|
||||
|
||||
this->convertFromImage( img );
|
||||
}
|
||||
|
||||
m_visibleDepth = Config::defaultRingDepth;
|
||||
m_visibleDepth = Config::defaultRingDepth;
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Map::make( const Directory *tree, bool refresh )
|
||||
void RadialMap::Map::make(const Directory *tree, bool refresh)
|
||||
{
|
||||
DEBUG_ANNOUNCE
|
||||
//**** determineText seems pointless optimisation
|
||||
// but is it good to keep the text consistent?
|
||||
// even if it makes it a lie?
|
||||
|
||||
//**** determineText seems pointless optimization
|
||||
// but is it good to keep the text consistent?
|
||||
// even if it makes it a lie?
|
||||
//slow operation so set the wait cursor
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
//slow operation so set the wait cursor
|
||||
QApplication::setOverrideCursor( KCursor::waitCursor() );
|
||||
{
|
||||
//build a signature of visible components
|
||||
delete [] m_signature;
|
||||
Builder builder(this, tree, refresh);
|
||||
}
|
||||
|
||||
{
|
||||
//build a signature of visible components
|
||||
delete [] m_signature;
|
||||
Builder builder( this, tree, refresh );
|
||||
}
|
||||
//colour the segments
|
||||
colorise();
|
||||
|
||||
//colour the segments
|
||||
colorise();
|
||||
//determine centerText
|
||||
if (!refresh)
|
||||
{
|
||||
int i;
|
||||
for (i = 2; i > 0; --i)
|
||||
if (tree->size() > File::DENOMINATOR[i])
|
||||
break;
|
||||
|
||||
//determine centerText
|
||||
if( !refresh )
|
||||
{
|
||||
int i;
|
||||
for( i = 2; i > 0; --i )
|
||||
if( tree->size() > File::DENOMINATOR[i] )
|
||||
break;
|
||||
m_centerText = tree->humanReadableSize((File::UnitPrefix)i);
|
||||
}
|
||||
|
||||
m_centerText = tree->humanReadableSize( (File::UnitPrefix)i );
|
||||
}
|
||||
//paint the pixmap
|
||||
aaPaint();
|
||||
|
||||
//paint the pixmap
|
||||
aaPaint();
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Map::setRingBreadth()
|
||||
void RadialMap::Map::setRingBreadth()
|
||||
{
|
||||
//FIXME called too many times on creation
|
||||
//FIXME called too many times on creation
|
||||
|
||||
m_ringBreadth = (height() - MAP_2MARGIN) / (2 * m_visibleDepth + 4);
|
||||
m_ringBreadth = (height() - MAP_2MARGIN) / (2 * m_visibleDepth + 4);
|
||||
|
||||
if( m_ringBreadth < MIN_RING_BREADTH )
|
||||
m_ringBreadth = MIN_RING_BREADTH;
|
||||
if (m_ringBreadth < MIN_RING_BREADTH)
|
||||
m_ringBreadth = MIN_RING_BREADTH;
|
||||
|
||||
else if( m_ringBreadth > MAX_RING_BREADTH )
|
||||
m_ringBreadth = MAX_RING_BREADTH;
|
||||
else if (m_ringBreadth > MAX_RING_BREADTH)
|
||||
m_ringBreadth = MAX_RING_BREADTH;
|
||||
}
|
||||
|
||||
bool
|
||||
RadialMap::Map::resize( const QRect &rect )
|
||||
bool RadialMap::Map::resize(const QRect &rect)
|
||||
{
|
||||
//there's a MAP_2MARGIN border
|
||||
//there's a MAP_2MARGIN border
|
||||
|
||||
#define mw width()
|
||||
#define mh height()
|
||||
#define cw rect.width()
|
||||
#define ch rect.height()
|
||||
#define mw width()
|
||||
#define mh height()
|
||||
#define cw rect.width()
|
||||
#define ch rect.height()
|
||||
|
||||
if( cw < mw || ch < mh || (cw > mw && ch > mh) )
|
||||
{
|
||||
uint size = (( cw < ch ) ? cw : ch) - MAP_2MARGIN;
|
||||
if (cw < mw || ch < mh || (cw > mw && ch > mh))
|
||||
{
|
||||
uint size = ((cw < ch) ? cw : ch) - MAP_2MARGIN;
|
||||
|
||||
//this also causes uneven sizes to always resize when resizing but map is small in that dimension
|
||||
//size -= size % 2; //even sizes mean less staggered non-antialiased resizing
|
||||
//this also causes uneven sizes to always resize when resizing but map is small in that dimension
|
||||
//size -= size % 2; //even sizes mean less staggered non-antialiased resizing
|
||||
|
||||
{
|
||||
const uint minSize = MIN_RING_BREADTH * 2 * (m_visibleDepth + 2);
|
||||
const uint mD2 = MAP_2MARGIN / 2;
|
||||
{
|
||||
const uint minSize = MIN_RING_BREADTH * 2 * (m_visibleDepth + 2);
|
||||
|
||||
if( size < minSize ) size = minSize;
|
||||
if (size < minSize)
|
||||
size = minSize;
|
||||
|
||||
//this QRect is used by paint()
|
||||
m_rect.setRect( mD2, mD2, size, size );
|
||||
}
|
||||
//this QRect is used by paint()
|
||||
m_rect.setRect(0,0,size,size);
|
||||
}
|
||||
|
||||
//resize the pixmap
|
||||
size += MAP_2MARGIN;
|
||||
KPixmap::resize( size, size );
|
||||
//resize the pixmap
|
||||
size += MAP_2MARGIN;
|
||||
m_pixmap = QPixmap(size, size);
|
||||
|
||||
// for summary widget this is a good optimization as it happens
|
||||
if (KPixmap::isNull())
|
||||
return false;
|
||||
// for summary widget this is a good optimisation as it happens
|
||||
if (m_pixmap.isNull())
|
||||
return false;
|
||||
|
||||
if( m_signature != 0 )
|
||||
{
|
||||
setRingBreadth();
|
||||
paint();
|
||||
}
|
||||
else fill(); //FIXME I don't like having to do this..
|
||||
if (m_signature != 0)
|
||||
{
|
||||
setRingBreadth();
|
||||
paint();
|
||||
}
|
||||
else m_pixmap.fill(); //FIXME I don't like having to do this..
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#undef mw
|
||||
#undef mh
|
||||
#undef cw
|
||||
#undef ch
|
||||
#undef mw
|
||||
#undef mh
|
||||
#undef cw
|
||||
#undef ch
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Map::colorise()
|
||||
void RadialMap::Map::colorise()
|
||||
{
|
||||
QColor cp, cb;
|
||||
double darkness = 1;
|
||||
double contrast = (double)Config::contrast / (double)100;
|
||||
int h, s1, s2, v1, v2;
|
||||
QColor cp, cb;
|
||||
double darkness = 1;
|
||||
double contrast = (double)Config::contrast / (double)100;
|
||||
int h, s1, s2, v1, v2;
|
||||
|
||||
QColor kdeColour[2] = { KGlobalSettings::inactiveTitleColor(), KGlobalSettings::activeTitleColor() };
|
||||
QColor kdeColour[2] = { KGlobalSettings::inactiveTitleColor(), KGlobalSettings::activeTitleColor() };
|
||||
|
||||
double deltaRed = (double)(kdeColour[0].red() - kdeColour[1].red()) / 2880; //2880 for semicircle
|
||||
double deltaGreen = (double)(kdeColour[0].green() - kdeColour[1].green()) / 2880;
|
||||
double deltaBlue = (double)(kdeColour[0].blue() - kdeColour[1].blue()) / 2880;
|
||||
double deltaRed = (double)(kdeColour[0].red() - kdeColour[1].red()) / 2880; //2880 for semicircle
|
||||
double deltaGreen = (double)(kdeColour[0].green() - kdeColour[1].green()) / 2880;
|
||||
double deltaBlue = (double)(kdeColour[0].blue() - kdeColour[1].blue()) / 2880;
|
||||
|
||||
for( uint i = 0; i <= m_visibleDepth; ++i, darkness += 0.04 )
|
||||
{
|
||||
for( Iterator<Segment> it = m_signature[i].iterator(); it != m_signature[i].end(); ++it )
|
||||
{
|
||||
switch( Config::scheme )
|
||||
for (uint i = 0; i <= m_visibleDepth; ++i, darkness += 0.04)
|
||||
{
|
||||
for (Iterator<Segment> it = m_signature[i].iterator(); it != m_signature[i].end(); ++it)
|
||||
{
|
||||
switch (Config::scheme)
|
||||
{
|
||||
case 2000: //HACK for summary view
|
||||
|
||||
if( (*it)->file()->name() == "Used" ) {
|
||||
cb = QApplication::palette().active().color( QColorGroup::Highlight );
|
||||
cb.getHsv( &h, &s1, &v1 );
|
||||
if ((*it)->file()->name() == "Used") {
|
||||
cb = QApplication::palette().highlight().color();
|
||||
cb.getHsv(&h, &s1, &v1);
|
||||
|
||||
if( s1 > 80 )
|
||||
s1 = 80;
|
||||
if (s1 > 80)
|
||||
s1 = 80;
|
||||
|
||||
v2 = v1 - int(contrast * v1);
|
||||
s2 = s1 + int(contrast * (255 - s1));
|
||||
v2 = v1 - int(contrast * v1);
|
||||
s2 = s1 + int(contrast * (255 - s1));
|
||||
|
||||
cb.setHsv( h, s1, v1 );
|
||||
cp.setHsv( h, s2, v2 );
|
||||
}
|
||||
else {
|
||||
cp = Qt::gray;
|
||||
cb = Qt::white;
|
||||
}
|
||||
cb.setHsv(h, s1, v1);
|
||||
cp.setHsv(h, s2, v2);
|
||||
}
|
||||
else {
|
||||
cp = Qt::gray;
|
||||
cb = Qt::white;
|
||||
}
|
||||
|
||||
(*it)->setPalette( cp, cb );
|
||||
(*it)->setPalette(cp, cb);
|
||||
|
||||
continue;
|
||||
continue;
|
||||
|
||||
case Filelight::KDE:
|
||||
{
|
||||
//gradient will work by figuring out rgb delta values for 360 degrees
|
||||
//then each component is angle*delta
|
||||
//gradient will work by figuring out rgb delta values for 360 degrees
|
||||
//then each component is angle*delta
|
||||
|
||||
int a = (*it)->start();
|
||||
int a = (*it)->start();
|
||||
|
||||
if( a > 2880 ) a = 2880 - (a - 2880);
|
||||
if (a > 2880) a = 2880 - (a - 2880);
|
||||
|
||||
h = (int)(deltaRed * a) + kdeColour[1].red();
|
||||
s1 = (int)(deltaGreen * a) + kdeColour[1].green();
|
||||
v1 = (int)(deltaBlue * a) + kdeColour[1].blue();
|
||||
h = (int)(deltaRed * a) + kdeColour[1].red();
|
||||
s1 = (int)(deltaGreen * a) + kdeColour[1].green();
|
||||
v1 = (int)(deltaBlue * a) + kdeColour[1].blue();
|
||||
|
||||
cb.setRgb( h, s1, v1 );
|
||||
cb.getHsv( &h, &s1, &v1 );
|
||||
cb.setRgb(h, s1, v1);
|
||||
cb.getHsv(&h, &s1, &v1);
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case Filelight::HighContrast:
|
||||
|
||||
cp.setHsv( 0, 0, 0 ); //values of h, s and v are irrelevant
|
||||
cb.setHsv( 180, 0, int(255.0 * contrast) );
|
||||
(*it)->setPalette( cp, cb );
|
||||
continue;
|
||||
cp.setHsv(0, 0, 0); //values of h, s and v are irrelevant
|
||||
cb.setHsv(180, 0, int(255.0 * contrast));
|
||||
(*it)->setPalette(cp, cb);
|
||||
continue;
|
||||
|
||||
default:
|
||||
h = int((*it)->start() / 16);
|
||||
s1 = 160;
|
||||
v1 = (int)(255.0 / darkness); //****doing this more often than once seems daft!
|
||||
h = int((*it)->start() / 16);
|
||||
s1 = 160;
|
||||
v1 = (int)(255.0 / darkness); //****doing this more often than once seems daft!
|
||||
}
|
||||
|
||||
v2 = v1 - int(contrast * v1);
|
||||
s2 = s1 + int(contrast * (255 - s1));
|
||||
|
||||
if( s1 < 80 ) s1 = 80; //can fall too low and makes contrast between the files hard to discern
|
||||
if (s1 < 80) s1 = 80; //can fall too low and makes contrast between the files hard to discern
|
||||
|
||||
if( (*it)->isFake() ) //multi-file
|
||||
if ((*it)->isFake()) //multi-file
|
||||
{
|
||||
cb.setHsv( h, s2, (v2 < 90) ? 90 : v2 ); //too dark if < 100
|
||||
cp.setHsv( h, 17, v1 );
|
||||
cb.setHsv(h, s2, (v2 < 90) ? 90 : v2); //too dark if < 100
|
||||
cp.setHsv(h, 17, v1);
|
||||
}
|
||||
else if( !(*it)->file()->isDirectory() ) //file
|
||||
else if (!(*it)->file()->isDirectory()) //file
|
||||
{
|
||||
cb.setHsv( h, 17, v1 );
|
||||
cp.setHsv( h, 17, v2 );
|
||||
cb.setHsv(h, 17, v1);
|
||||
cp.setHsv(h, 17, v2);
|
||||
}
|
||||
else //directory
|
||||
{
|
||||
cb.setHsv( h, s1, v1 ); //v was 225
|
||||
cp.setHsv( h, s2, v2 ); //v was 225 - delta
|
||||
cb.setHsv(h, s1, v1); //v was 225
|
||||
cp.setHsv(h, s2, v2); //v was 225 - delta
|
||||
}
|
||||
|
||||
(*it)->setPalette( cp, cb );
|
||||
(*it)->setPalette(cp, cb);
|
||||
|
||||
//TODO:
|
||||
//**** may be better to store KDE colours as H and S and vary V as others
|
||||
//**** perhaps make saturation difference for s2 dependent on contrast too
|
||||
//**** fake segments don't work with highContrast
|
||||
|
@ -271,164 +280,163 @@ RadialMap::Map::colorise()
|
|||
//**** change v1,v2 to vp, vb etc.
|
||||
//**** using percentages is not strictly correct as the eye doesn't work like that
|
||||
//**** darkness factor is not done for kde_colour scheme, and also value for files is incorrect really for files in this scheme as it is not set like rainbow one is
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Map::aaPaint()
|
||||
void RadialMap::Map::aaPaint()
|
||||
{
|
||||
//paint() is called during continuous processes
|
||||
//aaPaint() is not and is slower so set overidecursor (make sets it too)
|
||||
QApplication::setOverrideCursor( KCursor::waitCursor() );
|
||||
paint( Config::antiAliasFactor );
|
||||
QApplication::restoreOverrideCursor();
|
||||
//paint() is called during continuous processes
|
||||
//aaPaint() is not and is slower so set overidecursor (make sets it too)
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
paint(Config::antiAliasFactor);
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Map::paint( unsigned int scaleFactor )
|
||||
void RadialMap::Map::paint(unsigned int scaleFactor)
|
||||
{
|
||||
if (scaleFactor == 0) //just in case
|
||||
scaleFactor = 1;
|
||||
if (scaleFactor == 0) //just in case
|
||||
scaleFactor = 1;
|
||||
|
||||
QPainter paint;
|
||||
QRect rect = m_rect;
|
||||
int step = m_ringBreadth;
|
||||
int excess = -1;
|
||||
QPainter paint;
|
||||
QRect rect = m_rect;
|
||||
int step = m_ringBreadth;
|
||||
int excess = -1;
|
||||
|
||||
//scale the pixmap, or do intelligent distribution of excess to prevent nasty resizing
|
||||
if( scaleFactor > 1 )
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
rect.coords( &x1, &y1, &x2, &y2 );
|
||||
x1 *= scaleFactor;
|
||||
y1 *= scaleFactor;
|
||||
x2 *= scaleFactor;
|
||||
y2 *= scaleFactor;
|
||||
rect.setCoords( x1, y1, x2, y2 );
|
||||
//scale the pixmap, or do intelligent distribution of excess to prevent nasty resizing
|
||||
if (scaleFactor > 1)
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
rect.getCoords(&x1, &y1, &x2, &y2);
|
||||
x1 *= scaleFactor;
|
||||
y1 *= scaleFactor;
|
||||
x2 *= scaleFactor;
|
||||
y2 *= scaleFactor;
|
||||
rect.setCoords(x1, y1, x2, y2);
|
||||
|
||||
step *= scaleFactor;
|
||||
KPixmap::resize( this->size() * (int)scaleFactor );
|
||||
}
|
||||
else if( m_ringBreadth != MAX_RING_BREADTH && m_ringBreadth != MIN_RING_BREADTH ) {
|
||||
excess = rect.width() % m_ringBreadth;
|
||||
++step;
|
||||
}
|
||||
step *= scaleFactor;
|
||||
m_pixmap = QPixmap(m_pixmap.size() * (int)scaleFactor);
|
||||
}
|
||||
else if (m_ringBreadth != MAX_RING_BREADTH && m_ringBreadth != MIN_RING_BREADTH) {
|
||||
excess = rect.width() % m_ringBreadth;
|
||||
++step;
|
||||
}
|
||||
|
||||
//**** best option you can think of is to make the circles slightly less perfect,
|
||||
// ** i.e. slightly eliptic when resizing inbetween
|
||||
//**** best option you can think of is to make the circles slightly less perfect,
|
||||
// ** i.e. slightly eliptic when resizing inbetween
|
||||
|
||||
if (KPixmap::isNull())
|
||||
return;
|
||||
if (m_pixmap.isNull()) {
|
||||
kWarning() << "Refusing to draw on null pixmap.";
|
||||
return;
|
||||
}
|
||||
|
||||
paint.begin( this );
|
||||
paint.begin(&m_pixmap);
|
||||
|
||||
fill(); //erase background
|
||||
m_pixmap.fill(); //erase background
|
||||
|
||||
for( int x = m_visibleDepth; x >= 0; --x )
|
||||
{
|
||||
int width = rect.width() / 2;
|
||||
//clever geometric trick to find largest angle that will give biggest arrow head
|
||||
int a_max = int(acos( (double)width / double((width + 5) * scaleFactor) ) * (180*16 / M_PI));
|
||||
for (int x = m_visibleDepth; x >= 0; --x)
|
||||
{
|
||||
int width = rect.width() / 2;
|
||||
//clever geometric trick to find largest angle that will give biggest arrow head
|
||||
int a_max = int(acos((double)width / double((width + 5) * scaleFactor)) * (180*16 / M_PI));
|
||||
|
||||
for( ConstIterator<Segment> it = m_signature[x].constIterator(); it != m_signature[x].end(); ++it )
|
||||
{
|
||||
//draw the pie segments, most of this code is concerned with drawing the little
|
||||
//arrows on the ends of segments when they have hidden files
|
||||
for (ConstIterator<Segment> it = m_signature[x].constIterator(); it != m_signature[x].end(); ++it)
|
||||
{
|
||||
//draw the pie segments, most of this code is concerned with drawing the little
|
||||
//arrows on the ends of segments when they have hidden files
|
||||
|
||||
paint.setPen( (*it)->pen() );
|
||||
paint.setPen((*it)->pen());
|
||||
|
||||
if( (*it)->hasHiddenChildren() )
|
||||
{
|
||||
//draw arrow head to indicate undisplayed files/directories
|
||||
QPointArray pts( 3 );
|
||||
QPoint pos, cpos = rect.center();
|
||||
int a[3] = { (*it)->start(), (*it)->length(), 0 };
|
||||
|
||||
a[2] = a[0] + (a[1] / 2); //assign to halfway between
|
||||
if( a[1] > a_max )
|
||||
if ((*it)->hasHiddenChildren())
|
||||
{
|
||||
a[1] = a_max;
|
||||
a[0] = a[2] - a_max / 2;
|
||||
//draw arrow head to indicate undisplayed files/directories
|
||||
Q3PointArray pts(3);
|
||||
QPoint pos, cpos = rect.center();
|
||||
int a[3] = { (*it)->start(), (*it)->length(), 0 };
|
||||
|
||||
a[2] = a[0] + (a[1] / 2); //assign to halfway between
|
||||
if (a[1] > a_max)
|
||||
{
|
||||
a[1] = a_max;
|
||||
a[0] = a[2] - a_max / 2;
|
||||
}
|
||||
|
||||
a[1] += a[0];
|
||||
|
||||
for (int i = 0, radius = width; i < 3; ++i)
|
||||
{
|
||||
double ra = M_PI/(180*16) * a[i], sinra, cosra;
|
||||
|
||||
if (i == 2)
|
||||
radius += 5 * scaleFactor;
|
||||
sincos(ra, &sinra, &cosra);
|
||||
pos.rx() = cpos.x() + static_cast<int>(cosra * radius);
|
||||
pos.ry() = cpos.y() - static_cast<int>(sinra * radius);
|
||||
pts.setPoint(i, pos);
|
||||
}
|
||||
|
||||
paint.setBrush((*it)->pen());
|
||||
paint.drawPolygon(pts);
|
||||
}
|
||||
|
||||
a[1] += a[0];
|
||||
paint.setBrush((*it)->brush());
|
||||
paint.drawPie(rect, (*it)->start(), (*it)->length());
|
||||
|
||||
for( int i = 0, radius = width; i < 3; ++i )
|
||||
if ((*it)->hasHiddenChildren())
|
||||
{
|
||||
double ra = M_PI/(180*16) * a[i], sinra, cosra;
|
||||
|
||||
if( i == 2 )
|
||||
radius += 5 * scaleFactor;
|
||||
sincos( ra, &sinra, &cosra );
|
||||
pos.rx() = cpos.x() + static_cast<int>(cosra * radius);
|
||||
pos.ry() = cpos.y() - static_cast<int>(sinra * radius);
|
||||
pts.setPoint( i, pos );
|
||||
//**** code is bloated!
|
||||
paint.save();
|
||||
QPen pen = paint.pen();
|
||||
int width = 2 * scaleFactor;
|
||||
pen.setWidth(width);
|
||||
paint.setPen(pen);
|
||||
QRect rect2 = rect;
|
||||
width /= 2;
|
||||
rect2.adjust(width, width, -width, -width);
|
||||
paint.drawArc(rect2, (*it)->start(), (*it)->length());
|
||||
paint.restore();
|
||||
}
|
||||
}
|
||||
|
||||
paint.setBrush( (*it)->pen() );
|
||||
paint.drawPolygon( pts );
|
||||
}
|
||||
if (excess >= 0) { //excess allows us to resize more smoothly (still crud tho)
|
||||
if (excess < 2) //only decrease rect by more if even number of excesses left
|
||||
--step;
|
||||
excess -= 2;
|
||||
}
|
||||
|
||||
paint.setBrush( (*it)->brush() );
|
||||
paint.drawPie( rect, (*it)->start(), (*it)->length() );
|
||||
rect.adjust(step, step, -step, -step);
|
||||
}
|
||||
|
||||
if( (*it)->hasHiddenChildren() )
|
||||
{
|
||||
//**** code is bloated!
|
||||
paint.save();
|
||||
QPen pen = paint.pen();
|
||||
int width = 2 * scaleFactor;
|
||||
pen.setWidth( width );
|
||||
paint.setPen( pen );
|
||||
QRect rect2 = rect;
|
||||
width /= 2;
|
||||
rect2.addCoords( width, width, -width, -width );
|
||||
paint.drawArc( rect2, (*it)->start(), (*it)->length() );
|
||||
paint.restore();
|
||||
}
|
||||
}
|
||||
// if(excess > 0) rect.addCoords(excess, excess, 0, 0); //ugly
|
||||
|
||||
if( excess >= 0 ) { //excess allows us to resize more smoothly (still crud tho)
|
||||
if( excess < 2 ) //only decrease rect by more if even number of excesses left
|
||||
--step;
|
||||
excess -= 2;
|
||||
}
|
||||
paint.setPen(Qt::gray);
|
||||
paint.setBrush(Qt::white);
|
||||
paint.drawEllipse(rect);
|
||||
if (scaleFactor > 1)
|
||||
{
|
||||
//have to end in order to smoothscale()
|
||||
paint.end();
|
||||
|
||||
rect.addCoords( step, step, -step, -step );
|
||||
}
|
||||
int x1, y1, x2, y2;
|
||||
rect.getCoords(&x1, &y1, &x2, &y2);
|
||||
x1 /= scaleFactor;
|
||||
y1 /= scaleFactor;
|
||||
x2 /= scaleFactor;
|
||||
y2 /= scaleFactor;
|
||||
rect.setCoords(x1, y1, x2, y2);
|
||||
|
||||
// if( excess > 0 ) rect.addCoords( excess, excess, 0, 0 ); //ugly
|
||||
QImage img = m_pixmap.toImage();
|
||||
img = img.scaled(m_pixmap.size() / (int)scaleFactor, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
m_pixmap = QPixmap::fromImage(img);
|
||||
|
||||
paint.setPen( COLOR_GREY );
|
||||
paint.setBrush( Qt::white );
|
||||
paint.drawEllipse( rect );
|
||||
paint.begin(&m_pixmap);
|
||||
paint.setPen(Qt::gray);
|
||||
paint.setBrush(Qt::white);
|
||||
}
|
||||
|
||||
if( scaleFactor > 1 )
|
||||
{
|
||||
//have to end in order to smoothscale()
|
||||
paint.end();
|
||||
paint.drawText(rect, Qt::AlignCenter, m_centerText);
|
||||
|
||||
int x1, y1, x2, y2;
|
||||
rect.coords( &x1, &y1, &x2, &y2 );
|
||||
x1 /= scaleFactor;
|
||||
y1 /= scaleFactor;
|
||||
x2 /= scaleFactor;
|
||||
y2 /= scaleFactor;
|
||||
rect.setCoords( x1, y1, x2, y2 );
|
||||
m_innerRadius = rect.width() / 2; //rect.width should be multiple of 2
|
||||
|
||||
QImage img = this->convertToImage();
|
||||
img = img.smoothScale( this->size() / (int)scaleFactor );
|
||||
this->convertFromImage( img );
|
||||
|
||||
paint.begin( this );
|
||||
paint.setPen( COLOR_GREY );
|
||||
paint.setBrush( Qt::white );
|
||||
}
|
||||
|
||||
paint.drawText( rect, Qt::AlignCenter, m_centerText );
|
||||
|
||||
m_innerRadius = rect.width() / 2; //rect.width should be multiple of 2
|
||||
|
||||
paint.end();
|
||||
paint.end();
|
||||
}
|
||||
|
|
79
src/part/radialMap/map.h
Normal file
79
src/part/radialMap/map.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef MAP_H
|
||||
#define MAP_H
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
|
||||
namespace RadialMap {
|
||||
class Segment;
|
||||
|
||||
class Map
|
||||
{
|
||||
public:
|
||||
Map();
|
||||
~Map();
|
||||
|
||||
void make(const Directory *, bool = false);
|
||||
bool resize(const QRect&);
|
||||
|
||||
bool isNull() const {
|
||||
return (m_signature == 0);
|
||||
}
|
||||
void invalidate(const bool);
|
||||
|
||||
int height() const {
|
||||
return m_rect.height();
|
||||
}
|
||||
int width() const {
|
||||
return m_rect.width();
|
||||
}
|
||||
|
||||
QPixmap getPixmap() {
|
||||
return m_pixmap;
|
||||
}
|
||||
|
||||
friend class Builder;
|
||||
friend class Widget;
|
||||
|
||||
private:
|
||||
void paint(uint = 1);
|
||||
void aaPaint();
|
||||
void colorise();
|
||||
void setRingBreadth();
|
||||
|
||||
Chain<Segment> *m_signature;
|
||||
|
||||
QRect m_rect;
|
||||
uint m_visibleDepth; ///visible level depth of system
|
||||
QPixmap m_pixmap;
|
||||
uint m_ringBreadth; ///ring breadth
|
||||
uint m_innerRadius; ///radius of inner circle
|
||||
QString m_centerText;
|
||||
|
||||
uint MAP_2MARGIN;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,8 +1,26 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef RADIAL_MAP_H
|
||||
#define RADIAL_MAP_H
|
||||
#ifndef RADIALMAP_H
|
||||
#define RADIALMAP_H
|
||||
|
||||
#include <qcolor.h>
|
||||
|
||||
|
@ -11,41 +29,62 @@ class File;
|
|||
|
||||
namespace RadialMap
|
||||
{
|
||||
class Segment //all angles are in 16ths of degrees
|
||||
{
|
||||
public:
|
||||
Segment( const File *f, uint s, uint l, bool isFake = false )
|
||||
: m_angleStart( s )
|
||||
, m_angleSegment( l )
|
||||
, m_file( f )
|
||||
, m_hasHiddenChildren( false )
|
||||
, m_fake( isFake ) {}
|
||||
~Segment();
|
||||
class Segment //all angles are in 16ths of degrees
|
||||
{
|
||||
public:
|
||||
Segment(const File *f, uint s, uint l, bool isFake = false)
|
||||
: m_angleStart(s)
|
||||
, m_angleSegment(l)
|
||||
, m_file(f)
|
||||
, m_hasHiddenChildren(false)
|
||||
, m_fake(isFake) {}
|
||||
~Segment();
|
||||
|
||||
uint start() const { return m_angleStart; }
|
||||
uint length() const { return m_angleSegment; }
|
||||
uint end() const { return m_angleStart + m_angleSegment; }
|
||||
const File *file() const { return m_file; }
|
||||
const QColor& pen() const { return m_pen; }
|
||||
const QColor& brush() const { return m_brush; }
|
||||
uint start() const {
|
||||
return m_angleStart;
|
||||
}
|
||||
uint length() const {
|
||||
return m_angleSegment;
|
||||
}
|
||||
uint end() const {
|
||||
return m_angleStart + m_angleSegment;
|
||||
}
|
||||
const File *file() const {
|
||||
return m_file;
|
||||
}
|
||||
const QColor& pen() const {
|
||||
return m_pen;
|
||||
}
|
||||
const QColor& brush() const {
|
||||
return m_brush;
|
||||
}
|
||||
|
||||
bool isFake() const { return m_fake; }
|
||||
bool hasHiddenChildren() const { return m_hasHiddenChildren; }
|
||||
bool isFake() const {
|
||||
return m_fake;
|
||||
}
|
||||
bool hasHiddenChildren() const {
|
||||
return m_hasHiddenChildren;
|
||||
}
|
||||
|
||||
bool intersects( uint a ) const { return ( ( a >= start() ) && ( a < end() ) ); }
|
||||
bool intersects(uint a) const {
|
||||
return ((a >= start()) && (a < end()));
|
||||
}
|
||||
|
||||
friend class Map;
|
||||
friend class Builder;
|
||||
friend class Map;
|
||||
friend class Builder;
|
||||
|
||||
private:
|
||||
void setPalette( const QColor &p, const QColor &b ) { m_pen = p; m_brush = b; }
|
||||
private:
|
||||
void setPalette(const QColor &p, const QColor &b) {
|
||||
m_pen = p;
|
||||
m_brush = b;
|
||||
}
|
||||
|
||||
const uint m_angleStart, m_angleSegment;
|
||||
const File* const m_file;
|
||||
QColor m_pen, m_brush;
|
||||
bool m_hasHiddenChildren;
|
||||
const bool m_fake;
|
||||
};
|
||||
const uint m_angleStart, m_angleSegment;
|
||||
const File* const m_file;
|
||||
QColor m_pen, m_brush;
|
||||
bool m_hasHiddenChildren;
|
||||
const bool m_fake;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "fileTree.h"
|
||||
#include "part/fileTree.h"
|
||||
#include "segmentTip.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
@ -9,9 +27,12 @@
|
|||
#include <kglobal.h>
|
||||
#include <kglobalsettings.h>
|
||||
#include <klocale.h>
|
||||
#include <kpixmapeffect.h>
|
||||
#include <qpainter.h>
|
||||
|
||||
#include <qimageblitz/qimageblitz.h>
|
||||
#include <QPainter>
|
||||
#include <qtooltip.h> //for its palette
|
||||
//Added by qt3to4:
|
||||
#include <QEvent>
|
||||
|
||||
|
||||
|
||||
|
@ -20,29 +41,30 @@ namespace RadialMap {
|
|||
|
||||
bool isBackingStoreActive()
|
||||
{
|
||||
// # xdpyinfo | grep backing
|
||||
//TODO: THIS IS UGLY!
|
||||
// # xdpyinfo | grep backing
|
||||
// options: backing-store YES, save-unders YES
|
||||
|
||||
char buffer[4096];
|
||||
FILE *xdpyinfo = popen( "xdpyinfo", "r" );
|
||||
int const N = fread( (void*)buffer, sizeof(char), 4096, xdpyinfo );
|
||||
buffer[ N ] = '\0';
|
||||
pclose( xdpyinfo );
|
||||
FILE *xdpyinfo = popen("xdpyinfo", "r");
|
||||
int const N = fread((void*)buffer, sizeof(char), 4096, xdpyinfo);
|
||||
buffer[N] = '\0';
|
||||
pclose(xdpyinfo);
|
||||
|
||||
return QString::fromLocal8Bit( buffer ).contains( "backing-store YES" );
|
||||
return QString::fromLocal8Bit(buffer).contains("backing-store YES");
|
||||
}
|
||||
|
||||
|
||||
SegmentTip::SegmentTip( uint h )
|
||||
: QWidget( 0, 0, WNoAutoErase | WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WStyle_StaysOnTop | WX11BypassWM )
|
||||
, m_cursorHeight( -h )
|
||||
, m_backing_store( isBackingStoreActive() )
|
||||
SegmentTip::SegmentTip(uint h)
|
||||
: QWidget(0, Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint)
|
||||
, m_cursorHeight(-h)
|
||||
, m_backing_store(isBackingStoreActive())
|
||||
{
|
||||
setBackgroundMode( Qt::NoBackground );
|
||||
/* setBackgroundMode(Qt::NoBackground); */
|
||||
}
|
||||
|
||||
void
|
||||
SegmentTip::moveTo( QPoint p, const QWidget &canvas, bool placeAbove )
|
||||
SegmentTip::moveTo(QPoint p, QWidget &canvas, bool placeAbove)
|
||||
{
|
||||
//**** this function is very slow and seems to be visibly influenced by operations like mapFromGlobal() (who knows why!)
|
||||
// ** so any improvements are much desired
|
||||
|
@ -51,7 +73,7 @@ SegmentTip::moveTo( QPoint p, const QWidget &canvas, bool placeAbove )
|
|||
p.rx() -= rect().center().x();
|
||||
p.ry() -= (placeAbove ? 8 + height() : m_cursorHeight - 8);
|
||||
|
||||
const QRect screen = KGlobalSettings::desktopGeometry( parentWidget() );
|
||||
const QRect screen = KGlobalSettings::desktopGeometry(parentWidget());
|
||||
|
||||
const int x = p.x();
|
||||
const int y = p.y();
|
||||
|
@ -60,114 +82,114 @@ SegmentTip::moveTo( QPoint p, const QWidget &canvas, bool placeAbove )
|
|||
const int sw = screen.width();
|
||||
const int sh = screen.height();
|
||||
|
||||
if( x < 0 ) p.setX( 0 );
|
||||
if( y < 0 ) p.setY( 0 );
|
||||
if( x2 > sw ) p.rx() -= x2 - sw;
|
||||
if( y2 > sh ) p.ry() -= y2 - sh;
|
||||
if (x < 0 ) p.setX(0);
|
||||
if (y < 0 ) p.setY(0);
|
||||
if (x2 > sw) p.rx() -= x2 - sw;
|
||||
if (y2 > sh) p.ry() -= y2 - sh;
|
||||
|
||||
|
||||
//I'm using this QPoint to determine where to offset the bitBlt in m_pixmap
|
||||
QPoint offset = canvas.mapToGlobal( QPoint() ) - p;
|
||||
if( offset.x() < 0 ) offset.setX( 0 );
|
||||
if( offset.y() < 0 ) offset.setY( 0 );
|
||||
QPoint offset = canvas.mapToGlobal(QPoint()) - p;
|
||||
if (offset.x() < 0) offset.setX(0);
|
||||
if (offset.y() < 0) offset.setY(0);
|
||||
|
||||
|
||||
const QRect alphaMaskRect( canvas.mapFromGlobal( p ), size() );
|
||||
const QRect intersection( alphaMaskRect.intersect( canvas.rect() ) );
|
||||
const QRect alphaMaskRect(canvas.mapFromGlobal(p), size());
|
||||
const QRect intersection(alphaMaskRect.intersect(canvas.rect()));
|
||||
|
||||
m_pixmap.resize( size() ); //move to updateTip once you are sure it can never be null
|
||||
bitBlt( &m_pixmap, offset, &canvas, intersection, Qt::CopyROP );
|
||||
m_pixmap = QPixmap(size()); //move to updateTip once you are sure it can never be null
|
||||
|
||||
QColor const c = QToolTip::palette().color( QPalette::Active, QColorGroup::Background );
|
||||
const QColor c = QToolTip::palette().color(QPalette::Active, QPalette::Background);
|
||||
if (!m_backing_store)
|
||||
m_pixmap.fill( c );
|
||||
m_pixmap.fill(c);
|
||||
|
||||
QPainter paint( &m_pixmap );
|
||||
paint.setPen( Qt::black );
|
||||
paint.setBrush( Qt::NoBrush );
|
||||
paint.drawRect( rect() );
|
||||
QPainter paint(&m_pixmap);
|
||||
paint.setPen(Qt::black);
|
||||
paint.setBrush(Qt::NoBrush);
|
||||
paint.drawRect(rect());
|
||||
paint.end();
|
||||
|
||||
if (m_backing_store)
|
||||
m_pixmap = KPixmapEffect::fade( m_pixmap, 0.6, c );
|
||||
/* if (m_backing_store)
|
||||
m_pixmap = QPixmap::fromImage(Blitz::fade(m_pixmap.toImage() , 0.6f, c)); */ // TODO: reimplement this
|
||||
|
||||
paint.begin( &m_pixmap );
|
||||
paint.drawText( rect(), AlignCenter, m_text );
|
||||
paint.begin(&m_pixmap);
|
||||
paint.drawText(rect(), Qt::AlignCenter, m_text);
|
||||
paint.end();
|
||||
|
||||
p += screen.topLeft(); //for Xinerama users
|
||||
|
||||
move( x, y );
|
||||
move(x, y);
|
||||
show();
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
SegmentTip::updateTip( const File* const file, const Directory* const root )
|
||||
SegmentTip::updateTip(const File* const file, const Directory* const root)
|
||||
{
|
||||
const QString s1 = file->fullPath( root );
|
||||
const QString s1 = file->fullPath(root);
|
||||
QString s2 = file->humanReadableSize();
|
||||
KLocale *loc = KGlobal::locale();
|
||||
const uint MARGIN = 3;
|
||||
const uint pc = (100 * int64_t(file->size())) / root->size(); //64 bits for summaryWidget sizes
|
||||
const uint pc = 100 * file->size() / root->size();
|
||||
uint maxw = 0;
|
||||
uint h = fontMetrics().height()*2 + 2*MARGIN;
|
||||
|
||||
if( pc > 0 ) s2 += QString( " (%1%)" ).arg( loc->formatNumber( pc, 0 ) );
|
||||
if (pc > 0) s2 += QString(" (%1%)").arg(loc->formatNumber(pc, 0));
|
||||
|
||||
m_text = s1;
|
||||
m_text += '\n';
|
||||
m_text += s2;
|
||||
|
||||
if( file->isDirectory() )
|
||||
if (file->isDirectory())
|
||||
{
|
||||
double files = static_cast<const Directory*>(file)->children();
|
||||
const uint pc = uint((100 * files) / (double)root->children());
|
||||
QString s3 = i18n( "Files: %1" ).arg( loc->formatNumber( files, 0 ) );
|
||||
QString s3 = i18n("Files: %1", loc->formatNumber(files, 0));
|
||||
|
||||
if( pc > 0 ) s3 += QString( " (%1%)" ).arg( loc->formatNumber( pc, 0 ) );
|
||||
if (pc > 0) s3 += QString(" (%1%)").arg(loc->formatNumber(pc, 0));
|
||||
|
||||
maxw = fontMetrics().width( s3 );
|
||||
maxw = fontMetrics().width(s3);
|
||||
h += fontMetrics().height();
|
||||
m_text += '\n';
|
||||
m_text += s3;
|
||||
}
|
||||
|
||||
uint
|
||||
w = fontMetrics().width( s1 ); if( w > maxw ) maxw = w;
|
||||
w = fontMetrics().width( s2 ); if( w > maxw ) maxw = w;
|
||||
w = fontMetrics().width(s1);
|
||||
if (w > maxw) maxw = w;
|
||||
w = fontMetrics().width(s2);
|
||||
if (w > maxw) maxw = w;
|
||||
|
||||
resize( maxw + 2 * MARGIN, h );
|
||||
resize(maxw + 2 * MARGIN, h);
|
||||
}
|
||||
|
||||
bool
|
||||
SegmentTip::event( QEvent *e )
|
||||
SegmentTip::event(QEvent *e)
|
||||
{
|
||||
switch( e->type() )
|
||||
switch (e->type())
|
||||
{
|
||||
case QEvent::Show:
|
||||
kapp->installEventFilter( this );
|
||||
kapp->installEventFilter(this);
|
||||
break;
|
||||
case QEvent::Hide:
|
||||
kapp->removeEventFilter( this );
|
||||
kapp->removeEventFilter(this);
|
||||
break;
|
||||
case QEvent::Paint:
|
||||
{
|
||||
//QPainter( this ).drawPixmap( 0, 0, m_pixmap );
|
||||
bitBlt( this, 0, 0, &m_pixmap );
|
||||
QPainter(this).drawPixmap(0, 0, m_pixmap);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
return false/*QWidget::event( e )*/;
|
||||
return false/*QWidget::event(e)*/;
|
||||
}
|
||||
|
||||
bool
|
||||
SegmentTip::eventFilter( QObject*, QEvent *e )
|
||||
SegmentTip::eventFilter(QObject*, QEvent *e)
|
||||
{
|
||||
switch ( e->type() )
|
||||
switch (e->type())
|
||||
{
|
||||
case QEvent::Leave:
|
||||
// case QEvent::MouseButtonPress:
|
||||
|
|
|
@ -1,34 +1,52 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef SEGMENT_TIP_H
|
||||
#define SEGMENT_TIP_H
|
||||
#ifndef SEGMENTTIP_H
|
||||
#define SEGMENTTIP_H
|
||||
|
||||
#include <kpixmap.h>
|
||||
#include <qwidget.h>
|
||||
#include <QWidget>
|
||||
#include <QEvent>
|
||||
|
||||
class File;
|
||||
class Directory;
|
||||
|
||||
namespace RadialMap
|
||||
{
|
||||
class SegmentTip : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit SegmentTip( uint );
|
||||
class SegmentTip : public QWidget
|
||||
{
|
||||
public:
|
||||
SegmentTip(uint);
|
||||
|
||||
void updateTip( const File*, const Directory* );
|
||||
void moveTo( QPoint, const QWidget&, bool );
|
||||
void updateTip(const File*, const Directory*);
|
||||
void moveTo(QPoint, QWidget&, bool);
|
||||
|
||||
private:
|
||||
virtual bool eventFilter( QObject*, QEvent* );
|
||||
virtual bool event( QEvent* );
|
||||
private:
|
||||
virtual bool eventFilter(QObject*, QEvent*);
|
||||
virtual bool event(QEvent*);
|
||||
|
||||
uint m_cursorHeight;
|
||||
KPixmap m_pixmap;
|
||||
QString m_text;
|
||||
bool m_backing_store;
|
||||
};
|
||||
uint m_cursorHeight;
|
||||
QPixmap m_pixmap;
|
||||
QString m_text;
|
||||
bool m_backing_store;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,23 +1,41 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef SINCOS_H
|
||||
#define SINCOS_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#if !defined(__GLIBC__) || (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
|
||||
#if !defined(__GLIBC__) || (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
|
||||
|
||||
void
|
||||
sincos( int angleRadians, double *Sin, double *Cos );
|
||||
void
|
||||
sincos(int angleRadians, double *Sin, double *Cos);
|
||||
|
||||
#ifdef SINCOS_H_IMPLEMENTATION
|
||||
void
|
||||
sincos( int angleRadians, double *Sin, double *Cos )
|
||||
{
|
||||
*Sin = sin( angleRadians );
|
||||
*Cos = cos( angleRadians );
|
||||
}
|
||||
void
|
||||
sincos(int angleRadians, double *Sin, double *Cos)
|
||||
{
|
||||
*Sin = sin(angleRadians);
|
||||
*Cos = cos(angleRadians);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,187 +1,209 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include <kcursor.h> //ctor
|
||||
#include <klocale.h>
|
||||
#include <kurl.h>
|
||||
#include <qapplication.h> //sendEvent
|
||||
#include <qbitmap.h> //ctor - finding cursor size
|
||||
#include <qcursor.h> //slotPostMouseEvent()
|
||||
#include <qtimer.h> //member
|
||||
#include <KCursor> //ctor
|
||||
#include <KLocale>
|
||||
#include <KUrl>
|
||||
#include <QApplication> //sendEvent
|
||||
#include <QBitmap> //ctor - finding cursor size
|
||||
#include <QCursor> //slotPostMouseEvent()
|
||||
#include <QTimer> //member
|
||||
#include <QWidget>
|
||||
|
||||
#include "Config.h"
|
||||
#include "debug.h"
|
||||
#include "fileTree.h"
|
||||
#include "part/Config.h"
|
||||
#include "part/fileTree.h"
|
||||
#include "radialMap.h" //constants
|
||||
#include "widget.h"
|
||||
#include "map.h"
|
||||
|
||||
|
||||
|
||||
RadialMap::Widget::Widget( QWidget *parent, const char *name )
|
||||
: QWidget( parent, name, Qt::WNoAutoErase )
|
||||
, m_tree( 0 )
|
||||
, m_focus( 0 )
|
||||
, m_rootSegment( 0 ) //TODO we don't delete it, *shrug*
|
||||
RadialMap::Widget::Widget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_tree(0)
|
||||
, m_focus(0)
|
||||
, m_rootSegment(0) //TODO we don't delete it, *shrug*
|
||||
{
|
||||
setAcceptDrops( true );
|
||||
setBackgroundColor( Qt::white );
|
||||
const QBitmap *cursor = KCursor::handCursor().bitmap();
|
||||
m_tip = new SegmentTip(cursor ? cursor->height() : 16);
|
||||
setAcceptDrops(true);
|
||||
|
||||
connect( this, SIGNAL(created( const Directory* )), SLOT(sendFakeMouseEvent()) );
|
||||
connect( this, SIGNAL(created( const Directory* )), SLOT(update()) );
|
||||
connect( &m_timer, SIGNAL(timeout()), SLOT(resizeTimeout()) );
|
||||
QPalette palette;
|
||||
palette.setColor(this->backgroundRole(), Qt::white);
|
||||
setPalette(palette);
|
||||
|
||||
const QBitmap *cursor = QCursor(Qt::PointingHandCursor).bitmap();
|
||||
m_tip = new SegmentTip(cursor ? cursor->height() : 16);
|
||||
|
||||
connect(this, SIGNAL(created(const Directory*)), SLOT(sendFakeMouseEvent()));
|
||||
connect(this, SIGNAL(created(const Directory*)), SLOT(update()));
|
||||
connect(&m_timer, SIGNAL(timeout()), SLOT(resizeTimeout()));
|
||||
}
|
||||
|
||||
QString
|
||||
RadialMap::Widget::path() const
|
||||
{
|
||||
return m_tree->fullPath();
|
||||
return m_tree->fullPath();
|
||||
}
|
||||
|
||||
KURL
|
||||
RadialMap::Widget::url( File const * const file ) const
|
||||
KUrl
|
||||
RadialMap::Widget::url(File const * const file) const
|
||||
{
|
||||
return KURL::fromPathOrURL( file ? file->fullPath() : m_tree->fullPath() );
|
||||
return KUrl::KUrl(file ? file->fullPath() : m_tree->fullPath());
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::invalidate( const bool b )
|
||||
RadialMap::Widget::invalidate(const bool b)
|
||||
{
|
||||
if( isValid() )
|
||||
{
|
||||
//**** have to check that only way to invalidate is this function frankly
|
||||
//**** otherwise you may get bugs..
|
||||
if (isValid())
|
||||
{
|
||||
//**** have to check that only way to invalidate is this function frankly
|
||||
//**** otherwise you may get bugs..
|
||||
|
||||
//disable mouse tracking
|
||||
setMouseTracking( false );
|
||||
//disable mouse tracking
|
||||
setMouseTracking(false);
|
||||
|
||||
//ensure this class won't think we have a map still
|
||||
m_tree = 0;
|
||||
m_focus = 0;
|
||||
//ensure this class won't think we have a map still
|
||||
m_tree = 0;
|
||||
m_focus = 0;
|
||||
|
||||
delete m_rootSegment;
|
||||
m_rootSegment = 0;
|
||||
delete m_rootSegment;
|
||||
m_rootSegment = 0;
|
||||
|
||||
//FIXME move this disablement thing no?
|
||||
// it is confusing in other areas, like the whole createFromCache() thing
|
||||
m_map.invalidate( b ); //b signifies whether the pixmap is made to look disabled or not
|
||||
if( b )
|
||||
update();
|
||||
//FIXME move this disablement thing no?
|
||||
// it is confusing in other areas, like the whole createFromCache() thing
|
||||
m_map.invalidate(b); //b signifies whether the pixmap is made to look disabled or not
|
||||
if (b)
|
||||
update();
|
||||
|
||||
//tell rest of Filelight
|
||||
emit invalidated( url() );
|
||||
}
|
||||
//tell rest of Filelight
|
||||
emit invalidated(url());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::create( const Directory *tree )
|
||||
RadialMap::Widget::create(const Directory *tree)
|
||||
{
|
||||
//it is not the responsibility of create() to invalidate first
|
||||
//skip invalidation at your own risk
|
||||
//it is not the responsibility of create() to invalidate first
|
||||
//skip invalidation at your own risk
|
||||
|
||||
//FIXME make it the responsibility of create to invalidate first
|
||||
//FIXME make it the responsibility of create to invalidate first
|
||||
|
||||
if( tree )
|
||||
{
|
||||
//generate the filemap image
|
||||
m_map.make( tree );
|
||||
if (tree)
|
||||
{
|
||||
//generate the filemap image
|
||||
m_map.make(tree);
|
||||
|
||||
//this is the inner circle in the center
|
||||
m_rootSegment = new Segment( tree, 0, 16*360 );
|
||||
//this is the inner circle in the center
|
||||
m_rootSegment = new Segment(tree, 0, 16*360);
|
||||
|
||||
setMouseTracking( true );
|
||||
}
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
m_tree = tree;
|
||||
m_tree = tree;
|
||||
|
||||
//tell rest of Filelight
|
||||
emit created( tree );
|
||||
//tell rest of Filelight
|
||||
emit created(tree);
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::createFromCache( const Directory *tree )
|
||||
RadialMap::Widget::createFromCache(const Directory *tree)
|
||||
{
|
||||
//no scan was necessary, use cached tree, however we MUST still emit invalidate
|
||||
invalidate( false );
|
||||
create( tree );
|
||||
invalidate(false);
|
||||
create(tree);
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::sendFakeMouseEvent() //slot
|
||||
{
|
||||
QMouseEvent me( QEvent::MouseMove, mapFromGlobal( QCursor::pos() ), Qt::NoButton, Qt::NoButton );
|
||||
QApplication::sendEvent( this, &me );
|
||||
QMouseEvent me(QEvent::MouseMove, mapFromGlobal(QCursor::pos()), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
|
||||
QApplication::sendEvent(this, &me);
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::resizeTimeout() //slot
|
||||
{
|
||||
// the segments are about to erased!
|
||||
// this was a horrid bug, and proves the OO programming should be obeyed always!
|
||||
m_focus = 0;
|
||||
if( m_tree )
|
||||
m_map.make( m_tree, true );
|
||||
update();
|
||||
// the segments are about to erased!
|
||||
// this was a horrid bug, and proves the OO programming should be obeyed always!
|
||||
m_focus = 0;
|
||||
if (m_tree)
|
||||
m_map.make(m_tree, true);
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::refresh( int filth )
|
||||
RadialMap::Widget::refresh(int filth)
|
||||
{
|
||||
//TODO consider a more direct connection
|
||||
//TODO consider a more direct connection
|
||||
|
||||
if( !m_map.isNull() )
|
||||
{
|
||||
switch( filth )
|
||||
{
|
||||
case 1:
|
||||
m_map.make( m_tree, true ); //true means refresh only
|
||||
break;
|
||||
if (!m_map.isNull())
|
||||
{
|
||||
switch (filth)
|
||||
{
|
||||
case 1:
|
||||
m_map.make(m_tree, true); //true means refresh only
|
||||
break;
|
||||
|
||||
case 2:
|
||||
m_map.aaPaint();
|
||||
break;
|
||||
case 2:
|
||||
m_map.aaPaint();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
m_map.colorise(); //FALL THROUGH!
|
||||
case 4:
|
||||
m_map.paint();
|
||||
case 3:
|
||||
m_map.colorise(); //FALL THROUGH!
|
||||
case 4:
|
||||
m_map.paint();
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::zoomIn() //slot
|
||||
{
|
||||
if( m_map.m_visibleDepth > MIN_RING_DEPTH )
|
||||
{
|
||||
--m_map.m_visibleDepth;
|
||||
m_map.make( m_tree );
|
||||
Config::defaultRingDepth = m_map.m_visibleDepth;
|
||||
update();
|
||||
}
|
||||
if (m_map.m_visibleDepth > MIN_RING_DEPTH)
|
||||
{
|
||||
--m_map.m_visibleDepth;
|
||||
m_map.make(m_tree);
|
||||
Config::defaultRingDepth = m_map.m_visibleDepth;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::zoomOut() //slot
|
||||
{
|
||||
++m_map.m_visibleDepth;
|
||||
m_map.make( m_tree );
|
||||
if( m_map.m_visibleDepth > Config::defaultRingDepth )
|
||||
Config::defaultRingDepth = m_map.m_visibleDepth;
|
||||
update();
|
||||
++m_map.m_visibleDepth;
|
||||
m_map.make(m_tree);
|
||||
if (m_map.m_visibleDepth > Config::defaultRingDepth)
|
||||
Config::defaultRingDepth = m_map.m_visibleDepth;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
RadialMap::Segment::~Segment()
|
||||
{
|
||||
if( isFake() )
|
||||
delete m_file; //created by us in Builder::build()
|
||||
if (isFake())
|
||||
delete m_file; //created by us in Builder::build()
|
||||
}
|
||||
|
||||
#include "widget.moc"
|
||||
|
|
|
@ -1,113 +1,119 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef WIDGET_H
|
||||
#define WIDGET_H
|
||||
|
||||
#include <kurl.h>
|
||||
#include <qtimer.h>
|
||||
#include <KUrl>
|
||||
#include <QTimer>
|
||||
#include <QPixmap>
|
||||
//Added by qt3to4:
|
||||
#include <QResizeEvent>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QPaintEvent>
|
||||
|
||||
#include "segmentTip.h"
|
||||
#include "map.h"
|
||||
|
||||
template <class T> class Chain;
|
||||
class Directory;
|
||||
class File;
|
||||
namespace KIO { class Job; }
|
||||
class KURL;
|
||||
namespace KIO {
|
||||
class Job;
|
||||
}
|
||||
class KUrl;
|
||||
|
||||
namespace RadialMap
|
||||
{
|
||||
class Segment;
|
||||
class Segment;
|
||||
|
||||
class Map : public KPixmap
|
||||
{
|
||||
public:
|
||||
Map();
|
||||
~Map();
|
||||
class Widget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
void make( const Directory *, bool = false );
|
||||
bool resize( const QRect& );
|
||||
public:
|
||||
Widget(QWidget* = 0);
|
||||
~Widget() {
|
||||
delete m_tip;
|
||||
}
|
||||
|
||||
bool isNull() const { return ( m_signature == 0 ); }
|
||||
void invalidate( const bool );
|
||||
QString path() const;
|
||||
KUrl url(File const * const = 0) const;
|
||||
|
||||
friend class Builder;
|
||||
friend class Widget;
|
||||
bool isValid() const {
|
||||
return m_tree != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
void paint( uint = 1 );
|
||||
void aaPaint();
|
||||
void colorise();
|
||||
void setRingBreadth();
|
||||
friend class Label; //FIXME badness
|
||||
|
||||
Chain<Segment> *m_signature;
|
||||
public slots:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void create(const Directory*);
|
||||
void invalidate(const bool = true);
|
||||
void refresh(int);
|
||||
|
||||
QRect m_rect;
|
||||
uint m_ringBreadth; ///ring breadth
|
||||
uint m_innerRadius; ///radius of inner circle
|
||||
uint m_visibleDepth; ///visible level depth of system
|
||||
QString m_centerText;
|
||||
private slots:
|
||||
void resizeTimeout();
|
||||
void sendFakeMouseEvent();
|
||||
void deleteJobFinished(KIO::Job*);
|
||||
void createFromCache(const Directory*);
|
||||
|
||||
uint MAP_2MARGIN;
|
||||
};
|
||||
signals:
|
||||
void activated(const KUrl&);
|
||||
void invalidated(const KUrl&);
|
||||
void created(const Directory*);
|
||||
void mouseHover(const QString&);
|
||||
void giveMeTreeFor(const KUrl&);
|
||||
|
||||
class Widget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent*);
|
||||
virtual void resizeEvent(QResizeEvent*);
|
||||
virtual void mouseMoveEvent(QMouseEvent*);
|
||||
virtual void mousePressEvent(QMouseEvent*);
|
||||
virtual void dragEnterEvent(QDragEnterEvent*);
|
||||
virtual void dropEvent(QDropEvent*);
|
||||
|
||||
public:
|
||||
Widget( QWidget* = 0, const char* = 0 );
|
||||
~Widget() { delete m_tip; }
|
||||
protected:
|
||||
const Segment *segmentAt(QPoint&) const; //FIXME const reference for a library others can use
|
||||
const Segment *rootSegment() const {
|
||||
return m_rootSegment; ///never == 0
|
||||
}
|
||||
const Segment *focusSegment() const {
|
||||
return m_focus; ///0 == nothing in focus
|
||||
}
|
||||
|
||||
QString path() const;
|
||||
KURL url( File const * const = 0 ) const;
|
||||
private:
|
||||
void paintExplodedLabels(QPainter&) const;
|
||||
|
||||
bool isValid() const { return m_tree != 0; }
|
||||
|
||||
friend class Label; //FIXME badness
|
||||
|
||||
public slots:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void create( const Directory* );
|
||||
void invalidate( const bool = true );
|
||||
void refresh( int );
|
||||
|
||||
private slots:
|
||||
void resizeTimeout();
|
||||
void sendFakeMouseEvent();
|
||||
void createFromCache( const Directory* );
|
||||
|
||||
signals:
|
||||
void activated( const KURL& );
|
||||
void invalidated( const KURL& );
|
||||
void created( const Directory* );
|
||||
void mouseHover( const QString& );
|
||||
void giveMeTreeFor( const KURL& );
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent* );
|
||||
virtual void resizeEvent( QResizeEvent* );
|
||||
virtual void mouseMoveEvent( QMouseEvent* );
|
||||
virtual void mousePressEvent( QMouseEvent* );
|
||||
virtual void dragEnterEvent( QDragEnterEvent* );
|
||||
virtual void dropEvent( QDropEvent* );
|
||||
|
||||
protected:
|
||||
const Segment *segmentAt( QPoint& ) const; //FIXME const reference for a library others can use
|
||||
const Segment *rootSegment() const { return m_rootSegment; } ///never == 0
|
||||
const Segment *focusSegment() const { return m_focus; } ///0 == nothing in focus
|
||||
|
||||
private:
|
||||
void paintExplodedLabels( QPainter& ) const;
|
||||
|
||||
const Directory *m_tree;
|
||||
const Segment *m_focus;
|
||||
QPoint m_offset;
|
||||
QTimer m_timer;
|
||||
Map m_map;
|
||||
SegmentTip *m_tip;
|
||||
Segment *m_rootSegment;
|
||||
};
|
||||
const Directory *m_tree;
|
||||
const Segment *m_focus;
|
||||
QPoint m_offset;
|
||||
QTimer m_timer;
|
||||
Map m_map;
|
||||
SegmentTip *m_tip;
|
||||
Segment *m_rootSegment;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,25 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "debug.h"
|
||||
#include "deleteDialog.h"
|
||||
#include "fileTree.h"
|
||||
#include "part/fileTree.h"
|
||||
#include "radialMap.h" //class Segment
|
||||
#include "widget.h"
|
||||
|
||||
|
@ -12,23 +28,32 @@
|
|||
#include <kiconeffect.h> //::mousePressEvent()
|
||||
#include <kiconloader.h> //::mousePressEvent()
|
||||
#include <kio/job.h> //::mousePressEvent()
|
||||
#include <kio/deletejob.h>
|
||||
#include <kio/jobuidelegate.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h> //::mousePressEvent()
|
||||
#include <kpopupmenu.h> //::mousePressEvent()
|
||||
#include <kmenu.h> //::mousePressEvent()
|
||||
#include <krun.h> //::mousePressEvent()
|
||||
#include <kurldrag.h>
|
||||
#include <kurl.h>
|
||||
#include <qapplication.h>//QApplication::setOverrideCursor()
|
||||
#include <qclipboard.h>
|
||||
#include <qpainter.h>
|
||||
#include <qtimer.h> //::resizeEvent()
|
||||
//Added by qt3to4:
|
||||
#include <QDropEvent>
|
||||
#include <QPaintEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QDragEnterEvent>
|
||||
|
||||
|
||||
|
||||
void
|
||||
RadialMap::Widget::resizeEvent( QResizeEvent* )
|
||||
RadialMap::Widget::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
if( m_map.resize( rect() ) )
|
||||
m_timer.start( 500, true ); //will cause signature to rebuild for new size
|
||||
if (m_map.resize(rect()))
|
||||
m_timer.setSingleShot(true);
|
||||
m_timer.start(500); //will cause signature to rebuild for new size
|
||||
|
||||
//always do these as they need to be initialised on creation
|
||||
m_offset.rx() = (width() - m_map.width()) / 2;
|
||||
|
@ -36,73 +61,73 @@ RadialMap::Widget::resizeEvent( QResizeEvent* )
|
|||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::paintEvent( QPaintEvent* )
|
||||
RadialMap::Widget::paintEvent(QPaintEvent*)
|
||||
{
|
||||
//bltBit for some Qt setups will bitBlt _after_ the labels are painted. Which buggers things up!
|
||||
//shame as bitBlt is faster, possibly Qt bug? Should report the bug? - seems to be race condition
|
||||
//bitBlt( this, m_offset, &m_map );
|
||||
//bitBlt(this, m_offset, &m_map);
|
||||
|
||||
QPainter paint( this );
|
||||
QPainter paint(this);
|
||||
|
||||
paint.drawPixmap( m_offset, m_map );
|
||||
paint.drawPixmap(m_offset, m_map.getPixmap());
|
||||
|
||||
//vertical strips
|
||||
if( m_map.width() < width() )
|
||||
if (m_map.width() < width())
|
||||
{
|
||||
paint.eraseRect( 0, 0, m_offset.x(), height() );
|
||||
paint.eraseRect( m_map.width() + m_offset.x(), 0, m_offset.x() + 1, height() );
|
||||
paint.eraseRect(0, 0, m_offset.x(), height());
|
||||
paint.eraseRect(m_map.width() + m_offset.x(), 0, m_offset.x() + 1, height());
|
||||
}
|
||||
//horizontal strips
|
||||
if( m_map.height() < height() )
|
||||
if (m_map.height() < height())
|
||||
{
|
||||
paint.eraseRect( 0, 0, width(), m_offset.y() );
|
||||
paint.eraseRect( 0, m_map.height() + m_offset.y(), width(), m_offset.y() + 1 );
|
||||
paint.eraseRect(0, 0, width(), m_offset.y());
|
||||
paint.eraseRect(0, m_map.height() + m_offset.y(), width(), m_offset.y() + 1);
|
||||
}
|
||||
|
||||
//exploded labels
|
||||
if( !m_map.isNull() && !m_timer.isActive() )
|
||||
paintExplodedLabels( paint );
|
||||
if (!m_map.isNull() && !m_timer.isActive())
|
||||
paintExplodedLabels(paint);
|
||||
}
|
||||
|
||||
const RadialMap::Segment*
|
||||
RadialMap::Widget::segmentAt( QPoint &e ) const
|
||||
RadialMap::Widget::segmentAt(QPoint &e) const
|
||||
{
|
||||
//determine which segment QPoint e is above
|
||||
|
||||
e -= m_offset;
|
||||
|
||||
if( !m_map.m_signature )
|
||||
return 0;
|
||||
if (!m_map.m_signature)
|
||||
return 0;
|
||||
|
||||
if( e.x() <= m_map.width() && e.y() <= m_map.height() )
|
||||
if (e.x() <= m_map.width() && e.y() <= m_map.height())
|
||||
{
|
||||
//transform to cartesian coords
|
||||
e.rx() -= m_map.width() / 2; //should be an int
|
||||
e.ry() = m_map.height() / 2 - e.y();
|
||||
|
||||
double length = hypot( e.x(), e.y() );
|
||||
double length = hypot(e.x(), e.y());
|
||||
|
||||
if( length >= m_map.m_innerRadius ) //not hovering over inner circle
|
||||
if (length >= m_map.m_innerRadius) //not hovering over inner circle
|
||||
{
|
||||
uint depth = ((int)length - m_map.m_innerRadius) / m_map.m_ringBreadth;
|
||||
|
||||
if( depth <= m_map.m_visibleDepth ) //**** do earlier since you can //** check not outside of range
|
||||
if (depth <= m_map.m_visibleDepth) //**** do earlier since you can //** check not outside of range
|
||||
{
|
||||
//vector calculation, reduces to simple trigonometry
|
||||
//cos angle = (aibi + ajbj) / albl
|
||||
//ai = x, bi=1, aj=y, bj=0
|
||||
//cos angle = x / (length)
|
||||
|
||||
uint a = (uint)(acos( (double)e.x() / length ) * 916.736); //916.7324722 = #radians in circle * 16
|
||||
uint a = (uint)(acos((double)e.x() / length) * 916.736); //916.7324722 = #radians in circle * 16
|
||||
|
||||
//acos only understands 0-180 degrees
|
||||
if( e.y() < 0 ) a = 5760 - a;
|
||||
if (e.y() < 0) a = 5760 - a;
|
||||
|
||||
#define ring (m_map.m_signature + depth)
|
||||
for( ConstIterator<Segment> it = ring->constIterator(); it != ring->end(); ++it )
|
||||
if( (*it)->intersects( a ) )
|
||||
#define ring (m_map.m_signature + depth)
|
||||
for (ConstIterator<Segment> it = ring->constIterator(); it != ring->end(); ++it)
|
||||
if ((*it)->intersects(a))
|
||||
return *it;
|
||||
#undef ring
|
||||
#undef ring
|
||||
}
|
||||
}
|
||||
else return m_rootSegment; //hovering over inner circle
|
||||
|
@ -112,161 +137,159 @@ RadialMap::Widget::segmentAt( QPoint &e ) const
|
|||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::mouseMoveEvent( QMouseEvent *e )
|
||||
RadialMap::Widget::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
//set m_focus to what we hover over, update UI if it's a new segment
|
||||
//set m_focus to what we hover over, update UI if it's a new segment
|
||||
|
||||
Segment const * const oldFocus = m_focus;
|
||||
QPoint p = e->pos();
|
||||
Segment const * const oldFocus = m_focus;
|
||||
QPoint p = e->pos();
|
||||
|
||||
m_focus = segmentAt( p ); //NOTE p is passed by non-const reference
|
||||
m_focus = segmentAt(p); //NOTE p is passed by non-const reference
|
||||
|
||||
if( m_focus && m_focus->file() != m_tree )
|
||||
{
|
||||
if( m_focus != oldFocus ) //if not same as last time
|
||||
{
|
||||
setCursor( KCursor::handCursor() );
|
||||
m_tip->updateTip( m_focus->file(), m_tree );
|
||||
emit mouseHover( m_focus->file()->fullPath() );
|
||||
if (m_focus && m_focus->file() != m_tree)
|
||||
{
|
||||
if (m_focus != oldFocus) //if not same as last time
|
||||
{
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
m_tip->updateTip(m_focus->file(), m_tree);
|
||||
emit mouseHover(m_focus->file()->fullPath());
|
||||
|
||||
//repaint required to update labels now before transparency is generated
|
||||
repaint( false );
|
||||
}
|
||||
//repaint required to update labels now before transparency is generated
|
||||
repaint();
|
||||
}
|
||||
|
||||
m_tip->moveTo( e->globalPos(), *this, ( p.y() < 0 ) ); //updates tooltip pseudo-tranparent background
|
||||
}
|
||||
else if( oldFocus && oldFocus->file() != m_tree )
|
||||
{
|
||||
unsetCursor();
|
||||
m_tip->hide();
|
||||
update();
|
||||
m_tip->moveTo(e->globalPos(), *this, (p.y() < 0)); //updates tooltip psuedo-tranparent background
|
||||
}
|
||||
else if (oldFocus && oldFocus->file() != m_tree)
|
||||
{
|
||||
unsetCursor();
|
||||
m_tip->hide();
|
||||
update();
|
||||
|
||||
emit mouseHover( QString::null );
|
||||
}
|
||||
emit mouseHover(QString::null);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::mousePressEvent( QMouseEvent *e )
|
||||
void RadialMap::Widget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
//m_tip is hidden already by event filter
|
||||
//m_focus is set correctly (I've been strict, I assure you it is correct!)
|
||||
//m_tip is hidden already by event filter
|
||||
//m_focus is set correctly (I've been strict, I assure you it is correct!)
|
||||
|
||||
enum { Konqueror, Konsole, Center, Open, Copy, Delete };
|
||||
if (m_focus && !m_focus->isFake())
|
||||
{
|
||||
const KUrl url = Widget::url(m_focus->file());
|
||||
const bool isDir = m_focus->file()->isDirectory();
|
||||
|
||||
if (m_focus && !m_focus->isFake())
|
||||
{
|
||||
const KURL url = Widget::url( m_focus->file() );
|
||||
const bool isDir = m_focus->file()->isDirectory();
|
||||
// Actions in the right click menu
|
||||
QAction* openKonqueror = 0;
|
||||
QAction* openKonsole = 0;
|
||||
QAction* centerMap = 0;
|
||||
QAction* openFile = 0;
|
||||
QAction* copyClipboard = 0;
|
||||
QAction* deleteItem = 0;
|
||||
|
||||
if( e->button() == Qt::RightButton )
|
||||
{
|
||||
KPopupMenu popup;
|
||||
popup.insertTitle( m_focus->file()->fullPath( m_tree ) );
|
||||
if (e->button() == Qt::RightButton)
|
||||
{
|
||||
KMenu popup;
|
||||
popup.addTitle(m_focus->file()->fullPath(m_tree));
|
||||
|
||||
if (isDir) {
|
||||
popup.insertItem( SmallIconSet( "konqueror" ), i18n( "Open &Konqueror Here" ), Konqueror );
|
||||
if (isDir) {
|
||||
openKonqueror = popup.addAction(KIcon("konqueror"), i18n("Open &Konqueror Here"));
|
||||
|
||||
if( url.protocol() == "file" )
|
||||
popup.insertItem( SmallIconSet( "konsole" ), i18n( "Open &Konsole Here" ), Konsole );
|
||||
if (url.protocol() == "file")
|
||||
openKonsole = popup.addAction(KIcon("konsole"), i18n("Open &Konsole Here"));
|
||||
|
||||
if (m_focus->file() != m_tree) {
|
||||
popup.insertSeparator();
|
||||
popup.insertItem( SmallIconSet( "viewmag" ), i18n( "&Center Map Here" ), Center );
|
||||
}
|
||||
}
|
||||
else
|
||||
popup.insertItem( SmallIconSet( "fileopen" ), i18n( "&Open" ), Open );
|
||||
|
||||
popup.insertSeparator();
|
||||
popup.insertItem( SmallIconSet( "editcopy" ), i18n( "&Copy to clipboard" ), Copy );
|
||||
|
||||
popup.insertSeparator();
|
||||
popup.insertItem( SmallIconSet( "editdelete" ), i18n( "&Delete" ), Delete );
|
||||
|
||||
switch (popup.exec( e->globalPos(), 1 )) {
|
||||
case Konqueror:
|
||||
//KRun::runCommand will show an error message if there was trouble
|
||||
KRun::runCommand( QString( "kfmclient openURL \"%1\"" ).arg( url.url() ) );
|
||||
break;
|
||||
|
||||
case Konsole:
|
||||
// --workdir only works for local file paths
|
||||
KRun::runCommand( QString( "konsole --workdir \"%1\"" ).arg( url.path() ) );
|
||||
break;
|
||||
|
||||
case Center:
|
||||
case Open:
|
||||
goto section_two;
|
||||
|
||||
case Copy:
|
||||
QApplication::clipboard()->setData( new KURLDrag( KURL::List( url ) ) );
|
||||
break;
|
||||
|
||||
case Delete:
|
||||
{
|
||||
KURL const url = Widget::url( m_focus->file() );
|
||||
bool const is_dir = m_focus->file()->isDirectory();
|
||||
int const r = DeleteDialog( url, is_dir, this ).exec();
|
||||
|
||||
switch (r) {
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
File const *f = m_focus->file();
|
||||
f->parent()->remove( f );
|
||||
|
||||
createFromCache( m_tree );
|
||||
break;
|
||||
}
|
||||
case DeleteDialog::IndeterminateResult:
|
||||
invalidate();
|
||||
break;
|
||||
case QDialog::Rejected:
|
||||
break;
|
||||
if (m_focus->file() != m_tree) {
|
||||
popup.addSeparator();
|
||||
centerMap = popup.addAction(KIcon("viewmag"), i18n("&Center Map Here"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
openFile = popup.addAction(KIcon("fileopen"), i18n("&Open"));
|
||||
|
||||
default:
|
||||
popup.addSeparator();
|
||||
copyClipboard = popup.addAction(KIcon("editcopy"), i18n("&Copy to clipboard"));
|
||||
|
||||
popup.addSeparator();
|
||||
deleteItem = popup.addAction(KIcon("editdelete"), i18n("&Delete"));
|
||||
|
||||
QAction* clicked = popup.exec(e->globalPos(), 0);
|
||||
|
||||
if (openKonqueror && clicked == openKonqueror) {
|
||||
KRun::runCommand(QString("kfmclient openURL \"%1\"").arg(url.url()), this);
|
||||
} else if (openKonsole && clicked == openKonsole) {
|
||||
KRun::runCommand(QString("konsole --workdir \"%1\"").arg(url.path()), this);
|
||||
} else if (centerMap && clicked == centerMap) {
|
||||
goto section_two;
|
||||
} else if (openFile && clicked == openFile) {
|
||||
goto section_two;
|
||||
} else if (clicked == copyClipboard) {
|
||||
QMimeData* mimedata = new QMimeData();
|
||||
url.populateMimeData(mimedata);
|
||||
QApplication::clipboard()->setMimeData(mimedata , QClipboard::Clipboard);
|
||||
} else if (clicked == deleteItem) {
|
||||
const KUrl url = Widget::url(m_focus->file());
|
||||
const QString message = m_focus->file()->isDirectory()
|
||||
? i18n("<qt>The directory at <i>'%1'</i> will be <b>recursively</b> and <b>permanently</b> deleted.")
|
||||
: i18n("<qt><i>'%1'</i> will be <b>permanently</b> deleted.");
|
||||
const int userIntention = KMessageBox::warningContinueCancel(
|
||||
this, message.arg(url.prettyUrl()),
|
||||
QString::null, KGuiItem(i18n("&Delete"), "editdelete"));
|
||||
|
||||
if (userIntention == KMessageBox::Continue) {
|
||||
KIO::Job *job = KIO::del(url);
|
||||
job->ui()->setWindow(this);
|
||||
connect(job, SIGNAL(result(KIO::Job*)), SLOT(deleteJobFinished(KIO::Job*)));
|
||||
QApplication::setOverrideCursor(Qt::BusyCursor);
|
||||
}
|
||||
} else {
|
||||
//ensure m_focus is set for new mouse position
|
||||
sendFakeMouseEvent();
|
||||
}
|
||||
}
|
||||
else { // not right mouse button
|
||||
}
|
||||
}
|
||||
else { // not right mouse button
|
||||
|
||||
section_two:
|
||||
const QRect rect( e->x() - 20, e->y() - 20, 40, 40 );
|
||||
section_two:
|
||||
const QRect rect(e->x() - 20, e->y() - 20, 40, 40);
|
||||
|
||||
m_tip->hide(); // user expects this
|
||||
m_tip->hide(); // user expects this
|
||||
|
||||
if (!isDir || e->button() == Qt::MidButton) {
|
||||
KIconEffect::visualActivate( this, rect );
|
||||
new KRun( url, this, true ); //FIXME see above
|
||||
}
|
||||
else if (m_focus->file() != m_tree) { // is left click
|
||||
KIconEffect::visualActivate( this, rect );
|
||||
emit activated( url ); //activate first, this will cause UI to prepare itself
|
||||
createFromCache( (Directory *)m_focus->file() );
|
||||
}
|
||||
else
|
||||
emit giveMeTreeFor( url.upURL() );
|
||||
}
|
||||
}
|
||||
if (!isDir || e->button() == Qt::MidButton) {
|
||||
// KIconEffect::visualActivate(this, rect); // TODO: recreate this
|
||||
new KRun(url, this, true); //FIXME see above
|
||||
}
|
||||
else if (m_focus->file() != m_tree) { // is left click
|
||||
// KIconEffect::visualActivate(this, rect); // TODO: recreate this
|
||||
emit activated(url); //activate first, this will cause UI to prepare itself
|
||||
createFromCache((Directory *)m_focus->file());
|
||||
}
|
||||
else
|
||||
emit giveMeTreeFor(url.upUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::dropEvent( QDropEvent *e )
|
||||
RadialMap::Widget::deleteJobFinished(KIO::Job *job)
|
||||
{
|
||||
DEBUG_ANNOUNCE
|
||||
|
||||
KURL::List urls;
|
||||
if (KURLDrag::decode( e, urls ) && urls.count())
|
||||
emit giveMeTreeFor( urls.first() );
|
||||
QApplication::restoreOverrideCursor();
|
||||
if (!job->error())
|
||||
invalidate();
|
||||
else
|
||||
job->ui()->showErrorMessage();
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::dragEnterEvent( QDragEnterEvent *e )
|
||||
RadialMap::Widget::dropEvent(QDropEvent *e)
|
||||
{
|
||||
DEBUG_ANNOUNCE
|
||||
|
||||
e->accept( KURLDrag::canDecode( e ) );
|
||||
KUrl::List uriList = KUrl::List::fromMimeData(e->mimeData());
|
||||
if (!uriList.isEmpty())
|
||||
emit giveMeTreeFor(uriList.first());
|
||||
}
|
||||
|
||||
void
|
||||
RadialMap::Widget::dragEnterEvent(QDragEnterEvent *e)
|
||||
{
|
||||
KUrl::List uriList = KUrl::List::fromMimeData(e->mimeData());
|
||||
e->setAccepted(!uriList.isEmpty());
|
||||
}
|
||||
|
|
|
@ -1,160 +1,177 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "debug.h"
|
||||
#include "fileTree.h"
|
||||
#include <qapplication.h>
|
||||
#include <qtimer.h>
|
||||
#include <qvaluelist.h>
|
||||
#include "remoteLister.h"
|
||||
#include "fileTree.h"
|
||||
#include "scan.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <KDirLister>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLinkedList>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Filelight
|
||||
{
|
||||
//you need to use a single DirLister
|
||||
//one per directory breaks KIO (seemingly) and also uses un-godly amounts of memory!
|
||||
|
||||
//TODO delete all this stuff!
|
||||
//TODO: delete all this stuff!
|
||||
|
||||
struct Store {
|
||||
// You need to use a single DirLister.
|
||||
// One per directory breaks KIO (seemingly) and also uses un-godly amounts of memory!
|
||||
|
||||
typedef QValueList<Store*> List;
|
||||
struct Store {
|
||||
|
||||
/// location of the directory
|
||||
const KURL url;
|
||||
/// the directory on which we are operating
|
||||
Directory *directory;
|
||||
/// so we can reference the parent store
|
||||
Store *parent;
|
||||
/// directories in this directory that need to be scanned before we can propagate()
|
||||
List stores;
|
||||
typedef QLinkedList<Store*> List;
|
||||
|
||||
Store()
|
||||
: directory( 0 ), parent( 0 ) {}
|
||||
Store( const KURL &u, const QString &name, Store *s )
|
||||
: url( u ), directory( new Directory( name.local8Bit() + '/' ) ), parent( s ) {}
|
||||
/// location of the directory
|
||||
const KUrl url;
|
||||
/// the directory on which we are operating
|
||||
Directory *directory;
|
||||
/// so we can reference the parent store
|
||||
Store *parent;
|
||||
/// directories in this directory that need to be scanned before we can propagate()
|
||||
List stores;
|
||||
|
||||
Store() : directory(0), parent(0) {}
|
||||
Store(const KUrl &u, const QString &name, Store *s)
|
||||
: url(u), directory(new Directory(name.toLocal8Bit() + '/')), parent(s) {}
|
||||
|
||||
|
||||
Store*
|
||||
propagate()
|
||||
{
|
||||
/// returns the next store available for scanning
|
||||
Store* propagate()
|
||||
{
|
||||
/// returns the next store available for scanning
|
||||
|
||||
qDebug() << "propagate: " << url;
|
||||
kDebug() << "propagate: " << url << endl;
|
||||
|
||||
if( parent ) {
|
||||
parent->directory->append( directory );
|
||||
if( parent->stores.isEmpty() ) {
|
||||
return parent->propagate();
|
||||
if (parent) {
|
||||
parent->directory->append(directory);
|
||||
if (parent->stores.isEmpty()) {
|
||||
return parent->propagate();
|
||||
}
|
||||
else
|
||||
return parent;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
//we reached the root, let's get our next directory scanned
|
||||
return this;
|
||||
}
|
||||
//we reached the root, let's get our next directory scanned
|
||||
return this;
|
||||
}
|
||||
|
||||
private:
|
||||
Store( Store& );
|
||||
Store &operator=( const Store& );
|
||||
};
|
||||
private:
|
||||
Store(Store&);
|
||||
Store &operator=(const Store&);
|
||||
};
|
||||
|
||||
|
||||
RemoteLister::RemoteLister( const KURL &url, QWidget *parent )
|
||||
: KDirLister( true /*don't fetch mimetypes*/ )
|
||||
, m_root( new Store( url, url.url(), 0 ) )
|
||||
, m_store( m_root )
|
||||
{
|
||||
setAutoUpdate( false ); //don't use KDirWatchers
|
||||
setShowingDotFiles( true ); //stupid KDirLister API function names
|
||||
setMainWindow( parent );
|
||||
RemoteLister::RemoteLister(const KUrl &url, QWidget *parent)
|
||||
: KDirLister(parent)
|
||||
, m_root(new Store(url, url.url(), 0))
|
||||
, m_store(m_root)
|
||||
{
|
||||
setAutoUpdate(false); // Don't use KDirWatchers
|
||||
setShowingDotFiles(true); // Stupid KDirLister API function names
|
||||
setMainWindow(parent);
|
||||
|
||||
//use SIGNAL(result(KIO::Job*)) instead and then use Job::error()
|
||||
connect( this, SIGNAL(completed()), SLOT(completed()) );
|
||||
connect( this, SIGNAL(canceled()), SLOT(canceled()) );
|
||||
// Use SIGNAL(result(KIO::Job*)) instead and then use Job::error()
|
||||
connect(this, SIGNAL(completed()), SLOT(completed()));
|
||||
connect(this, SIGNAL(canceled()), SLOT(canceled()));
|
||||
|
||||
//we do this non-recursively - it is the only way!
|
||||
openURL( url );
|
||||
}
|
||||
// We do this non-recursively - it is the only way!
|
||||
openUrl(url);
|
||||
}
|
||||
|
||||
RemoteLister::~RemoteLister()
|
||||
{
|
||||
Directory *tree = isFinished() ? m_store->directory : 0;
|
||||
RemoteLister::~RemoteLister()
|
||||
{
|
||||
// Directory *tree = isFinished() ? m_store->directory : 0;
|
||||
|
||||
QCustomEvent *e = new QCustomEvent( 1000 );
|
||||
e->setData( tree );
|
||||
QApplication::postEvent( parent(), e );
|
||||
// qobject_cast<ScanManager*>(parent())->appendTree(tree, false);//FIXME TODO FUCK
|
||||
delete m_root;
|
||||
}
|
||||
|
||||
delete m_root;
|
||||
}
|
||||
void
|
||||
RemoteLister::completed()
|
||||
{
|
||||
kDebug() << "completed: " << url().prettyUrl() << endl;
|
||||
|
||||
void
|
||||
RemoteLister::completed()
|
||||
{
|
||||
qDebug() << "completed: " << url().prettyURL();
|
||||
//as usual KDE documentation didn't suggest I needed to do this at all
|
||||
//I had to figure it out myself
|
||||
// -- avoid crash
|
||||
QTimer::singleShot(0, this, SLOT(_completed()));
|
||||
}
|
||||
|
||||
//as usual KDE documentation didn't suggest I needed to do this at all
|
||||
//I had to figure it out myself
|
||||
// -- avoid crash
|
||||
QTimer::singleShot( 0, this, SLOT(_completed()) );
|
||||
}
|
||||
void
|
||||
RemoteLister::canceled()
|
||||
{
|
||||
kDebug() << "canceled: " << url().prettyUrl() << endl;
|
||||
|
||||
void
|
||||
RemoteLister::canceled()
|
||||
{
|
||||
qDebug() << "canceled: " << url().prettyURL();
|
||||
QTimer::singleShot(0, this, SLOT(_completed()));
|
||||
}
|
||||
|
||||
QTimer::singleShot( 0, this, SLOT(_completed()) );
|
||||
}
|
||||
void
|
||||
RemoteLister::_completed()
|
||||
{
|
||||
//m_directory is set to the directory we should operate on
|
||||
|
||||
void
|
||||
RemoteLister::_completed()
|
||||
{
|
||||
//m_directory is set to the directory we should operate on
|
||||
KFileItemList items = KDirLister::items();
|
||||
for (KFileItemList::ConstIterator it = items.begin(), end = items.end(); it != end; ++it)
|
||||
{
|
||||
if (it->isDir())
|
||||
m_store->stores += new Store(it->url(), it->name(), m_store);
|
||||
else
|
||||
m_store->directory->append(it->name().toLocal8Bit(), it->size() / 1024);
|
||||
|
||||
KFileItemList items = KDirLister::items();
|
||||
for( KFileItemList::ConstIterator it = items.begin(), end = items.end(); it != end; ++it )
|
||||
{
|
||||
if( (*it)->isDir() )
|
||||
m_store->stores += new Store( (*it)->url(), (*it)->name(), m_store );
|
||||
else
|
||||
m_store->directory->append( (*it)->name().local8Bit(), (*it)->size() / 1024 );
|
||||
|
||||
ScanManager::s_files++;
|
||||
}
|
||||
ScanManager::s_files++;
|
||||
}
|
||||
|
||||
|
||||
if( m_store->stores.isEmpty() )
|
||||
//no directories to scan, so we need to append ourselves to the parent directory
|
||||
//propagate() will return the next ancestor that has stores left to be scanned, or root if we are done
|
||||
m_store = m_store->propagate();
|
||||
if (m_store->stores.isEmpty())
|
||||
//no directories to scan, so we need to append ourselves to the parent directory
|
||||
//propagate() will return the next ancestor that has stores left to be scanned, or root if we are done
|
||||
m_store = m_store->propagate();
|
||||
|
||||
if( !m_store->stores.isEmpty() )
|
||||
{
|
||||
Store::List::Iterator first = m_store->stores.begin();
|
||||
const KURL url( (*first)->url );
|
||||
Store *currentStore = m_store;
|
||||
if (!m_store->stores.isEmpty())
|
||||
{
|
||||
Store::List::Iterator first = m_store->stores.begin();
|
||||
const KUrl url((*first)->url);
|
||||
Store *currentStore = m_store;
|
||||
|
||||
//we should operate with this store next time this function is called
|
||||
m_store = *first;
|
||||
//we should operate with this store next time this function is called
|
||||
m_store = *first;
|
||||
|
||||
//we don't want to handle this store again
|
||||
currentStore->stores.remove( first );
|
||||
//we don't want to handle this store again
|
||||
currentStore->stores.erase(first);
|
||||
|
||||
//this returns _immediately_
|
||||
qDebug() << "Scanning:" << url;
|
||||
openURL( url );
|
||||
}
|
||||
else {
|
||||
//this returns _immediately_
|
||||
kDebug() << "scanning: " << url << endl;
|
||||
openUrl(url);
|
||||
}
|
||||
else {
|
||||
kDebug() << "I think we're done\n";
|
||||
|
||||
qDebug() << "I think we're done";
|
||||
Q_ASSERT(m_root == m_store);
|
||||
|
||||
Q_ASSERT( m_root == m_store );
|
||||
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "remoteLister.moc"
|
||||
|
|
|
@ -1,28 +1,46 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef REMOTE_LISTER_H
|
||||
#define REMOTE_LISTER_H
|
||||
#ifndef REMOTELISTER_H
|
||||
#define REMOTELISTER_H
|
||||
|
||||
#include <kdirlister.h>
|
||||
#include <KDirLister>
|
||||
|
||||
namespace Filelight
|
||||
{
|
||||
class RemoteLister : public KDirLister
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RemoteLister( const KURL &url, QWidget *parent );
|
||||
~RemoteLister();
|
||||
class RemoteLister : public KDirLister
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RemoteLister(const KUrl &url, QWidget *parent);
|
||||
~RemoteLister();
|
||||
|
||||
private slots:
|
||||
void completed();
|
||||
void _completed();
|
||||
void canceled();
|
||||
private slots:
|
||||
void completed();
|
||||
void _completed();
|
||||
void canceled();
|
||||
|
||||
private:
|
||||
class Store *m_root, *m_store;
|
||||
};
|
||||
private:
|
||||
class Store *m_root, *m_store;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,204 +1,223 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "debug.h"
|
||||
#include "fileTree.h"
|
||||
#include <kcursor.h>
|
||||
#include "localLister.h"
|
||||
#include <qapplication.h>
|
||||
#include "remoteLister.h"
|
||||
#include "scan.h"
|
||||
#include "fileTree.h"
|
||||
#include "localLister.h"
|
||||
|
||||
#include <KCursor>
|
||||
#include <KDebug>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
namespace Filelight
|
||||
{
|
||||
bool ScanManager::s_abort = false;
|
||||
uint ScanManager::s_files = 0;
|
||||
bool ScanManager::s_abort = false;
|
||||
uint ScanManager::s_files = 0;
|
||||
|
||||
ScanManager::ScanManager( QObject *parent )
|
||||
: QObject( parent )
|
||||
, m_thread( 0 )
|
||||
, m_cache( new Chain<Directory> )
|
||||
{
|
||||
LocalLister::readMounts();
|
||||
}
|
||||
ScanManager::ScanManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_mutex()
|
||||
, m_thread(0)
|
||||
, m_cache(new Chain<Directory>)
|
||||
{
|
||||
Filelight::LocalLister::readMounts();
|
||||
connect(this, SIGNAL(branchCompleted(Directory*, bool)), this, SLOT(cacheTree(Directory*, bool)));
|
||||
}
|
||||
|
||||
ScanManager::~ScanManager()
|
||||
{
|
||||
if( m_thread ) {
|
||||
qDebug() << "Attempting to abort scan operation...";
|
||||
s_abort = true;
|
||||
m_thread->wait();
|
||||
}
|
||||
ScanManager::~ScanManager()
|
||||
{
|
||||
if (m_thread) {
|
||||
kDebug() << "Attempting to abort scan operation..." << endl;
|
||||
s_abort = true;
|
||||
m_thread->wait();
|
||||
}
|
||||
|
||||
delete m_cache;
|
||||
delete m_cache;
|
||||
|
||||
//RemoteListers are QObjects and get automatically deleted
|
||||
}
|
||||
//RemoteListers are QObjects and get automatically deleted
|
||||
}
|
||||
|
||||
bool
|
||||
ScanManager::running() const
|
||||
{
|
||||
//FIXME not complete
|
||||
return m_thread && m_thread->running();
|
||||
}
|
||||
bool ScanManager::running() const
|
||||
{
|
||||
//FIXME not complete
|
||||
return m_thread && m_thread->isRunning();
|
||||
}
|
||||
|
||||
bool
|
||||
ScanManager::start( const KURL &url )
|
||||
{
|
||||
//url is guaranteed clean and safe
|
||||
bool ScanManager::start(const KUrl &url)
|
||||
{
|
||||
//url is guarenteed clean and safe
|
||||
|
||||
qDebug() << "Scan requested for:" << url;
|
||||
kDebug() << "Scan requested for: " << url.prettyUrl() << endl;
|
||||
|
||||
if( running() ) {
|
||||
//shouldn't happen, but lets prevent mega-disasters just in case eh?
|
||||
qWarning() << "Attempted to run 2 scans concurrently!";
|
||||
//TODO give user an error
|
||||
return false;
|
||||
}
|
||||
if (running()) {
|
||||
//shouldn't happen, but lets prevent mega-disasters just in case eh?
|
||||
kWarning() << "Attempted to run 2 scans concurrently!\n";
|
||||
//TODO give user an error
|
||||
return false;
|
||||
}
|
||||
|
||||
s_files = 0;
|
||||
s_abort = false;
|
||||
s_files = 0;
|
||||
s_abort = false;
|
||||
|
||||
if( url.protocol() == "file" )
|
||||
{
|
||||
const QString path = url.path( 1 );
|
||||
if (url.protocol() == "file")
|
||||
{
|
||||
const QString path = url.path(KUrl::AddTrailingSlash);
|
||||
|
||||
Chain<Directory> *trees = new Chain<Directory>;
|
||||
Chain<Directory> *trees = new Chain<Directory>;
|
||||
|
||||
/* CHECK CACHE
|
||||
* user wants: /usr/local/
|
||||
* cached: /usr/
|
||||
*
|
||||
* user wants: /usr/
|
||||
* cached: /usr/local/, /usr/include/
|
||||
*/
|
||||
/* CHECK CACHE
|
||||
* user wants: /usr/local/
|
||||
* cached: /usr/
|
||||
*
|
||||
* user wants: /usr/
|
||||
* cached: /usr/local/, /usr/include/
|
||||
*/
|
||||
|
||||
for( Iterator<Directory> it = m_cache->iterator(); it != m_cache->end(); ++it )
|
||||
{
|
||||
for (Iterator<Directory> it = m_cache->iterator(); it != m_cache->end(); ++it)
|
||||
{
|
||||
QString cachePath = (*it)->name();
|
||||
|
||||
if( path.startsWith( cachePath ) ) //then whole tree already scanned
|
||||
if (path.startsWith(cachePath)) //then whole tree already scanned
|
||||
{
|
||||
//find a pointer to the requested branch
|
||||
//find a pointer to the requested branch
|
||||
|
||||
qDebug() << "Cache-(a)hit: " << cachePath;
|
||||
kDebug() << "Cache-(a)hit: " << cachePath << endl;
|
||||
|
||||
QStringList split = QStringList::split( '/', path.mid( cachePath.length() ) );
|
||||
Directory *d = *it;
|
||||
Iterator<File> jt;
|
||||
QStringList split = path.mid(cachePath.length()).split('/');
|
||||
Directory *d = *it;
|
||||
Iterator<File> jt;
|
||||
|
||||
while( !split.isEmpty() && d != NULL ) //if NULL we have got lost so abort!!
|
||||
{
|
||||
jt = d->iterator();
|
||||
while (!split.isEmpty() && d != NULL) //if NULL we have got lost so abort!!
|
||||
{
|
||||
jt = d->iterator();
|
||||
|
||||
const Link<File> *end = d->end();
|
||||
QString s = split.first(); s += '/';
|
||||
const Link<File> *end = d->end();
|
||||
QString s = split.first();
|
||||
s += '/';
|
||||
|
||||
for( d = 0; jt != end; ++jt )
|
||||
if( s == (*jt)->name() )
|
||||
{
|
||||
d = (Directory*)*jt;
|
||||
break;
|
||||
}
|
||||
for (d = 0; jt != end; ++jt)
|
||||
if (s == (*jt)->name())
|
||||
{
|
||||
d = (Directory*)*jt;
|
||||
break;
|
||||
}
|
||||
|
||||
split.pop_front();
|
||||
}
|
||||
split.pop_front();
|
||||
}
|
||||
|
||||
if( d )
|
||||
{
|
||||
delete trees;
|
||||
if (d)
|
||||
{
|
||||
delete trees;
|
||||
|
||||
//we found a completed tree, thus no need to scan
|
||||
qDebug() << "Found cache-handle, generating map..";
|
||||
//we found a completed tree, thus no need to scan
|
||||
kDebug() << "Found cache-handle, generating map.." << endl;
|
||||
|
||||
//1001 indicates that this should not be cached
|
||||
QCustomEvent *e = new QCustomEvent( 1001 );
|
||||
e->setData( d );
|
||||
QApplication::postEvent( this, e );
|
||||
emit branchCompleted(d, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//something went wrong, we couldn't find the directory we were expecting
|
||||
qError() << "Didn't find" << path << "in the cache!";
|
||||
delete it.remove(); //safest to get rid of it
|
||||
break; //do a full scan
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//something went wrong, we couldn't find the directory we were expecting
|
||||
kError() << "Didn't find " << path << " in the cache!\n";
|
||||
delete it.remove(); //safest to get rid of it
|
||||
break; //do a full scan
|
||||
}
|
||||
}
|
||||
else if( cachePath.startsWith( path ) ) //then part of the requested tree is already scanned
|
||||
else if (cachePath.startsWith(path)) //then part of the requested tree is already scanned
|
||||
{
|
||||
qDebug() << "Cache-(b)hit:" << cachePath;
|
||||
it.transferTo( *trees );
|
||||
kDebug() << "Cache-(b)hit: " << cachePath << endl;
|
||||
it.transferTo(*trees);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_url.setPath( path ); //FIXME stop switching between paths and KURLs all the time
|
||||
QApplication::setOverrideCursor( KCursor::workingCursor() );
|
||||
//starts listing by itself
|
||||
m_thread = new Filelight::LocalLister( path, trees, this );
|
||||
return true;
|
||||
}
|
||||
m_url.setPath(path); //FIXME stop switching between paths and KURLs all the time
|
||||
QApplication::setOverrideCursor(Qt::BusyCursor);
|
||||
//starts listing by itself
|
||||
m_thread = new Filelight::LocalLister(path, trees, this);
|
||||
connect(m_thread, SIGNAL(branchCompleted(Directory*, bool)), this, SLOT(cacheTree(Directory*, bool)));
|
||||
|
||||
m_url = url;
|
||||
QApplication::setOverrideCursor( KCursor::workingCursor() );
|
||||
//will start listing straight away
|
||||
QObject *o = new Filelight::RemoteLister( url, (QWidget*)parent() );
|
||||
insertChild( o );
|
||||
o->setName( "remote_lister" );
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ScanManager::abort()
|
||||
{
|
||||
s_abort = true;
|
||||
m_url = url;
|
||||
QApplication::setOverrideCursor(Qt::BusyCursor);
|
||||
//will start listing straight away
|
||||
QObject *o = new Filelight::RemoteLister(url, (QWidget*)parent());
|
||||
o->setParent(this);
|
||||
o->setObjectName("remote_lister");
|
||||
return true;
|
||||
}
|
||||
|
||||
delete child( "remote_lister" );
|
||||
bool
|
||||
ScanManager::abort()
|
||||
{
|
||||
s_abort = true;
|
||||
|
||||
return m_thread && m_thread->running();
|
||||
}
|
||||
delete findChild<RemoteLister *>("remote_lister");
|
||||
|
||||
void
|
||||
ScanManager::emptyCache()
|
||||
{
|
||||
s_abort = true;
|
||||
return m_thread && m_thread->isRunning();
|
||||
}
|
||||
|
||||
if( m_thread && m_thread->running() )
|
||||
m_thread->wait();
|
||||
void
|
||||
ScanManager::emptyCache()
|
||||
{
|
||||
s_abort = true;
|
||||
|
||||
emit aboutToEmptyCache();
|
||||
if (m_thread && m_thread->isRunning())
|
||||
m_thread->wait();
|
||||
|
||||
m_cache->empty();
|
||||
}
|
||||
emit aboutToEmptyCache();
|
||||
|
||||
void
|
||||
ScanManager::customEvent( QCustomEvent *e )
|
||||
{
|
||||
Directory *tree = (Directory*)e->data();
|
||||
m_cache->empty();
|
||||
}
|
||||
|
||||
if( m_thread ) {
|
||||
m_thread->terminate();
|
||||
m_thread->wait();
|
||||
delete m_thread; //note the lister deletes itself
|
||||
m_thread = 0;
|
||||
}
|
||||
void
|
||||
ScanManager::cacheTree(Directory *tree, bool finished)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex); // This gets released once it is destroyed.
|
||||
|
||||
emit completed( tree );
|
||||
if (m_thread) {
|
||||
m_thread->terminate();
|
||||
m_thread->wait();
|
||||
delete m_thread; //note the lister deletes itself
|
||||
m_thread = 0;
|
||||
}
|
||||
|
||||
if( tree ) {
|
||||
//we don't cache foreign stuff
|
||||
//we don't recache stuff (thus only type 1000 events)
|
||||
if( e->type() == 1000 && m_url.protocol() == "file" )
|
||||
emit completed(tree);
|
||||
|
||||
if (tree) {
|
||||
//we don't cache foreign stuff
|
||||
//we don't recache stuff (thus only type 1000 events)
|
||||
if (m_url.protocol() == "file" && finished)
|
||||
//TODO sanity check the cache
|
||||
m_cache->append( tree );
|
||||
}
|
||||
else //scan failed
|
||||
m_cache->empty(); //FIXME this is safe but annoying
|
||||
m_cache->append(tree);
|
||||
}
|
||||
else //scan failed
|
||||
m_cache->empty(); //FIXME this is safe but annoying
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
}
|
||||
|
||||
#include "scan.moc"
|
||||
|
|
|
@ -1,11 +1,30 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef SCAN_H
|
||||
#define SCAN_H
|
||||
|
||||
#include <kurl.h>
|
||||
#include <qobject.h>
|
||||
#include <KUrl>
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
|
||||
class QThread;
|
||||
class Directory;
|
||||
|
@ -13,40 +32,44 @@ template<class T> class Chain;
|
|||
|
||||
namespace Filelight
|
||||
{
|
||||
class ScanManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class ScanManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class LocalLister;
|
||||
friend class RemoteLister;
|
||||
friend class LocalLister;
|
||||
friend class RemoteLister;
|
||||
|
||||
public:
|
||||
explicit ScanManager( QObject *parent );
|
||||
~ScanManager();
|
||||
public:
|
||||
ScanManager(QObject *parent);
|
||||
virtual ~ScanManager();
|
||||
|
||||
bool start( const KURL& );
|
||||
bool running() const;
|
||||
bool start(const KUrl&);
|
||||
bool running() const;
|
||||
|
||||
static uint files() { return s_files; }
|
||||
static uint files() {
|
||||
return s_files;
|
||||
}
|
||||
|
||||
public slots:
|
||||
bool abort();
|
||||
void emptyCache();
|
||||
public slots:
|
||||
bool abort();
|
||||
void emptyCache();
|
||||
void cacheTree(Directory*, bool);
|
||||
|
||||
signals:
|
||||
void completed( Directory* );
|
||||
void aboutToEmptyCache();
|
||||
signals:
|
||||
void completed(Directory*);
|
||||
void aboutToEmptyCache();
|
||||
void branchCompleted(Directory* tree, bool finished);
|
||||
|
||||
private:
|
||||
static bool s_abort;
|
||||
static uint s_files;
|
||||
private:
|
||||
static bool s_abort;
|
||||
static uint s_files;
|
||||
|
||||
KURL m_url;
|
||||
QThread *m_thread;
|
||||
Chain<Directory> *m_cache;
|
||||
KUrl m_url;
|
||||
QMutex m_mutex;
|
||||
QThread *m_thread;
|
||||
Chain<Directory> *m_cache;
|
||||
|
||||
virtual void customEvent( QCustomEvent* );
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,66 +1,87 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
|
||||
#include <qapplication.h> //Getting desktop width
|
||||
#include <qcheckbox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qradiobutton.h>
|
||||
#include <qslider.h>
|
||||
#include <qvbuttongroup.h>
|
||||
|
||||
#include <kdirselectdialog.h>
|
||||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <knuminput.h>
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "settingsDialog.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include <KDirSelectDialog>
|
||||
#include <KIconLoader>
|
||||
#include <KLocale>
|
||||
#include <KMessageBox>
|
||||
#include <KNumInput>
|
||||
|
||||
SettingsDialog::SettingsDialog( QWidget *parent, const char *name )
|
||||
: Dialog( parent, name, false ) //3rd param => modal
|
||||
#include <QApplication> //Getting desktop width
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QSlider>
|
||||
#include <QVBoxLayout>
|
||||
#include <QCloseEvent>
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
colourSchemeGroup->setFrameShape( QFrame::NoFrame );
|
||||
setupUi(this);
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
//colourSchemeGroup->setFrameShape(QFrame::NoFrame);
|
||||
|
||||
colourSchemeGroup->insert( new QRadioButton( i18n("Rainbow"), colourSchemeGroup ), Filelight::Rainbow );
|
||||
colourSchemeGroup->insert( new QRadioButton( i18n("KDE Colors"), colourSchemeGroup ), Filelight::KDE );
|
||||
colourSchemeGroup->insert( new QRadioButton( i18n("High Contrast"), colourSchemeGroup ), Filelight::HighContrast );
|
||||
vbox->addWidget(new QRadioButton(i18n("Rainbow"), this), Filelight::Rainbow);
|
||||
vbox->addWidget(new QRadioButton(i18n("KDE Colors"), this), Filelight::KDE);
|
||||
vbox->addWidget(new QRadioButton(i18n("High Contrast"), this), Filelight::HighContrast);
|
||||
|
||||
colourSchemeGroup->setLayout(vbox);
|
||||
|
||||
//read in settings before you make all those nasty connections!
|
||||
reset(); //makes dialog reflect global settings
|
||||
|
||||
connect( &m_timer, SIGNAL(timeout()), SIGNAL(mapIsInvalid()) );
|
||||
connect(&m_timer, SIGNAL(timeout()), SIGNAL(mapIsInvalid()));
|
||||
|
||||
connect( m_addButton, SIGNAL( clicked() ), SLOT( addDirectory() ) );
|
||||
connect( m_removeButton, SIGNAL( clicked() ), SLOT( removeDirectory() ) );
|
||||
connect( m_resetButton, SIGNAL( clicked() ), SLOT( reset() ) );
|
||||
connect( m_closeButton, SIGNAL( clicked() ), SLOT( close() ) );
|
||||
connect(m_addButton, SIGNAL(clicked()), SLOT(addDirectory()));
|
||||
connect(m_removeButton, SIGNAL(clicked()), SLOT(removeDirectory()));
|
||||
connect(m_resetButton, SIGNAL(clicked()), SLOT(reset()));
|
||||
connect(m_closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||
|
||||
connect( colourSchemeGroup, SIGNAL(clicked( int )), SLOT(changeScheme( int )) );
|
||||
connect( contrastSlider, SIGNAL(valueChanged( int )), SLOT(changeContrast( int )) );
|
||||
connect( contrastSlider, SIGNAL(sliderReleased()), SLOT(slotSliderReleased()) );
|
||||
connect(colourSchemeGroup, SIGNAL(clicked(int)), SLOT(changeScheme(int)));
|
||||
connect(contrastSlider, SIGNAL(valueChanged(int)), SLOT(changeContrast(int)));
|
||||
connect(contrastSlider, SIGNAL(sliderReleased()), SLOT(slotSliderReleased()));
|
||||
|
||||
connect( scanAcrossMounts, SIGNAL( toggled( bool ) ), SLOT( startTimer() ) );
|
||||
connect( dontScanRemoteMounts, SIGNAL( toggled( bool ) ), SLOT( startTimer() ) );
|
||||
connect( dontScanRemovableMedia, SIGNAL( toggled( bool ) ), SLOT( startTimer() ) );
|
||||
connect(scanAcrossMounts, SIGNAL(toggled(bool)), SLOT(startTimer()));
|
||||
connect(dontScanRemoteMounts, SIGNAL(toggled(bool)), SLOT(startTimer()));
|
||||
connect(dontScanRemovableMedia, SIGNAL(toggled(bool)), SLOT(startTimer()));
|
||||
|
||||
connect( useAntialiasing, SIGNAL( toggled( bool ) ), SLOT( toggleUseAntialiasing( bool ) ) );
|
||||
connect( varyLabelFontSizes, SIGNAL( toggled( bool ) ), SLOT( toggleVaryLabelFontSizes( bool ) ) );
|
||||
connect( showSmallFiles, SIGNAL( toggled( bool ) ), SLOT( toggleShowSmallFiles( bool ) ) );
|
||||
connect(useAntialiasing, SIGNAL(toggled(bool)), SLOT(toggleUseAntialiasing(bool)));
|
||||
connect(varyLabelFontSizes, SIGNAL(toggled(bool)), SLOT(toggleVaryLabelFontSizes(bool)));
|
||||
connect(showSmallFiles, SIGNAL(toggled(bool)), SLOT(toggleShowSmallFiles(bool)));
|
||||
|
||||
connect( minFontPitch, SIGNAL ( valueChanged( int ) ), SLOT( changeMinFontPitch( int ) ) );
|
||||
connect(minFontPitch, SIGNAL (valueChanged(int)), SLOT(changeMinFontPitch(int)));
|
||||
|
||||
m_addButton->setIconSet( SmallIcon( "fileopen" ) );
|
||||
m_resetButton->setIconSet( SmallIcon( "undo" ) );
|
||||
m_closeButton->setIconSet( SmallIcon( "fileclose" ) );
|
||||
m_addButton->setIcon(SmallIcon("fileopen"));
|
||||
m_resetButton->setIcon(SmallIcon("undo"));
|
||||
m_closeButton->setIcon(SmallIcon("fileclose"));
|
||||
}
|
||||
|
||||
|
||||
void SettingsDialog::closeEvent( QCloseEvent* )
|
||||
void SettingsDialog::closeEvent(QCloseEvent*)
|
||||
{
|
||||
//if an invalidation is pending, force it now!
|
||||
if( m_timer.isActive() ) m_timer.changeInterval( 0 );
|
||||
if (m_timer.isActive()) m_timer.setInterval(0);
|
||||
|
||||
Config::write();
|
||||
|
||||
|
@ -73,53 +94,53 @@ void SettingsDialog::reset()
|
|||
Config::read();
|
||||
|
||||
//tab 1
|
||||
scanAcrossMounts->setChecked( Config::scanAcrossMounts );
|
||||
dontScanRemoteMounts->setChecked( !Config::scanRemoteMounts );
|
||||
dontScanRemovableMedia->setChecked( !Config::scanRemovableMedia );
|
||||
scanAcrossMounts->setChecked(Config::scanAcrossMounts);
|
||||
dontScanRemoteMounts->setChecked(!Config::scanRemoteMounts);
|
||||
dontScanRemovableMedia->setChecked(!Config::scanRemovableMedia);
|
||||
|
||||
dontScanRemoteMounts->setEnabled( Config::scanAcrossMounts );
|
||||
// dontScanRemovableMedia.setEnabled( Config::scanAcrossMounts );
|
||||
dontScanRemoteMounts->setEnabled(Config::scanAcrossMounts);
|
||||
// dontScanRemovableMedia.setEnabled(Config::scanAcrossMounts);
|
||||
|
||||
m_listBox->clear();
|
||||
m_listBox->insertStringList( Config::skipList );
|
||||
m_listBox->setSelected( 0, true );
|
||||
m_listBox->insertStringList(Config::skipList);
|
||||
m_listBox->setSelected(0, true);
|
||||
|
||||
m_removeButton->setEnabled( m_listBox->count() == 0 );
|
||||
m_removeButton->setEnabled(m_listBox->count() == 0);
|
||||
|
||||
//tab 2
|
||||
if( colourSchemeGroup->id( colourSchemeGroup->selected() ) != Config::scheme )
|
||||
if (colourSchemeGroup->selected() != Config::scheme) //TODO: This is probably wrong
|
||||
{
|
||||
colourSchemeGroup->setButton( Config::scheme );
|
||||
colourSchemeGroup->setSelected(Config::scheme);
|
||||
//setButton doesn't call a single QButtonGroup signal!
|
||||
//so we need to call this ourselves (and hence the detection above)
|
||||
changeScheme( Config::scheme );
|
||||
changeScheme(Config::scheme);
|
||||
}
|
||||
contrastSlider->setValue( Config::contrast );
|
||||
contrastSlider->setValue(Config::contrast);
|
||||
|
||||
useAntialiasing->setChecked( (Config::antiAliasFactor > 1) ? true : false );
|
||||
useAntialiasing->setChecked((Config::antiAliasFactor > 1) ? true : false);
|
||||
|
||||
varyLabelFontSizes->setChecked( Config::varyLabelFontSizes );
|
||||
minFontPitch->setEnabled( Config::varyLabelFontSizes );
|
||||
minFontPitch->setValue( Config::minFontPitch );
|
||||
showSmallFiles->setChecked( Config::showSmallFiles );
|
||||
varyLabelFontSizes->setChecked(Config::varyLabelFontSizes);
|
||||
minFontPitch->setEnabled(Config::varyLabelFontSizes);
|
||||
minFontPitch->setValue(Config::minFontPitch);
|
||||
showSmallFiles->setChecked(Config::showSmallFiles);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SettingsDialog::toggleScanAcrossMounts( bool b )
|
||||
void SettingsDialog::toggleScanAcrossMounts(bool b)
|
||||
{
|
||||
Config::scanAcrossMounts = b;
|
||||
|
||||
dontScanRemoteMounts->setEnabled( b );
|
||||
//dontScanRemovableMedia.setEnabled( b );
|
||||
dontScanRemoteMounts->setEnabled(b);
|
||||
//dontScanRemovableMedia.setEnabled(b);
|
||||
}
|
||||
|
||||
void SettingsDialog::toggleDontScanRemoteMounts( bool b )
|
||||
void SettingsDialog::toggleDontScanRemoteMounts(bool b)
|
||||
{
|
||||
Config::scanRemoteMounts = !b;
|
||||
}
|
||||
|
||||
void SettingsDialog::toggleDontScanRemovableMedia( bool b )
|
||||
void SettingsDialog::toggleDontScanRemovableMedia(bool b)
|
||||
{
|
||||
Config::scanRemovableMedia = !b;
|
||||
}
|
||||
|
@ -128,79 +149,80 @@ void SettingsDialog::toggleDontScanRemovableMedia( bool b )
|
|||
|
||||
void SettingsDialog::addDirectory()
|
||||
{
|
||||
const KURL url = KDirSelectDialog::selectDirectory( "/", false, this );
|
||||
const KUrl url = KDirSelectDialog::selectDirectory(KUrl("/"), false, this, "Select directory...");
|
||||
|
||||
//TODO error handling!
|
||||
//TODO wrong protocol handling!
|
||||
|
||||
if( !url.isEmpty() )
|
||||
if (!url.isEmpty())
|
||||
{
|
||||
const QString path = url.path( 1 );
|
||||
const QString path = url.path(KUrl::RemoveTrailingSlash);
|
||||
|
||||
if( !Config::skipList.contains( path ) )
|
||||
if (!Config::skipList.contains(path))
|
||||
{
|
||||
Config::skipList.append( path );
|
||||
m_listBox->insertItem( path );
|
||||
m_removeButton->setEnabled( true );
|
||||
Config::skipList.append(path);
|
||||
m_listBox->insertItem(path);
|
||||
m_removeButton->setEnabled(true);
|
||||
}
|
||||
else KMessageBox::sorry( this, i18n("That directory is already set to be excluded from scans") );
|
||||
else KMessageBox::sorry(this, i18n("That directory is already set to be excluded from scans"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SettingsDialog::removeDirectory()
|
||||
{
|
||||
Config::skipList.remove( m_listBox->currentText() ); //removes all entries that match
|
||||
Config::skipList.removeAll(m_listBox->currentText()); //removes all entries that match
|
||||
|
||||
//safest method to ensure consistency
|
||||
m_listBox->clear();
|
||||
m_listBox->insertStringList( Config::skipList );
|
||||
m_listBox->insertStringList(Config::skipList);
|
||||
|
||||
m_removeButton->setEnabled( m_listBox->count() == 0 );
|
||||
m_removeButton->setEnabled(m_listBox->count() == 0);
|
||||
}
|
||||
|
||||
|
||||
void SettingsDialog::startTimer()
|
||||
{
|
||||
m_timer.start( TIMEOUT, true );
|
||||
m_timer.setSingleShot(true);
|
||||
m_timer.start(TIMEOUT);
|
||||
}
|
||||
|
||||
void SettingsDialog::changeScheme( int s )
|
||||
void SettingsDialog::changeScheme(int s)
|
||||
{
|
||||
Config::scheme = (Filelight::MapScheme)s;
|
||||
emit canvasIsDirty( 1 );
|
||||
emit canvasIsDirty(1);
|
||||
}
|
||||
void SettingsDialog::changeContrast( int c )
|
||||
void SettingsDialog::changeContrast(int c)
|
||||
{
|
||||
Config::contrast = c;
|
||||
emit canvasIsDirty( 3 );
|
||||
emit canvasIsDirty(3);
|
||||
}
|
||||
void SettingsDialog::toggleUseAntialiasing( bool b )
|
||||
void SettingsDialog::toggleUseAntialiasing(bool b)
|
||||
{
|
||||
Config::antiAliasFactor = b ? 2 : 1;
|
||||
emit canvasIsDirty( 2 );
|
||||
emit canvasIsDirty(2);
|
||||
}
|
||||
void SettingsDialog::toggleVaryLabelFontSizes( bool b )
|
||||
void SettingsDialog::toggleVaryLabelFontSizes(bool b)
|
||||
{
|
||||
Config::varyLabelFontSizes = b;
|
||||
minFontPitch->setEnabled( b );
|
||||
emit canvasIsDirty( 0 );
|
||||
minFontPitch->setEnabled(b);
|
||||
emit canvasIsDirty(0);
|
||||
}
|
||||
void SettingsDialog::changeMinFontPitch( int p )
|
||||
void SettingsDialog::changeMinFontPitch(int p)
|
||||
{
|
||||
Config::minFontPitch = p;
|
||||
emit canvasIsDirty( 0 );
|
||||
emit canvasIsDirty(0);
|
||||
}
|
||||
void SettingsDialog::toggleShowSmallFiles( bool b )
|
||||
void SettingsDialog::toggleShowSmallFiles(bool b)
|
||||
{
|
||||
Config::showSmallFiles = b;
|
||||
emit canvasIsDirty( 1 );
|
||||
emit canvasIsDirty(1);
|
||||
}
|
||||
|
||||
|
||||
void SettingsDialog::slotSliderReleased()
|
||||
{
|
||||
emit canvasIsDirty( 2 );
|
||||
emit canvasIsDirty(2);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,48 +1,68 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef SETTINGS_DIALOG_H
|
||||
#define SETTINGS_DIALOG_H
|
||||
#ifndef SETTINGSDLG_H
|
||||
#define SETTINGSDLG_H
|
||||
|
||||
#include "dialog.h" //generated by uic
|
||||
#include <qtimer.h>
|
||||
#include "ui_dialog.h" //generated by uic
|
||||
|
||||
#include <QTimer>
|
||||
#include <QCloseEvent>
|
||||
|
||||
|
||||
class SettingsDialog : public Dialog
|
||||
class SettingsDialog : public QDialog, public Ui::Dialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SettingsDialog( QWidget* =0, const char* =0 );
|
||||
SettingsDialog(QWidget* = 0);
|
||||
|
||||
protected:
|
||||
virtual void closeEvent( QCloseEvent * );
|
||||
virtual void reject();
|
||||
virtual void closeEvent(QCloseEvent *);
|
||||
virtual void reject();
|
||||
|
||||
public slots:
|
||||
void addDirectory();
|
||||
void removeDirectory();
|
||||
void toggleScanAcrossMounts( bool );
|
||||
void toggleDontScanRemoteMounts( bool );
|
||||
void toggleDontScanRemovableMedia( bool );
|
||||
void reset();
|
||||
void startTimer();
|
||||
void toggleUseAntialiasing( bool = true );
|
||||
void toggleVaryLabelFontSizes( bool );
|
||||
void changeContrast( int );
|
||||
void changeScheme( int );
|
||||
void changeMinFontPitch( int );
|
||||
void toggleShowSmallFiles( bool );
|
||||
void slotSliderReleased();
|
||||
void addDirectory();
|
||||
void removeDirectory();
|
||||
void toggleScanAcrossMounts(bool);
|
||||
void toggleDontScanRemoteMounts(bool);
|
||||
void toggleDontScanRemovableMedia(bool);
|
||||
void reset();
|
||||
void startTimer();
|
||||
void toggleUseAntialiasing(bool = true);
|
||||
void toggleVaryLabelFontSizes(bool);
|
||||
void changeContrast(int);
|
||||
void changeScheme(int);
|
||||
void changeMinFontPitch(int);
|
||||
void toggleShowSmallFiles(bool);
|
||||
void slotSliderReleased();
|
||||
|
||||
signals:
|
||||
void mapIsInvalid();
|
||||
void canvasIsDirty( int );
|
||||
void mapIsInvalid();
|
||||
void canvasIsDirty(int);
|
||||
|
||||
private:
|
||||
QTimer m_timer;
|
||||
QTimer m_timer;
|
||||
|
||||
static const uint TIMEOUT=1000;
|
||||
static const uint TIMEOUT=1000;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,91 +1,112 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#include "Config.h"
|
||||
#include "debug.h"
|
||||
#include "fileTree.h"
|
||||
#include <kcursor.h>
|
||||
#include <kiconeffect.h> //MyRadialMap::mousePressEvent()
|
||||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlayout.h>
|
||||
#include <qtextstream.h>
|
||||
#include <qvbox.h>
|
||||
#include "radialMap/radialMap.h"
|
||||
#include "radialMap/widget.h"
|
||||
#include "summaryWidget.h"
|
||||
#include "summaryWidget.moc"
|
||||
|
||||
#include <KCursor>
|
||||
#include <KIconEffect> //MyRadialMap::mousePressEvent()
|
||||
#include <KIconLoader>
|
||||
#include <KIcon>
|
||||
#include <KLocale>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <Q3TextStream>
|
||||
#include <QApplication>
|
||||
#include <Q3CString>
|
||||
#include <Q3ValueList>
|
||||
#include <QMouseEvent>
|
||||
#include <QTextOStream>
|
||||
|
||||
|
||||
static Filelight::MapScheme oldScheme;
|
||||
|
||||
|
||||
struct Disk
|
||||
{
|
||||
QString device;
|
||||
QString type;
|
||||
QString mount;
|
||||
QString icon;
|
||||
QString device;
|
||||
QString type;
|
||||
QString mount;
|
||||
QString icon;
|
||||
|
||||
int size;
|
||||
int used;
|
||||
int free; //NOTE used+avail != size (clustersize!)
|
||||
int size;
|
||||
int used;
|
||||
int free; //NOTE used+avail != size (clustersize!)
|
||||
|
||||
void guessIconName();
|
||||
void guessIconName();
|
||||
};
|
||||
|
||||
|
||||
struct DiskList : QValueList<Disk>
|
||||
struct DiskList : Q3ValueList<Disk>
|
||||
{
|
||||
DiskList();
|
||||
DiskList();
|
||||
};
|
||||
|
||||
|
||||
class MyRadialMap : public RadialMap::Widget
|
||||
{
|
||||
public:
|
||||
MyRadialMap( QWidget *parent )
|
||||
: RadialMap::Widget( parent )
|
||||
{}
|
||||
|
||||
virtual void setCursor( const QCursor &c )
|
||||
MyRadialMap(QWidget *parent)
|
||||
: RadialMap::Widget(parent)
|
||||
{
|
||||
if( focusSegment() && focusSegment()->file()->name() == "Used" )
|
||||
RadialMap::Widget::setCursor( c );
|
||||
}
|
||||
|
||||
virtual void setCursor(const QCursor &c)
|
||||
{
|
||||
if (focusSegment() && focusSegment()->file()->name() == "Used")
|
||||
RadialMap::Widget::setCursor(c);
|
||||
else
|
||||
unsetCursor();
|
||||
}
|
||||
|
||||
virtual void mousePressEvent( QMouseEvent *e )
|
||||
virtual void mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
const RadialMap::Segment *segment = focusSegment();
|
||||
|
||||
//we will allow right clicks to the center circle
|
||||
if( segment == rootSegment() )
|
||||
RadialMap::Widget::mousePressEvent( e );
|
||||
if (segment == rootSegment())
|
||||
RadialMap::Widget::mousePressEvent(e);
|
||||
|
||||
//and clicks to the used segment
|
||||
else if( segment && segment->file()->name() == "Used" ) {
|
||||
const QRect rect( e->x() - 20, e->y() - 20, 40, 40 );
|
||||
KIconEffect::visualActivate( this, rect );
|
||||
emit activated( url() );
|
||||
else if (segment && segment->file()->name() == "Used") {
|
||||
const QRect rect(e->x() - 20, e->y() - 20, 40, 40);
|
||||
// KIconEffect::visualActivate(this, rect); TODO: Re-enable
|
||||
emit activated(url());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
SummaryWidget::SummaryWidget( QWidget *parent, const char *name )
|
||||
: QWidget( parent, name )
|
||||
SummaryWidget::SummaryWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
qApp->setOverrideCursor( KCursor::waitCursor() );
|
||||
|
||||
setPaletteBackgroundColor( Qt::white );
|
||||
(new QGridLayout( this, 1, 2 ))->setAutoAdd( true );
|
||||
|
||||
qApp->setOverrideCursor(Qt::WaitCursor);
|
||||
setLayout(new QHBoxLayout(this));
|
||||
createDiskMaps();
|
||||
|
||||
qApp->restoreOverrideCursor();
|
||||
}
|
||||
|
||||
|
@ -94,13 +115,12 @@ SummaryWidget::~SummaryWidget()
|
|||
Config::scheme = oldScheme;
|
||||
}
|
||||
|
||||
void
|
||||
SummaryWidget::createDiskMaps()
|
||||
void SummaryWidget::createDiskMaps()
|
||||
{
|
||||
DiskList disks;
|
||||
|
||||
const QCString free = i18n( "Free" ).local8Bit();
|
||||
const QCString used = i18n( "Used" ).local8Bit();
|
||||
const Q3CString free = i18n("Free").toLocal8Bit();
|
||||
const Q3CString used = i18n("Used").toLocal8Bit();
|
||||
|
||||
KIconLoader loader;
|
||||
|
||||
|
@ -114,27 +134,39 @@ SummaryWidget::createDiskMaps()
|
|||
if (disk.free == 0 && disk.used == 0)
|
||||
continue;
|
||||
|
||||
QWidget *box = new QVBox( this );
|
||||
RadialMap::Widget *map = new MyRadialMap( box );
|
||||
QWidget *box = new QWidget(this);
|
||||
box->setLayout(new QVBoxLayout(box));
|
||||
//box->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
|
||||
RadialMap::Widget *map = new MyRadialMap(box);
|
||||
|
||||
QString text; QTextOStream( &text )
|
||||
<< "<img src='" << loader.iconPath( disk.icon, KIcon::Toolbar ) << "'>"
|
||||
<< " " << disk.mount << " "
|
||||
<< "<i>(" << disk.device << ")</i>";
|
||||
// QString text; QTextOStream(&text)
|
||||
// << "<img src='" << loader.iconPath(disk.icon, KIconLoader::Toolbar) << "'>"
|
||||
// << " " << disk.mount << " "
|
||||
// << "<i>(" << disk.device << ")</i>";
|
||||
|
||||
QLabel *label = new QLabel( text, box );
|
||||
label->setAlignment( Qt::AlignCenter );
|
||||
label->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum );
|
||||
QGridLayout* horizontalLayout = new QGridLayout(box);
|
||||
|
||||
box->show(); // will show its children too
|
||||
QLabel *icon = new QLabel(box);
|
||||
icon->setPixmap(KIcon(disk.icon).pixmap(32,32));
|
||||
horizontalLayout->addWidget(icon);
|
||||
|
||||
Directory *tree = new Directory( disk.mount.local8Bit() );
|
||||
tree->append( free, disk.free );
|
||||
tree->append( used, disk.used );
|
||||
QLabel *label = new QLabel(disk.mount + " (" + disk.device + ")", box);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
horizontalLayout->addWidget(label);
|
||||
|
||||
map->create( tree ); //must be done when visible
|
||||
box->layout()->addWidget(map);
|
||||
box->layout()->addItem(horizontalLayout);
|
||||
|
||||
connect( map, SIGNAL(activated( const KURL& )), SIGNAL(activated( const KURL& )) );
|
||||
layout()->addWidget(box);
|
||||
//box->show(); // will show its children too
|
||||
|
||||
Directory *tree = new Directory(disk.mount.toLocal8Bit());
|
||||
tree->append(free, disk.free);
|
||||
tree->append(used, disk.used);
|
||||
|
||||
map->create(tree); //must be done when visible
|
||||
|
||||
connect(map, SIGNAL(activated(const KUrl&)), SIGNAL(activated(const KUrl&)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,81 +182,86 @@ SummaryWidget::createDiskMaps()
|
|||
DiskList::DiskList()
|
||||
{
|
||||
//FIXME bug prone
|
||||
setenv( "LANG", "en_US", 1 );
|
||||
setenv( "LC_ALL", "en_US", 1 );
|
||||
setenv( "LC_MESSAGES", "en_US", 1 );
|
||||
setenv( "LC_TYPE", "en_US", 1 );
|
||||
setenv( "LANGUAGE", "en_US", 1 );
|
||||
setenv("LANG", "en_US", 1);
|
||||
setenv("LC_ALL", "en_US", 1);
|
||||
setenv("LC_MESSAGES", "en_US", 1);
|
||||
setenv("LC_TYPE", "en_US", 1);
|
||||
setenv("LANGUAGE", "en_US", 1);
|
||||
|
||||
char buffer[4096];
|
||||
FILE *df = popen( "env LC_ALL=POSIX df " DF_ARGS, "r" );
|
||||
int const N = fread( (void*)buffer, sizeof(char), 4096, df );
|
||||
pclose( df );
|
||||
FILE *df = popen("env LC_ALL=POSIX df " DF_ARGS, "r");
|
||||
int const N = fread((void*)buffer, sizeof(char), 4096, df);
|
||||
buffer[ N ] = '\0';
|
||||
pclose(df);
|
||||
|
||||
QString output = QString::fromLocal8Bit( buffer, N );
|
||||
QTextStream t( &output, IO_ReadOnly );
|
||||
QChar const BLANK( ' ' ); //saves repeated creation of a QChar object
|
||||
QString output = QString::fromLocal8Bit(buffer);
|
||||
Q3TextStream t(&output, QIODevice::ReadOnly);
|
||||
QString const BLANK(QChar(' '));
|
||||
|
||||
while (!t.atEnd()) {
|
||||
QString s = t.readLine().simplifyWhiteSpace();
|
||||
QString s = t.readLine();
|
||||
s = s.simplified();
|
||||
|
||||
if (s.isEmpty())
|
||||
continue;
|
||||
|
||||
if (s.find( BLANK ) < 0)
|
||||
// devicename was too long, the rest wrapped to the next line
|
||||
if (!t.eof())
|
||||
s = s.append( t.readLine().simplifyWhiteSpace() );
|
||||
|
||||
#define GET_NEXT_COLUMN( assign_to_me, modifier ) \
|
||||
n = s.find( BLANK ); \
|
||||
assign_to_me = s.left( n ).modifier; \
|
||||
s.remove( 0, n + 1 );
|
||||
if (s.indexOf(BLANK) < 0) // devicename was too long, rest in next line
|
||||
if (!t.eof()) { // just appends the next line
|
||||
QString v = t.readLine();
|
||||
s = s.append(v.toLatin1());
|
||||
s = s.simplified();
|
||||
}
|
||||
|
||||
Disk disk;
|
||||
int n;
|
||||
disk.device = s.left(s.indexOf(BLANK));
|
||||
s = s.remove(0, s.indexOf(BLANK) + 1);
|
||||
|
||||
Q_DEBUG_BLOCK
|
||||
qDebug() << s;
|
||||
#ifndef NO_FS_TYPE
|
||||
disk.type = s.left(s.indexOf(BLANK));
|
||||
s = s.remove(0, s.indexOf(BLANK) + 1);
|
||||
#endif
|
||||
|
||||
GET_NEXT_COLUMN( disk.device, simplifyWhiteSpace() )
|
||||
#ifndef NO_FS_TYPE
|
||||
GET_NEXT_COLUMN( disk.type, simplifyWhiteSpace() )
|
||||
#endif
|
||||
GET_NEXT_COLUMN( disk.size, toInt() )
|
||||
GET_NEXT_COLUMN( disk.used, toInt() )
|
||||
GET_NEXT_COLUMN( disk.free, toInt() )
|
||||
int n = s.indexOf(BLANK);
|
||||
disk.size = s.left(n).toInt();
|
||||
s = s.remove(0, n + 1);
|
||||
|
||||
disk.mount = s.remove( 0, s.find( BLANK ) + 1 ); // delete the capacity %
|
||||
n = s.indexOf(BLANK);
|
||||
disk.used = s.left(n).toInt();
|
||||
s = s.remove(0, n + 1);
|
||||
|
||||
n = s.indexOf(BLANK);
|
||||
disk.free = s.left(n).toInt();
|
||||
s = s.remove(0, n + 1);
|
||||
|
||||
s = s.remove(0, s.indexOf(BLANK) + 1); // delete the capacity 94%
|
||||
disk.mount = s;
|
||||
|
||||
disk.guessIconName();
|
||||
|
||||
*this += disk;
|
||||
|
||||
qDebug() << "Used:" << disk.used;
|
||||
qDebug() << "Free:" << disk.free;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Disk::guessIconName()
|
||||
void Disk::guessIconName()
|
||||
{
|
||||
if (mount.contains( "cdrom", false )) icon = "cdrom";
|
||||
else if (device.contains( "cdrom", false )) icon = "cdrom";
|
||||
else if (mount.contains( "writer", false )) icon = "cdwriter";
|
||||
else if (device.contains( "writer", false )) icon = "cdwriter";
|
||||
else if (mount.contains( "mo", false )) icon = "mo";
|
||||
else if (device.contains( "mo", false )) icon = "mo";
|
||||
else if (device.contains( "fd", false )) {
|
||||
if (device.contains( "360", false )) icon = "5floppy";
|
||||
else if (device.contains( "1200", false )) icon = "5floppy";
|
||||
else icon = "3floppy";
|
||||
}
|
||||
else if (mount.contains( "floppy", false )) icon = "3floppy";
|
||||
else if (mount.contains( "zip", false )) icon = "zip";
|
||||
else if (type.contains( "nfs", false )) icon = "nfs";
|
||||
else icon = "hdd";
|
||||
if (mount.contains("cdrom")) icon = "media-optical";
|
||||
else if (device.contains("cdrom")) icon = "media-optical";
|
||||
else if (mount.contains("writer")) icon = "media-optical-recordable";
|
||||
else if (device.contains("writer")) icon = "media-optical-recordable";
|
||||
// else if(mount.contains("mo")) icon = "mo";
|
||||
// else if(device.contains("mo")) icon = "mo";
|
||||
else if (device.contains("fd")) {
|
||||
// if(device.contains("360")) icon = "media-floppy";
|
||||
// if(device.contains("1200")) icon = "media-floppy";
|
||||
// else
|
||||
icon = "media-floppy";
|
||||
}
|
||||
else if (mount.contains("floppy")) icon = "media-floppy";
|
||||
else if (mount.contains("zip")) icon = "media-floppy";
|
||||
else if (type.contains("nfs")) icon = "network-server-database";
|
||||
else
|
||||
icon = "drive-harddisk";
|
||||
|
||||
icon += /*mounted() ? */"_mount"/* : "_unmount"*/;
|
||||
// icon += /*mounted() ? */"_mount"/* : "_unmount"*/;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,28 @@
|
|||
// Copyright 2003-6 Max Howell <max.howell@methylblue.com>
|
||||
// Redistributable under the terms of the GNU General Public License
|
||||
/***********************************************************************
|
||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
||||
* Copyright 2008-2009 Martin Sandsmark <sandsmark@samfundet.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef SUMMARY_WIDGET_H
|
||||
#define SUMMARY_WIDGET_H
|
||||
#ifndef FILELIGHTSUMMARY_H
|
||||
#define FILELIGHTSUMMARY_H
|
||||
|
||||
#include <qwidget.h>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class SummaryWidget : public QWidget
|
||||
|
@ -12,11 +30,11 @@ class SummaryWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SummaryWidget( QWidget *parent, const char *name );
|
||||
SummaryWidget(QWidget *parent);
|
||||
~SummaryWidget();
|
||||
|
||||
signals:
|
||||
void activated( const KURL& );
|
||||
void activated(const KUrl&);
|
||||
|
||||
private:
|
||||
void createDiskMaps();
|
||||
|
|
Loading…
Reference in New Issue
Block a user