author | zautrix <zautrix> | 2005-01-16 08:49:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 08:49:00 (UTC) |
commit | 62ff81d5d292ddf3c6032b48f27a6daedf6a6cb0 (patch) (side-by-side diff) | |
tree | ef89d1577b47959c172e644701bf9dc7541c2987 | |
parent | 32795d059fa22cc9fd213db4b4d87e30866a7cb9 (diff) | |
download | kdepimpi-62ff81d5d292ddf3c6032b48f27a6daedf6a6cb0.zip kdepimpi-62ff81d5d292ddf3c6032b48f27a6daedf6a6cb0.tar.gz kdepimpi-62ff81d5d292ddf3c6032b48f27a6daedf6a6cb0.tar.bz2 |
beter time edit
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 5 | ||||
-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 17 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 12 | ||||
-rw-r--r-- | korganizer/ktimeedit.cpp | 82 | ||||
-rw-r--r-- | korganizer/ktimeedit.h | 3 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 4 |
6 files changed, 21 insertions, 102 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index c8293b2..5d8ef41 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt @@ -1,732 +1,737 @@ Info about the changes in new versions of KDE-Pim/Pi ********** VERSION 1.9.18 ************ FYI: The VERSION 1.9.17 was a testing release only. Please read the changelog of VERSION 1.9.17 as well. Cleaned up the syncing config dialog. Added sync config options for date range for events. Added sync config options for filters on incoming data. Added sync config options for filters on outgoing data. Please read the updated SyncHowTo about the new filter settings. These filter settings make it now possible to sync with shared calendars without writing back private or confidential data (via the outgoing filters). To sync only with particular parts of a shared calendar, the incoming filter settings can be used. An example can be found in the SyncHowTo. +KO/Pi: +The timeedit input has a pulldown list for times. +If opened, this pulldown list should now has the right time highlighted. + + ********** VERSION 1.9.17 ************ KO/Pi: Fixed that tooltips were not updated after moving an item in agenda view. Fixed a bug in sorting start date for recurring events in list view. Changed the left button in todo viewer from "Agenda" to "Set completed". This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View. Added more info in the todo viewer: Startdate, parent/sub todos. KA/Pi: All fields search does now actually search all the (possible) fields, not only those listed in the contact list. Made is possible to inline a picture in a vcard on the Z. This was only possible on the desktop, now is it possible on the Z as well. Fixed of missing save settings after filter configuration. Made saving of addressbook much faster. Fixed extension widget layout problem. Fixed saving of default formatted name settings. Fixed formatted name handling in edit dialog. Added an option for changing formatted names of many contacts (menu: File - Change - Set formatted name). QWhatsThis was not working on the Z ( only black rectangle was shown). This is Fixed. KDE-Sync: Now readonly KDE resources are synced as well. (They are not changed in KDE itself, of course). ********** VERSION 1.9.16 ************ KO/Pi: Fixed search dialog size on Z 6000 (480x640 display). Added setting to hide/show time in agenda items. Added setting to hide not running todos in todo view. Added columns for start date/time in todo view. Replaced the solid half-hour lines in agenda view by dot lines. Added possibility of printing the What's Next View on the desktop (i.e. Windows and Linux). Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. Added tooltips in month view.(Tooltips only available on desktop) Fixed a strange problem in KO/Pi alarm applet. Did not find the actual problem, such that now Qtopia reboots again if deinstalling the alarm applet. But the alarm applet should work again. KA/Pi: Fixed the problem, that internal pictures were not saved. Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. Fixed some minor problems. (Like word wrap in help text windows). Fixed a compiling problem in microkde/kresources. KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) such that now syncing KO/Pi with Sharp DTM should work on the Zaurus C 3000 model. ********** VERSION 1.9.15 ************ Usebilty enhancements in KO/Pi: When clicking on the date in a month view cell, the day view is shown. Old behaviour was, that the "new event" dialog popped up. Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). That means, you can restore the latest event/todo/journal you have deleted. A journal is deleted, if you clear all the text of the journal. Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. KA/Pi starting in 480x640 resolution: Hide the filter action in toolbar and added icons for undo/delete/redo in toolbar. Change in OM/Pi ViewMail dialog: When clicking on the "delete" icon the mail is deleted after confirmation as usual. But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any). Fixed a crash when deleting mail-accounts in OM/Pi. ********** VERSION 1.9.14 ************ Fixed some problems with the dialog sizes when switching portrait/landscape mode on 640x480 PDA display. Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. Fixed an ugly bug in KOpieMail: KOpieMail was not able to write files (mails) to MSDOS file system, like on an usual preformatted SD card. That should work now. To save your mail data on the Sd card do the following: Create a dir on the SD card: mkdir /mnt/card/localmail Go to your home dir: cd Go to kopiemail data storage dir: cd kdepim/apps/kopiemail Create a symlink to the SD card: ls -s /mnt/card/localmail Now KOpieMail will store all mails on the SD card. KO/Pi Monthview: Now "Go to Today" selects the current month from day 1-end, not the current date + some days. I.e. "Go to Today" shows now always the current month with first day of month in the first row. Added missing German translation. Fixed icons of executeable on Wintendo. Added a "Show next Mail" button to the OM/Pi mail viewer such that the mail below the current mail in the mail list view of the current folder can be read with a single click. ********** VERSION 1.9.13 ************ Fixed nasty PwM/Pi file reading bug, when the used hash algo of file is different then the global hash algo. Added KA/Pi support for opie mailit mailapplication. Fixed some bugs in OM/Pi. Now character conversion tables are available for the Zaurus to make OM/Pi working properly. To get the character conversion in OM/Pi working, please download at the sourceforge project site the package sr-character-conversion_SharpROM_arm.ipk.zip (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) from the section "general files for KDE/Pim" Instructions how to install this package are in a ReadMe in this file. Fixed the orientation change problem in KA/Pi when switching portrait/landscape mode. French translation available for KA/Pi and OM/Pi. Fixed some problems with categories in KO/Pi in DTM sync. Added selection dialog for export to phone in KA/Pi. If in KO/Pi is an attendee selected to add to a meeting and this attendee is already in the list of attendees, this person is not added again. Some menu cleanup in KA/Pi. ********** VERSION 1.9.12 ************ Fix for the bug in KO/Pi What's Next view of version 1.9.11. Bugfix: Licence file is now shown again. OM/Pi now supports Unicode (utf8 charset). Fixed some bugs in OM/Pi. KA/Pi has more German translation. ********** VERSION 1.9.11 ************ Fixed several problems in PWM/Pi, like asking the user, if unsaved changed are pending when closing the app. And PwM/Pi handles now different texts for the fields Description, Username, Password, configurable per category. Fixed a crash in KO/Pi , when importing/loading vcs files which have an entry with an attendee with state: NEEDS ACTION Fixed some problems in the German translation of OM/Pi, which makes some dialogs not fitting on the screen of the Z 5500. Fixed Qtopia crash, when disabling/deinstalling KO/Pi alarm applet. Implemented direct KDE<->KA/Pi sync for KA/Pi running on Linux desktop. Added feature "remove sync info" to sync menu. Tweaked the KO/Pi What's next view a bit, added setting to hide events that are done. Disabled "beam receive enabled" on startup to avoid problems if Fastload is enabled. Please set "beam receive enabled", if you want to receive data via IR. Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running on Linux desktop. Made in KA/Pi scrolling possible, if details view is selected. (The keyboard focus is set automatically to the search line) Fixed a bug in DMT sync, that a new entry in DTM was added on every sync to Kx/Pi. Fixed missing writing of KA/Pi categories to DMT entries when syncing. Fixed a bug in DMT sync with todos created in KO/Pi containing non-latin1 characters. Rearranged package contents of Sharp-ipks and made all packages installable on SD again. Fixed the writing of addressbook data in DTM sync. Empty fields in KA/Pi were not removed. Added better category handling in KA/Pi: Added item Edit Categories and Manage new categories to the settings menu. Possible to configure a view to display categories. Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. Fixed displaying of "free" days and time in KO Monthview and Agendaview. ... and many other bugfixes. ********** VERSION 1.9.10 ************ Many internal small bugfixes. And fix of the "big" bug in KO/Pi, that after Syncing the appointments had an offset by several hours. That was a problem with the internal timezone setting, introduced by the changed timezone configuration settings. German translation for OM/Pi is now available. ********** VERSION 1.9.9 ************ KDE-Pim/Pi has a new Member! It is called PWM/Pi (Passwordmanager/platform-independent) and it is available for the Zaurus. It is planned, that it will be available later for Windows. (And for Linux, of course). It is a port of the Passwordmanager of KDE. It will need the MicroKDElibs to run. Made loading of addressbooks in KA/Pi up to 7 times faster! The bigger your addressbook file, the more starting speed will you gain. (relatively) The Qtopia addressbook connector is now platform independend as well and should work on any platform for importing/exporting Qtopia and Opie XML files. Added a +30min feature to the timezone settings to make KDE-Pim/Pi useable in Australia and other parts on the world with strange timezones ;-) German "Umlaute" should now be sorted correctly on the Z in KA/Pi. It is now possible to disable the "receive data via infrared" feature, such that syncing with Outlook is now possible again with Kx/Pi runing. Please disable it, before syncing Sharp DTM with Outlook. For your convenience, the "receive data via infrared" feature is disabled automatically, if you sync Kx/Pi with DTM. You have to enable it again manually after syncing. Enabling this feature makes it impossible to start the Sharp DTM apps. If this feature is enabled, you will only get the alarm notification from KO/Pi and not from the Sharp calendar. This is very useful if you sync KO/Pi with Sharp DTM, because after syncing you usually would get notified about an alarm by KO/Pi and the Sharp Calendar. Together with the Linux desktop version of KO/Pi it is now possible to sync KO/Pi on the Zaurus with the complete KDE-desktop (3.3 or later) calendar data easily. That makes it possible to sync the Z with one click of a mouse with the KDE-Desktop. This feature it available for all Zaurus platforms KO/Pi is running on. The only thing needed is a running KO/Pi on Linux and a compiled version of the small KDE-Pim/Pi<->KDE-Desktop access command line program, which is in the KDE-Pim/Pi sources available. The "KDE-desktop" syncing feature for KA/Pi will follow in the next releases. Fixed the vcard export bug, which had the version 1.9.8. Added missing GERMAN translation to KO/Pi. Hi PsionX, could you add the missing french translation?Thx! Translation files for KA/Pi are available as well. GERMAN translation will be available in the next release. PsionX ( yres, you again ;-) ), could you start translating KA/Pi? Thx! You can download the version 1.9.9 at http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 Note: To run the mail program OM/Pi you need libopenssl. A link to a download loaction is available at ZSI at www.killefiz.de ********** VERSION 1.9.8 ************ Fixed character decoding in OM/Pi. (e.g. German "Umlaute" were not displayed properly.) Made is possible to reparent todos in KO/Pi. Use contextmenu or keys (look at Help-Keys + Colors) for that. Added the missing Sync-Howto and WhatsNew to the packages. KO/Pi on Linux desktop can now sync with KDE desktop. That means: When using KO/Pi on Linux desktop for syncing with KDE desktop and the Zaurus, the Zaurus can be synced now with all KDE-Calendar resources, not only with one local file. (That makes it possible to sync the Zaurus with the calendar data on a Kolab server) KA/Pi syncing with KDE desktop will be available in the next version. ********** VERSION 1.9.7 ************ KO/Pi - KA/Pi on Windows: Now a directory can be defined by the user, where the application/config data should be saved. Define your desired path in the evironment variable MICROKDEHOME before starting KO/Pi or KA/Pi. An easy Kx/Pi to Kx/Pi syncing is now possible (it is called Pi-Sync) via network. Please look at the Sync Howto. Exporting of calendar data and contacts to mobile phones is now possible. The SyncHowto is updated with information howto access/sync mobile phones. Please look at the Sync Howto. Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. Please disable Fastload for the original contact/calendar applications and close them. KO/Pi and KA/Pi must be running in order to receive the data. (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) In the KA/Pi details view are now the preferred tel. numbers displayed on top of the other data ( emails/tel.numbers/addresses) Fixed some syncing problems in KA/Pi. Added font settings for the KA/Pi details view. Added fields "children's name" and "gender" to KA/Pi. Made searching in KA/Pi better: Now the first item in a view is selected after a search automatically and the views can be scrolled up/down when the search input field has the keyboard focus. And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. ********** VERSION 1.9.6 ************ Changes in the external application communication on the Zaurus in order to use less RAM when the apps are running. First syncing of addressbooks (KA/Pi) is possible. ********** VERSION 1.9.5a ************ Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. Fixed some small bugs. KA/Pi shows now the birthday in summary view. Now OM/Pi and KA/Pi are using the date format defined in KO/Pi for displaying dates. ********** VERSION 1.9.5 ************ There is still no Addressbook syncing! New in 1.9.5: Many bugfixes. Better searching in KA/Pi. You can configure in KA/Pi if you want to search only after <return> key pressed. Better mail downloading in OM/Pi. First experimental alpha version of sync of KO/Pi with mobile phones. See gammu documentation for supported phones. You need to install the package kammu_1.9.5_arm.ipk for sync of KO/Pi with mobile phones. kammu_1.9.5_arm.ipk needs libbluetooth and libsdp. Quick hint how to use: NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. Create syncprofile - mobile device Remove entry for model. (Leave empty ). Enable infrared on Zaurus and your Phone. Sync. To get a more detailed log, start kopi from konsole. ********** VERSION 1.9.4 ************ This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. WARNING: PLEASE BACKUP ALL YOUR DATA! We have changed a lot and maybe there are some unknown problems. SYNC HANDLING HAS CHANGED! Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well. As programs are available: KO/Pi (korganizer ipk) - a calendar program. KA/Pi (kaddressbook ipk ) - an addressbook OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. (If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) All the applications are installed in a "Pim" TAB. If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk All the application are integrated. Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail. HINT: If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. What's new? SYNC HANDLING HAS CHANGED! Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). New in OM/Pi: When copying(i.e. downloading mails) , you can specify, that only mails of a given size should be downloaded. Added mail copy possibility for selected mails. New in KO/Pi: French is now available for KO/Pi. Choose menu:Actions - Configure:TAB locale Syncing has changed. Phone sync available soon. Not much changes, I cannot remember them ... New in KA/Pi: Beaming possible. Sharp DTM readonly access possible( create a new DTM resource ); Better searching possible. Search is performed only after pressing the return key. Use wildcard * to specify parts of a name. Better name/email selection dialog (called from KO/Pi or OM/Pi). In this dialog, now searching is possible. Like in KA/Pi, use return key and wildcard * . A big improvement is the new management of the contact access. In version 1.9.3, every application was using their own addressbook access data. That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. That was wasting of memory, if you had several hundreds of contacts. Now only KA/Pi accesses the addressbook. If KO/Pi or OM/Pi want to get some name/email data, they request KA/Pi to open the name/email selection dialog and send it back to them. If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. New in the KO/Pi alarm applet: Configure your own timer popup menu! (Text and minutes for timer countdown) Just edit the file (yourhomedir)/.kopialarmtimerrc and start/stop a timer to get a new menu with the data of this file. ********** VERSION 1.9.3 ************ 1) Now KO/Pi on Windows imports directly the calendar data of an installed Outlook. Should work with OL version >= 2000. ********** VERSION 1.9.2 ************ 1) KDE-Pim/Pi has got a new member: KmicroMail (KM/Pi) is a mail program, which can handle IMAP and POP mail access. It is based on Opie-Mail v3. All dependencies to the Opie libraries ar removed, such that no additional Opie lib is needed. It is already integrated in KO/Pi and KA/Pi. It it now available for the Zaurus,probably it will be available for other platforms later. Hint: Create your own contact (name + email) in KA/Pi, select this contact and choose menu: Settings - Set Who Am I. Now the settings of this contact are used as the sender data in KM/Pi. 2) KDE-Pim/Pi is split up in five different packages now precompiled for Sharp Zaurus: --kmicrokdelibs_1.9.2_arm.ipk The libs are needed for any of the following programs: --kaddressbook_1.9.2_arm.ipk --kmicromail_1.9.2_arm.ipk --korganizer_1.9.2_arm.ipk Independ from that, there is the alarm applet available for KO/Pi, which also offers quick access for a new mail or showing the addressbook.: --korganizer-alarm_1.9.2_arm.ipk Independend means, that the alarm applet does not need any of the libs or programs above to run. But it would be quite useless without these programs. NOTE: If you get a "This application depends on other programs" during installation of --kmicrokdelibs_1.9.2_arm.ipk you probably do not have to care about that. kmicrokdelibs_1.9.2 will come with some resource plugins, which needs additional libraries. (E.g. libopie1, if you want to use the opie resource connector in KA/Pi). If you do not have this libraries installed, you simply cannot use the resource. To make it clear: If the libraries are missing, the applications using kmicrokdelibs will start, because the resources are plugins. 3) KO/Pi and friends are now installable on SD-Card! It is recommended to install all libs and apps on the SD card or all in the internal storage. There may be problems, if this is mixed. 4) Fixed two bugs in the alarm notification on Windows. 5) Great improvement! KO/Pi uses now the latest version of libical. Libical is the library which actually reads the calendar files and extract the data from it. With the old version, there were problems (crashes or program hangs) when licical did read files, which were not stored from KO/Pi. I do not know, if the new libical works perfect, but actually it works much better than the old version. There are no problems with compatibility with old calendar files of KO/Pi, of course! 6) New in KA/Pi: Opie addressbook resource connector available! You will need libopie1 and the opie addressbook, of course. With the Opie addressbook resource connector, you can access the Opie addressbook readonly in KA/Pi. If you want to edit or import the data into KA/Pi, do this: a) Create an Opie resource. (Menu: Settings-Configure Resources). After configuration and restarting KA/Pi you should see the Opie contacts in KA/Pi. b) Select some or all Opie contacts. (NOTE: +++++ To know exactly, what contacts are Opie contacts, do this: Choose menu: View-Modify View - TAB Fields. Select in the above list "Resource" and click down arrow to add it to the "Selected fields". Click OK. Now you have a new column "Resource" in your list, where you can see, what an Opie resource is. ++++ NOTE end.) Ok, we do have now some Opie contacts seleted. (Use SHIFT or CTRL key in order to multiple select). c) Choose menu: Edit-Copy. d) Choose menu: Edit-Paste. e) Select the resource, you want to add the contacts to. Congrats! Now you have read/write access to the copied opie contacts as "real" KA/Pi contacts. ********** VERSION 1.9.1 ************ 1) +++ IMPORTANT 1 +++ The storing place of the default calendar file has changed! The default calendar file was Applications/korganizer/mycalendar.ics on Zaurus and (yourHomeDir)/korganizer/mycalendar.ics on Windows/Linux desktop. Now it is (yourHomeDir)/kdepim/korganizer/mycalendar.ics on Zaurus, Windows and Linux. To load the old file, choose menu File-Load calendar backup. (It should be loaded automatically at startup with a warning message displayed). The place of the configuration file has changed too. If you want to use your old KO/Pi config, copy it to (yourHomeDir)/kdepim/config/korganizerrc Please read VERSION 1.9.0 - topic 3) as well! +++ IMPORTANT 2 +++ Because of the new paths, you will need a new version of the KO/Pi alarm applet for Zaurus. Use version >= 1.9.1 2) Now the QWhat'sThis Icon works for items in the month view as well. (See VERSION 1.7.8 Topic 1) ). 3) You can import birtsdays/anniversaries from KA/Pi into KO/Pi. Choose menu File-Import birthdays. If you import twice, already imported items will not be imported again, if they have not been changed in KO/Pi. 4) When syncing with sharp DTM, now a progress is shown, when the data is written back. If there is much data in KO/Pi and no data in DTM, that can take a long time. (But only for the first time ). 5) In the search dialog, you can search now for the name/email of an attendee of an event/todo. To get more space for displaying search results, the buttons for "search" and "close" on the bottom are removed in the PDA version. You have to click OK in the top right corner to do a search. 6) Now it is possible to disable the displaying of todo items in the Allday part of the Agenda. Choose Menu Action-Configure, TAB Todo View, checkbox "Allday Agenda view shows todos" 7) If FastLoad is enabled, now the settings and the calendar data are saved, when KO/Pi is closed. (If no Fastload is enabled, KO/Pi saves the data as well, of course) 8) The Agenda View has a minimize-splitter now, such that the height of the allday part can be changed quickly. ********** VERSION 1.9.0 ************ 1) KO/Pi is now merged with the new microKDE from KA/Pi. KO/Pi accesses now KA/Pi as the addressbook. The other ddressbook-plugins are not working any longer. (It is planned, that later KA/Pi itself uses these plugins) New versions of KO/Pi are only available together with KA/Pi as the KDE-Pim/Pi package. 2) If you click on an attendee of a meeting in the event viewer, a detailed summary of the attendee is shown. 3) The place of the configuration file has changed. If you want to use your old KO/Pi config, copy Applications/korganizer/config_korganizerrc to Applications/korganizer/config/korganizerrc ********** VERSION 1.7.8 ************ 1) Now the QWhat'sThis ist working. Enable the QWhat'sThis icon in the toolbar. (You have to restart to reload the changed toolbar config). Now click on the QWhat'sThis Icon in the top right corner of KO/Pi. Then click on an item in the Agenda View: You will get a detailed display of the items content. 2) Some other very minor changes. But I have forgotten the details ... For that reason I start this log here: To document my changes, when I am doing it. ********** VERSION 1.7.7 ************ Stable Version of KO/Pi diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp index fc5be71..30b792b 100644 --- a/korganizer/koeditorgeneralevent.cpp +++ b/korganizer/koeditorgeneralevent.cpp @@ -1,444 +1,427 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 <qtooltip.h> #include <qlayout.h> #include <qvbox.h> #include <qbuttongroup.h> #include <qvgroupbox.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <kdebug.h> #include <kglobal.h> #include <klocale.h> #include <kiconloader.h> #include <kmessagebox.h> #include <kfiledialog.h> #include <kstandarddirs.h> #include <libkcal/event.h> #include <libkdepim/kdateedit.h> #include "koprefs.h" #include "koeditorgeneralevent.h" #include "kolocationbox.h" KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent, const char* name) : KOEditorGeneral( parent, name) { mTemplate = false; connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), SLOT(setDuration())); connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), SLOT(emitDateTimeStr())); } KOEditorGeneralEvent::~KOEditorGeneralEvent() { } void KOEditorGeneralEvent::finishSetup() { //disabled // QWidget::setTabOrder( mSummaryEdit, mLocationEdit ); // QWidget::setTabOrder( mLocationEdit, mStartDateEdit ); // QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit ); // QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit ); // QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit ); // QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton ); // QWidget::setTabOrder( mNoTimeButton, mAlarmButton ); // QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit ); // QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton ); // QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo ); // QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit ); mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); mSummaryEdit->setFocus(); } void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) { QBoxLayout *timeLayout = new QVBoxLayout(topLayout); QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, i18n("Date && Time"),parent); timeLayout->addWidget(timeGroupBox); timeGroupBox->layout()->setSpacing( 0 ); timeGroupBox->layout()->setMargin( 5 ); QFrame *timeBoxFrame = new QFrame(timeGroupBox); QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3); layoutTimeBox->setSpacing(topLayout->spacing()); mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame); layoutTimeBox->addWidget(mStartDateLabel,0,0); mStartDateEdit = new KDateEdit(timeBoxFrame); layoutTimeBox->addWidget(mStartDateEdit,0,1); mStartTimeEdit = new KOTimeEdit(timeBoxFrame); layoutTimeBox->addWidget(mStartTimeEdit,0,2); mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame); layoutTimeBox->addWidget(mEndDateLabel,1,0); mEndDateEdit = new KDateEdit(timeBoxFrame); layoutTimeBox->addWidget(mEndDateEdit,1,1); mEndTimeEdit = new KOTimeEdit(timeBoxFrame); layoutTimeBox->addWidget(mEndTimeEdit,1,2); QWidget* duration = new QWidget( timeBoxFrame ); QHBoxLayout *flagsBox = new QHBoxLayout( duration ); mNoTimeButton = new QCheckBox(i18n("Allday"),duration); flagsBox->addWidget(mNoTimeButton); connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool))); mDurationLabel = new QLabel( duration ); // if ( KOPrefs::instance()->mCompactDialogs ) { //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 ); //} else { flagsBox->addWidget( mDurationLabel ); //} flagsBox->setStretchFactor(mDurationLabel, 10 ); mDurationLabel->setAlignment( AlignRight | AlignVCenter); layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 ); // time widgets are checked if they contain a valid time connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(startTimeChanged(QTime))); connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(endTimeChanged(QTime))); // date widgets are checked if they contain a valid date connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), this, SLOT(startDateChanged(QDate))); connect(mEndDateEdit, SIGNAL(dateChanged(QDate)), this, SLOT(endDateChanged(QDate))); } void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) { QBoxLayout *classLayout = new QHBoxLayout(topLayout); QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); classLayout->addWidget(freeTimeLabel); mFreeTimeCombo = new QComboBox(false, parent); mFreeTimeCombo->insertItem(i18n("Busy")); mFreeTimeCombo->insertItem(i18n("Free")); classLayout->addWidget(mFreeTimeCombo); } void KOEditorGeneralEvent::timeStuffDisable(bool disable) { mStartTimeEdit->setEnabled( !disable ); mEndTimeEdit->setEnabled( !disable ); setDuration(); emitDateTimeStr(); } void KOEditorGeneralEvent::dontAssociateTime(bool noTime) { timeStuffDisable(noTime); //if(alarmButton->isChecked()) alarmStuffDisable(noTime); allDayChanged(noTime); } void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) { // kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; if ( !mTemplate ) mStartDateEdit->setDate(start.date()); // KTimeEdit seems to emit some signals when setTime() is called. mStartTimeEdit->blockSignals( true ); mStartTimeEdit->setTime(start.time()); mStartTimeEdit->blockSignals( false ); if ( !mTemplate ) mEndDateEdit->setDate(end.date()); mEndTimeEdit->setTime(end.time()); mCurrStartDateTime = start; mCurrEndDateTime = end; setDuration(); emitDateTimeStr(); } void KOEditorGeneralEvent::startTimeChanged(QTime newtime) { kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl; int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); mCurrStartDateTime.setTime(newtime); // adjust end time so that the event has the same duration as before. mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); mEndTimeEdit->setTime(mCurrEndDateTime.time()); mEndDateEdit->setDate(mCurrEndDateTime.date()); emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); } void KOEditorGeneralEvent::endTimeChanged(QTime newtime) { // kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl; QDateTime newdt(mCurrEndDateTime.date(), newtime); mCurrEndDateTime = newdt; emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); } void KOEditorGeneralEvent::startDateChanged(QDate newdate) { int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); mCurrStartDateTime.setDate(newdate); // adjust end date so that the event has the same duration as before mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); mEndDateEdit->setDate(mCurrEndDateTime.date()); emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); } void KOEditorGeneralEvent::endDateChanged(QDate newdate) { QDateTime newdt(newdate, mCurrEndDateTime.time()); if(newdt < mCurrStartDateTime) { // oops, we can't let that happen. newdt = mCurrStartDateTime; mEndDateEdit->setDate(newdt.date()); mEndTimeEdit->setTime(newdt.time()); } mCurrEndDateTime = newdt; emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); } void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay) { mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); mLocationEdit->load(KOLocationBox::LOCATION); KOEditorGeneral::setDefaults(allDay); mNoTimeButton->setChecked(allDay); timeStuffDisable(allDay); mFreeTimeCombo->setCurrentItem( 0 ); setDateTimes(from,to); } void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl ) { QString tmpStr; mTemplate = tmpl; // the rest is for the events only mNoTimeButton->setChecked(event->doesFloat()); timeStuffDisable(event->doesFloat()); setDateTimes(event->dtStart(),event->dtEnd()); mTemplate = false; switch( event->transparency() ) { case Event::Transparent: mFreeTimeCombo->setCurrentItem(1); break; case Event::Opaque: mFreeTimeCombo->setCurrentItem(0); break; } mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); mLocationEdit->load(KOLocationBox::LOCATION); readIncidence(event); } void KOEditorGeneralEvent::writeEvent(Event *event) { // kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl; writeIncidence(event); QDate tmpDate; QTime tmpTime; QDateTime tmpDT; // temp. until something better happens. QString tmpStr; if (mNoTimeButton->isChecked()) { event->setFloats(true); // need to change this. tmpDate = mStartDateEdit->date(); tmpTime.setHMS(0,0,0); tmpDT.setDate(tmpDate); tmpDT.setTime(tmpTime); event->setDtStart(tmpDT); tmpDate = mEndDateEdit->date(); tmpTime.setHMS(0,0,0); tmpDT.setDate(tmpDate); tmpDT.setTime(tmpTime); event->setDtEnd(tmpDT); } else { event->setFloats(false); // set date/time end tmpDate = mEndDateEdit->date(); tmpTime = mEndTimeEdit->getTime(); tmpDT.setDate(tmpDate); tmpDT.setTime(tmpTime); event->setDtEnd(tmpDT); // set date/time start tmpDate = mStartDateEdit->date(); tmpTime = mStartTimeEdit->getTime(); tmpDT.setDate(tmpDate); tmpDT.setTime(tmpTime); event->setDtStart(tmpDT); } // check for float mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); event->setTransparency(mFreeTimeCombo->currentItem() > 0 ? KCal::Event::Transparent : KCal::Event::Opaque); // kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; } void KOEditorGeneralEvent::setDuration() { QString tmpStr = "", catStr; int hourdiff, minutediff; // end<date is an accepted temporary state while typing, but don't show // any duration if this happens if(mCurrEndDateTime >= mCurrStartDateTime) { if (mNoTimeButton->isChecked()) { int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; tmpStr = i18n("Duration: "); tmpStr.append(i18n("1 Day","%n Days",daydiff)); } else { int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); hourdiff = secto / 3600; minutediff = (secto/60 ) % 60; if (hourdiff || minutediff){ tmpStr = i18n("Duration: "); if (hourdiff){ catStr = i18n("1 h","%n h",hourdiff); tmpStr.append(catStr); } if (hourdiff && minutediff){ tmpStr += i18n(", "); } if (minutediff){ catStr = i18n("1 min","%n min",minutediff); tmpStr += catStr; } } else tmpStr = ""; } } mDurationLabel->setText(tmpStr); } void KOEditorGeneralEvent::emitDateTimeStr() { KLocale *l = KGlobal::locale(); QString from,to; if (mNoTimeButton->isChecked()) { from = l->formatDate(mCurrStartDateTime.date()); to = l->formatDate(mCurrEndDateTime.date()); } else { from = l->formatDateTime(mCurrStartDateTime); to = l->formatDateTime(mCurrEndDateTime); } QString str = i18n("From: %1 To: %2 %3").arg(from).arg(to) .arg(mDurationLabel->text()); emit dateTimeStrChanged(str); } bool KOEditorGeneralEvent::validateInput() { -// kdDebug() << "KOEditorGeneralEvent::validateInput()" << endl; - - if (!mNoTimeButton->isChecked()) { - if (!mStartTimeEdit->inputIsValid()) { - KMessageBox::sorry( 0, - i18n("Please specify a valid start time, for example '%1'.") - .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) ); - return false; - } - - if (!mEndTimeEdit->inputIsValid()) { - KMessageBox::sorry( 0, - i18n("Please specify a valid end time, for example '%1'.") - .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) ); - return false; - } - } if (!mStartDateEdit->inputIsValid()) { KMessageBox::sorry( 0, i18n("Please specify a valid start date, for example '%1'.") .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); return false; } if (!mEndDateEdit->inputIsValid()) { KMessageBox::sorry( 0, i18n("Please specify a valid end date, for example '%1'.") .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); return false; } QDateTime startDt,endDt; startDt.setDate(mStartDateEdit->date()); endDt.setDate(mEndDateEdit->date()); if (!mNoTimeButton->isChecked()) { startDt.setTime(mStartTimeEdit->getTime()); endDt.setTime(mEndTimeEdit->getTime()); } if (startDt > endDt) { KMessageBox::sorry(0,i18n("The event ends before it starts.\n" "Please correct dates and times.")); return false; } return KOEditorGeneral::validateInput(); } diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index 7db7da0..158a7d3 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp @@ -1,466 +1,454 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 <qtooltip.h> #include <qfiledialog.h> #include <qlayout.h> #include <qvbox.h> #include <qbuttongroup.h> #include <qvgroupbox.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <kglobal.h> #include <klocale.h> #include <kiconloader.h> #include <kmessagebox.h> #include <kdebug.h> #include <krestrictedline.h> #include <kstandarddirs.h> #include <kfiledialog.h> #include <libkcal/todo.h> #include <libkdepim/kdateedit.h> #include "koprefs.h" #include "ktimeedit.h" #include "koeditorgeneraltodo.h" #include "kolocationbox.h" KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, const char* name) : KOEditorGeneral( parent, name) { } KOEditorGeneralTodo::~KOEditorGeneralTodo() { } void KOEditorGeneralTodo::finishSetup() { // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); // QWidget::setTabOrder(mLocationEdit, mDueCheck); // QWidget::setTabOrder(mDueCheck, mDueDateEdit); // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); // QWidget::setTabOrder(mStartCheck, mStartDateEdit); // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); // QWidget::setTabOrder(mTimeButton, mCompletedCombo); // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); mSummaryEdit->load(KOLocationBox::SUMMARYTODO); mSummaryEdit->setFocus(); } void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) { QBoxLayout *timeLayout = new QVBoxLayout(topLayout); QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, i18n("Date && Time"),parent); timeLayout->addWidget(timeGroupBox); timeGroupBox->layout()->setSpacing( 0 ); timeGroupBox->layout()->setMargin( 5 ); QFrame *timeBoxFrame = new QFrame(timeGroupBox); QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); layoutTimeBox->setSpacing(topLayout->spacing()); layoutTimeBox->setColStretch( 1, 1 ); mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); layoutTimeBox->addWidget(mDueCheck,0,0); connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); mDueDateEdit = new KDateEdit(timeBoxFrame); layoutTimeBox->addWidget(mDueDateEdit,0,1); mDueTimeEdit = new KOTimeEdit(timeBoxFrame); layoutTimeBox->addWidget(mDueTimeEdit,0,2); mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); layoutTimeBox->addWidget(mStartCheck,1,0); connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); mStartDateEdit = new KDateEdit(timeBoxFrame); layoutTimeBox->addWidget(mStartDateEdit,1,1); mStartTimeEdit = new KOTimeEdit(timeBoxFrame); layoutTimeBox->addWidget(mStartTimeEdit,1,2); mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); // some more layouting //layoutTimeBox->setColStretch(3,1); } void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) { mCompletedCombo = new QComboBox(parent); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 0 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 20 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 40 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 60 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 80 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n("100 %")); connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); topLayout->addWidget(mCompletedCombo); mCompletedLabel = new QLabel(i18n("completed"),parent); topLayout->addWidget(mCompletedLabel); } void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) { QHBox* h = new QHBox ( parent ); topLayout->addWidget( h ); QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); // topLayout->addWidget(priorityLabel); mPriorityCombo = new QComboBox( h ); mPriorityCombo->insertItem(i18n("1 (high)")); mPriorityCombo->insertItem(i18n("2")); mPriorityCombo->insertItem(i18n("3")); mPriorityCombo->insertItem(i18n("4")); mPriorityCombo->insertItem(i18n("5 (low)")); //topLayout->addWidget(mPriorityCombo); } void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) { QBoxLayout *statusLayout = new QHBoxLayout(topLayout); initCompletion( parent, statusLayout ); statusLayout->addStretch( 1 ); initPriority( parent, statusLayout ); } void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) { mSummaryEdit->load(KOLocationBox::SUMMARYTODO); mLocationEdit->load(KOLocationBox::LOCATION); KOEditorGeneral::setDefaults(allDay); mTimeButton->setChecked( !allDay ); if(mTimeButton->isChecked()) { mTimeButton->setEnabled(true); } else { mTimeButton->setEnabled(false); } enableTimeEdits( !allDay ); mDueCheck->setChecked(false); enableDueEdit(false); alarmDisable(true); mStartCheck->setChecked(false); enableStartEdit(false); mDueDateEdit->setDate(due.date()); mDueTimeEdit->setTime(due.time()); mStartDateEdit->setDate(QDate::currentDate()); mStartTimeEdit->setTime(QTime::currentTime()); mPriorityCombo->setCurrentItem(2); mCompletedLabel->setText(i18n("completed"));; mCompletedCombo->setCurrentItem(0); } void KOEditorGeneralTodo::readTodo(Todo *todo) { mSummaryEdit->load(KOLocationBox::SUMMARYTODO); mLocationEdit->load(KOLocationBox::LOCATION); KOEditorGeneral::readIncidence(todo); QDateTime dueDT; if (todo->hasDueDate()) { enableAlarmEdit(true); dueDT = todo->dtDue(); mDueDateEdit->setDate(todo->dtDue().date()); mDueTimeEdit->setTime(todo->dtDue().time()); mDueCheck->setChecked(true); } else { alarmDisable(true); mDueDateEdit->setEnabled(false); mDueTimeEdit->setEnabled(false); mDueDateEdit->setDate(QDate::currentDate()); mDueTimeEdit->setTime(QTime::currentTime()); mDueCheck->setChecked(false); } if (todo->hasStartDate()) { mStartDateEdit->setDate(todo->dtStart().date()); mStartTimeEdit->setTime(todo->dtStart().time()); mStartCheck->setChecked(true); } else { mStartDateEdit->setEnabled(false); mStartTimeEdit->setEnabled(false); mStartDateEdit->setDate(QDate::currentDate()); mStartTimeEdit->setTime(QTime::currentTime()); mStartCheck->setChecked(false); } mTimeButton->setChecked( !todo->doesFloat() ); mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); if (todo->isCompleted() && todo->hasCompletedDate()) { mCompleted = todo->completed(); } setCompletedDate(); mPriorityCombo->setCurrentItem(todo->priority()-1); } void KOEditorGeneralTodo::writeTodo(Todo *todo) { KOEditorGeneral::writeIncidence(todo); // temp. until something better happens. QString tmpStr; todo->setHasDueDate(mDueCheck->isChecked()); todo->setHasStartDate(mStartCheck->isChecked()); QDate tmpDate; QTime tmpTime; QDateTime tmpDT; if ( mTimeButton->isChecked() ) { todo->setFloats(false); // set due date/time tmpDate = mDueDateEdit->date(); tmpTime = mDueTimeEdit->getTime(); tmpDT.setDate(tmpDate); tmpDT.setTime(tmpTime); todo->setDtDue(tmpDT); // set start date/time tmpDate = mStartDateEdit->date(); tmpTime = mStartTimeEdit->getTime(); tmpDT.setDate(tmpDate); tmpDT.setTime(tmpTime); todo->setDtStart(tmpDT); } else { todo->setFloats(true); // need to change this. tmpDate = mDueDateEdit->date(); tmpTime.setHMS(0,0,0); tmpDT.setDate(tmpDate); tmpDT.setTime(tmpTime); todo->setDtDue(tmpDT); tmpDate = mStartDateEdit->date(); tmpTime.setHMS(0,0,0); tmpDT.setDate(tmpDate); tmpDT.setTime(tmpTime); todo->setDtStart(tmpDT); } todo->setPriority(mPriorityCombo->currentItem()+1); // set completion state todo->setPercentComplete(mCompletedCombo->currentItem() * 20); if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { todo->setCompleted(mCompleted); } mSummaryEdit->save(KOLocationBox::SUMMARYTODO); } void KOEditorGeneralTodo::enableDueEdit(bool enable) { mDueDateEdit->setEnabled( enable ); if(mDueCheck->isChecked() || mStartCheck->isChecked()) { mTimeButton->setEnabled(true); } else { mTimeButton->setEnabled(false); mTimeButton->setChecked(false); } if (enable) { mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); } else { mDueTimeEdit->setEnabled( false ); } } void KOEditorGeneralTodo::enableStartEdit( bool enable ) { mStartDateEdit->setEnabled( enable ); if(mDueCheck->isChecked() || mStartCheck->isChecked()) { mTimeButton->setEnabled(true); } else { mTimeButton->setEnabled(false); mTimeButton->setChecked(false); } if (enable) { mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); } else { mStartTimeEdit->setEnabled( false ); } } void KOEditorGeneralTodo::enableTimeEdits(bool enable) { if(mStartCheck->isChecked()) { mStartTimeEdit->setEnabled( enable ); } if(mDueCheck->isChecked()) { mDueTimeEdit->setEnabled( enable ); } } void KOEditorGeneralTodo::showAlarm() { if ( mDueCheck->isChecked() ) { alarmDisable(false); } else { alarmDisable(true); } } bool KOEditorGeneralTodo::validateInput() { if (mDueCheck->isChecked()) { if (!mDueDateEdit->inputIsValid()) { KMessageBox::sorry(0,i18n("Please specify a valid due date.")); return false; } - if (mTimeButton->isChecked()) { - if (!mDueTimeEdit->inputIsValid()) { - KMessageBox::sorry(0,i18n("Please specify a valid due time.")); - return false; - } - } } if (mStartCheck->isChecked()) { if (!mStartDateEdit->inputIsValid()) { KMessageBox::sorry(0,i18n("Please specify a valid start date.")); return false; } - if (mTimeButton->isChecked()) { - if (!mStartTimeEdit->inputIsValid()) { - KMessageBox::sorry(0,i18n("Please specify a valid start time.")); - return false; - } - } } if (mStartCheck->isChecked() && mDueCheck->isChecked()) { QDateTime startDate; QDateTime dueDate; startDate.setDate(mStartDateEdit->date()); dueDate.setDate(mDueDateEdit->date()); if (mTimeButton->isChecked()) { startDate.setTime(mStartTimeEdit->getTime()); dueDate.setTime(mDueTimeEdit->getTime()); } if (startDate > dueDate) { KMessageBox::sorry(0, i18n("The start date cannot be after the due date.")); return false; } } return KOEditorGeneral::validateInput(); } void KOEditorGeneralTodo::completedChanged(int index) { if (index == 5) { mCompleted = QDateTime::currentDateTime(); } setCompletedDate(); } void KOEditorGeneralTodo::setCompletedDate() { if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { mCompletedLabel->setText(i18n("completed on %1") .arg(KGlobal::locale()->formatDateTime(mCompleted))); } else { mCompletedLabel->setText(i18n("completed")); } } void KOEditorGeneralTodo::modified (Todo* todo, int modification) { switch (modification) { case KOGlobals::PRIORITY_MODIFIED: mPriorityCombo->setCurrentItem(todo->priority()-1); break; case KOGlobals::COMPLETION_MODIFIED: mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); if (todo->isCompleted() && todo->hasCompletedDate()) { mCompleted = todo->completed(); } setCompletedDate(); break; case KOGlobals::CATEGORY_MODIFIED: setCategories (todo->categoriesStr ()); break; case KOGlobals::UNKNOWN_MODIFIED: // fall through default: readTodo( todo ); break; } } diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp index f5a1c50..5222ac9 100644 --- a/korganizer/ktimeedit.cpp +++ b/korganizer/ktimeedit.cpp @@ -1,528 +1,474 @@ /* This file is part of KOrganizer. Copyright (c) 1999 Preston Brown, Ian Dawes 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 <qkeycode.h> #include <qcombobox.h> #include <qdatetime.h> #include <qlineedit.h> +#include <qlistbox.h> #include <qapplication.h> #include <kmessagebox.h> #include <kglobal.h> #include <kdebug.h> #include <klocale.h> #include <kpimglobalprefs.h> #include "ktimeedit.h" #include "koprefs.h" #include <qvalidator.h> // Validator for a time value with only hours and minutes (no seconds) // Mostly locale aware. Author: David Faure <faure@kde.org> -class KOTimeValidator : public QValidator -{ -public: - KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {} - - virtual State validate(QString& str, int& /*cursorPos*/) const - { - return Acceptable; - bool ok = false; - // TODO use KLocale::WithoutSeconds in HEAD - /*QTime time =*/ KGlobal::locale()->readTime(str, &ok); - if ( ok ) - return Acceptable; - // readTime doesn't help knowing when the string is "Intermediate". - int length = str.length(); - if ( !str ) // empty string? - return Invalid; // there should always be a ':' in it, right? - // HACK. Not fully locale aware etc. (esp. the separator is '.' in sv_SE...) - QChar sep = ':'; - // I want to allow "HH:", ":MM" and ":" to make editing easier - if ( str[0] == sep ) - { - if ( length == 1 ) // just ":" - return Intermediate; - QString minutes = str.mid(1); - int m = minutes.toInt(&ok); - if ( ok && m >= 0 && m < 60 ) - return Intermediate; - } else if ( str.at(str.length()-1) == sep ) - { - QString hours = str.left(length-1); - int h = hours.toInt(&ok); - if ( ok && h >= 0 && h < 24 ) - return Intermediate; - } - return Invalid; - } -}; // KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. // Difficult to get all in one... // But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) : QComboBox(TRUE, parent, name) { setInsertionPolicy(NoInsertion); - setValidator( new KOTimeValidator( this ) ); mFlagKeyPressed = false; if ( QApplication::desktop()->width() < 650 ) setSizeLimit ( 6 ); mTime = qt; // mNoTimeString = i18n("No Time"); // insertItem( mNoTimeString ); // Fill combo box with selection of times in localized format. QTime timeEntry(0,0,0); do { insertItem(KGlobal::locale()->formatTime(timeEntry)); timeEntry = timeEntry.addSecs(60*15); } while (!timeEntry.isNull()); // Add end of day. insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); updateText(); setFocusPolicy(QWidget::StrongFocus); connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); QFontMetrics fm ( font() ); QString timeString = "24:00"; if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) timeString = "02:00pm"; int addSpace = 32; if ( QApplication::desktop()->width() > 320 ) timeString += ":00"; setFixedWidth(fm.width( timeString ) + 32 ); // Highlight Background and Textcolor change from default QPalette palette = QWidget::palette(); unsigned char red, green, blue; red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); setPalette( palette ); } KOTimeEdit::~KOTimeEdit() { } bool KOTimeEdit::hasTime() const { // Can't happen if ( currentText().isEmpty() ) return false; //if ( currentText() == mNoTimeString ) return false; return true; // always } QTime KOTimeEdit::getTime() const { - //kdDebug(5850) << "KOTimeEdit::getTime(), currentText() = " << currentText() << endl; - // TODO use KLocale::WithoutSeconds in HEAD - QTime time = KGlobal::locale()->readTime(currentText()); - // kdDebug(5850) << "KOTimeEdit::getTime(): " << time.toString() << endl; - return time; + return KGlobal::locale()->readTime(currentText()); } /* QSizePolicy KOTimeEdit::sizePolicy() const { // Set size policy to Fixed, because edit cannot contain more text than the // string representing the time. It doesn't make sense to provide more space. QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); return sizePolicy; } */ void KOTimeEdit::setTime(QTime newTime) { if ( mTime != newTime ) { - kdDebug(5850) << "KOTimeEdit::setTime(): " << newTime.toString() << endl; - mTime = newTime; updateText(); } } void KOTimeEdit::activ(int i) { // The last entry, 23:59, is a special case if( i == count() - 1 ) mTime = QTime( 23, 59, 0 ); else mTime = QTime(0,0,0).addSecs(i*15*60); emit timeChanged(mTime); } void KOTimeEdit::hilit(int ) { // we don't currently need to do anything here. } void KOTimeEdit::addTime(QTime qt, bool update) { // Calculate the new time. //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); // if ( update ) updateText(); emit timeChanged(mTime); } void KOTimeEdit::subTime(QTime qt, bool update) { int h, m; //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); // store the newly calculated time. // mTime.setHMS(h, m, 0); //if ( update ) updateText(); emit timeChanged(mTime); } // void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) // { // qDebug("mouseReleaseEvent ( QMouseEvent * ) "); // } // void KOTimeEdit::focusInEvent ( QFocusEvent * ) // { // qDebug("focusInEvent ( QFocusEvent * ) "); // } void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) { if ( !e->isAutoRepeat() ) { mFlagKeyPressed = false; } } void KOTimeEdit::setSelect( int from, int to ) { if ( KOPrefs::instance()->mHightlightDateTimeEdit) lineEdit()->setSelection( from , to ); } void KOTimeEdit::keyPressEvent(QKeyEvent *e) { qApp->processEvents(); bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ); int maxpos = hour12Format?7:5; if ( e->isAutoRepeat() && !mFlagKeyPressed ) { e->ignore(); // qDebug(" ignore %d",e->isAutoRepeat() ); return; } if (! e->isAutoRepeat() ) { mFlagKeyPressed = true; } // Tap -> Focus Next Widget if ( e->key() == Key_Tab ) { QComboBox::keyPressEvent(e); return; } // save Text from QLineEdit and CursorPosition QString text = lineEdit()->text(); int cpos = lineEdit()->cursorPosition(); // qDebug("cpos %d ", cpos); // Switch for arrows, backspace and escape switch(e->key()) { case Key_Escape: lineEdit()->deselect(); case Key_Tab: QComboBox::keyPressEvent(e); break; case Key_Up: if ( e->state () == Qt::ControlButton ) { addTime(QTime(0,15,0), false ); lineEdit()->setCursorPosition(3); setSelect( 3 , 2 ); } else if ( e->state () == Qt::ShiftButton ) { addTime(QTime(1,0,0), false ); lineEdit()->setCursorPosition(0); setSelect( 0 , 2 ); } else // switch time up, cursor location depend switch (cpos) { case 7: case 6: case 5: if(!hour12Format) { lineEdit()->setCursorPosition(cpos = 4); } else { addTime(QTime(12,0,0), false ); setSelect ( 5 , 2 ); break; } case 4: addTime(QTime(0,1,0), false ); setSelect ( cpos , 1 ); break; case 3: addTime(QTime(0,10,0), false ); setSelect ( cpos , 1 ); break; case 2: lineEdit()->setCursorPosition(--cpos); case 1: case 0: addTime(QTime(1,0,0), false ); setSelect ( 0, 2 ); break; } break; case Key_Down: if ( e->state () == Qt::ControlButton ) { subTime(QTime(0,15,0), false ); lineEdit()->setCursorPosition(3); setSelect( 3 , 2 ); } else if ( e->state () == Qt::ShiftButton ) { subTime(QTime(1,0,0), false ); lineEdit()->setCursorPosition(0); setSelect( 0 , 2 ); } else // switch time down, cursor location depend switch (cpos) { case 7: case 6: case 5: if(!hour12Format) { lineEdit()->setCursorPosition(cpos = 4); } else { subTime(QTime(12,0,0), false ); setSelect ( 5 , 2 ); break; } case 4: subTime(QTime(0,1,0), false ); setSelect ( cpos , 1 ); break; case 3: subTime(QTime(0,10,0), false ); setSelect ( cpos , 1 ); break; case 2: lineEdit()->setCursorPosition(--cpos); case 1: case 0: subTime(QTime(1,0,0), false ); setSelect ( 0 , 2 ); break; } break; // set cursor to correct place case Key_Left: if ( cpos == 3 ) --cpos; if ( cpos > 0) { lineEdit()->setCursorPosition(--cpos); setSelect ( cpos , 1 ); } else setSelect ( 0 , 1 ); break; // set cursor to correct place case Key_Right: if ( cpos == 1 ) ++cpos; if ( cpos < maxpos ) { lineEdit()->setCursorPosition(++cpos); setSelect ( cpos , 1 ); } break; // rest case Key_Prior: subTime(QTime(1,0,0)); break; case Key_Next: addTime(QTime(1,0,0)); break; case Key_Backspace: + qDebug("+++++++++++back "); if ( cpos > 0) { if ( cpos == 3 ) --cpos; if ( cpos > 5) cpos = 5; text.at( cpos-1 ) = '0'; lineEdit()->setText( text ); lineEdit()->setCursorPosition(--cpos); setSelect ( cpos , 1 ); changedText(); + qDebug("---------back "); } break; } // switch arrows // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { lineEdit()->deselect(); cpos = 0; lineEdit()->setCursorPosition(cpos); setSelect(cpos , 1); } if ( cpos == 2 ) { lineEdit()->setCursorPosition(++cpos); } // num keys when cursorPos preEnd if ( cpos < 5 ) { // switch another keys switch(e->key()) { case Key_Delete: text.at( cpos ) = '0'; lineEdit()->setText( text ); lineEdit()->setCursorPosition(cpos); setSelect ( cpos , 1 ); changedText(); break; case Key_9: case Key_8: case Key_7: case Key_6: if ( !(cpos == 1 || cpos == 4) ) return; if ( cpos == 1 && text.at( 0 ) > '1') text.at( 0 ) = '1'; case Key_5: case Key_4: case Key_3: if ( cpos < 1 ) return; if ( hour12Format && cpos == 1 ) return; case Key_2: if ( hour12Format && cpos == 0 ) return; if ( cpos == 0 && text.at( 1 ) > '3') text.at( 1 ) = '3'; case Key_1: case Key_0: if ( hour12Format ) { if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) return; if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) text.at( 1 ) = '1'; } text.at( cpos ) = QChar ( e->key() ); lineEdit()->setText( text ); if ( cpos == 1 ) ++cpos; if ( cpos < 5) lineEdit()->setCursorPosition(++cpos); setSelect( cpos , 1 ); changedText(); break; case Key_Home: lineEdit()->setCursorPosition(0); setSelect( cpos , 1 ); break; case Key_End: lineEdit()->setCursorPosition(5); lineEdit()->deselect(); break; default: // QComboBox::keyPressEvent(e); break; } // switch num keys } else if ( cpos == 5 ) {// if cpos < 5 if ( hour12Format ) { if ( e->key() == Key_A ) { text.at( 5 ) = 'a'; lineEdit()->setText( text ); lineEdit()->setCursorPosition(5); } else if ( e->key() == Key_P ) { text.at( 5 ) = 'p'; lineEdit()->setText( text ); lineEdit()->setCursorPosition(5); } } } } void KOTimeEdit::updateText() { -// kdDebug(5850) << "KOTimeEdit::updateText() " << endl + listBox()->blockSignals( true ); + blockSignals( true ); QString s = KGlobal::locale()->formatTime(mTime); // Set the text but without emitting signals, nor losing the cursor position QLineEdit *line = lineEdit(); line->blockSignals(true); int pos = line->cursorPosition(); - // qDebug(" settext *%s* ", s.latin1()); - line->setText(s); - // line->setCursorPosition(pos); -// line->blockSignals(false); - -// kdDebug(5850) << "KOTimeEdit::updateText(): " << s << endl; - - if (!mTime.minute() % 15) { setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); - } + line->setText(s); line->setCursorPosition(pos); line->blockSignals(false); + blockSignals( false ); + listBox()->blockSignals( false ); } -bool KOTimeEdit::inputIsValid() const -{ - int cursorPos = lineEdit()->cursorPosition(); - QString str = currentText(); - return validator()->validate( str, cursorPos ) == QValidator::Acceptable; -} - void KOTimeEdit::changedText() { - //kdDebug(5850) << "KOTimeEdit::changedText()" << endl; - if ( inputIsValid() ) - { int pos = lineEdit()->cursorPosition(); mTime = getTime(); - // updateText(); + blockSignals( true ); + QString text = lineEdit()->text(); + setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); + lineEdit()->setText(text); + blockSignals( false ); emit timeChanged(mTime); lineEdit()->setCursorPosition(pos); } -} diff --git a/korganizer/ktimeedit.h b/korganizer/ktimeedit.h index 7923070..b3d842d 100644 --- a/korganizer/ktimeedit.h +++ b/korganizer/ktimeedit.h @@ -1,97 +1,94 @@ /* This file is part of KOrganizer. Copyright (c) 1999 Preston Brown, Ian Dawes 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 _KTIMEEDIT_H #define _KTIMEEDIT_H #include <qevent.h> #include <qkeycode.h> #include <qstring.h> #include <qdatetime.h> #include <qcombobox.h> #include <kapplication.h> /** This is a class that provides an easy, user friendly way to edit times. up/down/ increase or decrease time, respectively. @short Provides a way to edit times in a user-friendly manner. @author Preston Brown, Ian Dawes */ class KOTimeEdit : public QComboBox { Q_OBJECT public: /** constructs a new time edit. */ KOTimeEdit(QWidget *parent=0, QTime qt=QTime(12,0), const char *name=0); virtual ~KOTimeEdit(); /** Returns, if a time is selected. Can not return false anymore.... */ bool hasTime() const; /** returns the time that is currently set in the timeLineEdit. */ QTime getTime() const; /** returns the prefered size policy of the KOTimeEdit */ //QSizePolicy sizePolicy() const; - /** return true if input is a valid time and false if not */ - bool inputIsValid() const; - signals: /** Emitted every time the time displayed changes. "newt" is the new time. */ void timeChanged(QTime newt); public slots: /** used to set the time which is displayed to a specific value. */ void setTime(QTime qt); protected slots: void activ(int); void hilit(int); void changedText(); protected: void keyPressEvent(QKeyEvent *qke); void keyReleaseEvent(QKeyEvent *qke); void setSelect ( int, int ); bool mFlagKeyPressed; void addTime(QTime qt, bool update = true ); void subTime(QTime qt, bool update = true ); // Update the lineedit text from mTime void updateText(); // void mouseReleaseEvent ( QMouseEvent * ) ; //void focusInEvent ( QFocusEvent * ) ; private: QTime mTime; // the widget's displayed time. //QString mNoTimeString; }; #endif diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index d7e384c..7f31ab1 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp @@ -1,1085 +1,1085 @@ #include <qregexp.h> #include <qapplication.h> #include "kdebug.h" #include "kcalendarsystemgregorian.h" #include "klocale.h" #include <qstringlist.h> //#define COLLECT_TRANSLATION QDict<QString> *mLocaleDict = 0; void setLocaleDict( QDict<QString> * dict ) { mLocaleDict = dict; } #ifdef COLLECT_TRANSLATION QStringList missingTrans; QStringList existingTrans1; QStringList existingTrans2; void addMissing(const char *text) { QString mis ( text ); if ( !missingTrans.contains( mis ) ) missingTrans.append(mis); } void addExist(const char *text,QString trans ) { //return; QString mis ( text ); if ( !existingTrans1.contains( mis ) ) { existingTrans1.append(mis); existingTrans2.append(trans); } } #include <qfile.h> #include <qtextstream.h> #include <qtextcodec.h> #endif void dumpMissing() { #ifdef COLLECT_TRANSLATION QString fileName = "/tmp/usernewtrans.txt"; QFile file( fileName ); if (!file.open( IO_WriteOnly ) ) { return ; } QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); int i; for ( i = 0; i< missingTrans.count(); ++i ) { QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; } file.close(); { QString fileName = "/tmp/usertrans.txt"; QFile file( fileName ); if (!file.open( IO_WriteOnly ) ) { return ; } QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); int i; for ( i = 0; i< existingTrans1.count(); ++i ) { QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; } file.close(); } #endif } QString i18n(const char *text) { if ( ! mLocaleDict ) { #ifdef COLLECT_TRANSLATION addMissing( text ); #endif return QString( text ); } else { QString* ret = mLocaleDict->find(QString(text)) ; if ( ret == 0 ) { #ifdef COLLECT_TRANSLATION addMissing( text ); #endif return QString( text ); } else { if ( (*ret).isEmpty() ) { #ifdef COLLECT_TRANSLATION addMissing( text ); #endif return QString( text ); } else { #ifdef COLLECT_TRANSLATION addExist( text, *ret ); #endif return (*ret); } } } } QString i18n(const char *,const char *text) { return i18n( text ); } QString i18n(const char *text1, const char *textn, int num) { if ( num == 1 ) return i18n( text1 ); else { QString text = i18n( textn ); int pos = text.find( "%n" ); if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); return text; } } inline void put_it_in( QChar *buffer, uint& index, const QString &s ) { for ( uint l = 0; l < s.length(); l++ ) buffer[index++] = s.at( l ); } inline void put_it_in( QChar *buffer, uint& index, int number ) { buffer[index++] = number / 10 + '0'; buffer[index++] = number % 10 + '0'; } static int readInt(const QString &str, uint &pos) { if (!str.at(pos).isDigit()) return -1; int result = 0; for (; str.length() > pos && str.at(pos).isDigit(); pos++) { result *= 10; result += str.at(pos).digitValue(); } return result; } KLocale::KLocale() : mCalendarSystem( 0 ) { m_decimalSymbol = "."; m_positiveSign = ""; m_negativeSign = "-"; m_thousandsSeparator = ","; mWeekStartsMonday = true; mHourF24Format = true; mIntDateFormat = Default; mIntTimeFormat = Default; mLanguage = 0; mDateFormat = "%a %Y %b %d"; mDateFormatShort = "%Y-%m-%d"; mTimeZoneList << ("-11:00 US/Samoa") << ("-10:00 US/Hawaii") << ("-09:00 US/Alaska") << ("-08:00 US/Pacific") << ("-07:00 US/Mountain") << ("-06:00 US/Central") << ("-05:00 US/Eastern") << ("-04:00 Brazil/West") << ("-03:00 Brazil/East") << ("-02:00 Brazil/DeNoronha") << ("-01:00 Atlantic/Azores") << (" 00:00 Europe/London(UTC)") << ("+01:00 Europe/Oslo(CET)") << ("+02:00 Europe/Helsinki") << ("+03:00 Europe/Moscow") << ("+04:00 Indian/Mauritius") << ("+05:00 Indian/Maldives") << ("+06:00 Indian/Chagos") << ("+07:00 Asia/Bangkok") << ("+08:00 Asia/Hongkong") << ("+09:00 Asia/Tokyo") << ("+10:00 Asia/Vladivostok") << ("+11:00 Asia/Magadan") << ("+12:00 Asia/Kamchatka") // << (" xx:xx User defined offset") << i18n (" Local Time"); mSouthDaylight = false; mTimeZoneOffset = 0; daylightEnabled = false; } void KLocale::setDateFormat( QString s ) { mDateFormat = s; } void KLocale::setDateFormatShort( QString s ) { mDateFormatShort = s; } void KLocale::setHore24Format ( bool b ) { mHourF24Format = b; } void KLocale::setWeekStartMonday( bool b ) { mWeekStartsMonday = b; } KLocale::IntDateFormat KLocale::getIntDateFormat( ) { return mIntDateFormat; } void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) { mIntDateFormat = i; } KLocale::IntDateFormat KLocale::getIntTimeFormat( ) { return mIntTimeFormat; } void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) { mIntTimeFormat = i; } void KLocale::setLanguage( int i ) { mLanguage = i; } int KLocale::language( ) { return mLanguage; } QString KLocale::translate( const char *index ) const { return i18n( index ); } QString KLocale::translate( const char *, const char *fallback) const { return i18n( fallback ); } QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const { const QString rst = timeFormat(intIntDateFormat); // only "pm/am" here can grow, the rest shrinks, but // I'm rather safe than sorry QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; uint index = 0; bool escape = false; int number = 0; for ( uint format_index = 0; format_index < rst.length(); format_index++ ) { if ( !escape ) { if ( rst.at( format_index ).unicode() == '%' ) escape = true; else buffer[index++] = rst.at( format_index ); } else { switch ( rst.at( format_index ).unicode() ) { case '%': buffer[index++] = '%'; break; case 'H': put_it_in( buffer, index, pTime.hour() ); break; case 'I': put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); break; case 'M': put_it_in( buffer, index, pTime.minute() ); break; case 'S': if (includeSecs) put_it_in( buffer, index, pTime.second() ); else { // we remove the seperator sign before the seconds and // assume that works everywhere --index; break; } break; case 'k': number = pTime.hour(); case 'l': // to share the code if ( rst.at( format_index ).unicode() == 'l' ) number = (pTime.hour() + 11) % 12 + 1; if ( number / 10 ) buffer[index++] = number / 10 + '0'; buffer[index++] = number % 10 + '0'; break; case 'p': { QString s; if ( pTime.hour() >= 12 ) put_it_in( buffer, index, i18n("pm") ); else put_it_in( buffer, index, i18n("am") ); break; } default: buffer[index++] = rst.at( format_index ); break; } escape = false; } } QString ret( buffer, index ); delete [] buffer; return ret; } QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const { const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); // I'm rather safe than sorry QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; unsigned int index = 0; bool escape = false; int number = 0; for ( uint format_index = 0; format_index < rst.length(); ++format_index ) { if ( !escape ) { if ( rst.at( format_index ).unicode() == '%' ) escape = true; else buffer[index++] = rst.at( format_index ); } else { switch ( rst.at( format_index ).unicode() ) { case '%': buffer[index++] = '%'; break; case 'Y': put_it_in( buffer, index, pDate.year() / 100 ); case 'y': put_it_in( buffer, index, pDate.year() % 100 ); break; case 'n': number = pDate.month(); case 'e': // to share the code if ( rst.at( format_index ).unicode() == 'e' ) number = pDate.day(); if ( number / 10 ) buffer[index++] = number / 10 + '0'; buffer[index++] = number % 10 + '0'; break; case 'm': put_it_in( buffer, index, pDate.month() ); break; case 'b': put_it_in( buffer, index, monthName(pDate.month(), true) ); break; case 'B': put_it_in( buffer, index, monthName(pDate.month(), false) ); break; case 'd': put_it_in( buffer, index, pDate.day() ); break; case 'a': put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); break; case 'A': put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); break; default: buffer[index++] = rst.at( format_index ); break; } escape = false; } } QString ret( buffer, index ); delete [] buffer; return ret; } QString KLocale::formatDateTime(const QDateTime &pDateTime, bool shortFormat, bool includeSeconds, IntDateFormat intIntDateFormat) const { QString format("%1 %2"); if ( intIntDateFormat == Default ) format = "%1 %2"; else if ( intIntDateFormat == Format1 ) format = "%1 %2"; else if ( intIntDateFormat == ISODate ) format = "%1T%2"; QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); return res; } QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const { return formatDateTime(pDateTime, true, true, intIntDateFormat); } QDate KLocale::readDate(const QString &intstr, bool* ok) const { QDate date; date = readDate(intstr, true, ok); if (date.isValid()) return date; return readDate(intstr, false, ok); } QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const { QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); return readDate( intstr, fmt, ok ); } QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const { //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; QString str = intstr.simplifyWhiteSpace().lower(); int day = -1, month = -1; // allow the year to be omitted if not in the format int year = QDate::currentDate().year(); uint strpos = 0; uint fmtpos = 0; while (fmt.length() > fmtpos || str.length() > strpos) { if ( !(fmt.length() > fmtpos && str.length() > strpos) ) goto error; QChar c = fmt.at(fmtpos++); if (c != '%') { if (c.isSpace()) strpos++; else if (c != str.at(strpos++)) goto error; continue; } // remove space at the begining if (str.length() > strpos && str.at(strpos).isSpace()) strpos++; c = fmt.at(fmtpos++); switch (c) { case 'a': case 'A': // this will just be ignored { // Cristian Tache: porting to Win: Block added because of "j" redefinition for (int j = 1; j < 8; j++) { QString s = weekDayName(j, c == 'a').lower(); int len = s.length(); if (str.mid(strpos, len) == s) strpos += len; } break; } case 'b': case 'B': { // Cristian Tache: porting to Win: Block added because of "j" redefinition for (int j = 1; j < 13; j++) { QString s = monthName(j, c == 'b').lower(); int len = s.length(); if (str.mid(strpos, len) == s) { month = j; strpos += len; } } break; } case 'd': case 'e': day = readInt(str, strpos); if (day < 1 || day > 31) goto error; break; case 'n': case 'm': month = readInt(str, strpos); if (month < 1 || month > 12) goto error; break; case 'Y': case 'y': year = readInt(str, strpos); if (year < 0) goto error; // Qt treats a year in the range 0-100 as 1900-1999. // It is nicer for the user if we treat 0-68 as 2000-2068 if (year < 69) year += 2000; else if (c == 'y') year += 1900; break; } } //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; if ( year != -1 && month != -1 && day != -1 ) { if (ok) *ok = true; return QDate(year, month, day); } error: if (ok) *ok = false; return QDate(); // invalid date } QTime KLocale::readTime(const QString &intstr, bool *ok) const { QTime _time; - _time = readTime(intstr, true, ok); + _time = readTime(intstr, false, ok); if (_time.isValid()) return _time; - return readTime(intstr, false, ok); + return readTime(intstr, true, ok); } QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const { QString str = intstr.simplifyWhiteSpace().lower(); QString Format = timeFormat().simplifyWhiteSpace(); if (!seconds) Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds bool g_12h = false; bool pm = false; uint strpos = 0; uint Formatpos = 0; while (Format.length() > Formatpos || str.length() > strpos) { if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; QChar c = Format.at(Formatpos++); if (c != '%') { if (c.isSpace()) strpos++; else if (c != str.at(strpos++)) goto error; continue; } // remove space at the begining if (str.length() > strpos && str.at(strpos).isSpace()) strpos++; c = Format.at(Formatpos++); switch (c) { case 'p': { QString s; s = i18n("pm").lower(); int len = s.length(); if (str.mid(strpos, len) == s) { pm = true; strpos += len; } else { s = i18n("am").lower(); len = s.length(); if (str.mid(strpos, len) == s) { pm = false; strpos += len; } else goto error; } } break; case 'k': case 'H': g_12h = false; hour = readInt(str, strpos); if (hour < 0 || hour > 23) goto error; break; case 'l': case 'I': g_12h = true; hour = readInt(str, strpos); if (hour < 1 || hour > 12) goto error; break; case 'M': minute = readInt(str, strpos); if (minute < 0 || minute > 59) goto error; break; case 'S': second = readInt(str, strpos); if (second < 0 || second > 59) goto error; break; } } if (g_12h) { hour %= 12; if (pm) hour += 12; } if (ok) *ok = true; return QTime(hour, minute, second); error: if (ok) *ok = false; return QTime(-1, -1, -1); // return invalid date if it didn't work // This will be removed in the near future, since it gives a warning on stderr. // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. } QDateTime KLocale::readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const { bool ok1, ok2; // AT the moment we can not read any other format then ISODate if ( intIntDateFormat != ISODate ) { qDebug("KLocale::readDateTime, only ISODate is supported."); return QDateTime(); } int pos = intstr.find("T"); QString date = intstr.left(pos); QString time = intstr.mid(pos+1); QString dformat = dateFormat(intIntDateFormat); QString tformat = timeFormat(intIntDateFormat); QDate m_date = readDate(date, dformat, &ok1); QTime m_time = readTime(time, tformat, &ok2); QDateTime m_dt; if (ok) { if ((ok1 == false) || (ok2 == false)) *ok = false; else *ok = true; } //only set values if both operations returned true. if ((ok1 == true) && (ok2 == true)) { m_dt.setDate(m_date); m_dt.setTime(m_time); } //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); return m_dt; } QDate KLocale::readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const { bool ok1; QString dformat = dateFormat(intIntDateFormat); QDate m_date = readDate(intstr, dformat, &ok1); if (ok) *ok = ok1; //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); return m_date; } bool KLocale::use12Clock() const { return !mHourF24Format ;; } bool KLocale::weekStartsMonday() const { return mWeekStartsMonday; } int KLocale::weekStartDay() const { if ( mWeekStartsMonday ) return 1; return 7; } QString KLocale::weekDayName(int i,bool shortName) const { if ( shortName ) switch ( i ) { case 1: return i18n("Monday", "Mon"); case 2: return i18n("Tuesday", "Tue"); case 3: return i18n("Wednesday", "Wed"); case 4: return i18n("Thursday", "Thu"); case 5: return i18n("Friday", "Fri"); case 6: return i18n("Saturday", "Sat"); case 7: return i18n("Sunday", "Sun"); } else switch ( i ) { case 1: return i18n("Monday"); case 2: return i18n("Tuesday"); case 3: return i18n("Wednesday"); case 4: return i18n("Thursday"); case 5: return i18n("Friday"); case 6: return i18n("Saturday"); case 7: return i18n("Sunday"); } return QString::null; } QString KLocale::monthName(int i,bool shortName) const { if ( shortName ) switch ( i ) { case 1: return i18n("January", "Jan"); case 2: return i18n("February", "Feb"); case 3: return i18n("March", "Mar"); case 4: return i18n("April", "Apr"); case 5: return i18n("May short", "May"); case 6: return i18n("June", "Jun"); case 7: return i18n("July", "Jul"); case 8: return i18n("August", "Aug"); case 9: return i18n("September", "Sep"); case 10: return i18n("October", "Oct"); case 11: return i18n("November", "Nov"); case 12: return i18n("December", "Dec"); } else switch (i) { case 1: return i18n("January"); case 2: return i18n("February"); case 3: return i18n("March"); case 4: return i18n("April"); case 5: return i18n("May long", "May"); case 6: return i18n("June"); case 7: return i18n("July"); case 8: return i18n("August"); case 9: return i18n("September"); case 10: return i18n("October"); case 11: return i18n("November"); case 12: return i18n("December"); } return QString::null; } QString KLocale::country() const { return QString::null; } QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const { const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; if ( dformat == ISODate ) return "%Y-%m-%d"; if ( QApplication::desktop()->width() < 480 ) { if ( dformat == Default ) return "%a %d %b %Y"; else if ( dformat == Format1 ) return "%a %b %d %Y"; } else { if ( dformat == Default ) return "%A %d %B %Y"; else if ( dformat == Format1 ) return "%A %B %d %Y"; } return mDateFormat ; } QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const { const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; if ( dformat == Default ) return "%d.%m.%Y"; else if ( dformat == Format1 ) return "%m.%d.%Y"; else if ( dformat == ISODate ) // = Qt::ISODate return "%Y-%m-%d"; return mDateFormatShort ; } QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const { const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; if ( tformat == Default ) if ( mHourF24Format) return "%H:%M:%S"; else return "%I:%M:%S%p"; else if ( tformat == Format1 ) if ( mHourF24Format) return "%H:%M:%S"; else return "%I:%M:%S%p"; else if ( tformat == ISODate ) // = Qt::ISODate if ( mHourF24Format) return "%H:%M:%S"; else return "%I:%M:%S%p"; // to satisfy the compiler return "%H:%M:%S"; } void KLocale::insertCatalogue ( const QString & ) { } KCalendarSystem *KLocale::calendar() { if ( !mCalendarSystem ) { mCalendarSystem = new KCalendarSystemGregorian; } return mCalendarSystem; } int KLocale::timezoneOffset( QString timeZone ) { int ret = 1001; int index = mTimeZoneList.findIndex( timeZone ); if ( index < 24 ) ret = ( index-11 ) * 60 ; return ret; } QStringList KLocale::timeZoneList() const { return mTimeZoneList; } void KLocale::setTimezone( const QString &timeZone, bool oddTZ ) { mTimeZoneOffset = timezoneOffset( timeZone ); if ( oddTZ ) mTimeZoneOffset += 30; } void KLocale::setDaylightSaving( bool b, int start , int end ) { daylightEnabled = b; daylightStart = start; daylightEnd = end; mSouthDaylight = (end < start); // qDebug("klocale daylight %d %d %d ", b, start , end ); } int KLocale::localTimeOffset( const QDateTime &dt ) { bool addDaylight = false; if ( daylightEnabled ) { int d_end, d_start; int dayofyear = dt.date().dayOfYear(); int year = dt.date().year(); int add = 0; if ( QDate::leapYear(year) ) add = 1; QDate date ( year,1,1 ); if ( daylightEnd > 59 ) d_end = daylightEnd +add; else d_end = daylightEnd; if ( daylightStart > 59 ) d_start = daylightStart +add; else d_start = daylightStart; QDate s_date = date.addDays( d_start -1 ); QDate e_date = date.addDays( d_end -1 ); int dof = s_date.dayOfWeek(); if ( dof < 7 ) s_date = s_date.addDays( -dof ); dof = e_date.dayOfWeek(); if ( dof < 7 ) e_date = e_date.addDays( -dof ); QTime startTime ( 3,0,0 ); QDateTime startDt( s_date, startTime ); QDateTime endDt( e_date, startTime ); //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); if ( mSouthDaylight ) { if ( ! ( endDt < dt && dt < startDt) ) addDaylight = true; } else { if ( startDt < dt && dt < endDt ) addDaylight = true; } } int addMin = 0; if ( addDaylight ) addMin = 60; return mTimeZoneOffset + addMin; } // ****************************************************************** // added LR QString KLocale::formatNumber(double num, int precision) const { bool neg = num < 0; if (precision == -1) precision = 2; QString res = QString::number(neg?-num:num, 'f', precision); int pos = res.find('.'); if (pos == -1) pos = res.length(); else res.replace(pos, 1, decimalSymbol()); while (0 < (pos -= 3)) res.insert(pos, thousandsSeparator()); // thousand sep // How can we know where we should put the sign? res.prepend(neg?negativeSign():positiveSign()); return res; } QString KLocale::formatNumber(const QString &numStr) const { return formatNumber(numStr.toDouble()); } double KLocale::readNumber(const QString &_str, bool * ok) const { QString str = _str.stripWhiteSpace(); bool neg = str.find(negativeSign()) == 0; if (neg) str.remove( 0, negativeSign().length() ); /* will hold the scientific notation portion of the number. Example, with 2.34E+23, exponentialPart == "E+23" */ QString exponentialPart; int EPos; EPos = str.find('E', 0, false); if (EPos != -1) { exponentialPart = str.mid(EPos); str = str.left(EPos); } int pos = str.find(decimalSymbol()); QString major; QString minor; if ( pos == -1 ) major = str; else { major = str.left(pos); minor = str.mid(pos + decimalSymbol().length()); } // Remove thousand separators int thlen = thousandsSeparator().length(); int lastpos = 0; while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) { // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N int fromEnd = major.length() - pos; if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error || pos - lastpos > 3 // More than 3 digits between two separators -> error || pos == 0 // Can't start with a separator || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators { if (ok) *ok = false; return 0.0; } lastpos = pos; major.remove( pos, thlen ); } if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator { if (ok) *ok = false; return 0.0; } QString tot; if (neg) tot = '-'; tot += major + '.' + minor + exponentialPart; return tot.toDouble(ok); } QString KLocale::decimalSymbol() const { return m_decimalSymbol; } QString KLocale::thousandsSeparator() const { return m_thousandsSeparator; } QString KLocale::positiveSign() const { return m_positiveSign; } QString KLocale::negativeSign() const { return m_negativeSign; } |