Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:wolfi323:branches:KDE:Unstable:Applications
libkdepim.ppc
_service:obs_scm:libkdepim-VERSIONgit.20200716T...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:libkdepim-VERSIONgit.20200716T080123~b231803.obscpio of Package libkdepim.ppc
07070100000000000081A40000000200000002000000015F0FED3300000802000000000000000000000000000000000000003C00000000libkdepim-VERSIONgit.20200716T080123~b231803/.gitlab-ci.ymlinclude: - https://invent.kde.org/sysadmin/ci-tooling/raw/master/invent/ci-before.yml - https://invent.kde.org/sysadmin/ci-tooling/raw/master/invent/ci-applications-linux.yml build_clazy_clang_tidy: stage: build image: kdeorg/ci-suse-qt514 extends: .linux #only: # - merge_requests before_script: - zypper install -y clazy - git clone --depth=1 https://invent.kde.org/sysadmin/ci-tooling.git $CI_TOOLING - git clone --depth=1 https://invent.kde.org/sysadmin/repo-metadata.git $CI_TOOLING/repo-metadata - git clone --depth=1 https://invent.kde.org/sysadmin/kde-build-metadata.git $CI_TOOLING/kde-build-metadata - git clone --depth=1 https://invent.kde.org/sdk/kde-dev-scripts.git $CI_TOOLING/kde-dev-scripts script: - export CXX=clazy - export CC=clang - export CXXFLAGS="-Wno-deprecated-declarations" - export CLAZY_HEADER_FILTER='^(?!ui_)\w+.h\$' - export CLAZY_CHECKS="level0,level1,detaching-member,ifndef-define-typo,isempty-vs-count,qrequiredresult-candidates,reserve-candidates,signal-with-return-value,unneeded-cast,function-args-by-ref,function-args-by-value,returning-void-expression,no-ctor-missing-parent-argument,isempty-vs-count,qhash-with-char-pointer-key,raw-environment-function,qproperty-type-mismatch,old-style-connect,qstring-allocations,container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,qstring-varargs" - python3 -u $CI_TOOLING/helpers/prepare-dependencies.py --product $PRODUCT --project $PROJECT --branchGroup $BRANCH_GROUP --environment production --platform $PLATFORM --installTo $INSTALL_PREFIX - python3 -u $CI_TOOLING/helpers/configure-build.py --product $PRODUCT --project $PROJECT --branchGroup $BRANCH_GROUP --platform $PLATFORM --installTo $INSTALL_PREFIX - python3 -u $CI_TOOLING/helpers/compile-build.py --product $PRODUCT --project $PROJECT --branchGroup $BRANCH_GROUP --platform $PLATFORM --usingInstall $INSTALL_PREFIX - cd build && run-clang-tidy variables: PLATFORM: SUSEQt5.14 BRANCH_GROUP: kf5-qt5 07070100000001000081A40000000200000002000000015F0FED3300000A12000000000000000000000000000000000000003C00000000libkdepim-VERSIONgit.20200716T080123~b231803/CMakeLists.txtcmake_minimum_required(VERSION 3.5) set(PIM_VERSION "5.15.41") project(libkdepim VERSION ${PIM_VERSION}) set(KF5_MIN_VERSION "5.72.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(LIBRARY_NAMELINK) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(GenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(FeatureSummary) include(ECMQtDeclareLoggingCategory) include(ECMAddTests) set(LIBKDEPIM_LIB_VERSION ${PIM_VERSION}) set(QT_REQUIRED_VERSION "5.13.0") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test DBus Network) find_package(KF5Codecs ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Completion ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ItemViews ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5JobWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KCMUtils ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) option(BUILD_DESIGNERPLUGIN "Build plugin for Qt Designer" ON) add_feature_info(DESIGNERPLUGIN ${BUILD_DESIGNERPLUGIN} "Build plugin for Qt Designer") add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00) add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054800) add_definitions(-DQT_NO_FOREACH) add_definitions(-DQT_NO_KEYWORDS) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) ########### CMake Config Files ########### set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Libkdepim") configure_package_config_file(MailTransportDBusServiceConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/MailTransportDBusServiceConfig.cmake PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_PREFIX}/MailTransportDBusService") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MailTransportDBusServiceConfig.cmake DESTINATION "${CMAKECONFIG_INSTALL_PREFIX}/MailTransportDBusService") add_subdirectory(src) ecm_qt_install_logging_categories( EXPORT LIBKDEPIM FILE libkdepim.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) 07070100000002000081A40000000200000002000000015F0FED3300004761000000000000000000000000000000000000003500000000libkdepim-VERSIONgit.20200716T080123~b231803/COPYINGNOTE! The GPL below is copyrighted by the Free Software Foundation, but the instance of code that it refers to (the kde programs) are copyrighted by the authors who actually wrote it. --------------------------------------------------------------------------- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) 19yy <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. 07070100000003000081A40000000200000002000000015F0FED330000679F000000000000000000000000000000000000003900000000libkdepim-VERSIONgit.20200716T080123~b231803/COPYING.LIB GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the library's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. <signature of Ty Coon>, 1 April 1990 Ty Coon, President of Vice That's all there is to it! 07070100000004000081A40000000200000002000000015F0FED330000007C000000000000000000000000000000000000005500000000libkdepim-VERSIONgit.20200716T080123~b231803/MailTransportDBusServiceConfig.cmake.in@PACKAGE_INIT@ set(MAILTRANSPORT_DBUS_SERVICE "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@/org.kde.mailtransport.service.xml") 07070100000005000081A40000000200000002000000015F0FED33000002A9000000000000000000000000000000000000003200000000libkdepim-VERSIONgit.20200716T080123~b231803/PLANIntro: Plans for cleaning up libkdepim. Goal: libkdepim should no longer be a dumping ground of misc stuff for pim apps. # Rewrite and move to kdepimlibs/akonadi/contacts addresseelineedit completionordereditor kmailcompletion # Move to kdepimlibs/kontactinterfaces? agentprogressmonitor overlaywidget progressdialog progressmanager ssllabel statusbarprogresswidget # Move to kdeui/widgets after api review kdatepickerpopup kwidgetlister uistatesaver # Port korganizer and kontact to kconfigdialogmanager instead kprefsdialog # Get rid of recentaddresses # replace with live searches? # Still needed? or replaced by a new parameterized AkonadiDrag object? maillistdrag 07070100000006000081A40000000200000002000000015F0FED33000000EE000000000000000000000000000000000000003B00000000libkdepim-VERSIONgit.20200716T080123~b231803/metainfo.yamlname: libkdepim description: KDEpim Library maintainer: mlaurent public_lib: true type: functional group: kdepim platforms: - name: All irc: akonadi libraries: - qmake: Libkdepim cmake: "KF5::Libkdepim" cmakename: KF5Libkdepim 07070100000007000041ED0000000200000002000000035F0FED3300000000000000000000000000000000000000000000003100000000libkdepim-VERSIONgit.20200716T080123~b231803/src07070100000008000081A40000000200000002000000015F0FED3300000090000000000000000000000000000000000000004000000000libkdepim-VERSIONgit.20200716T080123~b231803/src/CMakeLists.txtadd_definitions(-DTRANSLATION_DOMAIN=\"libkdepim\") if(BUILD_TESTING) add_definitions(-DBUILD_TESTING) endif() add_subdirectory(libkdepim) 07070100000009000081A40000000200000002000000015F0FED3300000080000000000000000000000000000000000000003D00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/Messages.sh#! /bin/sh $XGETTEXT `find . -name '*.h' -o -name '*.cpp' | grep -v '/tests/' | grep -v '/autotests/'` -o $podir/libkdepim.pot 0707010000000A000041ED0000000200000002000000095F0FED3300000000000000000000000000000000000000000000003B00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim0707010000000B000081A40000000200000002000000015F0FED33000014BB000000000000000000000000000000000000004A00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/CMakeLists.txt ecm_setup_version(PROJECT VARIABLE_PREFIX LIBKDEPIM VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/libkdepim_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5LibkdepimConfigVersion.cmake" SOVERSION 5 ) if (BUILD_TESTING) add_subdirectory(tests) add_subdirectory(progresswidget/autotests/) add_subdirectory(progresswidget/tests/) endif() ########### next target ############### set(kdepim_progresswidget_LIB_SRCS progresswidget/progressmanager.cpp progresswidget/progressdialog.cpp progresswidget/statusbarprogresswidget.cpp progresswidget/ssllabel.cpp progresswidget/progressstatusbarwidget.cpp ) set(kdepim_widgets_LIB_SRCS widgets/kcheckcombobox.cpp widgets/kwidgetlister.cpp widgets/progressindicatorlabel.cpp ) set(kdepim_misc_LIB_SRCS misc/uistatesaver.cpp misc/lineeditcatchreturnkey.cpp ) set(kdepim_multiplyingline_LIB_SRCS multiplyingline/multiplyingline.cpp multiplyingline/multiplyinglineeditor.cpp multiplyingline/multiplyinglineview_p.cpp ) set(kdepim_LIB_SRCS ${kdepim_progresswidget_LIB_SRCS} ${kdepim_widgets_LIB_SRCS} ${kdepim_misc_LIB_SRCS} ${kdepim_multiplyingline_LIB_SRCS} ) ecm_qt_declare_logging_category(kdepim_LIB_SRCS HEADER libkdepim_debug.h IDENTIFIER LIBKDEPIM_LOG CATEGORY_NAME org.kde.pim.libkdepim DESCRIPTION "libkdepim (libkdepim)" OLD_CATEGORY_NAMES log_libkdepim EXPORT LIBKDEPIM ) add_library(KF5Libkdepim ${kdepim_LIB_SRCS}) generate_export_header(KF5Libkdepim BASE_NAME kdepim) add_library(KF5::Libkdepim ALIAS KF5Libkdepim) target_include_directories(KF5Libkdepim INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/Libkdepim/;${KDE_INSTALL_INCLUDEDIR_KF5}/libkdepim>") target_include_directories(KF5Libkdepim PUBLIC "$<BUILD_INTERFACE:${libkdepim_SOURCE_DIR}/src;${libkdepim_BINARY_DIR}/src;>") target_link_libraries(KF5Libkdepim PRIVATE KF5::Codecs KF5::Completion KF5::I18n KF5::KIOCore KF5::KIOWidgets KF5::ConfigGui KF5::KCMUtils ) if(MINGW) target_link_libraries(KF5Libkdepim oleaut32) endif() set_target_properties(KF5Libkdepim PROPERTIES VERSION ${LIBKDEPIM_VERSION_STRING} SOVERSION ${LIBKDEPIM_SOVERSION} EXPORT_NAME Libkdepim ) install(TARGETS KF5Libkdepim EXPORT KF5LibkdepimTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS} ${LIBRARY_NAMELINK} ) ecm_generate_headers(libkdepim_Camelcasewidgets_HEADERS HEADER_NAMES KCheckComboBox KWidgetLister ProgressIndicatorLabel REQUIRED_HEADERS libkdepim_widgets_HEADERS PREFIX Libkdepim RELATIVE widgets ) ecm_generate_headers(libkdepim_Camelcasemisc_HEADERS HEADER_NAMES UiStateSaver KCursorSaver LineEditCatchReturnKey REQUIRED_HEADERS libkdepim_misc_HEADERS PREFIX Libkdepim RELATIVE misc ) ecm_generate_headers(libkdepim_Camelcaseprogresswidget_HEADERS HEADER_NAMES ProgressStatusBarWidget StatusbarProgressWidget ProgressDialog ProgressManager REQUIRED_HEADERS libkdepim_progresswidget_HEADERS PREFIX Libkdepim RELATIVE progresswidget ) ecm_generate_headers(libkdepim_Camelcasemultiline_HEADERS HEADER_NAMES MultiplyingLine MultiplyingLineEditor REQUIRED_HEADERS libkdepim_multiline_HEADERS PREFIX Libkdepim RELATIVE multiplyingline ) ecm_generate_pri_file(BASE_NAME Libkdepim LIB_NAME KF5Libkdepim DEPS "" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/Libkdepim ) install(FILES ${libkdepim_CamelcaseCamelCase_HEADERS} ${libkdepim_Camelcasewidgets_HEADERS} ${libkdepim_Camelcaseprogresswidget_HEADERS} ${libkdepim_Camelcasemisc_HEADERS} ${libkdepim_Camelcasemultiline_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/Libkdepim COMPONENT Devel ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kdepim_export.h ${libkdepim_CamelCase_HEADERS} ${libkdepim_progresswidget_HEADERS} ${libkdepim_misc_HEADERS} ${libkdepim_widgets_HEADERS} ${libkdepim_multiline_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/libkdepim COMPONENT Devel ) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) if(BUILD_DESIGNERPLUGIN) add_subdirectory(designer) endif() ########### install files ############### install(FILES interfaces/org.kde.addressbook.service.xml interfaces/org.kde.mailtransport.service.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR}) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Libkdepim") configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5LibkdepimConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5LibkdepimConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5LibkdepimConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5LibkdepimConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5LibkdepimTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5LibkdepimTargets.cmake NAMESPACE KF5::) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libkdepim_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) 0707010000000C000081A40000000200000002000000015F0FED3300000071000000000000000000000000000000000000005700000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/KF5LibkdepimConfig.cmake.in@PACKAGE_INIT@ include(CMakeFindDependencyMacro) include("${CMAKE_CURRENT_LIST_DIR}/KF5LibkdepimTargets.cmake") 0707010000000D000041ED0000000200000002000000025F0FED3300000000000000000000000000000000000000000000004400000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/designer0707010000000E000081A40000000200000002000000015F0FED3300000242000000000000000000000000000000000000005300000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/designer/CMakeLists.txtinclude(ECMAddQtDesignerPlugin) ecm_qtdesignerplugin_widget(KPIM::KCheckComboBox INCLUDE_FILE "Libkdepim/KCheckComboBox" TOOLTIP "Combobox with checkable items (KDE-PIM)" WHATSTHIS "A combobox that allows the user to check the items in the drop down menu" GROUP "Input (KDE-PIM)" ) ecm_add_qtdesignerplugin(kdepimwidgets NAME KDEPimWidgets OUTPUT_NAME kdepimwidgets WIDGETS KPIM::KCheckComboBox LINK_LIBRARIES KF5::Libkdepim KF5::Completion INSTALL_DESTINATION "${KDE_INSTALL_QTPLUGINDIR}/designer" COMPONENT Devel ) 0707010000000F000041ED0000000200000002000000025F0FED3300000000000000000000000000000000000000000000004600000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/interfaces07070100000010000081A40000000200000002000000015F0FED3300000145000000000000000000000000000000000000006600000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/interfaces/org.kde.addressbook.service.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="org.kde.adressbook.service"> <method name="importVCardFromData"> <arg name="vCard" type="s" direction="in"/> </method> </interface> </node> 07070100000011000081A40000000200000002000000015F0FED3300000441000000000000000000000000000000000000006800000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/interfaces/org.kde.mailtransport.service.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="org.kde.mailtransport.service"> <method name="sendMessage"> <arg type="b" direction="out"/> <arg name="from" type="s" direction="in"/> <arg name="to" type="s" direction="in"/> <arg name="cc" type="s" direction="in"/> <arg name="bcc" type="s" direction="in"/> <arg name="subject" type="s" direction="in"/> <arg name="body" type="s" direction="in"/> <arg name="attachments" type="as" direction="in"/> </method> <method name="sendMessage"> <arg type="b" direction="out"/> <arg name="from" type="s" direction="in"/> <arg name="to" type="s" direction="in"/> <arg name="cc" type="s" direction="in"/> <arg name="bcc" type="s" direction="in"/> <arg name="subject" type="s" direction="in"/> <arg name="body" type="s" direction="in"/> <arg name="attachment" type="ay" direction="in"/> </method> </interface> </node> 07070100000012000081A40000000200000002000000015F0FED33000004C7000000000000000000000000000000000000005600000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/libkdepim_private_export.h/* This file is part of the KDE project Copyright (C) 2017-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LIBKDEPIMPRIVATE_EXPORT_H #define LIBKDEPIMPRIVATE_EXPORT_H #include "kdepim_export.h" /* Classes which are exported only for unit tests */ #ifdef BUILD_TESTING # ifndef LIBKDEPIM_TESTS_EXPORT # define LIBKDEPIM_TESTS_EXPORT KDEPIM_EXPORT # endif #else /* not compiling tests */ # define LIBKDEPIM_TESTS_EXPORT #endif #endif 07070100000013000041ED0000000200000002000000025F0FED3300000000000000000000000000000000000000000000004000000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/misc07070100000014000081A40000000200000002000000015F0FED3300000876000000000000000000000000000000000000004F00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/misc/kcursorsaver.h/* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef kcursorsaver_h #define kcursorsaver_h #include <QCursor> #include <QApplication> namespace KPIM { /** * @short sets a cursor and makes sure it's restored on destruction * Create a KCursorSaver object when you want to set the cursor. * As soon as it gets out of scope, it will restore the original * cursor. */ class KCursorSaver { public: /// constructor taking QCursor shapes explicit KCursorSaver(Qt::CursorShape shape) { QApplication::setOverrideCursor(QCursor(shape)); inited = true; } /// copy constructor. The right side won't restore the cursor KCursorSaver(const KCursorSaver &rhs) { *this = rhs; } /// restore the cursor ~KCursorSaver() { if (inited) { QApplication::restoreOverrideCursor(); } } /// call this to explitly restore the cursor inline void restoreCursor() { QApplication::restoreOverrideCursor(); inited = false; } protected: void operator=(const KCursorSaver &rhs) { inited = rhs.inited; rhs.inited = false; } private: mutable bool inited; }; /** * convenience functions */ namespace KBusyPtr { inline KCursorSaver idle() { return KCursorSaver(Qt::ArrowCursor); } inline KCursorSaver busy() { return KCursorSaver(Qt::WaitCursor); } } } #endif /*kbusyptr_h_*/ 07070100000015000081A40000000200000002000000015F0FED3300000729000000000000000000000000000000000000005B00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/misc/lineeditcatchreturnkey.cpp/* Copyright (C) 2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lineeditcatchreturnkey.h" #include <QEvent> #include <QKeyEvent> #include <QLineEdit> using namespace KPIM; LineEditCatchReturnKey::LineEditCatchReturnKey(QLineEdit *lineEdit, QObject *parent) : QObject(parent) , mLineEdit(lineEdit) { mLineEdit->installEventFilter(this); } LineEditCatchReturnKey::~LineEditCatchReturnKey() { } bool LineEditCatchReturnKey::eventFilter(QObject *obj, QEvent *event) { if (obj == mLineEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent *e = static_cast<QKeyEvent *>(event); if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) { const bool stopEvent = (e->modifiers() == Qt::NoButton || e->modifiers() == Qt::KeypadModifier); if (stopEvent) { Q_EMIT mLineEdit->returnPressed(); } return true; } } } return QObject::eventFilter(obj, event); } 07070100000016000081A40000000200000002000000015F0FED3300000594000000000000000000000000000000000000005900000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/misc/lineeditcatchreturnkey.h/* Copyright (C) 2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINEEDITCATCHRETURNKEY_H #define LINEEDITCATCHRETURNKEY_H #include <QObject> #include "kdepim_export.h" class QLineEdit; namespace KPIM { /** * @brief The LineEditCatchReturnKey class * @author Laurent Montel <montel@kde.org> */ class KDEPIM_EXPORT LineEditCatchReturnKey : public QObject { Q_OBJECT public: explicit LineEditCatchReturnKey(QLineEdit *lineEdit, QObject *parent = nullptr); ~LineEditCatchReturnKey(); protected: bool eventFilter(QObject *obj, QEvent *event) override; private: QLineEdit *mLineEdit = nullptr; }; } #endif // LINEEDITCATCHRETURNKEY_H 07070100000017000081A40000000200000002000000015F0FED3300000EA5000000000000000000000000000000000000005100000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/misc/uistatesaver.cpp/* Copyright (c) 2008 Volker Krause <vkrause@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "uistatesaver.h" #include <KConfigGroup> #include <QComboBox> #include <QHeaderView> #include <QSplitter> #include <QTabWidget> #include <QTreeView> using namespace KPIM; struct Saver { static void process(QSplitter *splitter, KConfigGroup &config) { if (splitter->sizes().count(0) == splitter->sizes().count()) { return; } config.writeEntry(splitter->objectName(), splitter->sizes()); } static void process(QTabWidget *tab, KConfigGroup &config) { config.writeEntry(tab->objectName(), tab->currentIndex()); } static void process(QTreeView *tv, KConfigGroup &config) { config.writeEntry(tv->objectName(), tv->header()->saveState()); } static void process(QComboBox *cb, KConfigGroup &config) { config.writeEntry(cb->objectName(), cb->currentIndex()); } }; struct Restorer { static void process(QSplitter *splitter, const KConfigGroup &config) { const QList<int> sizes = config.readEntry(splitter->objectName(), QList<int>()); if (!sizes.isEmpty() && splitter->count() == sizes.count() && sizes.count() != sizes.count(0)) { splitter->setSizes(sizes); } } static void process(QTabWidget *tab, const KConfigGroup &config) { const int index = config.readEntry(tab->objectName(), -1); if (index >= 0 && index < tab->count()) { tab->setCurrentIndex(index); } } static void process(QTreeView *tv, const KConfigGroup &config) { const QByteArray state = config.readEntry(tv->objectName(), QByteArray()); if (!state.isEmpty()) { tv->header()->restoreState(state); } } static void process(QComboBox *cb, const KConfigGroup &config) { const int index = config.readEntry(cb->objectName(), -1); if (index >= 0 && index < cb->count()) { cb->setCurrentIndex(index); } } }; #define PROCESS_TYPE(T) \ { \ T *obj = qobject_cast<T *>(w); \ if (obj) { \ Op::process(obj, config); \ continue; \ } \ } template<typename Op, typename Config> static void processWidgets(QWidget *widget, Config config) { QList<QWidget *> widgets = widget->findChildren<QWidget *>(); widgets << widget; for (QWidget *w : qAsConst(widgets)) { if (w->objectName().isEmpty()) { continue; } PROCESS_TYPE(QSplitter); PROCESS_TYPE(QTabWidget); PROCESS_TYPE(QTreeView); PROCESS_TYPE(QComboBox); } } #undef PROCESS_TYPE void UiStateSaver::saveState(QWidget *widget, KConfigGroup &config) { processWidgets<Saver, KConfigGroup &>(widget, config); } void UiStateSaver::restoreState(QWidget *widget, const KConfigGroup &config) { processWidgets<Restorer, const KConfigGroup &>(widget, config); } 07070100000018000081A40000000200000002000000015F0FED330000083B000000000000000000000000000000000000004F00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/misc/uistatesaver.h/* Copyright (c) 2008 Volker Krause <vkrause@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef UISTATESAVER_H #define UISTATESAVER_H #include "kdepim_export.h" class QWidget; class KConfigGroup; namespace KPIM { /** * @short Methods to save and restore the UI state of an application. * * This namespace provides methods that automatically save and restore * the state of various UI elements to/from a configuration group. * * The following widgets are supported so far: * - QSplitter * - QTabWidget * - QTreeView * - QComboBox * * @note The widgets need to have set an objectName, otherwise they are ignored * on processing. * * @author Volker Krause <vkrause@kde.org> * @since 4.5 */ namespace UiStateSaver { /** * Saves the state of @p widget and all its sub-widgets to @p config. * @param widget The top-level widget which state should be saved. * @param config The config group the settings should be written to. */ KDEPIM_EXPORT void saveState(QWidget *widget, KConfigGroup &config); /** * Restores the UI state of @p widget and all its sub-widgets from @p config. * @param widget The top-level widget which state should be restored. * @param config The config gorup the settings should be read from. */ KDEPIM_EXPORT void restoreState(QWidget *widget, const KConfigGroup &config); } } #endif 07070100000019000041ED0000000200000002000000025F0FED3300000000000000000000000000000000000000000000004B00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/multiplyingline0707010000001A000081A40000000200000002000000015F0FED330000070B000000000000000000000000000000000000005F00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/multiplyingline/multiplyingline.cpp/* Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com> Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> Refactored from earlier code by: Copyright (c) 2010 Volker Krause <vkrause@kde.org> Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "multiplyingline.h" #include <QKeyEvent> using namespace KPIM; MultiplyingLine::MultiplyingLine(QWidget *parent) : QWidget(parent) { } void MultiplyingLine::slotReturnPressed() { Q_EMIT returnPressed(this); } void MultiplyingLine::slotPropagateDeletion() { Q_EMIT deleteLine(this); } void MultiplyingLine::slotFocusUp() { Q_EMIT upPressed(this); } void MultiplyingLine::slotFocusDown() { Q_EMIT downPressed(this); } void MultiplyingLine::keyPressEvent(QKeyEvent *ev) { if (ev->key() == Qt::Key_Up) { Q_EMIT upPressed(this); } else if (ev->key() == Qt::Key_Down) { Q_EMIT downPressed(this); } } void MultiplyingLine::aboutToBeDeleted() { } 0707010000001B000081A40000000200000002000000015F0FED330000182F000000000000000000000000000000000000005D00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/multiplyingline/multiplyingline.h/* Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com> Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> Refactored from earlier code by: Copyright (c) 2010 Volker Krause <vkrause@kde.org> Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MULTIPLYINGLINE_H #define MULTIPLYINGLINE_H #include "kdepim_export.h" #include <KCompletion> #include <QWidget> #include <QSharedPointer> namespace KPIM { /** @short ABC representing line data @author Casey Link */ class KDEPIM_EXPORT MultiplyingLineData { public: typedef QSharedPointer<MultiplyingLineData> Ptr; virtual ~MultiplyingLineData() { } /** Clear data, reset to defaults */ virtual void clear() = 0; /** Is the data empty? */ virtual bool isEmpty() const = 0; }; /** @short Abstract Base Class representing a line in the Multiplying line widget. This class (and its subclasses) represent the lines in the MultiplyingLineEditor. Users of the MultiplyingLineEditor widget should subclass this class, and add their own input widgets as members, then implement the pure virtual methods and connect all the appropriate slots. @author Casey Link */ class KDEPIM_EXPORT MultiplyingLine : public QWidget { Q_OBJECT public: explicit MultiplyingLine(QWidget *parent); ~MultiplyingLine() override { } /** This line is being activated. Focus should be set on the first or most important widget in the line. */ virtual void activate() = 0; /** Check if whatever receives focus in activate() currently has focus. @return true if this line is active */ virtual bool isActive() const = 0; /** Determine if this line was modified. @return true if the user has made any modifications to this MultiplyingLine. */ virtual bool isModified() const = 0; /** Resets the modified flag to false. */ virtual void clearModified() = 0; /** Retrieve the data. @return the data associated with this line. */ virtual MultiplyingLineData::Ptr data() const = 0; /** Set the data of this line. The containing widgets should be populated accordingly. @param data the data to populate this line wit */ virtual void setData(const MultiplyingLineData::Ptr &data) = 0; /** Whether this line is empty or not. Usually there is a primary widget that can be tested (such as a line edit). @return true if this line is empty, false otherwise. */ virtual bool isEmpty() const = 0; virtual bool canDeleteLineEdit() const = 0; /** Set the width of the left most column to be the argument width. This method allows other widgets to align their label/combobox column with ours by communicating how many pixels that first column is for them. @param w the width to set the left most column to. @return the width that is actually being used. */ virtual int setColumnWidth(int w) = 0; /** Used to set setup the correct chain of widgets to focus on when the user presses tab. @param previous the previous widget (probably from the preceding line) Example with a 3 widget line: void YourLine::fixTabOrder( QWidget *previous ) { setTabOrder( previous, mLeftMost ); setTabOrder( mLeftMost, mMiddle); setTabOrder( mMiddle, mRightMost); } */ virtual void fixTabOrder(QWidget *previous) = 0; /** @return The final widget in this line on which if the user presses tab focus should be given to the next line. This will commonly be used as the parameter of fixTabOrder( QWidget *previous ). @see fixTabOrder( QWidget *previous ) */ virtual QWidget *tabOut() const = 0; /** Clear the contents of this line. Reset to default state */ virtual void clear() = 0; /** Sets the type of completion to be used for KLineEdits in this line @param mode the completion mode */ virtual void setCompletionMode(KCompletion::CompletionMode mode) = 0; /** * Re implement this method if you need to do something * before a line is deleted. * * Default implementation does nothing. */ virtual void aboutToBeDeleted(); Q_SIGNALS: /** Emitted when the return/enter key is pressed */ void returnPressed(KPIM::MultiplyingLine *); /** Emitted when the down key is pressed */ void downPressed(KPIM::MultiplyingLine *); /** Emitted when the up key is pressed */ void upPressed(KPIM::MultiplyingLine *); /** Emitted when the right key is pressed */ void rightPressed(); /** Should be emitted when the line should be deleted */ void deleteLine(KPIM::MultiplyingLine *); /** Emitted when the completion mode changes */ void completionModeChanged(KCompletion::CompletionMode); public Q_SLOTS: void slotPropagateDeletion(); protected Q_SLOTS: void slotReturnPressed(); void slotFocusUp(); void slotFocusDown(); protected: /** Handles key press events on this line. Default behavior handles Up and Down presses. */ void keyPressEvent(QKeyEvent *) override; }; } #endif // MULTIPLYINGLINE_H 0707010000001C000081A40000000200000002000000015F0FED33000011C7000000000000000000000000000000000000006500000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/multiplyingline/multiplyinglineeditor.cpp/* Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com> Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> Refactored from earlier code by: Copyright (c) 2010 Volker Krause <vkrause@kde.org> Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "multiplyinglineeditor.h" #include "multiplyinglineview_p.h" #include <QHBoxLayout> using namespace KPIM; MultiplyingLineEditor::MultiplyingLineEditor(MultiplyingLineFactory *factory, QWidget *parent) : QWidget(parent) , mMultiplyingLineFactory(factory) { QBoxLayout *topLayout = new QHBoxLayout(this); topLayout->setContentsMargins(0, 0, 0, 0); mView = new MultiplyingLineView(mMultiplyingLineFactory, this); topLayout->addWidget(mView); connect(mView, &MultiplyingLineView::focusUp, this, &MultiplyingLineEditor::focusUp); connect(mView, &MultiplyingLineView::focusDown, this, &MultiplyingLineEditor::focusDown); connect(mView, &MultiplyingLineView::completionModeChanged, this, &MultiplyingLineEditor::completionModeChanged); connect(mView, &MultiplyingLineView::lineDeleted, this, &MultiplyingLineEditor::lineDeleted); connect(mView, &MultiplyingLineView::lineAdded, this, &MultiplyingLineEditor::lineAdded); connect(mView, &MultiplyingLineView::sizeHintChanged, this, &MultiplyingLineEditor::sizeHintChanged); } MultiplyingLineEditor::~MultiplyingLineEditor() { delete mMultiplyingLineFactory; } bool MultiplyingLineEditor::addData(const MultiplyingLineData::Ptr &data) { MultiplyingLine *line = mView->emptyLine(); bool tooManyAddress = false; if (!line) { line = mView->addLine(); } if (!line) { tooManyAddress = true; } if (line && data) { line->setData(data); } return tooManyAddress; } void MultiplyingLineEditor::removeData(const MultiplyingLineData::Ptr &data) { mView->removeData(data); } void MultiplyingLineEditor::clear() { const auto lstLines = mView->lines(); for (MultiplyingLine *line : lstLines) { line->slotPropagateDeletion(); } } bool MultiplyingLineEditor::isModified() { return mModified || mView->isModified(); } void MultiplyingLineEditor::clearModified() { mModified = false; mView->clearModified(); } void MultiplyingLineEditor::setFocus() { mView->setFocus(); } void MultiplyingLineEditor::setFocusTop() { mView->setFocusTop(); } void MultiplyingLineEditor::setFocusBottom() { mView->setFocusBottom(); } int MultiplyingLineEditor::setFirstColumnWidth(int w) { return mView->setFirstColumnWidth(w); } void MultiplyingLineEditor::setCompletionMode(KCompletion::CompletionMode mode) { mView->setCompletionMode(mode); } MultiplyingLineFactory *MultiplyingLineEditor::factory() const { return mMultiplyingLineFactory; } QVector< MultiplyingLineData::Ptr > MultiplyingLineEditor::allData() const { return mView->allData(); } MultiplyingLineData::Ptr MultiplyingLineEditor::activeData() const { return mView->activeLine()->data(); } QList< MultiplyingLine * > MultiplyingLineEditor::lines() const { return mView->lines(); } MultiplyingLine *MultiplyingLineEditor::activeLine() const { return mView->activeLine(); } void MultiplyingLineEditor::setFrameStyle(int shape) { mView->setFrameStyle(shape); } void MultiplyingLineEditor::setAutoResizeView(bool resize) { mView->setAutoResize(resize); } bool MultiplyingLineEditor::autoResizeView() { return mView->autoResize(); } void MultiplyingLineEditor::setDynamicSizeHint(bool dynamic) { mView->setDynamicSizeHint(dynamic); } bool MultiplyingLineEditor::dynamicSizeHint() const { return mView->dynamicSizeHint(); } 0707010000001D000081A40000000200000002000000015F0FED33000016AC000000000000000000000000000000000000006300000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/multiplyingline/multiplyinglineeditor.h/* Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com> Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> Refactored from earlier code by: Copyright (c) 2010 Volker Krause <vkrause@kde.org> Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MULTIPLYINGLINEEDITOR_H #define MULTIPLYINGLINEEDITOR_H #include "kdepim_export.h" #include "multiplyingline.h" #include <KCompletion> #include <QWidget> #include <QObject> namespace KPIM { class MultiplyingLineView; /** @short An Abstract Base Class used to create MultiplyingLines Subclass this class and MultiplyingLine, then implement newLine() such that it allocates and returns an instance of your MultiplyingLine. */ class KDEPIM_EXPORT MultiplyingLineFactory : public QObject { Q_OBJECT public: explicit MultiplyingLineFactory(QObject *parent) : QObject(parent) { } virtual ~MultiplyingLineFactory() { } virtual MultiplyingLine *newLine(QWidget *parent) = 0; virtual int maximumRecipients() { return -1; } }; /** @short An editor that adds rows (lines) of widgets and deletes them as the user edits Line widgets in the MultiplyingLineEditor are usually composed of multiple basic widgets. An example is below: ------------------------------------------------- | ComboBox| Line edit | Checkbox | <-- 1 line ------------------------------------------------- | ComboBox| Line edit | Checkbox | <-- another line Default behavior is one line with default settings, and when the user edits it, another line is automatically added. Lines are added and deleted on demand. Implement this class and MultiplyingLineData. Then implement MultiplyingLineFactory to return instances of your line. */ class KDEPIM_EXPORT MultiplyingLineEditor : public QWidget { Q_OBJECT Q_PROPERTY(bool autoResizeView READ autoResizeView WRITE setAutoResizeView) Q_PROPERTY(bool dynamicSizeHint READ dynamicSizeHint WRITE setDynamicSizeHint) public: // We take ownership of factory explicit MultiplyingLineEditor(MultiplyingLineFactory *factory, QWidget *parent = nullptr); ~MultiplyingLineEditor() override; /** Get the current line factory for this instance of the widget. */ MultiplyingLineFactory *factory() const; /** Retrieve the data from the editor */ QVector<MultiplyingLineData::Ptr> allData() const; /** Retrieve the data of the active line */ MultiplyingLineData::Ptr activeData() const; /** Clear all lines from the widget. */ void clear(); /** Returns true if the user has made any modifications to the list of recipients. */ bool isModified(); /** Resets the modified flag to false. */ void clearModified(); /** Adds data to one line of the editor. @param data The data you want to add. Can be used to add an empty/default line. */ bool addData(const MultiplyingLineData::Ptr &data = MultiplyingLineData::Ptr()); /** Removes data provided it can be found. The Data class must support operator== @param data The data you want to add. */ void removeData(const MultiplyingLineData::Ptr &data); /** Set the width of the left most column to be the argument width. This method allows other widgets to align their label/combobox column with ours by communicating how many pixels that first column is for them. @param w what the left most column width should be @return the width that is actually being used. */ int setFirstColumnWidth(int w); /** Set completion mode for all lines @param mode the completion mode */ void setCompletionMode(KCompletion::CompletionMode mode); /** Set the underlying view's frame shape, default is none. @param shape of type QFrame::Shape */ void setFrameStyle(int shape); /** Make the line view follow it's children's size @param resize turn on or off this behavior of auto resizing */ void setAutoResizeView(bool resize); bool autoResizeView(); /** * Sets whether the size hint of the editor shall be calculated * dynamically by the number of lines. Default is @c true. */ void setDynamicSizeHint(bool dynamic); bool dynamicSizeHint() const; virtual QList<MultiplyingLine *> lines() const; Q_SIGNALS: void focusUp(); void focusDown(); void completionModeChanged(KCompletion::CompletionMode); void sizeHintChanged(); void lineDeleted(int pos); void lineAdded(KPIM::MultiplyingLine *); public Q_SLOTS: void setFocus(); void setFocusTop(); void setFocusBottom(); protected: virtual MultiplyingLine *activeLine() const; bool mModified = false; private: MultiplyingLineFactory *const mMultiplyingLineFactory; MultiplyingLineView *mView = nullptr; }; } #endif // MULTIPLYINGLINEEDITOR_H 0707010000001E000081A40000000200000002000000015F0FED3300002B06000000000000000000000000000000000000006500000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/multiplyingline/multiplyinglineview_p.cpp/* Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com> Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> Refactored from earlier code by: Copyright (c) 2010 Volker Krause <vkrause@kde.org> Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "multiplyinglineview_p.h" #include "libkdepim_debug.h" #include <KMessageBox> #include <KLocalizedString> #include <QVBoxLayout> #include <QTimer> #include <QScrollBar> #include <QResizeEvent> using namespace KPIM; MultiplyingLineView::MultiplyingLineView(MultiplyingLineFactory *factory, MultiplyingLineEditor *parent) : QScrollArea(parent) , mPage(new QWidget(this)) , mTopLayout(new QVBoxLayout(this)) , mMultiplyingLineFactory(factory) { setWidgetResizable(true); setFrameStyle(QFrame::NoFrame); mPage->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setWidget(mPage); mTopLayout->setContentsMargins(0, 0, 0, 0); mTopLayout->setSpacing(0); mPage->setLayout(mTopLayout); } MultiplyingLine *MultiplyingLineView::activeLine() const { return mLines.last(); } MultiplyingLine *MultiplyingLineView::emptyLine() const { for (MultiplyingLine *line : qAsConst(mLines)) { if (line->isEmpty()) { return line; } } return nullptr; } MultiplyingLine *MultiplyingLineView::addLine() { const int maximumRecipients = mMultiplyingLineFactory->maximumRecipients(); if (maximumRecipients != -1) { int numberOfLine = mLines.count(); if (numberOfLine++ >= maximumRecipients) { KMessageBox::sorry(this, i18n("We can not add more recipients. We have reached maximum recipients")); return nullptr; } } MultiplyingLine *line = mMultiplyingLineFactory->newLine(widget()); mTopLayout->addWidget(line); line->setCompletionMode(mCompletionMode); line->show(); connect(line, &MultiplyingLine::returnPressed, this, &MultiplyingLineView::slotReturnPressed); connect(line, &MultiplyingLine::upPressed, this, &MultiplyingLineView::slotUpPressed); connect(line, &MultiplyingLine::downPressed, this, &MultiplyingLineView::slotDownPressed); connect(line, &MultiplyingLine::rightPressed, this, &MultiplyingLineView::focusRight); connect(line, &MultiplyingLine::deleteLine, this, &MultiplyingLineView::slotDecideLineDeletion); connect(line, &MultiplyingLine::completionModeChanged, this, &MultiplyingLineView::setCompletionMode); if (!mLines.isEmpty()) { line->fixTabOrder(mLines.last()->tabOut()); } mLines.append(line); mFirstColumnWidth = line->setColumnWidth(mFirstColumnWidth); mLineHeight = line->minimumSizeHint().height(); line->resize(viewport()->width(), mLineHeight); resizeView(); ensureVisible(0, mLines.count() * mLineHeight, 0, 0); QTimer::singleShot(0, this, &MultiplyingLineView::moveScrollBarToEnd); Q_EMIT lineAdded(line); return line; } void MultiplyingLineView::moveScrollBarToEnd() { // scroll to bottom verticalScrollBar()->triggerAction(QAbstractSlider::SliderToMaximum); } void MultiplyingLineView::slotReturnPressed(MultiplyingLine *line) { if (!line->data()->isEmpty()) { MultiplyingLine *empty = emptyLine(); if (!empty) { empty = addLine(); } if (!empty) { return; } activateLine(empty); } } void MultiplyingLineView::slotDownPressed(MultiplyingLine *line) { int pos = mLines.indexOf(line); if (pos >= (mLines.count() - 1)) { Q_EMIT focusDown(); } else if (pos >= 0) { activateLine(mLines.at(pos + 1)); } } void MultiplyingLineView::slotUpPressed(MultiplyingLine *line) { int pos = mLines.indexOf(line); if (pos > 0) { activateLine(mLines.at(pos - 1)); } else { Q_EMIT focusUp(); } } void MultiplyingLineView::slotDecideLineDeletion(MultiplyingLine *line) { if (!line->isEmpty()) { mModified = true; } if (mLines.count() == 1) { line->clear(); } else if (!line->canDeleteLineEdit()) { line->clear(); } else if (mLines.indexOf(line) != mLines.count() - 1) { mCurDelLine = line; slotDeleteLine(); } } void MultiplyingLineView::slotDeleteLine() { if (!mCurDelLine) { return; } MultiplyingLine *line = mCurDelLine; line->aboutToBeDeleted(); int pos = mLines.indexOf(line); if (mCurDelLine->isActive()) { int newPos; if (pos == 0) { newPos = pos + 1; } else { newPos = pos - 1; } // if there is something left to activate, do so if (mLines.at(newPos)) { mLines.at(newPos)->activate(); } } mLines.removeAll(line); line->hide(); line->setParent(nullptr); line->deleteLater(); if (pos > 0) { Q_EMIT lineDeleted(pos); } resizeView(); } void MultiplyingLineView::resizeView() { if (mDynamicSizeHint) { if (!mAutoResize) { if (mLines.count() < 6) { setMinimumHeight(mLineHeight * mLines.count()); } else { setMinimumHeight(mLineHeight * 5); setMaximumHeight(mLineHeight * mLines.count()); } } else { setMinimumHeight(mLineHeight * mLines.count()); } } parentWidget()->layout()->activate(); Q_EMIT sizeHintChanged(); } void MultiplyingLineView::activateLine(MultiplyingLine *line) { line->activate(); ensureWidgetVisible(line); } void MultiplyingLineView::resizeEvent(QResizeEvent *ev) { QScrollArea::resizeEvent(ev); const int numberLine(mLines.count()); for (int i = 0; i < numberLine; ++i) { mLines.at(i)->resize(ev->size().width(), mLineHeight); } ensureVisible(0, numberLine * mLineHeight, 0, 0); } QSize MultiplyingLineView::sizeHint() const { if (mDynamicSizeHint) { return QSize(200, mLineHeight * mLines.count()); } else { return QScrollArea::sizeHint(); } } QSize MultiplyingLineView::minimumSizeHint() const { if (mDynamicSizeHint) { int height; int numLines = 5; if (mLines.count() < numLines) { height = mLineHeight * mLines.count(); } else { height = mLineHeight * numLines; } return QSize(200, height); } else { return QScrollArea::minimumSizeHint(); } } QVector<MultiplyingLineData::Ptr> MultiplyingLineView::allData() const { QVector<MultiplyingLineData::Ptr> data; QListIterator<MultiplyingLine *> it(mLines); while (it.hasNext()) { MultiplyingLine *line = it.next(); if (!line->data()->isEmpty()) { data.append(line->data()); } } return data; } void MultiplyingLineView::setCompletionMode(KCompletion::CompletionMode mode) { if (mCompletionMode == mode) { return; } mCompletionMode = mode; QListIterator<MultiplyingLine *> it(mLines); while (it.hasNext()) { MultiplyingLine *line = it.next(); line->blockSignals(true); line->setCompletionMode(mode); line->blockSignals(false); } Q_EMIT completionModeChanged(mode); //report change to MultiplyingLineEditor } void MultiplyingLineView::removeData(const MultiplyingLineData::Ptr &data) { // search a line which matches recipient and type QListIterator<MultiplyingLine *> it(mLines); MultiplyingLine *line = nullptr; while (it.hasNext()) { line = it.next(); if (line->data() == data) { break; } } if (line) { line->slotPropagateDeletion(); } } bool MultiplyingLineView::isModified() const { if (mModified) { return true; } QListIterator<MultiplyingLine *> it(mLines); MultiplyingLine *line = nullptr; while (it.hasNext()) { line = it.next(); if (line->isModified()) { return true; } } return false; } void MultiplyingLineView::clearModified() { mModified = false; QListIterator<MultiplyingLine *> it(mLines); while (it.hasNext()) { MultiplyingLine *line = it.next(); line->clearModified(); } } void MultiplyingLineView::setFocus() { if (!mLines.empty() && mLines.constLast()->isActive()) { setFocusBottom(); } else { setFocusTop(); } } void MultiplyingLineView::setFocusTop() { if (!mLines.empty()) { MultiplyingLine *line = mLines.constFirst(); if (line) { line->activate(); } else { qCWarning(LIBKDEPIM_LOG) << "No first"; } } else { qCWarning(LIBKDEPIM_LOG) << "No first"; } } void MultiplyingLineView::setFocusBottom() { MultiplyingLine *line = mLines.constLast(); if (line) { ensureWidgetVisible(line); line->activate(); } else { qCWarning(LIBKDEPIM_LOG) << "No last"; } } int MultiplyingLineView::setFirstColumnWidth(int w) { mFirstColumnWidth = w; QListIterator<MultiplyingLine *> it(mLines); while (it.hasNext()) { MultiplyingLine *line = it.next(); mFirstColumnWidth = line->setColumnWidth(mFirstColumnWidth); } resizeView(); return mFirstColumnWidth; } QList< MultiplyingLine * > MultiplyingLineView::lines() const { return mLines; } void MultiplyingLineView::setAutoResize(bool resize) { mAutoResize = resize; if (mAutoResize) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setMaximumHeight(QWIDGETSIZE_MAX); } else { setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); } } bool MultiplyingLineView::autoResize() { return mAutoResize; } void MultiplyingLineView::setDynamicSizeHint(bool dynamic) { mDynamicSizeHint = dynamic; } bool MultiplyingLineView::dynamicSizeHint() const { return mDynamicSizeHint; } 0707010000001F000081A40000000200000002000000015F0FED330000110D000000000000000000000000000000000000006300000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/multiplyingline/multiplyinglineview_p.h/* Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com> Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> Refactored from earlier code by: Copyright (c) 2010 Volker Krause <vkrause@kde.org> Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MULTIPLYINGLINEVIEW_P_H #define MULTIPLYINGLINEVIEW_P_H #include "multiplyingline.h" #include "multiplyinglineeditor.h" #include <QPointer> #include <QScrollArea> namespace KPIM { class MultiplyingLineView : public QScrollArea { Q_OBJECT public: MultiplyingLineView(MultiplyingLineFactory *factory, MultiplyingLineEditor *parent); ~MultiplyingLineView() override { } QSize minimumSizeHint() const override; QSize sizeHint() const override; MultiplyingLine *activeLine() const; MultiplyingLine *emptyLine() const; QVector<MultiplyingLineData::Ptr> allData() const; /** Removes data provided it can be found. The Data class must support operator== @param data The data you want to remove. */ void removeData(const MultiplyingLineData::Ptr &data); /** Returns true if the user has made any modifications to the list of recipients. @return whether the view is modified or not. */ bool isModified() const; /** Resets the modified flag to false. */ void clearModified(); /** Activates the line */ void activateLine(MultiplyingLine *line); /**QScrollArea * Set the width of the left most column to be the argument width. * This method allows other widgets to align their label/combobox column with ours * by communicating how many pixels that first column is for them. * Returns the width that is actually being used. */ int setFirstColumnWidth(int); /** Make this widget follow it's children's size @param resize turn on or off this behavior of auto resizing */ void setAutoResize(bool resize); bool autoResize(); /** * Sets whether the size hint of the editor shall be calculated * dynamically by the number of lines. Default is @c true. */ void setDynamicSizeHint(bool dynamic); bool dynamicSizeHint() const; QList<MultiplyingLine *> lines() const; public Q_SLOTS: void setCompletionMode(KCompletion::CompletionMode mode); MultiplyingLine *addLine(); void setFocus(); void setFocusTop(); void setFocusBottom(); Q_SIGNALS: void focusUp(); void focusDown(); void focusRight(); void completionModeChanged(KCompletion::CompletionMode); void sizeHintChanged(); void lineDeleted(int pos); void lineAdded(KPIM::MultiplyingLine *); protected: void resizeEvent(QResizeEvent *) override; void resizeView(); protected Q_SLOTS: void slotReturnPressed(KPIM::MultiplyingLine *); void slotDownPressed(KPIM::MultiplyingLine *); void slotUpPressed(KPIM::MultiplyingLine *); void slotDecideLineDeletion(KPIM::MultiplyingLine *); void slotDeleteLine(); void moveScrollBarToEnd(); private: QList<MultiplyingLine *> mLines; QPointer<MultiplyingLine> mCurDelLine = nullptr; QWidget *mPage = nullptr; QLayout *mTopLayout = nullptr; MultiplyingLineFactory *mMultiplyingLineFactory = nullptr; int mLineHeight = 0; int mFirstColumnWidth = 0; KCompletion::CompletionMode mCompletionMode = KCompletion::CompletionNone; bool mAutoResize = false; bool mDynamicSizeHint = true; bool mModified = false; }; } #endif //MULTIPLYINGLINEVIEW_P_H 07070100000020000041ED0000000200000002000000045F0FED3300000000000000000000000000000000000000000000004A00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget07070100000021000041ED0000000200000002000000025F0FED3300000000000000000000000000000000000000000000005400000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/autotests07070100000022000081A40000000200000002000000015F0FED33000001BB000000000000000000000000000000000000006300000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/autotests/CMakeLists.txtmacro(add_libkdepim_progresswidget_unittest _name) ecm_add_test(${ARGN} TEST_NAME ${_name} NAME_PREFIX "libkdepim-progresswidget-" LINK_LIBRARIES Qt5::Test Qt5::Widgets KF5::Libkdepim ) endmacro() add_libkdepim_progresswidget_unittest(statusbarprogresswidgettest statusbarprogresswidgettest.cpp) add_libkdepim_progresswidget_unittest(progressstatusbarwidgettest progressstatusbarwidgettest.cpp) 07070100000023000081A40000000200000002000000015F0FED33000006ED000000000000000000000000000000000000007400000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/autotests/progressstatusbarwidgettest.cpp/* Copyright (C) 2017-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "progressstatusbarwidgettest.h" #include "../progressstatusbarwidget.h" #include <QTest> #include "../progressdialog.h" #include "../statusbarprogresswidget.h" QTEST_MAIN(ProgressStatusBarWidgetTest) ProgressStatusBarWidgetTest::ProgressStatusBarWidgetTest(QObject *parent) : QObject(parent) { } void ProgressStatusBarWidgetTest::shouldHaveDefaultValue() { QWidget *widget = new QWidget; KPIM::ProgressStatusBarWidget w(widget, widget); widget->show(); KPIM::ProgressDialog *progressDialog = widget->findChild<KPIM::ProgressDialog *>(QStringLiteral("progressDialog")); QVERIFY(progressDialog); QVERIFY(progressDialog->isHidden()); KPIM::StatusbarProgressWidget *mLittleProgress = widget->findChild<KPIM::StatusbarProgressWidget *>(QStringLiteral("littleprogress")); QVERIFY(mLittleProgress); QVERIFY(mLittleProgress->isVisible()); QCOMPARE(mLittleProgress, w.littleProgress()); } 07070100000024000081A40000000200000002000000015F0FED33000004C1000000000000000000000000000000000000007200000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/autotests/progressstatusbarwidgettest.h/* Copyright (C) 2017-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PROGRESSSTATUSBARWIDGETTEST_H #define PROGRESSSTATUSBARWIDGETTEST_H #include <QObject> class ProgressStatusBarWidgetTest : public QObject { Q_OBJECT public: explicit ProgressStatusBarWidgetTest(QObject *parent = nullptr); ~ProgressStatusBarWidgetTest() = default; private Q_SLOTS: void shouldHaveDefaultValue(); }; #endif // PROGRESSSTATUSBARWIDGETTEST_H 07070100000025000081A40000000200000002000000015F0FED3300000BDC000000000000000000000000000000000000007400000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/autotests/statusbarprogresswidgettest.cpp/* Copyright (C) 2017-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "statusbarprogresswidgettest.h" #include "../statusbarprogresswidget.h" #include "../progressdialog.h" #include "../progressmanager.h" #include <QTest> #include <QHBoxLayout> #include <QPushButton> #include <QStackedWidget> #include <QProgressBar> #include <QStandardPaths> #include <progresswidget/ssllabel.h> QTEST_MAIN(StatusbarProgressWidgetTest) StatusbarProgressWidgetTest::StatusbarProgressWidgetTest(QObject *parent) : QObject(parent) { QStandardPaths::setTestModeEnabled(true); } void StatusbarProgressWidgetTest::shouldHaveDefaultValue() { QWidget *widget = new QWidget; KPIM::ProgressDialog *progress = new KPIM::ProgressDialog(widget, widget); KPIM::StatusbarProgressWidget w(progress, widget); QHBoxLayout *boxLayout = w.findChild<QHBoxLayout *>(QStringLiteral("boxLayout")); QVERIFY(boxLayout); QCOMPARE(boxLayout->contentsMargins(), QMargins(0, 0, 0, 0)); QCOMPARE(boxLayout->spacing(), 0); QPushButton *mButton = w.findChild<QPushButton *>(QStringLiteral("button")); QVERIFY(mButton); QVERIFY(mButton->text().isEmpty()); QStackedWidget *mStackedWidget = w.findChild<QStackedWidget *>(QStringLiteral("stackedwidget")); QVERIFY(mStackedWidget); KPIM::SSLLabel *mSslLabel = w.findChild<KPIM::SSLLabel *>(QStringLiteral("ssllabel")); QVERIFY(mSslLabel); QProgressBar *mProgressBar = w.findChild<QProgressBar *>(QStringLiteral("progressbar")); QVERIFY(mProgressBar); QLabel *mLabel = w.findChild<QLabel *>(QStringLiteral("emptylabel")); QVERIFY(mLabel); } void StatusbarProgressWidgetTest::shouldShowItems() { /* QWidget *widget = new QWidget; KPIM::ProgressDialog *progress = new KPIM::ProgressDialog(widget, widget); KPIM::StatusbarProgressWidget w(progress, widget); w.show(); QPushButton *mButton = w.findChild<QPushButton *>(QStringLiteral("button")); QProgressBar *mProgressBar = w.findChild<QProgressBar *>(QStringLiteral("progressbar")); QVERIFY(!mProgressBar->isVisible()); KPIM::ProgressManager::createProgressItem(KPIM::ProgressManager::getUniqueID(), QStringLiteral("Title"), QString(), true); QVERIFY(mProgressBar->isVisible()); */ } 07070100000026000081A40000000200000002000000015F0FED33000004DD000000000000000000000000000000000000007200000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/autotests/statusbarprogresswidgettest.h/* Copyright (C) 2017-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef STATUSBARPROGRESSWIDGETTEST_H #define STATUSBARPROGRESSWIDGETTEST_H #include <QObject> class StatusbarProgressWidgetTest : public QObject { Q_OBJECT public: explicit StatusbarProgressWidgetTest(QObject *parent = nullptr); ~StatusbarProgressWidgetTest() = default; private Q_SLOTS: void shouldHaveDefaultValue(); void shouldShowItems(); }; #endif // STATUSBARPROGRESSWIDGETTEST_H 07070100000027000081A40000000200000002000000015F0FED3300003DCE000000000000000000000000000000000000005D00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/progressdialog.cpp/** -*- c++ -*- * progressdialog.cpp * * Copyright (c) 2004 Till Adam <adam@kde.org>, * David Faure <faure@kde.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of this program with any edition of * the Qt library by Trolltech AS, Norway (or with modified versions * of Qt that use the same license as Qt), and distribute linked * combinations including the two. You must obey the GNU General * Public License in all respects for all of the code used other than * Qt. If you modify this file, you may extend this exception to * your version of the file, but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from * your version. */ #include "progressdialog.h" #include "ssllabel.h" #include <QHBoxLayout> #include <KLocalizedString> #include <QCloseEvent> #include <QFrame> #include <QLabel> #include <QObject> #include <QProgressBar> #include <QPushButton> #include <QScrollBar> #include <QTimer> #include <QLayout> #include <QVBoxLayout> using namespace KPIM; static const int MAX_LABEL_WIDTH = 650; class KPIM::OverlayWidgetPrivate { public: OverlayWidgetPrivate() { } QWidget *mAlignWidget = nullptr; }; OverlayWidget::OverlayWidget(QWidget *alignWidget, QWidget *parent) : QFrame(parent) , d(new KPIM::OverlayWidgetPrivate) { setAlignWidget(alignWidget); setLayout(new QHBoxLayout(this)); } OverlayWidget::~OverlayWidget() { delete d; } QWidget *OverlayWidget::alignWidget() const { return d->mAlignWidget; } void OverlayWidget::reposition() { if (!d->mAlignWidget) { return; } // p is in the alignWidget's coordinates QPoint p; // We are always above the alignWidget, right-aligned with it for // LTR locales, and left-aligned for RTL locales (default value=0). if (layoutDirection() == Qt::LeftToRight) { p.setX(d->mAlignWidget->width() - width()); } p.setY(-height()); // Position in the toplevelwidget's coordinates QPoint pTopLevel = d->mAlignWidget->mapTo(topLevelWidget(), p); // Position in the widget's parentWidget coordinates QPoint pParent = parentWidget()->mapFrom(topLevelWidget(), pTopLevel); // Move 'this' to that position. move(pParent); } void OverlayWidget::setAlignWidget(QWidget *w) { if (w == d->mAlignWidget) { return; } if (d->mAlignWidget) { d->mAlignWidget->removeEventFilter(this); } d->mAlignWidget = w; if (d->mAlignWidget) { d->mAlignWidget->installEventFilter(this); } reposition(); } bool OverlayWidget::eventFilter(QObject *o, QEvent *e) { if (o == d->mAlignWidget && (e->type() == QEvent::Move || e->type() == QEvent::Resize)) { reposition(); } return QFrame::eventFilter(o, e); } void OverlayWidget::resizeEvent(QResizeEvent *ev) { reposition(); QFrame::resizeEvent(ev); } TransactionItemView::TransactionItemView(QWidget *parent, const QString &name) : QScrollArea(parent) { setObjectName(name); setFrameStyle(NoFrame); mBigBox = new QWidget(this); QVBoxLayout *mBigBoxVBoxLayout = new QVBoxLayout(mBigBox); mBigBoxVBoxLayout->setContentsMargins(0, 0, 0, 0); setWidget(mBigBox); setWidgetResizable(true); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); } TransactionItem *TransactionItemView::addTransactionItem(ProgressItem *item, bool first) { TransactionItem *ti = new TransactionItem(mBigBox, item, first); mBigBox->layout()->addWidget(ti); resize(mBigBox->width(), mBigBox->height()); return ti; } void TransactionItemView::resizeEvent(QResizeEvent *event) { // Tell the layout in the parent (progressdialog) that our size changed updateGeometry(); QSize sz = parentWidget()->sizeHint(); int currentWidth = parentWidget()->width(); // Don't resize to sz.width() every time when it only reduces a little bit if (currentWidth < sz.width() || currentWidth > sz.width() + 100) { currentWidth = sz.width(); } parentWidget()->resize(currentWidth, sz.height()); QScrollArea::resizeEvent(event); } QSize TransactionItemView::sizeHint() const { return minimumSizeHint(); } QSize TransactionItemView::minimumSizeHint() const { int f = 2 * frameWidth(); // Make room for a vertical scrollbar in all cases, to avoid a horizontal one int vsbExt = verticalScrollBar()->sizeHint().width(); int minw = topLevelWidget()->width() / 3; int maxh = topLevelWidget()->height() / 2; QSize sz(mBigBox->minimumSizeHint()); sz.setWidth(qMax(sz.width(), minw) + f + vsbExt); sz.setHeight(qMin(sz.height(), maxh) + f); return sz; } void TransactionItemView::slotLayoutFirstItem() { //This slot is called whenever a TransactionItem is deleted, so this is a //good place to call updateGeometry(), so our parent takes the new size //into account and resizes. updateGeometry(); /* The below relies on some details in Qt's behaviour regarding deleting objects. This slot is called from the destroyed signal of an item just going away. That item is at that point still in the list of chilren, but since the vtable is already gone, it will have type QObject. The first one with both the right name and the right class therefor is what will be the first item very shortly. That's the one we want to remove the hline for. */ TransactionItem *ti = mBigBox->findChild<KPIM::TransactionItem *>(QStringLiteral("TransactionItem")); if (ti) { ti->hideHLine(); } } // ---------------------------------------------------------------------------- TransactionItem::TransactionItem(QWidget *parent, ProgressItem *item, bool first) : QWidget(parent) , mCancelButton(nullptr) , mItem(item) { QVBoxLayout *vboxLayout = new QVBoxLayout(this); vboxLayout->setSpacing(2); vboxLayout->setContentsMargins(2, 2, 2, 2); setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); mFrame = new QFrame(this); mFrame->setFrameShape(QFrame::HLine); mFrame->setFrameShadow(QFrame::Raised); mFrame->show(); layout()->addWidget(mFrame); QWidget *h = new QWidget(this); QHBoxLayout *hHBoxLayout = new QHBoxLayout(h); hHBoxLayout->setContentsMargins(0, 0, 0, 0); hHBoxLayout->setSpacing(5); layout()->addWidget(h); mItemLabel = new QLabel(fontMetrics().elidedText(item->label(), Qt::ElideRight, MAX_LABEL_WIDTH), h); h->layout()->addWidget(mItemLabel); h->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); mProgress = new QProgressBar(h); hHBoxLayout->addWidget(mProgress); mProgress->setMaximum(100); mProgress->setValue(item->progress()); h->layout()->addWidget(mProgress); if (item->canBeCanceled()) { mCancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), QString(), h); hHBoxLayout->addWidget(mCancelButton); mCancelButton->setToolTip(i18n("Cancel this operation.")); connect(mCancelButton, &QAbstractButton::clicked, this, &TransactionItem::slotItemCanceled); h->layout()->addWidget(mCancelButton); } h = new QWidget(this); hHBoxLayout = new QHBoxLayout(h); hHBoxLayout->setContentsMargins(0, 0, 0, 0); hHBoxLayout->setSpacing(5); h->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); layout()->addWidget(h); mSSLLabel = new SSLLabel(h); hHBoxLayout->addWidget(mSSLLabel); mSSLLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); h->layout()->addWidget(mSSLLabel); mItemStatus = new QLabel(h); hHBoxLayout->addWidget(mItemStatus); mItemStatus->setTextFormat(Qt::RichText); mItemStatus->setText( fontMetrics().elidedText(item->status(), Qt::ElideRight, MAX_LABEL_WIDTH)); h->layout()->addWidget(mItemStatus); setCryptoStatus(item->cryptoStatus()); if (first) { hideHLine(); } } KPIM::TransactionItem::~TransactionItem() { } void TransactionItem::hideHLine() { mFrame->hide(); } void TransactionItem::setProgress(int progress) { mProgress->setValue(progress); } void TransactionItem::setLabel(const QString &label) { mItemLabel->setText(fontMetrics().elidedText(label, Qt::ElideRight, MAX_LABEL_WIDTH)); } void TransactionItem::setStatus(const QString &status) { mItemStatus->setText(fontMetrics().elidedText(status, Qt::ElideRight, MAX_LABEL_WIDTH)); } void TransactionItem::setCryptoStatus(KPIM::ProgressItem::CryptoStatus status) { switch (status) { case KPIM::ProgressItem::Encrypted: mSSLLabel->setEncrypted(SSLLabel::Encrypted); break; case KPIM::ProgressItem::Unencrypted: mSSLLabel->setEncrypted(SSLLabel::Unencrypted); break; case KPIM::ProgressItem::Unknown: mSSLLabel->setEncrypted(SSLLabel::Unknown); break; } mSSLLabel->setState(mSSLLabel->lastState()); } void TransactionItem::setTotalSteps(int totalSteps) { mProgress->setMaximum(totalSteps); } void TransactionItem::slotItemCanceled() { if (mItem) { mItem->cancel(); } } void TransactionItem::addSubTransaction(ProgressItem *item) { Q_UNUSED(item); } // --------------------------------------------------------------------------- ProgressDialog::ProgressDialog(QWidget *alignWidget, QWidget *parent) : OverlayWidget(alignWidget, parent) { // Qt Bug: Sunken is not applied for RTL layouts correctly (is not mirrored). // For now let's just use Plain, which is fine for this. if (layoutDirection() == Qt::LeftToRight) { setFrameStyle(QFrame::Panel | QFrame::Sunken); // QFrame } else { setFrameStyle(QFrame::Panel | QFrame::Plain); // QFrame } setAutoFillBackground(true); mScrollView = new TransactionItemView(this, QStringLiteral("ProgressScrollView")); layout()->addWidget(mScrollView); /* * Get the singleton ProgressManager item which will inform us of * appearing and vanishing items. */ ProgressManager *pm = ProgressManager::instance(); connect(pm, &ProgressManager::progressItemAdded, this, &ProgressDialog::slotTransactionAdded); connect(pm, &ProgressManager::progressItemCompleted, this, &ProgressDialog::slotTransactionCompleted); connect(pm, &ProgressManager::progressItemProgress, this, &ProgressDialog::slotTransactionProgress); connect(pm, &ProgressManager::progressItemStatus, this, &ProgressDialog::slotTransactionStatus); connect(pm, &ProgressManager::progressItemLabel, this, &ProgressDialog::slotTransactionLabel); connect(pm, &ProgressManager::progressItemCryptoStatus, this, &ProgressDialog::slotTransactionCryptoStatus); connect(pm, &ProgressManager::progressItemUsesBusyIndicator, this, &ProgressDialog::slotTransactionUsesBusyIndicator); connect(pm, &ProgressManager::showProgressDialog, this, &ProgressDialog::slotShow); } void ProgressDialog::closeEvent(QCloseEvent *e) { e->accept(); hide(); } bool ProgressDialog::wasLastShown() const { return mWasLastShown; } /* * Destructor */ ProgressDialog::~ProgressDialog() { // no need to delete child widgets. } void ProgressDialog::setShowTypeProgressItem(unsigned int type) { mShowTypeProgressItem = type; } void ProgressDialog::slotTransactionAdded(ProgressItem *item) { if (item->typeProgressItem() == mShowTypeProgressItem) { if (item->parent()) { if (TransactionItem *parent = mTransactionsToListviewItems.value(item->parent())) { parent->addSubTransaction(item); } } else { const bool first = mTransactionsToListviewItems.empty(); TransactionItem *ti = mScrollView->addTransactionItem(item, first); if (ti) { mTransactionsToListviewItems.insert(item, ti); } if (first && mWasLastShown) { QTimer::singleShot(1000, this, &ProgressDialog::slotShow); } } } } void ProgressDialog::slotTransactionCompleted(ProgressItem *item) { if (TransactionItem *ti = mTransactionsToListviewItems.value(item)) { mTransactionsToListviewItems.remove(item); ti->setItemComplete(); QTimer::singleShot(3000, ti, &QObject::deleteLater); // see the slot for comments as to why that works connect(ti, &QObject::destroyed, mScrollView, &TransactionItemView::slotLayoutFirstItem); } // This was the last item, hide. if (mTransactionsToListviewItems.empty()) { QTimer::singleShot(3000, this, &ProgressDialog::slotHide); } } void ProgressDialog::slotTransactionCanceled(ProgressItem *) { } void ProgressDialog::slotTransactionProgress(ProgressItem *item, unsigned int progress) { if (TransactionItem *ti = mTransactionsToListviewItems.value(item)) { ti->setProgress(progress); } } void ProgressDialog::slotTransactionStatus(ProgressItem *item, const QString &status) { if (TransactionItem *ti = mTransactionsToListviewItems.value(item)) { ti->setStatus(status); } } void ProgressDialog::slotTransactionLabel(ProgressItem *item, const QString &label) { if (TransactionItem *ti = mTransactionsToListviewItems.value(item)) { ti->setLabel(label); } } void ProgressDialog::slotTransactionCryptoStatus(ProgressItem *item, KPIM::ProgressItem::CryptoStatus value) { if (TransactionItem *ti = mTransactionsToListviewItems.value(item)) { ti->setCryptoStatus(value); } } void ProgressDialog::slotTransactionUsesBusyIndicator(KPIM::ProgressItem *item, bool value) { if (TransactionItem *ti = mTransactionsToListviewItems.value(item)) { if (value) { ti->setTotalSteps(0); } else { ti->setTotalSteps(100); } } } void ProgressDialog::slotShow() { setVisible(true); } void ProgressDialog::slotHide() { // check if a new item showed up since we started the timer. If not, hide if (mTransactionsToListviewItems.isEmpty()) { setVisible(false); } } void ProgressDialog::slotClose() { mWasLastShown = false; setVisible(false); } void ProgressDialog::setVisible(bool b) { OverlayWidget::setVisible(b); Q_EMIT visibilityChanged(b); } void ProgressDialog::slotToggleVisibility() { /* Since we are only hiding with a timeout, there is a short period of * time where the last item is still visible, but clicking on it in * the statusbarwidget should not display the dialog, because there * are no items to be shown anymore. Guard against that. */ if (!isHidden() || !mTransactionsToListviewItems.isEmpty()) { const bool showNow = isHidden(); setVisible(showNow); mWasLastShown = showNow; } } 07070100000028000081A40000000200000002000000015F0FED33000015DA000000000000000000000000000000000000005B00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/progressdialog.h/* -*- c++ -*- * progressdialog.h * * Copyright (c) 2004 Till Adam <adam@kde.org> * based on imapprogressdialog.cpp ,which is * Copyright (c) 2002-2003 Klar�vdalens Datakonsult AB * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of this program with any edition of * the Qt library by Trolltech AS, Norway (or with modified versions * of Qt that use the same license as Qt), and distribute linked * combinations including the two. You must obey the GNU General * Public License in all respects for all of the code used other than * Qt. If you modify this file, you may extend this exception to * your version of the file, but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from * your version. */ #ifndef KDEPIM_PROGRESSDIALOG_H #define KDEPIM_PROGRESSDIALOG_H #include "kdepim_export.h" #include "progressmanager.h" #include <QScrollArea> #include <QMap> class QProgressBar; class QFrame; class QLabel; class QPushButton; namespace KPIM { class TransactionItem; class SSLLabel; /** * This is a widget that can align itself with another one, without using a layout, * so that it can actually be on top of other widgets. * Currently the only supported type of alignment is "right aligned, on top of the other widget". * */ class OverlayWidgetPrivate; class OverlayWidget : public QFrame { Q_OBJECT public: OverlayWidget(QWidget *alignWidget, QWidget *parent); ~OverlayWidget() override; Q_REQUIRED_RESULT QWidget *alignWidget() const; void setAlignWidget(QWidget *alignWidget); protected: void resizeEvent(QResizeEvent *ev) override; bool eventFilter(QObject *o, QEvent *e) override; private: void reposition(); private: OverlayWidgetPrivate *const d; }; class TransactionItemView : public QScrollArea { Q_OBJECT public: explicit TransactionItemView(QWidget *parent = nullptr, const QString &name = QString()); ~TransactionItemView() override { } TransactionItem *addTransactionItem(ProgressItem *item, bool first); QSize sizeHint() const override; QSize minimumSizeHint() const override; public Q_SLOTS: void slotLayoutFirstItem(); protected: void resizeEvent(QResizeEvent *event) override; private: QWidget *mBigBox = nullptr; }; class TransactionItem : public QWidget { Q_OBJECT public: TransactionItem(QWidget *parent, ProgressItem *item, bool first); ~TransactionItem(); void hideHLine(); void setProgress(int progress); void setLabel(const QString &); // the given text is interpreted as RichText, so you might need to // .toHtmlEscaped() it before passing void setStatus(const QString &); void setCryptoStatus(KPIM::ProgressItem::CryptoStatus); void setTotalSteps(int totalSteps); ProgressItem *item() const { return mItem; } void addSubTransaction(ProgressItem *item); // The progressitem is deleted immediately, we take 5s to go out, // so better not use mItem during this time. void setItemComplete() { mItem = nullptr; } public Q_SLOTS: void slotItemCanceled(); protected: QProgressBar *mProgress = nullptr; QPushButton *mCancelButton = nullptr; QLabel *mItemLabel = nullptr; QLabel *mItemStatus = nullptr; QFrame *mFrame = nullptr; SSLLabel *mSSLLabel = nullptr; ProgressItem *mItem = nullptr; }; class KDEPIM_EXPORT ProgressDialog : public OverlayWidget { Q_OBJECT public: ProgressDialog(QWidget *alignWidget, QWidget *parent); ~ProgressDialog() override; void setVisible(bool b) override; void setShowTypeProgressItem(unsigned int type); bool wasLastShown() const; public Q_SLOTS: void slotToggleVisibility(); protected Q_SLOTS: void slotTransactionAdded(KPIM::ProgressItem *item); void slotTransactionCompleted(KPIM::ProgressItem *item); void slotTransactionCanceled(KPIM::ProgressItem *item); void slotTransactionProgress(KPIM::ProgressItem *item, unsigned int progress); void slotTransactionStatus(KPIM::ProgressItem *item, const QString &); void slotTransactionLabel(KPIM::ProgressItem *item, const QString &); void slotTransactionCryptoStatus(KPIM::ProgressItem *item, KPIM::ProgressItem::CryptoStatus); void slotTransactionUsesBusyIndicator(KPIM::ProgressItem *, bool); void slotClose(); void slotShow(); void slotHide(); Q_SIGNALS: void visibilityChanged(bool); protected: void closeEvent(QCloseEvent *) override; TransactionItemView *mScrollView = nullptr; QMap<const ProgressItem *, TransactionItem *> mTransactionsToListviewItems; unsigned int mShowTypeProgressItem = 0; bool mWasLastShown = false; }; } // namespace KPIM #endif // __KPIM_PROGRESSDIALOG_H__ 07070100000029000081A40000000200000002000000015F0FED3300002A22000000000000000000000000000000000000005E00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/progressmanager.cpp/* progressmanager.cpp This file is part of libkdepim. Copyright (c) 2004 Till Adam <adam@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "progressmanager.h" #include "libkdepim_debug.h" #include <KLocalizedString> using namespace KPIM; unsigned int KPIM::ProgressManager::uID = 42; ProgressItem::ProgressItem(ProgressItem *parent, const QString &id, const QString &label, const QString &status, bool canBeCanceled, CryptoStatus cryptoStatus) : mId(id) , mLabel(label) , mStatus(status) , mParent(parent) , mCanBeCanceled(canBeCanceled) , mCryptoStatus(cryptoStatus) { } ProgressItem::~ProgressItem() { } void ProgressItem::setComplete() { // qCDebug(LIBKDEPIM_LOG) << label(); if (mChildren.isEmpty()) { if (mCompletedCalled) { return; } if (!mCanceled) { setProgress(100); } mCompletedCalled = true; if (parent()) { parent()->removeChild(this); } Q_EMIT progressItemCompleted(this); } else { mWaitingForKids = true; } } void ProgressItem::reset() { setProgress(0); setStatus(QString()); mCompleted = 0; } void ProgressItem::addChild(ProgressItem *kiddo) { mChildren.insert(kiddo, true); } void ProgressItem::removeChild(ProgressItem *kiddo) { if (mChildren.isEmpty()) { mWaitingForKids = false; return; } if (mChildren.remove(kiddo) == 0) { // do nothing if the specified item is not in the map return; } // in case we were waiting for the last kid to go away, now is the time if (mChildren.isEmpty() && mWaitingForKids) { Q_EMIT progressItemCompleted(this); } } bool ProgressItem::canceled() const { return mCanceled; } unsigned int ProgressItem::typeProgressItem() const { return mType; } void ProgressItem::setTypeProgressItem(unsigned int type) { mType = type; } void ProgressItem::cancel() { if (mCanceled || !mCanBeCanceled) { return; } qCDebug(LIBKDEPIM_LOG) << label(); mCanceled = true; // Cancel all children. for (auto it = mChildren.cbegin(), end = mChildren.cend(); it != end; ++it) { ProgressItem *kid = it.key(); if (kid->canBeCanceled()) { kid->cancel(); } } setStatus(i18n("Aborting...")); Q_EMIT progressItemCanceled(this); } void ProgressItem::updateProgress() { setProgress(mTotal ? mCompleted * 100 / mTotal : 0); } void ProgressItem::setProgress(unsigned int v) { mProgress = v; // qCDebug(LIBKDEPIM_LOG) << label() << " :" << v; Q_EMIT progressItemProgress(this, mProgress); } const QString &ProgressItem::id() const { return mId; } ProgressItem *ProgressItem::parent() const { return mParent.data(); } const QString &ProgressItem::label() const { return mLabel; } void ProgressItem::setLabel(const QString &v) { mLabel = v; Q_EMIT progressItemLabel(this, mLabel); } const QString &ProgressItem::status() const { return mStatus; } void ProgressItem::setStatus(const QString &v) { mStatus = v; Q_EMIT progressItemStatus(this, mStatus); } bool ProgressItem::canBeCanceled() const { return mCanBeCanceled; } void ProgressItem::setCanBeCanceled(bool b) { mCanBeCanceled = b; } ProgressItem::CryptoStatus ProgressItem::cryptoStatus() const { return mCryptoStatus; } void ProgressItem::setCryptoStatus(ProgressItem::CryptoStatus v) { mCryptoStatus = v; Q_EMIT progressItemCryptoStatus(this, v); } bool ProgressItem::usesBusyIndicator() const { return mUsesBusyIndicator; } void ProgressItem::setUsesBusyIndicator(bool useBusyIndicator) { mUsesBusyIndicator = useBusyIndicator; Q_EMIT progressItemUsesBusyIndicator(this, useBusyIndicator); } unsigned int ProgressItem::progress() const { return mProgress; } // ====================================== struct KPIM::ProgressManagerPrivate { ProgressManager instance; }; Q_GLOBAL_STATIC(KPIM::ProgressManagerPrivate, progressManagerPrivate) ProgressManager::ProgressManager() : QObject() { } ProgressManager::~ProgressManager() { } ProgressManager *ProgressManager::instance() { return progressManagerPrivate.isDestroyed() ? nullptr : &progressManagerPrivate->instance; } QString ProgressManager::getUniqueID() { return QString::number(++uID); } bool ProgressManager::isEmpty() const { return mTransactions.isEmpty(); } ProgressItem *ProgressManager::createProgressItem(const QString &id, const QString &label, const QString &status, bool canBeCanceled, ProgressItem::CryptoStatus cryptoStatus) { return instance()->createProgressItemImpl(nullptr, id, label, status, canBeCanceled, cryptoStatus); } ProgressItem *ProgressManager::createProgressItem(const QString &parent, const QString &id, const QString &label, const QString &status, bool canBeCanceled, ProgressItem::CryptoStatus cryptoStatus) { return instance()->createProgressItemImpl(parent, id, label, status, canBeCanceled, cryptoStatus); } ProgressItem *ProgressManager::createProgressItem(ProgressItem *parent, const QString &id, const QString &label, const QString &status, bool canBeCanceled, ProgressItem::CryptoStatus cryptoStatus) { return instance()->createProgressItemImpl(parent, id, label, status, canBeCanceled, cryptoStatus); } ProgressItem *ProgressManager::createProgressItem(const QString &label) { return instance()->createProgressItemImpl(nullptr, getUniqueID(), label, QString(), true, KPIM::ProgressItem::Unencrypted); } ProgressItem *ProgressManager::createProgressItem(unsigned int progressType, const QString &label) { return instance()->createProgressItemImpl(nullptr, getUniqueID(), label, QString(), true, KPIM::ProgressItem::Unencrypted, progressType); } ProgressItem *ProgressManager::createProgressItemImpl(ProgressItem *parent, const QString &id, const QString &label, const QString &status, bool cancellable, ProgressItem::CryptoStatus cryptoStatus, unsigned int progressType) { ProgressItem *t = nullptr; if (!mTransactions.value(id)) { t = new ProgressItem(parent, id, label, status, cancellable, cryptoStatus); t->setTypeProgressItem(progressType); mTransactions.insert(id, t); if (parent) { ProgressItem *p = mTransactions.value(parent->id()); if (p) { p->addChild(t); } } // connect all signals connect(t, &ProgressItem::progressItemCompleted, this, &ProgressManager::slotTransactionCompleted); connect(t, &ProgressItem::progressItemProgress, this, &ProgressManager::progressItemProgress); connect(t, &ProgressItem::progressItemAdded, this, &ProgressManager::progressItemAdded); connect(t, &ProgressItem::progressItemCanceled, this, &ProgressManager::progressItemCanceled); connect(t, &ProgressItem::progressItemStatus, this, &ProgressManager::progressItemStatus); connect(t, &ProgressItem::progressItemLabel, this, &ProgressManager::progressItemLabel); connect(t, &ProgressItem::progressItemCryptoStatus, this, &ProgressManager::progressItemCryptoStatus); connect(t, &ProgressItem::progressItemUsesBusyIndicator, this, &ProgressManager::progressItemUsesBusyIndicator); Q_EMIT progressItemAdded(t); } else { // Hm, is this what makes the most sense? t = mTransactions.value(id); } return t; } ProgressItem *ProgressManager::createProgressItemImpl(const QString &parent, const QString &id, const QString &label, const QString &status, bool canBeCanceled, ProgressItem::CryptoStatus cryptoStatus, unsigned int progressType) { ProgressItem *p = mTransactions.value(parent); return createProgressItemImpl(p, id, label, status, canBeCanceled, cryptoStatus, progressType); } void ProgressManager::emitShowProgressDialogImpl() { Q_EMIT showProgressDialog(); } // slots void ProgressManager::slotTransactionCompleted(ProgressItem *item) { mTransactions.remove(item->id()); Q_EMIT progressItemCompleted(item); } void ProgressManager::slotStandardCancelHandler(ProgressItem *item) { item->setComplete(); } ProgressItem *ProgressManager::singleItem() const { ProgressItem *item = nullptr; QHash< QString, ProgressItem * >::const_iterator it = mTransactions.constBegin(); QHash< QString, ProgressItem * >::const_iterator end = mTransactions.constEnd(); while (it != end) { // No single item for progress possible, as one of them is a busy indicator one. if ((*it)->usesBusyIndicator()) { return nullptr; } if (!(*it)->parent()) { // if it's a top level one, only those count if (item) { return nullptr; // we found more than one } else { item = (*it); } } ++it; } return item; } void ProgressManager::emitShowProgressDialog() { instance()->emitShowProgressDialogImpl(); } ProgressItem *ProgressManager::progressItem(const QString &id) const { return mTransactions.value(id); } void ProgressManager::slotAbortAll() { QHashIterator<QString, ProgressItem *> it(mTransactions); while (it.hasNext()) { it.next().value()->cancel(); } } void KPIM::ProgressItem::setTotalItems(unsigned int v) { mTotal = v; } unsigned int ProgressItem::totalItems() const { return mTotal; } void ProgressItem::setCompletedItems(unsigned int v) { mCompleted = v; } void ProgressItem::incCompletedItems(unsigned int v) { mCompleted += v; } unsigned int ProgressItem::completedItems() const { return mCompleted; } 0707010000002A000081A40000000200000002000000015F0FED3300003B62000000000000000000000000000000000000005C00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/progressmanager.h/* progressmanager.h This file is part of libkdepim. Copyright (C) 2004 Till Adam <adam@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEPIM_PROGRESSMANAGER_H #define KDEPIM_PROGRESSMANAGER_H #include "kdepim_export.h" #include <QObject> #include <QString> #include <QMap> #include <QHash> #include <QPointer> namespace KPIM { class ProgressItem; class ProgressManager; typedef QMap<ProgressItem *, bool> ProgressItemMap; /** * @brief The ProgressItem class */ class KDEPIM_EXPORT ProgressItem : public QObject { Q_OBJECT friend class ProgressManager; public: enum CryptoStatus { Encrypted, Unencrypted, Unknown }; /** * @return The id string which uniquely identifies the operation * represented by this item. */ Q_REQUIRED_RESULT const QString &id() const; /** * @return The parent item of this one, if there is one. */ Q_REQUIRED_RESULT ProgressItem *parent() const; /** * @return The user visible string to be used to represent this item. */ Q_REQUIRED_RESULT const QString &label() const; /** * @param v Set the user visible string identifying this item. */ void setLabel(const QString &v); /** * @return The string to be used for showing this item's current status. */ Q_REQUIRED_RESULT const QString &status() const; /** * Set the string to be used for showing this item's current status. * @param v The status string. */ void setStatus(const QString &v); /** * @return Whether this item can be canceled. */ Q_REQUIRED_RESULT bool canBeCanceled() const; /** * @param b Set if can be canceled */ void setCanBeCanceled(bool b); /** * @return Whether this item uses secure communication * (Account uses ssl, for example.). */ Q_REQUIRED_RESULT CryptoStatus cryptoStatus() const; /** * Set whether this item uses crypted communication, so listeners * can display a nice crypto icon. * @param v The value. */ void setCryptoStatus(ProgressItem::CryptoStatus v); /** * @return whether this item uses a busy indicator instead of real progress display */ Q_REQUIRED_RESULT bool usesBusyIndicator() const; /** * Sets whether this item uses a busy indicator instead of real progress for its progress bar. * If it uses a busy indicator, you are still responsible for calling setProgress() from time to * time to update the busy indicator. */ void setUsesBusyIndicator(bool useBusyIndicator); /** * @return The current progress value of this item in percent. */ Q_REQUIRED_RESULT unsigned int progress() const; /** * Set the progress (percentage of completion) value of this item. * @param v The percentage value. */ void setProgress(unsigned int v); /** * Tell the item it has finished. This will Q_EMIT progressItemCompleted() * result in the destruction of the item after all slots connected to this * signal have executed. This is the only way to get rid of an item and * needs to be called even if the item is canceled. Don't use the item * after this has been called on it. */ void setComplete(); /** * Reset the progress value of this item to 0 and the status string to * the empty string. */ void reset(); void cancel(); // Often needed values for calculating progress. void setTotalItems(unsigned int v); Q_REQUIRED_RESULT unsigned int totalItems() const; void setCompletedItems(unsigned int v); void incCompletedItems(unsigned int v = 1); Q_REQUIRED_RESULT unsigned int completedItems() const; /** * Recalculate progress according to total/completed items and update. */ void updateProgress(); void addChild(ProgressItem *kiddo); void removeChild(ProgressItem *kiddo); bool canceled() const; unsigned int typeProgressItem() const; void setTypeProgressItem(unsigned int); Q_SIGNALS: /** * Emitted when a new ProgressItem is added. * @param The ProgressItem that was added. */ void progressItemAdded(KPIM::ProgressItem *); /** * Emitted when the progress value of an item changes. * @param The item which got a new value. * @param The value, for convenience. */ void progressItemProgress(KPIM::ProgressItem *, unsigned int); /** * Emitted when a progress item was completed. The item will be * deleted afterwards, so slots connected to this are the last * chance to work with this item. * @param The completed item. */ void progressItemCompleted(KPIM::ProgressItem *); /** * Emitted when an item was canceled. It will _not_ go away immediately, * only when the owner sets it complete, which will usually happen. Can be * used to visually indicate the canceled status of an item. Should be used * by the owner of the item to make sure it is set completed even if it is * canceled. There is a ProgressManager::slotStandardCancelHandler which * simply sets the item completed and can be used if no other work needs to * be done on cancel. * @param The canceled item; */ void progressItemCanceled(KPIM::ProgressItem *); /** * Emitted when the status message of an item changed. Should be used by * progress dialogs to update the status message for an item. * @param The updated item. * @param The new message. */ void progressItemStatus(KPIM::ProgressItem *, const QString &); /** * Emitted when the label of an item changed. Should be used by * progress dialogs to update the label of an item. * @param The updated item. * @param The new label. */ void progressItemLabel(KPIM::ProgressItem *, const QString &); /** * Emitted when the crypto status of an item changed. Should be used by * progress dialogs to update the crypto indicator of an item. * @param The updated item. * @param The new state. */ void progressItemCryptoStatus(KPIM::ProgressItem *, KPIM::ProgressItem::CryptoStatus); /** * Emitted when the busy indicator state of an item changes. Should be used * by progress dialogs so that they can adjust the display of the progress bar * to the new mode. * @param item The updated item * @param value True if the item uses a busy indicator now, false otherwise */ void progressItemUsesBusyIndicator(KPIM::ProgressItem *item, bool value); protected: /* Only to be used by our good friend the ProgressManager */ ProgressItem(ProgressItem *parent, const QString &id, const QString &label, const QString &status, bool isCancellable, CryptoStatus cryptoStatus); ~ProgressItem() override; private: QString mId; QString mLabel; QString mStatus; QPointer<ProgressItem> mParent; bool mCanBeCanceled = false; unsigned int mProgress = 0; ProgressItemMap mChildren; unsigned int mTotal = 0; unsigned int mCompleted = 0; CryptoStatus mCryptoStatus; unsigned int mType = 0; bool mWaitingForKids = false; bool mCanceled = false; bool mUsesBusyIndicator = false; bool mCompletedCalled = false; }; struct ProgressManagerPrivate; /** * The ProgressManager singleton keeps track of all ongoing transactions * and notifies observers (progress dialogs) when their progress percent value * changes, when they are completed (by their owner), and when they are canceled. * Each ProgressItem emits those signals individually and the singleton * broadcasts them. Use the ::createProgressItem() statics to acquire an item * and then call ->setProgress( int percent ) on it every time you want to * update the item and ->setComplete() when the operation is done. This will * delete the item. Connect to the item's progressItemCanceled() signal to be * notified when the user cancels the transaction using one of the observing * progress dialogs or by calling item->cancel() in some other way. The owner * is responsible for calling setComplete() on the item, even if it is canceled. * Use the standardCancelHandler() slot if that is all you want to do on cancel. * * Note that if you request an item with a certain id and there is already * one with that id, there will not be a new one created but the existing * one will be returned. This is convenient for accessing items that are * needed regularly without the to store a pointer to them or to add child * items to parents by id. */ class KDEPIM_EXPORT ProgressManager : public QObject { Q_OBJECT friend struct ProgressManagerPrivate; public: ~ProgressManager() override; /** * @return The singleton instance of this class. */ static ProgressManager *instance(); /** * Use this to acquire a unique id number which can be used to discern * an operation from all others going on at the same time. Use that * number as the id string for your progressItem to ensure it is unique. * @return */ static QString getUniqueID(); /** * Creates a ProgressItem with a unique id and the given label. * This is the simplest way to acquire a progress item. It will not * have a parent and will be set to be cancellable and not using crypto. */ static ProgressItem *createProgressItem(unsigned int progressType, const QString &label); /** * Creates a ProgressItem with a unique id and the given label. * This is the simplest way to acquire a progress item. It will not * have a parent and will be set to be cancellable and not using crypto. */ static ProgressItem *createProgressItem(const QString &label); /** * Creates a new progressItem with the given parent, id, label and initial * status. * * @param parent Specify an already existing item as the parent of this one. * @param id Used to identify this operation for cancel and progress info. * @param label The text to be displayed by progress handlers * @param status Additional text to be displayed for the item. * @param canBeCanceled can the user cancel this operation? * @param usesCrypto does the operation use secure transports (SSL) * Cancelling the parent will cancel the children as well (if they can be * canceled) and ongoing children prevent parents from finishing. * @return The ProgressItem representing the operation. */ static ProgressItem *createProgressItem(ProgressItem *parent, const QString &id, const QString &label, const QString &status = QString(), bool canBeCanceled = true, KPIM::ProgressItem::CryptoStatus cryptoStatus = KPIM::ProgressItem::Unencrypted); /** * Use this version if you have the id string of the parent and want to * add a subjob to it. */ static ProgressItem *createProgressItem(const QString &parent, const QString &id, const QString &label, const QString &status = QString(), bool canBeCanceled = true, KPIM::ProgressItem::CryptoStatus cryptoStatus = KPIM::ProgressItem::Unencrypted); /** * Version without a parent. */ static ProgressItem *createProgressItem(const QString &id, const QString &label, const QString &status = QString(), bool canBeCanceled = true, KPIM::ProgressItem::CryptoStatus cryptoStatus = KPIM::ProgressItem::Unencrypted); /** * @return true when there are no more progress items. */ bool isEmpty() const; /** * @return the only top level progressitem when there's only one. * Returns 0 if there is no item, or more than one top level item. * Since this is used to calculate the overall progress, it will also return * 0 if there is an item which uses a busy indicator, since that will invalidate * the overall progress. */ ProgressItem *singleItem() const; /** * Ask all listeners to show the progress dialog, because there is * something that wants to be shown. */ static void emitShowProgressDialog(); ProgressItem *progressItem(const QString &id) const; Q_SIGNALS: /** @see ProgressItem::progressItemAdded() */ void progressItemAdded(KPIM::ProgressItem *); /** @see ProgressItem::progressItemProgress() */ void progressItemProgress(KPIM::ProgressItem *, unsigned int); /** @see ProgressItem::progressItemCompleted() */ void progressItemCompleted(KPIM::ProgressItem *); /** @see ProgressItem::progressItemCanceled() */ void progressItemCanceled(KPIM::ProgressItem *); /** @see ProgressItem::progressItemStatus() */ void progressItemStatus(KPIM::ProgressItem *, const QString &); /** @see ProgressItem::progressItemLabel() */ void progressItemLabel(KPIM::ProgressItem *, const QString &); /** @see ProgressItem::progressItemCryptoStatus() */ void progressItemCryptoStatus(KPIM::ProgressItem *, KPIM::ProgressItem::CryptoStatus); /** @see ProgressItem::progressItemUsesBusyIndicator */ void progressItemUsesBusyIndicator(KPIM::ProgressItem *, bool); /** * Emitted when an operation requests the listeners to be shown. * Use emitShowProgressDialog() to trigger it. */ void showProgressDialog(); public Q_SLOTS: /** * Calls setCompleted() on the item, to make sure it goes away. * Provided for convenience. * @param item the canceled item. */ void slotStandardCancelHandler(KPIM::ProgressItem *item); /** * Aborts all running jobs. Bound to "Esc" */ void slotAbortAll(); private Q_SLOTS: void slotTransactionCompleted(KPIM::ProgressItem *item); private: ProgressManager(); // prevent unsolicited copies ProgressManager(const ProgressManager &); ProgressItem *createProgressItemImpl(ProgressItem *parent, const QString &id, const QString &label, const QString &status, bool cancellable, ProgressItem::CryptoStatus cryptoStatus, unsigned int progressType = 0); ProgressItem *createProgressItemImpl(const QString &parent, const QString &id, const QString &label, const QString &status, bool cancellable, ProgressItem::CryptoStatus cryptoStatus, unsigned int progressType = 0); void emitShowProgressDialogImpl(); QHash< QString, ProgressItem * > mTransactions; static unsigned int uID; }; } #endif // __KPIM_PROGRESSMANAGER_H__ 0707010000002B000081A40000000200000002000000015F0FED33000007F2000000000000000000000000000000000000006600000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/progressstatusbarwidget.cpp/* Copyright (C) 2014-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "progressstatusbarwidget.h" #include "statusbarprogresswidget.h" #include "progressdialog.h" using namespace KPIM; class KPIM::ProgressStatusBarWidgetPrivate { public: ProgressStatusBarWidgetPrivate() { } KPIM::StatusbarProgressWidget *mLittleProgress = nullptr; }; ProgressStatusBarWidget::ProgressStatusBarWidget(QWidget *alignWidget, QWidget *parent, unsigned int showTypeProgressItem) : QObject(parent) , d(new KPIM::ProgressStatusBarWidgetPrivate) { KPIM::ProgressDialog *progressDialog = new KPIM::ProgressDialog(alignWidget, parent); progressDialog->setObjectName(QStringLiteral("progressDialog")); progressDialog->setShowTypeProgressItem(showTypeProgressItem); progressDialog->hide(); d->mLittleProgress = new KPIM::StatusbarProgressWidget(progressDialog, alignWidget); d->mLittleProgress->setObjectName(QStringLiteral("littleprogress")); d->mLittleProgress->setShowTypeProgressItem(showTypeProgressItem); d->mLittleProgress->show(); } ProgressStatusBarWidget::~ProgressStatusBarWidget() { delete d; } KPIM::StatusbarProgressWidget *ProgressStatusBarWidget::littleProgress() const { return d->mLittleProgress; } 0707010000002C000081A40000000200000002000000015F0FED330000060C000000000000000000000000000000000000006400000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/progressstatusbarwidget.h/* Copyright (C) 2014-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PROGRESSSTATUSBARWIDGET_H #define PROGRESSSTATUSBARWIDGET_H #include <QObject> #include "kdepim_export.h" namespace KPIM { class StatusbarProgressWidget; class ProgressStatusBarWidgetPrivate; /** * @brief The ProgressStatusBarWidget class * @author Laurent Montel <montel@kde.org> */ class KDEPIM_EXPORT ProgressStatusBarWidget : public QObject { Q_OBJECT public: explicit ProgressStatusBarWidget(QWidget *alignWidget, QWidget *parent = nullptr, unsigned int showTypeProgressItem = 0); ~ProgressStatusBarWidget(); Q_REQUIRED_RESULT KPIM::StatusbarProgressWidget *littleProgress() const; private: ProgressStatusBarWidgetPrivate *const d; }; } #endif // PROGRESSSTATUSBARWIDGET_H 0707010000002D000081A40000000200000002000000015F0FED3300000A98000000000000000000000000000000000000005700000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/ssllabel.cpp/* * * This file is part of KMail, the KDE mail client. * * Copyright (c) 2003 Zack Rusin <zack@kde.org> * * KMail is free software; you can redistribute it and/or modify it * under the 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. * * KMail is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of this program with any edition of * the Qt library by Trolltech AS, Norway (or with modified versions * of Qt that use the same license as Qt), and distribute linked * combinations including the two. You must obey the GNU General * Public License in all respects for all of the code used other than * Qt. If you modify this file, you may extend this exception to * your version of the file, but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from * your version. */ #include "ssllabel.h" #include <KLocalizedString> #include <QLabel> #include <QIcon> #include <QStyle> using namespace KPIM; SSLLabel::SSLLabel(QWidget *parent) : QLabel(parent) { setState(Done); } void SSLLabel::setEncrypted(SSLLabel::State state) { m_lastEncryptionState = state; } SSLLabel::State SSLLabel::lastState() const { return m_lastEncryptionState; } void SSLLabel::setState(State state) { switch (state) { case Encrypted: setToolTip(i18n("Connection is encrypted")); setPixmap(QIcon::fromTheme(QStringLiteral("security-high")).pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize))); show(); break; case Unencrypted: setToolTip(i18n("Connection is unencrypted")); setPixmap(QIcon::fromTheme(QStringLiteral("security-low")).pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize))); show(); break; case Unknown: case Done: setToolTip(QString()); hide(); break; case Clean: setToolTip(QString()); hide(); //we return because we do not save the state as the only //action we want to perform is to hide ourself return; } m_lastEncryptionState = state; } 0707010000002E000081A40000000200000002000000015F0FED330000078A000000000000000000000000000000000000005500000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/ssllabel.h/* * * This file is part of KMail, the KDE mail client. * * Copyright (c) 2003 Zack Rusin <zack@kde.org> * * KMail is free software; you can redistribute it and/or modify it * under the 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. * * KMail is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of this program with any edition of * the Qt library by Trolltech AS, Norway (or with modified versions * of Qt that use the same license as Qt), and distribute linked * combinations including the two. You must obey the GNU General * Public License in all respects for all of the code used other than * Qt. If you modify this file, you may extend this exception to * your version of the file, but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from * your version. */ #ifndef KDEPIM_SSLLABEL_H #define KDEPIM_SSLLABEL_H #include <QLabel> namespace KPIM { class SSLLabel : public QLabel { public: enum State { Encrypted, Unencrypted, Clean, Done, Unknown }; explicit SSLLabel(QWidget *parent); void setEncrypted(State enc = Encrypted); void setState(State state); Q_REQUIRED_RESULT State lastState() const; private: State m_lastEncryptionState; }; } #endif 0707010000002F000081A40000000200000002000000015F0FED3300002B45000000000000000000000000000000000000006600000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/statusbarprogresswidget.cpp/* statusbarprogresswidget.cpp (C) 2004 Till Adam <adam@kde.org> Don Sanders David Faure <dfaure@kde.org> Copyright 2004 David Faure <faure@kde.org> Includes StatusbarProgressWidget which is based on KIOLittleProgressDlg by Matt Koss <koss@miesto.sk> KMail is free software; you can redistribute it and/or modify it under the 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. KMail is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include "statusbarprogresswidget.h" #include "progressdialog.h" #include "ssllabel.h" using KPIM::SSLLabel; #include "progressmanager.h" using KPIM::ProgressItem; using KPIM::ProgressManager; #include <KLocalizedString> #include <QEvent> #include <QFrame> #include <QHBoxLayout> #include <QLabel> #include <QMouseEvent> #include <QProgressBar> #include <QPushButton> #include <QStackedWidget> #include <QTimer> using namespace KPIM; //----------------------------------------------------------------------------- StatusbarProgressWidget::StatusbarProgressWidget(ProgressDialog *progressDialog, QWidget *parent, bool button) : QFrame(parent) , mShowButton(button) , mProgressDialog(progressDialog) { int w = fontMetrics().boundingRect(QStringLiteral(" 999.9 kB/s 00:00:01 ")).width() + 8; QHBoxLayout *boxLayout = new QHBoxLayout(this); boxLayout->setObjectName(QStringLiteral("boxLayout")); boxLayout->setContentsMargins(0, 0, 0, 0); boxLayout->setSpacing(0); mButton = new QPushButton(this); mButton->setObjectName(QStringLiteral("button")); mButton->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); mButton->setIcon(QIcon::fromTheme(QStringLiteral("go-up"))); boxLayout->addWidget(mButton); mStackedWidget = new QStackedWidget(this); mStackedWidget->setObjectName(QStringLiteral("stackedwidget")); int maximumHeight = qMax(mButton->iconSize().height(), fontMetrics().height()); mStackedWidget->setMaximumHeight(maximumHeight); boxLayout->addWidget(mStackedWidget); mSslLabel = new SSLLabel(this); mSslLabel->setObjectName(QStringLiteral("ssllabel")); boxLayout->addWidget(mSslLabel); mButton->setToolTip(i18n("Open detailed progress dialog")); mProgressBar = new QProgressBar(this); mProgressBar->setObjectName(QStringLiteral("progressbar")); mProgressBar->installEventFilter(this); mProgressBar->setMinimumWidth(w); mStackedWidget->insertWidget(1, mProgressBar); mLabel = new QLabel(QString(), this); mLabel->setObjectName(QStringLiteral("emptylabel")); mLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); mLabel->installEventFilter(this); mLabel->setMinimumWidth(w); mStackedWidget->insertWidget(2, mLabel); mButton->setMaximumHeight(maximumHeight); setFixedWidth(600); mMode = Progress; // so the call below works setMode(Clean); connect(mButton, &QAbstractButton::clicked, this, &StatusbarProgressWidget::slotProgressButtonClicked); connect(ProgressManager::instance(), &ProgressManager::progressItemAdded, this, &StatusbarProgressWidget::slotProgressItemAdded); connect(ProgressManager::instance(), &ProgressManager::progressItemCompleted, this, &StatusbarProgressWidget::slotProgressItemCompleted); connect(ProgressManager::instance(), &ProgressManager::progressItemUsesBusyIndicator, this, &StatusbarProgressWidget::updateBusyMode); connect(progressDialog, &ProgressDialog::visibilityChanged, this, &StatusbarProgressWidget::slotProgressDialogVisible); mDelayTimer = new QTimer(this); mDelayTimer->setSingleShot(true); connect(mDelayTimer, &QTimer::timeout, this, &StatusbarProgressWidget::slotShowItemDelayed); mCleanTimer = new QTimer(this); mCleanTimer->setSingleShot(true); connect(mCleanTimer, &QTimer::timeout, this, &StatusbarProgressWidget::slotClean); } void StatusbarProgressWidget::setShowTypeProgressItem(unsigned int type) { mShowTypeProgressItem = type; } // There are three cases: no progressitem, one progressitem (connect to it directly), // or many progressitems (display busy indicator). Let's call them 0,1,N. // In slot..Added we can only end up in 1 or N. // In slot..Removed we can end up in 0, 1, or we can stay in N if we were already. void StatusbarProgressWidget::updateBusyMode(KPIM::ProgressItem *item) { if (item->typeProgressItem() == mShowTypeProgressItem) { connectSingleItem(); // if going to 1 item if (mCurrentItem) { // Exactly one item delete mBusyTimer; mBusyTimer = nullptr; mDelayTimer->start(1000); } else { // N items if (!mBusyTimer) { mBusyTimer = new QTimer(this); connect(mBusyTimer, &QTimer::timeout, this, &StatusbarProgressWidget::slotBusyIndicator); mDelayTimer->start(1000); } } } } void StatusbarProgressWidget::slotProgressItemAdded(ProgressItem *item) { if (item->parent()) { return; // we are only interested in top level items } updateBusyMode(item); } void StatusbarProgressWidget::slotProgressItemCompleted(ProgressItem *item) { if (item->parent()) { item->deleteLater(); item = nullptr; return; // we are only interested in top level items } item->deleteLater(); item = nullptr; connectSingleItem(); // if going back to 1 item if (ProgressManager::instance()->isEmpty()) { // No item // Done. In 5s the progress-widget will close, then we can clean up the statusbar mCleanTimer->start(5000); } else if (mCurrentItem) { // Exactly one item delete mBusyTimer; mBusyTimer = nullptr; activateSingleItemMode(); } } void StatusbarProgressWidget::connectSingleItem() { if (mCurrentItem) { disconnect(mCurrentItem, &ProgressItem::progressItemProgress, this, &StatusbarProgressWidget::slotProgressItemProgress); mCurrentItem = nullptr; } mCurrentItem = ProgressManager::instance()->singleItem(); if (mCurrentItem) { connect(mCurrentItem, &ProgressItem::progressItemProgress, this, &StatusbarProgressWidget::slotProgressItemProgress); } } void StatusbarProgressWidget::activateSingleItemMode() { mProgressBar->setMaximum(100); mProgressBar->setValue(mCurrentItem->progress()); mProgressBar->setTextVisible(true); } void StatusbarProgressWidget::slotShowItemDelayed() { bool noItems = ProgressManager::instance()->isEmpty(); if (mCurrentItem) { activateSingleItemMode(); } else if (!noItems) { // N items mProgressBar->setMaximum(0); mProgressBar->setTextVisible(false); Q_ASSERT(mBusyTimer); if (mBusyTimer) { mBusyTimer->start(100); } } if (!noItems) { setMode(Progress); } } void StatusbarProgressWidget::slotBusyIndicator() { const int p = mProgressBar->value(); mProgressBar->setValue(p + 10); } void StatusbarProgressWidget::slotProgressItemProgress(ProgressItem *item, unsigned int value) { Q_ASSERT(item == mCurrentItem); // the only one we should be connected to Q_UNUSED(item); mProgressBar->setValue(value); } void StatusbarProgressWidget::setMode(Mode mode) { if (mMode == mode) { return; } mMode = mode; switch (mMode) { case Clean: if (mShowButton) { mButton->hide(); } mSslLabel->setState(SSLLabel::Done); // show the empty label in order to make the status bar look better mStackedWidget->show(); mStackedWidget->setCurrentWidget(mLabel); break; case Progress: mStackedWidget->show(); mStackedWidget->setCurrentWidget(mProgressBar); if (mShowButton) { mShowDetailedProgress = mProgressDialog->wasLastShown(); updateProgressButton(mShowDetailedProgress); mButton->show(); } mSslLabel->setState(mSslLabel->lastState()); break; } } void StatusbarProgressWidget::slotClean() { // check if a new item showed up since we started the timer. If not, clear if (ProgressManager::instance()->isEmpty()) { mProgressBar->setValue(0); setMode(Clean); } } bool StatusbarProgressWidget::eventFilter(QObject *obj, QEvent *ev) { if (ev->type() == QEvent::MouseButtonPress) { QMouseEvent *e = static_cast<QMouseEvent *>(ev); if (e->button() == Qt::LeftButton && mMode == Progress) { // toggle view on left mouse button // Consensus seems to be that we should show/hide the fancy dialog when the user // clicks anywhere in the small one. slotProgressButtonClicked(); return true; } } return QFrame::eventFilter(obj, ev); } void StatusbarProgressWidget::updateProgressButton(bool showingProgress) { if (!showingProgress) { mButton->setIcon(QIcon::fromTheme(QStringLiteral("go-up"))); mButton->setToolTip(i18n("Show detailed progress window")); } else { mButton->setIcon(QIcon::fromTheme(QStringLiteral("go-down"))); mButton->setToolTip(i18n("Hide detailed progress window")); } } void StatusbarProgressWidget::slotProgressButtonClicked() { mProgressDialog->slotToggleVisibility(); mShowDetailedProgress = !mProgressDialog->isHidden(); setFixedWidth(qMax(600, mProgressDialog->width())); } void StatusbarProgressWidget::slotProgressDialogVisible(bool b) { // Show the hide/show button (mButton) as soon as the progress dialog is shown // (StatusbarProgressWidget::slotShowItemDelayed happens later) if (b) { setMode(Progress); } updateProgressButton(b); } 07070100000030000081A40000000200000002000000015F0FED3300000D5B000000000000000000000000000000000000006400000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/statusbarprogresswidget.h#ifndef KDEPIM_STATUSBARPROGRESSWIDGET_H #define KDEPIM_STATUSBARPROGRESSWIDGET_H /* statusbarprogresswidget.h (C) 2004 Till Adam <adam@kde.org> Don Sanders David Faure <dfaure@kde.org> Copyright 2004 David Faure <faure@kde.org> KMail is free software; you can redistribute it and/or modify it under the 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. KMail is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ /** * A specialized progress widget class, heavily based on * kio_littleprogress_dlg (it looks similar) */ #include "kdepim_export.h" #include <QFrame> class QEvent; class QProgressBar; class QPushButton; class QStackedWidget; class QLabel; class QTimer; namespace KPIM { class SSLLabel; class ProgressItem; class ProgressDialog; class KDEPIM_EXPORT StatusbarProgressWidget : public QFrame { Q_OBJECT public: explicit StatusbarProgressWidget(ProgressDialog *progressDialog, QWidget *parent, bool button = true); void setShowTypeProgressItem(unsigned int type); public Q_SLOTS: void slotClean(); void slotProgressItemAdded(KPIM::ProgressItem *i); void slotProgressItemCompleted(KPIM::ProgressItem *i); void slotProgressItemProgress(KPIM::ProgressItem *i, unsigned int value); void slotProgressButtonClicked(); protected Q_SLOTS: void slotProgressDialogVisible(bool); void slotShowItemDelayed(); void slotBusyIndicator(); void updateBusyMode(KPIM::ProgressItem *); protected: bool eventFilter(QObject *, QEvent *) override; private: enum Mode { Progress, Clean }; void setMode(Mode mode); void updateProgressButton(bool showingProgress); void connectSingleItem(); void activateSingleItemMode(); unsigned int mShowTypeProgressItem = 0; QProgressBar *mProgressBar = nullptr; QLabel *mLabel = nullptr; SSLLabel *mSslLabel = nullptr; QPushButton *mButton = nullptr; Mode mMode = Clean; bool mShowButton = false; bool mShowDetailedProgress = false; QStackedWidget *mStackedWidget = nullptr; ProgressItem *mCurrentItem = nullptr; ProgressDialog *mProgressDialog = nullptr; QTimer *mDelayTimer = nullptr; QTimer *mBusyTimer = nullptr; QTimer *mCleanTimer = nullptr; }; } // namespace #endif 07070100000031000041ED0000000200000002000000025F0FED3300000000000000000000000000000000000000000000005000000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/tests07070100000032000081A40000000200000002000000015F0FED33000000FE000000000000000000000000000000000000005F00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/tests/CMakeLists.txtset(statusbarprogresswidgetgui_SRCS statusbarprogresswidget_gui.cpp) add_executable(statusbarprogresswidgetgui ${statusbarprogresswidgetgui_SRCS}) target_link_libraries(statusbarprogresswidgetgui Qt5::Widgets Qt5::Core KF5::I18n KF5::Libkdepim ) 07070100000033000081A40000000200000002000000015F0FED3300000585000000000000000000000000000000000000007000000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/tests/statusbarprogresswidget_gui.cpp/* Copyright (C) 2017-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "statusbarprogresswidget_gui.h" #include "../statusbarprogresswidget.h" #include <QApplication> #include <QCommandLineParser> StatusbarProgressWidget_Gui::StatusbarProgressWidget_Gui(QWidget *parent) : QWidget(parent) { } int main(int argc, char **argv) { QApplication app(argc, argv); QCommandLineParser parser; parser.addVersionOption(); parser.addHelpOption(); parser.process(app); StatusbarProgressWidget_Gui *w = new StatusbarProgressWidget_Gui; w->resize(800, 600); w->show(); app.exec(); delete w; return 0; } 07070100000034000081A40000000200000002000000015F0FED330000048D000000000000000000000000000000000000006E00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/progresswidget/tests/statusbarprogresswidget_gui.h/* Copyright (C) 2017-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef STATUSBARPROGRESSWIDGET_GUI_H #define STATUSBARPROGRESSWIDGET_GUI_H #include <QWidget> class StatusbarProgressWidget_Gui : public QWidget { Q_OBJECT public: explicit StatusbarProgressWidget_Gui(QWidget *parent = nullptr); ~StatusbarProgressWidget_Gui() = default; }; #endif // STATUSBARPROGRESSWIDGET_GUI_H 07070100000035000041ED0000000200000002000000025F0FED3300000000000000000000000000000000000000000000004100000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/tests07070100000036000081A40000000200000002000000015F0FED330000011B000000000000000000000000000000000000005000000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/tests/CMakeLists.txt########### next target ############### set(testkcheckcomboboxtest_gui_SRCS kcheckcomboboxtest_gui.cpp) add_executable(kcheckcomboboxtest_gui ${testkcheckcomboboxtest_gui_SRCS}) target_link_libraries(kcheckcomboboxtest_gui KF5::Libkdepim KF5::I18n KF5::Completion KF5::CoreAddons) 07070100000037000081A40000000200000002000000015F0FED3300000706000000000000000000000000000000000000005C00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/tests/kcheckcomboboxtest_gui.cpp/* This file is part of libkdepim. Copyright (c) 2010 David Faure <faure@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include <QApplication> #include <QCommandLineParser> #include <QStandardPaths> #include "../src/libkdepim/widgets/kcheckcombobox.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); QCommandLineParser parser; QStandardPaths::setTestModeEnabled(true); parser.addVersionOption(); parser.addHelpOption(); parser.process(app); KPIM::KCheckComboBox *combo = new KPIM::KCheckComboBox(nullptr); combo->addItems(QStringList() << QStringLiteral("KDE") << QStringLiteral("Mac OSX") << QStringLiteral("Windows") << QStringLiteral("XFCE") << QStringLiteral("FVWM") << QStringLiteral("TWM")); combo->setCheckedItems(QStringList() << QStringLiteral("KDE") << QStringLiteral("Mac OSX") << QStringLiteral("Windows")); combo->resize(400, 20); combo->setSqueezeText(true); combo->setDefaultText(QStringLiteral("Default text")); combo->show(); return app.exec(); } 07070100000038000041ED0000000200000002000000025F0FED3300000000000000000000000000000000000000000000004300000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/widgets07070100000039000081A40000000200000002000000015F0FED33000029E7000000000000000000000000000000000000005600000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/widgets/kcheckcombobox.cpp/* This file is part of libkdepim. Copyright (c) 2008 Thomas Thrainer <tom_t@gmx.at> Copyright (c) 2010 Bertjan Broeksema <broeksema@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include "kcheckcombobox.h" #include "libkdepim_debug.h" #include <QAbstractItemView> #include <QKeyEvent> #include <QLineEdit> #include <QStandardItemModel> using namespace KPIM; /// Class KCheckComboBox::Private namespace KPIM { class Q_DECL_HIDDEN KCheckComboBox::Private { KCheckComboBox *q = nullptr; public: Private(KCheckComboBox *qq) : q(qq) , mSeparator(QLatin1Char(',')) , mSqueezeText(false) , mIgnoreHide(false) , mAlwaysShowDefaultText(false) { } void makeInsertedItemsCheckable(const QModelIndex &, int start, int end); Q_REQUIRED_RESULT QString squeeze(const QString &text); void updateCheckedItems(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex(), int role = Qt::DisplayRole); void toggleCheckState(); public: QString mSeparator; QString mDefaultText; bool mSqueezeText; bool mIgnoreHide; bool mAlwaysShowDefaultText; }; } void KCheckComboBox::Private::makeInsertedItemsCheckable(const QModelIndex &parent, int start, int end) { Q_UNUSED(parent); QStandardItemModel *model = qobject_cast<QStandardItemModel *>(q->model()); if (model) { for (int r = start; r <= end; ++r) { QStandardItem *item = model->item(r, 0); item->setCheckable(true); } } else { qCWarning(LIBKDEPIM_LOG) << "KCheckComboBox: model is not a QStandardItemModel but a" << q->model() << ". Cannot proceed."; } } QString KCheckComboBox::Private::squeeze(const QString &text) { QFontMetrics fm(q->fontMetrics()); // The 4 pixels is 2 * horizontalMargin from QLineEdit. // The rest is code from QLineEdit::paintEvent, where it determines whether to scroll the text // (on my machine minLB=2 and minRB=2, so this removes 8 pixels in total) const int minLB = qMax(0, -fm.minLeftBearing()); const int minRB = qMax(0, -fm.minRightBearing()); const int lineEditWidth = q->lineEdit()->width() - 4 - minLB - minRB; const int textWidth = fm.boundingRect(text).width(); if (textWidth > lineEditWidth) { return fm.elidedText(text, Qt::ElideMiddle, lineEditWidth); } return text; } void KCheckComboBox::Private::updateCheckedItems(const QModelIndex &topLeft, const QModelIndex &bottomRight, int role) { Q_UNUSED(topLeft); Q_UNUSED(bottomRight); const QStringList items = q->checkedItems(role); QString text; if (items.isEmpty() || mAlwaysShowDefaultText) { text = mDefaultText; } else { text = items.join(mSeparator); } if (mSqueezeText) { text = squeeze(text); } q->lineEdit()->setText(text); Q_EMIT q->checkedItemsChanged(items); } void KCheckComboBox::Private::toggleCheckState() { if (q->view()->isVisible()) { const QModelIndex index = q->view()->currentIndex(); QVariant value = index.data(Qt::CheckStateRole); if (value.isValid()) { Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt()); q->model()->setData(index, state == Qt::Unchecked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); } } } /// Class KCheckComboBox KCheckComboBox::KCheckComboBox(QWidget *parent) : QComboBox(parent) , d(new KCheckComboBox::Private(this)) { connect(this, qOverload<int>(&QComboBox::activated), this, [this]() { d->toggleCheckState(); }); connect(model(), &QAbstractItemModel::rowsInserted, this, [this](const QModelIndex &index, int start, int end) { d->makeInsertedItemsCheckable(index, start, end); }); connect(model(), &QAbstractItemModel::dataChanged, this, [this](const QModelIndex &topLeft, const QModelIndex &bottomRight) { d->updateCheckedItems(topLeft, bottomRight); }); // read-only contents setEditable(true); lineEdit()->setAlignment(Qt::AlignLeft); connect(lineEdit(), &QLineEdit::textChanged, this, [this](const QString &text) { if (text.isEmpty()) { //Clear checked items setCheckedItems(QStringList()); } }); view()->installEventFilter(this); view()->viewport()->installEventFilter(this); lineEdit()->installEventFilter(this); d->updateCheckedItems(); } KCheckComboBox::~KCheckComboBox() { delete d; } void KCheckComboBox::hidePopup() { if (!d->mIgnoreHide) { QComboBox::hidePopup(); } d->mIgnoreHide = false; } Qt::CheckState KCheckComboBox::itemCheckState(int index) const { return static_cast<Qt::CheckState>(itemData(index, Qt::CheckStateRole).toInt()); } void KCheckComboBox::setItemCheckState(int index, Qt::CheckState state) { setItemData(index, state, Qt::CheckStateRole); } QStringList KCheckComboBox::checkedItems(int role) const { QStringList items; if (model()) { const QModelIndex index = model()->index(0, modelColumn(), rootModelIndex()); const QModelIndexList indexes = model()->match(index, Qt::CheckStateRole, Qt::Checked, -1, Qt::MatchExactly); items.reserve(indexes.count()); for (const QModelIndex &index : indexes) { items += index.data(role).toString(); } } return items; } void KCheckComboBox::setCheckedItems(const QStringList &items, int role) { for (int r = 0; r < model()->rowCount(rootModelIndex()); ++r) { const QModelIndex indx = model()->index(r, modelColumn(), rootModelIndex()); const QString text = indx.data(role).toString(); const bool found = items.contains(text); model()->setData(indx, found ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); } d->updateCheckedItems(QModelIndex(), QModelIndex(), role); } QString KCheckComboBox::defaultText() const { return d->mDefaultText; } void KCheckComboBox::setDefaultText(const QString &text) { if (d->mDefaultText != text) { d->mDefaultText = text; d->updateCheckedItems(); } } bool KCheckComboBox::squeezeText() const { return d->mSqueezeText; } void KCheckComboBox::setSqueezeText(bool squeeze) { if (d->mSqueezeText != squeeze) { d->mSqueezeText = squeeze; d->updateCheckedItems(); } } bool KCheckComboBox::itemEnabled(int index) { Q_ASSERT(index >= 0 && index <= count()); QStandardItemModel *itemModel = qobject_cast<QStandardItemModel *>(model()); Q_ASSERT(itemModel); QStandardItem *item = itemModel->item(index, 0); return item->isEnabled(); } void KCheckComboBox::setItemEnabled(int index, bool enabled) { Q_ASSERT(index >= 0 && index <= count()); QStandardItemModel *itemModel = qobject_cast<QStandardItemModel *>(model()); Q_ASSERT(itemModel); QStandardItem *item = itemModel->item(index, 0); item->setEnabled(enabled); } QString KCheckComboBox::separator() const { return d->mSeparator; } void KCheckComboBox::setSeparator(const QString &separator) { if (d->mSeparator != separator) { d->mSeparator = separator; d->updateCheckedItems(); } } void KCheckComboBox::keyPressEvent(QKeyEvent *event) { switch (event->key()) { case Qt::Key_Up: case Qt::Key_Down: showPopup(); event->accept(); break; case Qt::Key_Return: case Qt::Key_Enter: case Qt::Key_Escape: hidePopup(); event->accept(); break; default: break; } // don't call base class implementation, we don't need all that stuff in there } #ifndef QT_NO_WHEELEVENT void KCheckComboBox::wheelEvent(QWheelEvent *event) { // discard mouse wheel events on the combo box event->accept(); } #endif void KCheckComboBox::resizeEvent(QResizeEvent *event) { QComboBox::resizeEvent(event); if (d->mSqueezeText) { d->updateCheckedItems(); } } bool KCheckComboBox::eventFilter(QObject *receiver, QEvent *event) { switch (event->type()) { case QEvent::KeyPress: case QEvent::KeyRelease: case QEvent::ShortcutOverride: switch (static_cast<QKeyEvent *>(event)->key()) { case Qt::Key_Space: if (event->type() == QEvent::KeyPress && view()->isVisible()) { d->toggleCheckState(); } // Always eat the event: don't let QItemDelegate toggle the current index when the view is hidden. return true; case Qt::Key_Return: case Qt::Key_Enter: case Qt::Key_Escape: // ignore Enter keys, they would normally select items. // but we select with Space, because multiple selection is possible // we simply close the popup on Enter/Escape hidePopup(); return true; } break; case QEvent::MouseButtonDblClick: case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: d->mIgnoreHide = true; if (receiver == lineEdit()) { showPopup(); return true; } break; default: break; } return QComboBox::eventFilter(receiver, event); } bool KCheckComboBox::alwaysShowDefaultText() const { return d->mAlwaysShowDefaultText; } void KCheckComboBox::setAlwaysShowDefaultText(bool always) { if (always != d->mAlwaysShowDefaultText) { d->mAlwaysShowDefaultText = always; d->updateCheckedItems(); } } void KCheckComboBox::updateCheckedItems(const QModelIndex &topLeft, const QModelIndex &bottomRight, int role) { d->updateCheckedItems(topLeft, bottomRight, role); } #include "moc_kcheckcombobox.cpp" 0707010000003A000081A40000000200000002000000015F0FED3300001749000000000000000000000000000000000000005400000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/widgets/kcheckcombobox.h/* This file is part of libkdepim. Copyright (c) 2008 Thomas Thrainer <tom_t@gmx.at> Copyright (c) 2010 Bertjan Broeksema <broeksema@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KCHECKCOMBOBOX_H #define KCHECKCOMBOBOX_H #include "kdepim_export.h" #include <QComboBox> #include <QModelIndex> namespace KPIM { /** * A combobox that shows its items in such a way that they can be checked in the * drop menu. It provides methods to set the default text when no items are selected * and the separator that is used to show the items that are selected in the line * edit. */ class KDEPIM_EXPORT KCheckComboBox : public QComboBox { Q_OBJECT Q_PROPERTY(QString separator READ separator WRITE setSeparator) Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText) Q_PROPERTY(bool squeezeText READ squeezeText WRITE setSqueezeText) Q_PROPERTY(QStringList checkedItems READ checkedItems WRITE setCheckedItems) public: /** * Creates a new checkable combobox. * * @param parent The parent widget. */ explicit KCheckComboBox(QWidget *parent = nullptr); /** * Destroys the time zone combobox. */ ~KCheckComboBox() override; /** * Hides the popup list if it is currently shown. */ void hidePopup() override; /** * Returns the default text that is shown when no items are selected. */ Q_REQUIRED_RESULT QString defaultText() const; /** * Sets the default text that is shown when no items are selected. * * @param text The new default text */ void setDefaultText(const QString &text); /** * Returns whether the default text is always shown, even if there are * no checked items. */ bool alwaysShowDefaultText() const; /** * Sets if the default text should always be shown even if there are * no checked items. * * Default is false. */ void setAlwaysShowDefaultText(bool always); /** * Returns whether or not the text will be squeezed to fit in the combo's line * edit. This property is false by default. * * @see KSqueezedTextLabel */ Q_REQUIRED_RESULT bool squeezeText() const; /** * Sets whether or not the text must be squeezed. * * @param squeeze The new squeeze status */ void setSqueezeText(bool squeeze); /** * Return whether or not the item at @param index is enabled, i.e. if the * user can (un)check the item. */ Q_REQUIRED_RESULT bool itemEnabled(int index); /** * Set the item at @param index to @param enabled, i.e. if the * user can (un)check the item. */ void setItemEnabled(int index, bool enabled = true); /** * Returns the check state of item at given index. * * @param index The index for which to return the check state. */ Q_REQUIRED_RESULT Qt::CheckState itemCheckState(int index) const; /** * Changes the check state of the given index to the given state. * * @param index The index of which the state needs to be changed * @param state The new state */ void setItemCheckState(int index, Qt::CheckState state); /** * Returns the current separator used to separate the selected items in the * line edit of the combo box. */ Q_REQUIRED_RESULT QString separator() const; /** * Sets the separator used to separate items in the line edit. * * @param separator The new separator */ void setSeparator(const QString &separator); /** * Returns The currently selected items. * @param role The role the returned values belong to. */ Q_REQUIRED_RESULT QStringList checkedItems(int role = Qt::DisplayRole) const; /** * Update the KCheckComboBox text with Item belonging to the role. * @param topLeft Curently unused. * @param bottomRight Curently unused. * @param role The role the updated values belong to. */ void updateCheckedItems(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex(), int role = Qt::DisplayRole); public Q_SLOTS: /** * Sets the currently selected items. Items that are not found in the model * are silently ignored. * * @param items The items that will be set to checked. * @param role The role @p items belong to. */ void setCheckedItems(const QStringList &items, int role = Qt::DisplayRole); Q_SIGNALS: /** * Signal to notify listeners that the current selections has changed. * * @param items The new selection. */ void checkedItemsChanged(const QStringList &items); protected: bool eventFilter(QObject *receiver, QEvent *event) override; void keyPressEvent(QKeyEvent *event) override; void resizeEvent(QResizeEvent *event) override; #ifndef QT_NO_WHEELEVENT void wheelEvent(QWheelEvent *event) override; #endif private: //@cond PRIVATE class Private; Private *const d; //@endcond }; } #endif // KCHECKCOMBOBOX_H 0707010000003B000081A40000000200000002000000015F0FED3300001F89000000000000000000000000000000000000005500000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/widgets/kwidgetlister.cpp/* -*- c++ -*- kwidgetlister.cpp This file is part of libkdepim. Copyright (c) 2001 Marc Mutz <mutz@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this library with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include "kwidgetlister.h" #include <KLocalizedString> #include <KGuiItem> #include <QHBoxLayout> #include <QPushButton> #include <QVBoxLayout> #include <assert.h> #include <KStandardGuiItem> using namespace KPIM; class Q_DECL_HIDDEN KWidgetLister::Private { public: Private(KWidgetLister *qq) : q(qq) { } ~Private() { qDeleteAll(mWidgetList); mWidgetList.clear(); } void enableControls(); KWidgetLister *q = nullptr; QPushButton *mBtnMore = nullptr; QPushButton *mBtnFewer = nullptr; QPushButton *mBtnClear = nullptr; QVBoxLayout *mLayout = nullptr; QWidget *mButtonBox = nullptr; QList<QWidget *> mWidgetList; int mMinWidgets = 0; int mMaxWidgets = 0; }; void KWidgetLister::Private::enableControls() { const int count = mWidgetList.count(); const bool isMaxWidgets = (count >= mMaxWidgets); const bool isMinWidgets = (count <= mMinWidgets); if (mBtnMore) { mBtnMore->setEnabled(!isMaxWidgets); } if (mBtnFewer) { mBtnFewer->setEnabled(!isMinWidgets); } } KWidgetLister::KWidgetLister(bool fewerMoreButton, int minWidgets, int maxWidgets, QWidget *parent) : QWidget(parent) , d(new Private(this)) { d->mMinWidgets = qMax(minWidgets, 1); d->mMaxWidgets = qMax(maxWidgets, d->mMinWidgets + 1); init(fewerMoreButton); } KWidgetLister::~KWidgetLister() { delete d; } void KWidgetLister::init(bool fewerMoreButton) { //--------- the button box d->mLayout = new QVBoxLayout(this); d->mLayout->setContentsMargins(0, 0, 0, 0); d->mLayout->setSpacing(4); d->mButtonBox = new QWidget(this); QHBoxLayout *mButtonBoxHBoxLayout = new QHBoxLayout(d->mButtonBox); mButtonBoxHBoxLayout->setContentsMargins(0, 0, 0, 0); d->mLayout->addWidget(d->mButtonBox); if (fewerMoreButton) { d->mBtnMore = new QPushButton(d->mButtonBox); mButtonBoxHBoxLayout->addWidget(d->mBtnMore); KGuiItem::assign(d->mBtnMore, KGuiItem(i18nc("more widgets", "More"), QStringLiteral("list-add"))); mButtonBoxHBoxLayout->setStretchFactor(d->mBtnMore, 0); d->mBtnFewer = new QPushButton(d->mButtonBox); mButtonBoxHBoxLayout->addWidget(d->mBtnFewer); KGuiItem::assign(d->mBtnFewer, KGuiItem(i18nc("fewer widgets", "Fewer"), QStringLiteral("list-remove"))); mButtonBoxHBoxLayout->setStretchFactor(d->mBtnFewer, 0); } QWidget *spacer = new QWidget(d->mButtonBox); mButtonBoxHBoxLayout->addWidget(spacer); mButtonBoxHBoxLayout->setStretchFactor(spacer, 1); d->mBtnClear = new QPushButton(d->mButtonBox); mButtonBoxHBoxLayout->addWidget(d->mBtnClear); KGuiItem::assign(d->mBtnClear, KStandardGuiItem::clear()); // FIXME a useful whats this. KStandardGuiItem::clear() returns a text with an edit box d->mBtnClear->setWhatsThis(QString()); mButtonBoxHBoxLayout->setStretchFactor(d->mBtnClear, 0); //---------- connect everything if (fewerMoreButton) { connect(d->mBtnMore, &QPushButton::clicked, this, &KWidgetLister::slotMore); connect(d->mBtnFewer, &QPushButton::clicked, this, &KWidgetLister::slotFewer); } connect(d->mBtnClear, &QPushButton::clicked, this, &KWidgetLister::slotClear); d->enableControls(); } void KWidgetLister::slotMore() { // the class should make certain that slotMore can't // be called when mMaxWidgets are on screen. assert(d->mWidgetList.count() < d->mMaxWidgets); addWidgetAtEnd(); // adjustSize(); d->enableControls(); } void KWidgetLister::slotFewer() { // the class should make certain that slotFewer can't // be called when mMinWidgets are on screen. assert(d->mWidgetList.count() > d->mMinWidgets); removeLastWidget(); // adjustSize(); d->enableControls(); } void KWidgetLister::slotClear() { setNumberOfShownWidgetsTo(d->mMinWidgets); // clear remaining widgets for (QWidget *widget : qAsConst(d->mWidgetList)) { clearWidget(widget); } // adjustSize(); d->enableControls(); Q_EMIT clearWidgets(); } void KWidgetLister::addWidgetAtEnd(QWidget *widget) { if (!widget) { widget = this->createWidget(this); } d->mLayout->insertWidget(d->mLayout->indexOf(d->mButtonBox), widget); d->mWidgetList.append(widget); widget->show(); d->enableControls(); Q_EMIT widgetAdded(); Q_EMIT widgetAdded(widget); } void KWidgetLister::removeLastWidget() { // The layout will take care that the // widget is removed from screen, too. delete d->mWidgetList.takeLast(); d->enableControls(); Q_EMIT widgetRemoved(); } void KWidgetLister::clearWidget(QWidget *widget) { Q_UNUSED(widget); } QWidget *KWidgetLister::createWidget(QWidget *parent) { return new QWidget(parent); } void KWidgetLister::setNumberOfShownWidgetsTo(int aNum) { int superfluousWidgets = qMax(d->mWidgetList.count() - aNum, 0); int missingWidgets = qMax(aNum - d->mWidgetList.count(), 0); // remove superfluous widgets for (; superfluousWidgets; superfluousWidgets--) { removeLastWidget(); } // add missing widgets for (; missingWidgets; missingWidgets--) { addWidgetAtEnd(); } } QList<QWidget *> KWidgetLister::widgets() const { return d->mWidgetList; } int KWidgetLister::widgetsMinimum() const { return d->mMinWidgets; } int KWidgetLister::widgetsMaximum() const { return d->mMaxWidgets; } void KWidgetLister::removeWidget(QWidget *widget) { // The layout will take care that the // widget is removed from screen, too. if (d->mWidgetList.count() <= widgetsMinimum()) { return; } const int index = d->mWidgetList.indexOf(widget); QWidget *w = d->mWidgetList.takeAt(index); w->deleteLater(); w = nullptr; d->enableControls(); Q_EMIT widgetRemoved(widget); Q_EMIT widgetRemoved(); } void KWidgetLister::addWidgetAfterThisWidget(QWidget *currentWidget, QWidget *widget) { if (!widget) { widget = this->createWidget(this); } int index = d->mLayout->indexOf(currentWidget ? currentWidget : d->mButtonBox) + 1; d->mLayout->insertWidget(index, widget); if (currentWidget) { index = d->mWidgetList.indexOf(currentWidget); d->mWidgetList.insert(index + 1, widget); } else { d->mWidgetList.append(widget); } widget->show(); d->enableControls(); Q_EMIT widgetAdded(); Q_EMIT widgetAdded(widget); } 0707010000003C000081A40000000200000002000000015F0FED3300001C18000000000000000000000000000000000000005300000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/widgets/kwidgetlister.h/* -*- c++ -*- kwidgetlister.h This file is part of libkdepim Copyright (c) 2001 Marc Mutz <mutz@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this library with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef KDEPIM_KWIDGETLISTER_H #define KDEPIM_KWIDGETLISTER_H #include "kdepim_export.h" #include <QWidget> namespace KPIM { /** @short Widget that manages a list of other widgets (incl. 'more', 'fewer' and 'clear' buttons). Simple widget that nonetheless does a lot of the dirty work for the filter edit widgets (KMSearchPatternEdit and KMFilterActionEdit). It provides a growable and shrinkable area where widget may be displayed in rows. Widgets can be added by hitting the provided 'More' button, removed by the 'Fewer' button and cleared (e.g. reset, if an derived class implements that and removed for all but @ref mMinWidgets). To use this widget, derive from it with the template changed to the type of widgets this class should list. Then reimplement @ref addWidgetAtEnd, @ref removeLastWidget, calling the original implementation as necessary. Instantiate an object of the class and put it in your dialog. @author Marc Mutz <Marc@Mutz.com> @see KMSearchPatternEdit::WidgetLister KMFilterActionEdit::WidgetLister */ class KDEPIM_EXPORT KWidgetLister : public QWidget { Q_OBJECT public: /** * Creates a new widget lister. * @param fewerMoreButton Add or Not fewerMoreButton * @param minWidgets The minimum number of widgets to stay on the screen. * @param maxWidgets The maximum number of widgets to stay on the screen. * @param parent The parent widget. */ explicit KWidgetLister(bool fewerMoreButton, int minWidgets = 1, int maxWidgets = 8, QWidget *parent = nullptr); /** * Destroys the widget lister. */ ~KWidgetLister() override; protected Q_SLOTS: /** * Called whenever the user clicks on the 'more' button. * Reimplementations should call this method, because this * implementation does all the dirty work with adding the widgets * to the layout (through @ref addWidgetAtEnd) and enabling/disabling * the control buttons. */ virtual void slotMore(); /** * Called whenever the user clicks on the 'fewer' button. * Reimplementations should call this method, because this * implementation does all the dirty work with removing the widgets * from the layout (through @ref removeLastWidget) and * enabling/disabling the control buttons. */ virtual void slotFewer(); /** * Called whenever the user clicks on the 'clear' button. * Reimplementations should call this method, because this * implementation does all the dirty work with removing all but * @ref mMinWidgets widgets from the layout and enabling/disabling * the control buttons. */ virtual void slotClear(); protected: /** * Adds a single widget. Doesn't care if there are already @ref * mMaxWidgets on screen and whether it should enable/disable any * controls. It simply does what it is asked to do. You want to * reimplement this method if you want to initialize the widget * when showing it on screen. Make sure you call this * implementaion, though, since you cannot put the widget on screen * from derived classes (@p mLayout is private). * Make sure the parent of the QWidget to add is this KWidgetLister. */ virtual void addWidgetAtEnd(QWidget *widget = nullptr); /** * Removes a single (always the last) widget. Doesn't care if there * are still only @ref mMinWidgets left on screen and whether it * should enable/disable any controls. It simply does what it is * asked to do. You want to reimplement this method if you want to * save the widget's state before removing it from screen. Make * sure you call this implementaion, though, since you should not * remove the widget from screen from derived classes. */ virtual void removeLastWidget(); /** * Called to clear a given widget. The default implementation does * nothing. */ virtual void clearWidget(QWidget *w); /** * Returns a new widget that shall be added to the lister. * * @param parent The parent widget of the new widget. */ virtual QWidget *createWidget(QWidget *parent); /** * Sets the number of widgets on scrren to exactly @p count. Doesn't * check if @p count is inside the range @p [mMinWidgets,mMaxWidgets]. */ virtual void setNumberOfShownWidgetsTo(int count); /** * Returns the list of widgets. */ QList<QWidget *> widgets() const; /** * The minimum number of widgets that are to stay on screen. */ int widgetsMinimum() const; /** * The maximum number of widgets that are to be shown on screen. */ int widgetsMaximum() const; /** * Remove specific widget */ virtual void removeWidget(QWidget *widget); /** * Add widget after specific widget */ virtual void addWidgetAfterThisWidget(QWidget *currentWidget, QWidget *widget = nullptr); private: void init(bool fewerMoreButton = true); Q_SIGNALS: /** * This signal is emitted whenever a widget was added. */ void widgetAdded(); /** * This signal is emitted whenever a widget was added. * * @param widget The added widget. */ void widgetAdded(QWidget *widget); /** * This signal is emitted whenever a widget was removed. */ void widgetRemoved(); /** * This signal is emitted whenever a widget was removed. */ void widgetRemoved(QWidget *widget); /** * This signal is emitted whenever the clear button is clicked. */ void clearWidgets(); private: //@cond PRIVATE class Private; Private *const d; //@endcond }; } #endif /* _KWIDGETLISTER_H_ */ 0707010000003D000081A40000000200000002000000015F0FED33000009E3000000000000000000000000000000000000005E00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/widgets/progressindicatorlabel.cpp/* Copyright (c) 2013-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "progressindicatorlabel.h" #include <KBusyIndicatorWidget> #include <QHBoxLayout> #include <QLabel> using namespace KPIM; class KPIM::ProgressIndicatorLabelPrivate { public: ProgressIndicatorLabelPrivate(const QString &_label, ProgressIndicatorLabel *qq) : labelStr(_label) , q(qq) { QHBoxLayout *lay = new QHBoxLayout(q); lay->setContentsMargins(0, 0, 0, 0); indicator = new KBusyIndicatorWidget; lay->addWidget(indicator); label = new QLabel; lay->addWidget(label); } ~ProgressIndicatorLabelPrivate() { } void setActiveLabel(const QString &str) { if (!indicator->isHidden()) { label->setText(str); } } void start() { indicator->show(); label->setText(labelStr); } void stop() { indicator->hide(); label->clear(); } QString labelStr; QLabel *label = nullptr; KBusyIndicatorWidget *indicator = nullptr; ProgressIndicatorLabel *q; }; ProgressIndicatorLabel::ProgressIndicatorLabel(const QString &label, QWidget *parent) : QWidget(parent) , d(new ProgressIndicatorLabelPrivate(label, this)) { d->stop(); } ProgressIndicatorLabel::ProgressIndicatorLabel(QWidget *parent) : QWidget(parent) , d(new ProgressIndicatorLabelPrivate(QString(), this)) { d->stop(); } ProgressIndicatorLabel::~ProgressIndicatorLabel() { delete d; } void ProgressIndicatorLabel::start() { d->start(); } void ProgressIndicatorLabel::stop() { d->stop(); } void ProgressIndicatorLabel::setActiveLabel(const QString &label) { d->setActiveLabel(label); } 0707010000003E000081A40000000200000002000000015F0FED3300000677000000000000000000000000000000000000005C00000000libkdepim-VERSIONgit.20200716T080123~b231803/src/libkdepim/widgets/progressindicatorlabel.h/* Copyright (c) 2013-2020 Laurent Montel <montel@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PROGRESSINDICATORLABEL_H #define PROGRESSINDICATORLABEL_H #include "kdepim_export.h" #include <QWidget> namespace KPIM { class ProgressIndicatorLabelPrivate; /** * @brief The ProgressIndicatorLabel class * @author Laurent Montel <montel@kde.org> */ class KDEPIM_EXPORT ProgressIndicatorLabel : public QWidget { Q_OBJECT public: /** * @since 4.12 */ explicit ProgressIndicatorLabel(const QString &labelStr, QWidget *parent = nullptr); explicit ProgressIndicatorLabel(QWidget *parent = nullptr); ~ProgressIndicatorLabel(); void setActiveLabel(const QString &label); public Q_SLOTS: void start(); void stop(); private: friend class ProgressIndicatorLabelPrivate; ProgressIndicatorLabelPrivate *const d; }; } #endif // PROGRESSINDICATORLABEL_H 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!461 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor