-rw-r--r-- | bin/kdepim/SyncHowto.txt | 2 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 6 | ||||
-rw-r--r-- | microkde/kdeui/klistview.cpp | 12 | ||||
-rw-r--r-- | version | 2 |
4 files changed, 15 insertions, 7 deletions
diff --git a/bin/kdepim/SyncHowto.txt b/bin/kdepim/SyncHowto.txt index 64f6f14..b0473a1 100644 --- a/bin/kdepim/SyncHowto.txt +++ b/bin/kdepim/SyncHowto.txt @@ -1,580 +1,580 @@ WARNING: YOU MAY GET UNEXPECTED (I.E. WRONG) SYNCHRONIZATION RESULTS, IF YOU CHANGE AN EVENT ON THE FIRST DEVICE AND SYNC IMMEDIATELY FROM THE OTHER DEVICE WITH THIS DEVICE, IF THE CLOCKS OF THE TWO DEVICES HAVE TOO MUCH DIFFERENCE. In other words: Please make sure, that the clocks of the devices you want to sync have only a difference of some seconds! CONTENT: 0) How syncing works 1) Qick overview of settings 2) Sync settings in sync dialog 3) Syncing background 4) Sync preferences 5) How a filter works 6) Details about sync profile kinds ************************************************************************* 0) How syncing works ************************************************************************* Note: The recommended and easiest way to syncronize two devices where KO/Pi, KA/Pi or PWM/Pi is installed, is the profile kind "Pi-Sync". Details about that in 6) b). In KDE-Pim/Pi you can synchronize ( sync ) your calendar/addressbook/ passwordfile with another calendar/addressbook/passwordfile, by syncing your (local) calendar/addressbook/passwordfile with a (remote) file. This remote file may on your local filesystem or on another (remote) device. If you want to sync with another remote device, you have to create a sync profile. You have two choices for choosing the profil kind: I) You can choose profile kind "Remote file" and specify a command line download/upload command ( like scp, ftp, ...) to a) download the remote file to your local machine to a temp file b) sync with this temp file c) upload the synced file to the remote device II) If you want to sync with a device, where KO/Pi( or KA/Pi, PWM/Pi) is installed, you can easily get the remote file via network with the build in file transfer feature: Choose profile kind "Pi-Sync" and a) Start KO/Pi,KA/Pi or PWM/Pi on remote device and enable "Pi-Sync" on remote device with password and port. b) Specify password, port and IP address in your profile. You can sync with your mobile phone as well. Everything is explained in more details below. NOTE: If you do not use profile kind "Pi-Sync", it is recommended to close a running KO/Pi (KA/Pi, PWM/Pi) on the remote device. (Note: KO/Pi(KA/Pi, PWM/Pi) running on Zaurus with FastLoad enabled will never be closed!) After syncing with a running KO/Pi on the remote device, a "save" on the remote device will tell you that it needs to merge (sync). After merging (just a syncing with the changed file) you will get the new data showing in remote KO/Pi. ************************************************************************* 1) Qick overview of settings ************************************************************************* a) Open sync settings dialog (Menu Synchronize - Configure...) b) Give your device a unique name. (unique in the set of all devices you want to sync with). If you have already configured another devive and created there a sync profile to sync with this device, give your device the same name as this sync profile! The same name is important, because it makes it possible to sync first A->B (A local device, that performs the sync, B remote device) and then B->A. Such that the B->A sync knows about the already performed A->B sync. That means: It is unimportant if you sync A->B or B->A, the devices A and B will be synced properly. c) Create a new sync profile and give it a unique name. (unique in the set of all sync profiles on this device). If you want to sync with a device, where KO/Pi is already installed and which has a given unique device name, use this device name as your profile name ( refer to b) ). -d) Coose the profile kind of your syncing method: +d) Choose the profile kind of your syncing method: (i) Local file or (ii) Pi-Sync or (iii) Remote file or (iiii) Mobile Phone. Detailed explanation in 6) e) Choose the other profile options. Detailed explanation in 2) f) Close sync dialog with OK. g) Sync. NOTE: AFTER SYNCING THERE ARE "SYNC EVENTS" CREATED (OR UPDATED, IF IT ALREADY EXITS) FOR EACH SYNC PROFILE. YOU MAY NOT DELETE OR CHANGE THESE EVENTS. ************************************************************************* 2) Sync settings in sync dialog ************************************************************************* a) Local device name: -> 1) b) b) Profile: -> 1) c) c) Multiple Sync options: Include in multiple sync: In the Synchronize menu, there is a multiple sync menu entry. If you choose this menu entry, all user defined profiles with this 'Include in multiple sync' option enabled will be synced one after another. And this twice. This will take some time. After that sync, on all devices should be the same data. d)- j) Sync algo options: d) Ask for preferences before sync: Check this to be asked for "Sync preferences" settings before each sync. If the profile kind is "Pi-Sync" you will be asked to confirm the "Pi-Sync" specific settings (Password,IP address, port number) as well. That makes it possible to use that profile for a device that is connected via DHCP to the network and gets different IP addresses when connecting to the network. e) Sync preferences: Choose here your sync preferences. Details -> 4) f) Show summary after sync: Check this to get a small summary dialog after sync about number of added/changed/deleted events on local/remote. g) Apply filter when adding data to local: What is a filter? You can read this in -> 5) With this option you can specify a filter for events/contacts, which should be added to the local database, because they are in the remote database and not in the local database. (Database = calendar file or addressbook file). Note that the filter is NOT applied to the remote database before syncing. It is only applied to a particular item which should be added to the local database. Well, but what is the difference? The differnce is: If the remote database AND the local database contain an already synced item, which does not match the filter, then this item is synced. If the remote database contains an item which does not match the filter and the local database does not contain this item, then this item is not added to the local database, but it is still in the remote database after syncing. g) Write back synced data: Uncheck this to update the local calendar only. I.e. your local calendar is synced with the remote calendar but nothing on the remote calendar is changed. If you uncheck "Write back synced data", the settings under h) and i) are ignored, of course. h) - j) Write back options: h) Write back (on remote) existing entries only: Check this to update the remote data only. I.e. no data from yor local calendar/addressbook is added to the remote device. You may use this option to sync against some kind of "public calendar/addressbook" without adding anything of your personal data. But in this case, you cannot add an item to the remoet device. i) Apply filter when adding data to remote: What is a filter? You can read this in -> 5) With this option you can specify a filter for events/contacts, which should be added to the remote database, because they are in the local database and not in the remote database. (Database = calendar file or addressbook file). Note that the filter is NOT applied to the local database before syncing. It is only applied to a particular item of the local database which should be added to the remote database. Well, but what is the difference? The differnce is: If the local database AND the remote database contain an already synced item, which does not match the filter, then this item is synced. If the local database contains an item which does not match the filter and the remote database does not contain this item, then this item is not added to the remote database, but it is still in the local database after syncing. Example: You have specified a calendar filter "only public events". You specify this filter as the outgoing filter for syncing. If there is an event in the local database which is not "public", but "private", this event is not added to the remote database. If there is an event in the local database and in the remote database which is "private" (maybe added by someone else) then this event is synced and it is in the local database and in the remote database after syncing. That means in particular you cannot remove an event from the remote database but setting it to "private". If you want to remove the event you can clone it, set it to private and delete the original event. Then the original event is deleted in the remote database after sync and the cloned event is not added to the remote database, because it is private. j) Write back (calendar) entries for time period only: Check this to write back only calendar entries for a given time period. (Useful when syncing with mobile phones.) You can specify the date range in weeks for the weeks in the past to the weeks in the future. k) Profile kind: Details -> 6) ************************************************************************* 3) Syncing background ************************************************************************* The same mentioned for calendars is valid for addressbooks as well. Synchronizing calendars ( i.e. files ) means, to merge two calendars in a useful way. If the two calendars are completely different, there is no problem, the resulting calendar contains all data from the local and from the remote calendar. Problems will occur, if you have edited items from the local calendar on the remote machine. Then it could be, that items are in conflict. Two items are "in conflict", if they have the same unique ID (which get an item at time of creation and owns it until it is deleted ) and they both are modified after the last synchronization. At first sync of two calendars there is no item deleted. If the calendars are synced before and there is an item, which is not edited after the last sync and is only available in one calendar, then this item is deleted in this calendar. But when was the last synchronization between two calendars? To know that, KO/Pi creates at first syncing of two files an unique event "<profile name> - sync Event" on the remote and the local calendar. After syncing, the start time of this event is set to the time of syncing. The event is read only and the user may not change it. If two such files are synced, that both have an event "<profile name> - sync Event" and the events have the same start time, then deleted items on the one calendar are deleted on the other as well. ************************************************************************* 4) Sync preferences ************************************************************************* Two items are "in conflict", if they have the same unique ID and they both are modified after the last synchronization. (Details -> 3) ). If an item is not modified after the last sync and it is not found in the other calendar, it is deleted. On the first sync, there is no item deleted. SYNC PREFERENCES: -Take local entry on conflict: Takes the local entry on conflict. If it is the first sync, "Ask for every entry" is chosen automatically, if this is selected. -Take remote entry on conflict: Takes the remote entry on conflict. If it is the first sync, "Ask for every entry" is chosen automatically, if this is selected. -Take newest entry on conflict: This takes the newest entry on conflict. May be the most useful syncing mode. -Ask for every entry on conflict: Pops up an event viewer dialog and shows the two conflicting entries there. The user can chose, which entry he would like to take. The button for the newest entry is automatically set as default button. The color for the newest entry is green. -Force: Take local entry always: Even if the calendars are already synced there is no item deleted on local. -Force: Take remote entry always: Analogous to "Force: Take local entry always" ************************************************************************* 5) How a filter works ************************************************************************* A filter is a rule to decide if a particular item (calendar iten item or contact item) belongs to a set of items. For example, you can specify a set as: Only items, that belongs to that category. Or: Only items, that does not belong to that category. Or: Only items, that are public. If you specify a filter in a syncing profile, you can set the rules of adding items to the local or remote database. Example: You have a public calendar in your company, which contains all company relevant data. You have different projects in the company and for project specific events is always set the project name as a category: E.g. all events of the project PRO_ABC do have set the categorie PRO_ABC. But you are not interested in events of PRO_ABC, because you are not working on it. Then you can specify a filter: All, but not with categoroy PRO_ABC. When you specify this filter as an incoming filter for your sync profile, all events of the company are synced and added to your local calendar, but not the evenst of the project PRO_ABC. You do not want that your private data can be seen in the public calendar of your company. Well, set the property to "private" for all your private data and specify an outgoing filter: Only " public" and "confidential". Then you can sync your personal calendar with the calendar of the company, but your private data is not added to the public calendar. ************************************************************************* 6) Details about sync profile kinds ************************************************************************* a) Local file Please specify a local file you want to sync with. Note: If you are syncing a file, which is used by KA/Pi, please check the "Addressbook file (*.vcf) is used by KA/Pi". If you are syncing with a file from KAddressbook or another program, please uncheck "Addressbook file (*.vcf) is used by KA/Pi". To set this properly is important! KA/Pi uses a "last modified" property, which is not supported by KAddressbook. b) Pi-Sync (direct Kx/Pi to Kx/Pi sync) We mention here only KO/Pi, but the same is valid for KA/Pi. If you want to sync with a device, where KO/Pi is installed, you can easily get the remote file via network with the build in file transfer feature "Pi-Sync": You have first to enable file transfer on the remote device: - Start KO/Pi on the remote device. - Choose Menu Synchronize-Enable Pi-Sync. - Choose a port number, where KO/Pi should listen for file sending requests. Valid port numbers are numbers between 1 and 65565. Do not specify port numbers, that are used by other applications. A port number between 9000 and 9999 is most likely not used by another application. The default port number is 9197 for KO/Pi. If you specify a port number, which is already in use, you will get an error message when closing this dialog. - Choose a password. - Click OK. Now KO/Pi will send the calendar data via the network, if some other device is sending a "please send calendar" request on the given port using the given password. If you want to be sure, nobody can access your calendar data, simply disable the file transfer feature on the remote device after the syncing is done by choosing: Menu Synchronize-Disable Pi-Sync. Note: If you want to sync with a remote device that gets different IPaddresses each time connected to the network (this may be the case, if you use DHCP for connection of the remote device to the network) simply enable "Ask for preferences before sync". Then you will be asked to confirm the "Pi-Sync" specific settings (Password,IP address, port number) and you can easily change the IP address before each sync. On your local device, create a new profile and choose profile kind "Pi-Sync". Fill in the needed values: - Password for remote access: The password you specified on the remote device. - Remote IP address: The IP address of the remote device. - Remote port number: The port number you specified on the remote device. Now you can syncronize your local device easily with your remote device. This works well for all platforms KO/Pi is running on, e.g. syncing a KO/Pi on Zaurus with KO/Pi on Windows is now very easy. c) Remote file Note: If you are syncing a file, which is used by KA/Pi, please check the "Addressbook file (*.vcf) is used by KA/Pi". If you are syncing with a file from KAddressbook or another program, please uncheck "Addressbook file (*.vcf) is used by KA/Pi". To set this properly is important! KA/Pi uses a "last modified" property, which is not supported by KAddressbook. Syncing with the profile kind "Remote file" is performed in three steps: i) download the remote file to your local machine to a temp file ii) sync with this temp file iii) upload the synced file to the remote device The down-/uploading if i) and iii) is done via a command line command. Please specify the download/upload command ( like scp, ftp, ...) and the file name of the temp file in the corresponding fields. d) Mobile device (cell phone) Note: On the Zaurus you have to install the phoneaccess_xxx_arm.ipk package to be able to access mobile phones. We mention here only KO/Pi, but the same is valid for KA/Pi. Note: It is only possible to sync a mobile phone with one particular device running KO/Pi. If you want to be able to write data of more than one device to the mobile phone (e.g. from your Zaurus and from your Windows Laptop) do not sync with the mobile phone at all, but use the "Export to phone" functionality from the different devices. Using "Export to phone" makes it not possible to get back data from the phone, if it was changed there, of course. If you sync with the phone, do not use "Export to phone" from any device. (And do not sync, as mentioned above, from any other device with that phone). It would delete the needed information for syncing with that phone! We are using Gammu (Version: 0.98.9) ( http://freshmeat.net/projects/gammu/ ) for accessing the phones. Note: You cannot use the original Gammu for syncing KDE-Pim/Pi, because we have modified the original version to make it useable for syncing! Gammu allows access to many phones in many ways (Irda, Bluetooth, serial,...). The recommended phone access using Gammu with KDE-Pim/Pi is Irda (infrared). Bluetooth access is disabled on the Zaurus, but may work on Windows. Please look at the Gammu homepage and documentation about more details configuring Gammu how to access your phone. If you have problems accessing your phone, start KO/Pi from the konsole and you will get a more detailed output what went wrong. About Gammu from the Gammu homepage: Gammu (formerly known as MyGnokii2) is a cellular manager for various mobile phones/modems. It supports the Nokia 2100, 3100, 32xx, 33xx, 3410, 35xx, 51xx, 5210, 5510, 61xx, 62xx, 63xx, 6510, 6610, 6800, 71xx, 7210, 7250, 7250i, 82xx, 83xx, 8910, 9110, 9210 and compatible and AT devices (Siemens, Alcatel, Falcom, WaveCom, IPAQ, Samsung, SE, and others) over cables/infrared/BlueTooth. Here is an example what to specify to access a Nokia 6310i via infrared: On Linux (Zaurus): I/O device: /dev/ircomm Connection: irda Model: <leave empty> On Windows: I/O device: <ignored - i.e. leave empty> Connection: irda Model: <leave empty> Here is the overview from the Gammu documentation, how to specify the connection settings for I/O device: Connection: Model: Note: The documentation uses the term "port", where we use the term "I/O device". Note: You do not have to create/change the gammurc configuration file. That will do KO/Pi for you. Note: For a known model, leave "Model:" always empty, such that Gammu can auto detect the model. # This is a sample ~/.gammurc file. # In Unix/Linux copy it into your home directory and name it .gammurc # or into /etc and name it gammurc # In Win32 copy it into directory with Gammu.exe and name gammurc # More about parameters later # ----------------------------------------------------------------------------- [gammu] port = com8: #model = 6110 connection = fbusblue #synchronizetime = yes #logfile = gammulog #logformat = textall #use_locking = yes #gammuloc = locfile #startinfo = yes #gammucoding = utf8 [gammu1] port = com8: #model = 6110 connection = fbusblue #synchronizetime = yes #logfile = gammulog #logformat = textall #use_locking = yes #gammuloc = locfile #startinfo = yes #gammucoding = utf8 # ----------------------------------------------------------------------------- # Now info about "Connection" parameter and connected with it port type # (more about port types later) # ----------------------------------------------------------------------------- # "Connection" parameter | Port type | More details # -----------------------|-----------|----------------------------------------- # "fbus" | serial | Nokia FBUS2 # "fbusirda"/"infrared" | serial | Nokia FBUS2 over direct infrared device # "fbusdlr3"/"dlr3" | serial | Nokia FBUS2 with DLR3 cable # "fbusdku5" | dku5 | Nokia FBUS2 with DKU5 cable. WIN32 ONLY # "fbuspl2303" | usb | Nokia FBUS2 with USB cable based on # | | PL2303 chip. # "fbusblue" | serial | Nokia FBUS2 over Bluetooth serial device # "phonetblue" | serial | Nokia PHONET FBUS over Bluetooth serial # | | device # "mrouterblue" | serial | # "mbus" | serial | Nokia MBUS2 # "at19200"/"at115200"/..| serial | AT commands.8 bits, None parity, 1 stop # | | bit, no flow control # -----------------------|-----------|----------------------------------------- # "irdaphonet"/"irda" | irda | Nokia PHONET FBUS over socket infrared # "irdaat" | irda | AT commands with socket infrared # "irdaobex" | irda | OBEX over socket infrared. MODEL "obex" # -----------------------|-----------|----------------------------------------- # "bluephonet" | BT | Nokia PHONET FBUS with Bluetooth stack # "bluefbus"/"dlr3blue" | BT | Nokia FBUS2 with Bluetooth stack # "blueat"/"atblue" | BT | AT commands with Bluetooth stack # "blueobex" | BT | OBEX with Bluetooth. MODEL "obex" # # Now more about port types and connected with it "Port" parameter # ----------------------------------------------------------------------------- # Port type | "Port" parameter in Windows/DOS | "Port" parameter in Linux/Unix # ----------|---------------------------------|-------------------------------- # serial | "com*:" | "/dev/ttyS*" # | (example "com1:") | (example "/dev/ttyS1") # | | or "/dev/tts/**" (with DevFS) # ----------|---------------------------------|-------------------------------- # irda | ignored (can be empty) | "/dev/ircomm*" # ----------|---------------------------------|-------------------------------- # BT | Bluetooth device address # | (example "") # ----------|---------------------------------|-------------------------------- # dku5 | ignored (can be empty) | connection with it not possible # ----------|---------------------------------|-------------------------------- # usb | connection with it not possible | "/dev/ttyUSB*" # # Other config parameters # ----------------------------------------------------------------------------- # Parameter name | Description # ----------------|------------------------------------------------------------ # Model | use only, when Gammu doesn't recognize your phone model. # | Put it here. Example values: "6110", "6150", "6210", "8210" # SynchronizeTime | if you want to set time from computer to phone during # | starting connection. Do not rather use this option when # | when to reset phone during connection (in some phones need # | to set time again after restart) # GammuLoc | name of localisation file # StartInfo | this option allow to set, that you want (setting "yes") # | to see message on the phone screen or phone should enable # | light for a moment during starting connection. Phone # | WON'T beep during starting connection with this option. # GammuCoding | forces using specified codepage (in win32 - for example # | "1250" will force CP1250) or UTF8 (in Linux - "utf8") # ----------------|------------------------------------------------------------ # Logfile | Use, when want to have logfile from communication. # Logformat | What debug info and format should be used: # | "nothing" - no debug level (default) # | "text" - transmission dump in text format # | "textall" - all possible info in text format # | "errors" - errors in text format # | "binary" - transmission dump in binary format # ----------------|------------------------------------------------------------ # Use_Locking | under Unix/Linux use "yes", if want to lock used device # | to prevent using it by other applications. In win32 ignored diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 347d982..ead8628 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp @@ -1,457 +1,457 @@ /* 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. */ #include <klocale.h> #include <kdebug.h> #include <qapp.h> #include <kiconloader.h> #include "kotodoviewitem.h" #include "kotodoview.h" #include "koprefs.h" KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) { construct(); } KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) { construct(); } QString KOTodoViewItem::key(int column,bool) const { QMap<int,QString>::ConstIterator it = mKeyMap.find(column); if (it == mKeyMap.end()) { return text(column).lower(); } else { return *it; } } void KOTodoViewItem:: setup() { int h = 20; if ( listView () ) { QFontMetrics fm ( listView ()->font () ); h = fm.height(); } setHeight( h ); } void KOTodoViewItem::setSortKey(int column,const QString &key) { mKeyMap.insert(column,key); } #if QT_VERSION >= 300 void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, int y,int h) { QListViewItem::paintBranches(p,cg,w,y,h); } #else #endif void KOTodoViewItem::construct() { // qDebug("KOTodoViewItem::construct() "); m_init = true; QString keyd = "=="; QString keyt = "=="; QString skeyd = "=="; QString skeyt = "=="; setOn(mTodo->isCompleted()); setText(0,mTodo->summary()); setText(1,QString::number(mTodo->priority())); setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); if (mTodo->percentComplete()<100) { if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); else setSortKey(2,QString::number(mTodo->percentComplete())); } else { if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); else setSortKey(2,QString::number(99)); } if (mTodo->hasDueDate()) { setText(3, mTodo->dtDueDateStr()); QDate d = mTodo->dtDue().date(); keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); // setSortKey(3,keyd); if (mTodo->doesFloat()) { setText(4,""); } else { setText(4,mTodo->dtDueTimeStr()); QTime t = mTodo->dtDue().time(); keyt.sprintf("%02d%02d",t.hour(),t.minute()); //setSortKey(4,keyt); } } else { setText(3,""); setText(4,""); } setSortKey(3,keyd); setSortKey(4,keyt); if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); if (mTodo->hasStartDate()) { setText(5, mTodo->dtStartDateStr()); QDate d = mTodo->dtStart().date(); skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); if (mTodo->doesFloat()) { setText(6,""); } else { setText(6,mTodo->dtStartTimeStr()); QTime t = mTodo->dtStart().time(); skeyt.sprintf("%02d%02d",t.hour(),t.minute()); } } else { setText(5,""); setText(6,""); } setSortKey(5,skeyd); setSortKey(6,skeyt); setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); setText(8,mTodo->categoriesStr()); #if 0 // Find sort id in description. It's the text behind the last '#' character // found in the description. White spaces are removed from beginning and end // of sort id. int pos = mTodo->description().findRev('#'); if (pos < 0) { setText(6,""); } else { QString str = mTodo->description().mid(pos+1); str.stripWhiteSpace(); setText(6,str); } #endif m_known = false; m_init = false; setMyPixmap(); } void KOTodoViewItem::setMyPixmap() { int size = 5; QPixmap pixi = QPixmap( 1, 1 ); // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { // pixi = SmallIcon("redcross16"); // } else { QPainter p; int pixSize = 0; QPixmap pPix = QPixmap( size, size ); if ( mTodo->description().length() > 0 ) { pixi.resize(size, pixSize+size); pPix.fill( Qt::darkGreen ); p.begin( &pixi ); p. drawPixmap ( 0, pixSize, pPix); p.end(); pixSize += size; } if ( mTodo->isAlarmEnabled() ) { pixi.resize(size, pixSize+size); pPix.fill( Qt::red ); p.begin( &pixi ); p. drawPixmap ( 0, pixSize, pPix); p.end(); pixSize += size; } // } if ( pixi.width() > 1 ) { setPixmap ( 0,pixi ) ; + } else { + setPixmap ( 0,QPixmap() ) ; } - - } void KOTodoViewItem::stateChange(bool state) { // qDebug("KOTodoViewItem::stateChange "); // do not change setting on startup if ( m_init ) return; kdDebug() << "State changed, modified " << state << endl; QString keyd = "=="; QString keyt = "=="; if (state) mTodo->setCompleted(state); else mTodo->setPercentComplete(0); if (isOn()!=state) { setOn(state); } if (mTodo->hasDueDate()) { setText(3, mTodo->dtDueDateStr()); QDate d = mTodo->dtDue().date(); keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); setSortKey(3,keyd); if (mTodo->doesFloat()) { setText(4,""); } else { setText(4,mTodo->dtDueTimeStr()); QTime t = mTodo->dtDue().time(); keyt.sprintf("%02d%02d",t.hour(),t.minute()); setSortKey(4,keyt); } } if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); if (mTodo->percentComplete()<100) { if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); else setSortKey(2,QString::number(mTodo->percentComplete())); } else { if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); else setSortKey(2,QString::number(99)); } QListViewItem * myChild = firstChild(); KOTodoViewItem *item; while( myChild ) { item = static_cast<KOTodoViewItem*>(myChild); item->stateChange(state); myChild = myChild->nextSibling(); } mTodoView->modified(true); - mTodoView->setTodoModified( mTodo ); setMyPixmap(); + mTodoView->setTodoModified( mTodo ); } bool KOTodoViewItem::isAlternate() { #ifndef KORG_NOLVALTERNATION KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); if (lv && lv->alternateBackground().isValid()) { KOTodoViewItem *above = 0; above = dynamic_cast<KOTodoViewItem *>(itemAbove()); m_known = above ? above->m_known : true; if (m_known) { m_odd = above ? !above->m_odd : false; } else { KOTodoViewItem *item; bool previous = true; if (QListViewItem::parent()) { item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); if (item) previous = item->m_odd; item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); } else { item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); } while(item) { item->m_odd = previous = !previous; item->m_known = true; item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); } } return m_odd; } return false; #else return false; #endif } void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup _cg = cg; QColorGroup::ColorRole role; if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) role = QColorGroup::Text; else role = QColorGroup::Base; //#ifndef KORG_NOLVALTERNATION // if (isAlternate()) // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; QColor colorToSet; if ( setColor ) { QStringList categories = mTodo->categories(); QString cat = categories.first(); if ( !cat.isEmpty()) { colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); } else setColor = false; } if (mTodo->hasDueDate()) { if (mTodo->dtDue().date()==QDate::currentDate() && !mTodo->isCompleted()) { //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); colorToSet = KOPrefs::instance()->mTodoDueTodayColor; setColor = true; } if (mTodo->dtDue().date() < QDate::currentDate() && !mTodo->isCompleted()) { //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); colorToSet = KOPrefs::instance()->mTodoOverdueColor; setColor = true; } } if ( setColor ) { _cg.setColor(role,colorToSet ); if ( role == QColorGroup::Base) { int rgb = colorToSet.red(); rgb += colorToSet.blue()/2; rgb += colorToSet.green(); if ( rgb < 200 ) _cg.setColor(QColorGroup::Text,Qt::white ); } } //#endif if ( column > 0 ){ if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { p->save(); int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); p->fillRect( 0, 0, width, height(), _cg.base() ); // background // p->setPen(Qt::black ); //border // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling QColor fc = KOPrefs::instance()->mHighlightColor; if ( mTodo->percentComplete() == 100 ) fc = darkGreen; p->drawRect( 2, 2, width-4, height()-4); p->fillRect( 3, 3, progress, height()-6, fc ); p->restore(); } else { QCheckListItem::paintCell(p, _cg, column, width, alignment); } return; } int align = alignment; if ( !p ) return; p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); QListView *lv = listView(); if ( !lv ) return; int marg = 2;//lv->itemMargin(); int r = 0; QCheckListItem::Type myType = QCheckListItem::CheckBox; int BoxSize = 20; int boxOffset = 2; int xOffset = 2; if (qApp->desktop()->width() < 300 ) { BoxSize = 14; boxOffset = -1; xOffset = 1; // marg = 0; } if ( height() < BoxSize ) { boxOffset = boxOffset - ((BoxSize - height())/2) ; // qDebug("boxOffset %d height %d", boxOffset, height() ); BoxSize = height(); } //bool winStyle = lv->style() == WindowsStyle; int lineStart = 5; if ( myType == Controller ) { if ( !pixmap( 0 ) ) r += BoxSize + 4; } else { ASSERT( lv ); //### // QFontMetrics fm( lv->font() ); // int d = fm.height(); int x = 0; int y = (height() - BoxSize) / 2; // p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); if ( myType == CheckBox ) { if ( isEnabled() ) p->setPen( QPen( _cg.text(), 1 ) ); else p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); lineStart = x+marg; ///////////////////// x++; y++; if ( isOn() ) { QPointArray a( 7*2 ); int i, xx, yy; xx = x+xOffset+marg+(boxOffset/2); yy = y+5+boxOffset; for ( i=0; i<3; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); // qDebug(" "); xx++; yy++; } yy -= 2; for ( i=3; i<7; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy--; } p->setPen( darkGreen ); p->drawLineSegments( a ); } //////////////////////// } r += BoxSize + 4; } p->translate( r, 0 ); p->setPen( QPen( _cg.text() ) ); QListViewItem::paintCell( p, _cg, column, width - r, align ); if ( mTodo->cancelled () ) { p->setPen( black ); QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); int wid = br.width() +lineStart; if ( wid > width-3 ) wid = width-3; p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); } } diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp index 6859d36..154cd02 100644 --- a/microkde/kdeui/klistview.cpp +++ b/microkde/kdeui/klistview.cpp @@ -1144,1078 +1144,1086 @@ QListViewItem* KListView::lastChild () const if (lastchild) for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); return lastchild; } QListViewItem *KListView::lastItem() const { QListViewItem* last = lastChild(); for (QListViewItemIterator it (last); it.current(); ++it) last = it.current(); return last; } KLineEdit *KListView::renameLineEdit() const { //US return d->editor; qDebug("KListView::renameLineEdit returns 0. Might crash"); return 0; } void KListView::startDrag() { qDebug("KListView::startDrag drag&drop not supported yet."); /*US QDragObject *drag = dragObject(); if (!drag) return; if (drag->drag() && drag->target() != viewport()) emit moved(); */ } QDragObject *KListView::dragObject() { if (!currentItem()) return 0; return new QStoredDrag("application/x-qlistviewitem", viewport()); } void KListView::setItemsMovable(bool b) { d->itemsMovable=b; } bool KListView::itemsMovable() const { return d->itemsMovable; } void KListView::setItemsRenameable(bool b) { d->itemsRenameable=b; } bool KListView::itemsRenameable() const { return d->itemsRenameable; } void KListView::setDragEnabled(bool b) { d->dragEnabled=b; } bool KListView::dragEnabled() const { return d->dragEnabled; } void KListView::setAutoOpen(bool b) { d->autoOpen=b; } bool KListView::autoOpen() const { return d->autoOpen; } bool KListView::dropVisualizer() const { return d->dropVisualizer; } void KListView::setDropVisualizer(bool b) { d->dropVisualizer=b; } QPtrList<QListViewItem> KListView::selectedItems() const { QPtrList<QListViewItem> list; for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) if (i->isSelected()) list.append(i); return list; } void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) { // sanity check - don't move a item into it's own child structure QListViewItem *i = parent; while(i) { if(i == item) return; i = i->parent(); } // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor // in here, without ever deleting the item. if (item->parent()) item->parent()->takeItem(item); else takeItem(item); if (parent) parent->insertItem(item); else insertItem(item); if (after) ;//item->moveToJustAfter(after); } void KListView::contentsDragEnterEvent(QDragEnterEvent *event) { qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); /*US if (acceptDrag (event)) event->accept(); */ } void KListView::setDropVisualizerWidth (int w) { d->mDropVisualizerWidth = w > 0 ? w : 1; } QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, QListViewItem *after) { QRect insertmarker; if (!after && !parent) insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); else { int level = 0; if (after) { QListViewItem* it = 0L; if (after->isOpen()) { // Look for the last child (recursively) it = after->firstChild(); if (it) while (it->nextSibling() || it->firstChild()) if ( it->nextSibling() ) it = it->nextSibling(); else it = it->firstChild(); } insertmarker = itemRect (it ? it : after); level = after->depth(); } else if (parent) { insertmarker = itemRect (parent); level = parent->depth() + 1; } insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); insertmarker.setRight (viewport()->width()); insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); } // This is not used anymore, at least by KListView itself (see viewportPaintEvent) // Remove for KDE 3.0. if (p) p->fillRect(insertmarker, Dense4Pattern); return insertmarker; } QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) { QRect r; if (item) { r = itemRect(item); r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); if (painter) { //US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), //US QStyle::Style_FocusAtBorder, colorGroup().highlight()); const QColor* pHighl = &(colorGroup().highlight()); //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); qDebug("KListView::drawItemHighlighter has to be verified"); } } return r; } void KListView::cleanItemHighlighter () { if (d->mOldDropHighlighter.isValid()) { QRect rect=d->mOldDropHighlighter; d->mOldDropHighlighter = QRect(); viewport()->repaint(rect, true); } } void KListView::rename(QListViewItem *item, int c) { if (d->renameable.contains(c)) { ensureItemVisible(item); //US d->editor->load(item,c); qDebug("KListView::rename has to be verified"); } } bool KListView::isRenameable (int col) const { return d->renameable.contains(col); } void KListView::setRenameable (int col, bool yesno) { if (col>=header()->count()) return; d->renameable.remove(col); if (yesno && d->renameable.find(col)==d->renameable.end()) d->renameable+=col; else if (!yesno && d->renameable.find(col)!=d->renameable.end()) d->renameable.remove(col); } void KListView::doneEditing(QListViewItem *item, int row) { emit itemRenamed(item, item->text(row), row); emit itemRenamed(item); } bool KListView::acceptDrag(QDropEvent* e) const { qDebug("KListView::acceptDrag drag&drop not supported yet"); //US return acceptDrops() && itemsMovable() && (e->source()==viewport()); return false; } void KListView::setCreateChildren(bool b) { d->createChildren=b; } bool KListView::createChildren() const { return d->createChildren; } int KListView::tooltipColumn() const { return d->tooltipColumn; } void KListView::setTooltipColumn(int column) { d->tooltipColumn=column; } void KListView::setDropHighlighter(bool b) { d->dropHighlighter=b; } bool KListView::dropHighlighter() const { return d->dropHighlighter; } bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const { return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); } QString KListView::tooltip(QListViewItem *item, int column) const { return item->text(column); } void KListView::setTabOrderedRenaming(bool b) { d->tabRename = b; } bool KListView::tabOrderedRenaming() const { return d->tabRename; } void KListView::keyPressEvent (QKeyEvent* e) { //don't we need a contextMenuModifier too ? (aleXXX) if (e->key() == d->contextMenuKey) { emit menuShortCutPressed (this, currentItem()); return; } if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) { emit signalDelete ( ); return; } if (d->selectionMode != FileManager) QListView::keyPressEvent (e); else fileManagerKeyPressEvent (e); } void KListView::activateAutomaticSelection() { d->selectedBySimpleMove=true; d->selectedUsingMouse=false; if (currentItem()!=0) { selectAll(false); currentItem()->setSelected(true); currentItem()->repaint(); emit selectionChanged(); }; } void KListView::deactivateAutomaticSelection() { d->selectedBySimpleMove=false; } bool KListView::automaticSelection() const { return d->selectedBySimpleMove; } void KListView::fileManagerKeyPressEvent (QKeyEvent* e) { //don't care whether it's on the keypad or not int e_state=(e->state() & ~Keypad); int oldSelectionDirection(d->selectionDirection); if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) { if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) selectAll(FALSE); d->selectionDirection=0; d->wasShiftEvent = (e_state == ShiftButton); }; //d->wasShiftEvent = (e_state == ShiftButton); QListViewItem* item = currentItem(); if (item==0) return; QListViewItem* repaintItem1 = item; QListViewItem* repaintItem2 = 0L; QListViewItem* visItem = 0L; QListViewItem* nextItem = 0L; int items = 0; bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); int selectedItems(0); for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) if (tmpItem->isSelected()) selectedItems++; if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) && (e_state==NoButton) && ((e->key()==Key_Down) || (e->key()==Key_Up) || (e->key()==Key_Next) || (e->key()==Key_Prior) || (e->key()==Key_Home) || (e->key()==Key_End))) { d->selectedBySimpleMove=true; d->selectedUsingMouse=false; } else if (selectedItems>1) d->selectedBySimpleMove=false; bool emitSelectionChanged(false); switch (e->key()) { case Key_Escape: selectAll(FALSE); emitSelectionChanged=TRUE; break; case Key_Space: //toggle selection of current item if (d->selectedBySimpleMove) d->selectedBySimpleMove=false; item->setSelected(!item->isSelected()); emitSelectionChanged=TRUE; break; case Key_Insert: //toggle selection of current item and move to the next item if (d->selectedBySimpleMove) { d->selectedBySimpleMove=false; if (!item->isSelected()) item->setSelected(TRUE); } else { item->setSelected(!item->isSelected()); }; nextItem=item->itemBelow(); if (nextItem!=0) { repaintItem2=nextItem; visItem=nextItem; setCurrentItem(nextItem); }; d->selectionDirection=1; emitSelectionChanged=TRUE; break; case Key_Down: nextItem=item->itemBelow(); //toggle selection of current item and move to the next item if (shiftOrCtrl) { d->selectionDirection=1; if (d->selectedBySimpleMove) d->selectedBySimpleMove=false; else { if (oldSelectionDirection!=-1) { item->setSelected(!item->isSelected()); emitSelectionChanged=TRUE; }; }; } else if ((d->selectedBySimpleMove) && (nextItem!=0)) { item->setSelected(false); emitSelectionChanged=TRUE; }; if (nextItem!=0) { if (d->selectedBySimpleMove) nextItem->setSelected(true); repaintItem2=nextItem; visItem=nextItem; setCurrentItem(nextItem); }; break; case Key_Up: nextItem=item->itemAbove(); d->selectionDirection=-1; //move to the prev. item and toggle selection of this one // => No, can't select the last item, with this. For symmetry, let's // toggle selection and THEN move up, just like we do in down (David) if (shiftOrCtrl) { if (d->selectedBySimpleMove) d->selectedBySimpleMove=false; else { if (oldSelectionDirection!=1) { item->setSelected(!item->isSelected()); emitSelectionChanged=TRUE; }; } } else if ((d->selectedBySimpleMove) && (nextItem!=0)) { item->setSelected(false); emitSelectionChanged=TRUE; }; if (nextItem!=0) { if (d->selectedBySimpleMove) nextItem->setSelected(true); repaintItem2=nextItem; visItem=nextItem; setCurrentItem(nextItem); }; break; case Key_End: //move to the last item and toggle selection of all items inbetween nextItem=item; if (d->selectedBySimpleMove) item->setSelected(false); if (shiftOrCtrl) d->selectedBySimpleMove=false; while(nextItem!=0) { if (shiftOrCtrl) nextItem->setSelected(!nextItem->isSelected()); if (nextItem->itemBelow()==0) { if (d->selectedBySimpleMove) nextItem->setSelected(true); repaintItem2=nextItem; visItem=nextItem; setCurrentItem(nextItem); } nextItem=nextItem->itemBelow(); } emitSelectionChanged=TRUE; break; case Key_Home: // move to the first item and toggle selection of all items inbetween nextItem = firstChild(); visItem = nextItem; repaintItem2 = visItem; if (d->selectedBySimpleMove) item->setSelected(false); if (shiftOrCtrl) { d->selectedBySimpleMove=false; while ( nextItem != item ) { nextItem->setSelected( !nextItem->isSelected() ); nextItem = nextItem->itemBelow(); } item->setSelected( !item->isSelected() ); } setCurrentItem( firstChild() ); emitSelectionChanged=TRUE; break; case Key_Next: items=visibleHeight()/item->height(); nextItem=item; if (d->selectedBySimpleMove) item->setSelected(false); if (shiftOrCtrl) { d->selectedBySimpleMove=false; d->selectionDirection=1; }; for (int i=0; i<items; i++) { if (shiftOrCtrl) nextItem->setSelected(!nextItem->isSelected()); //the end if ((i==items-1) || (nextItem->itemBelow()==0)) { if (shiftOrCtrl) nextItem->setSelected(!nextItem->isSelected()); if (d->selectedBySimpleMove) nextItem->setSelected(true); ensureItemVisible(nextItem); setCurrentItem(nextItem); update(); if ((shiftOrCtrl) || (d->selectedBySimpleMove)) { emit selectionChanged(); } return; } nextItem=nextItem->itemBelow(); } break; case Key_Prior: items=visibleHeight()/item->height(); nextItem=item; if (d->selectedBySimpleMove) item->setSelected(false); if (shiftOrCtrl) { d->selectionDirection=-1; d->selectedBySimpleMove=false; }; for (int i=0; i<items; i++) { if ((nextItem!=item) &&(shiftOrCtrl)) nextItem->setSelected(!nextItem->isSelected()); //the end if ((i==items-1) || (nextItem->itemAbove()==0)) { if (d->selectedBySimpleMove) nextItem->setSelected(true); ensureItemVisible(nextItem); setCurrentItem(nextItem); update(); if ((shiftOrCtrl) || (d->selectedBySimpleMove)) { emit selectionChanged(); } return; } nextItem=nextItem->itemAbove(); } break; case Key_Minus: if ( item->isOpen() ) setOpen( item, FALSE ); break; case Key_Plus: if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) setOpen( item, TRUE ); break; default: bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); if (realKey && selectCurrentItem) item->setSelected(false); //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) QListView::SelectionMode oldSelectionMode = selectionMode(); setSelectionMode (QListView::Multi); QListView::keyPressEvent (e); setSelectionMode (oldSelectionMode); if (realKey && selectCurrentItem) { currentItem()->setSelected(true); emitSelectionChanged=TRUE; } repaintItem2=currentItem(); if (realKey) visItem=currentItem(); break; } if (visItem) ensureItemVisible(visItem); QRect ir; if (repaintItem1) ir = ir.unite( itemRect(repaintItem1) ); if (repaintItem2) ir = ir.unite( itemRect(repaintItem2) ); if ( !ir.isEmpty() ) { // rectangle to be repainted if ( ir.x() < 0 ) ir.moveBy( -ir.x(), 0 ); viewport()->repaint( ir, FALSE ); } /*if (repaintItem1) repaintItem1->repaint(); if (repaintItem2) repaintItem2->repaint();*/ update(); if (emitSelectionChanged) emit selectionChanged(); } void KListView::setSelectionModeExt (SelectionModeExt mode) { d->selectionMode = mode; switch (mode) { case Single: case Multi: case Extended: case NoSelection: setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); break; case FileManager: setSelectionMode (QListView::Extended); break; default: kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; break; } } KListView::SelectionModeExt KListView::selectionModeExt () const { return d->selectionMode; } int KListView::itemIndex( const QListViewItem *item ) const { if ( !item ) return -1; if ( item == firstChild() ) return 0; else { QListViewItemIterator it(firstChild()); uint j = 0; for (; it.current() && it.current() != item; ++it, ++j ); if( !it.current() ) return -1; return j; } } QListViewItem* KListView::itemAtIndex(int index) { if (index<0) return 0; int j(0); for (QListViewItemIterator it=firstChild(); it.current(); it++) { if (j==index) return it.current(); j++; }; return 0; } void KListView::emitContextMenu (KListView*, QListViewItem* i) { QPoint p; // qDebug("KListView::emitContextMenu "); if (i) p = viewport()->mapToGlobal(itemRect(i).center()); else p = mapToGlobal(rect().center()); emit contextMenu (this, i, p); } void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) { + QListViewItem* item = i; + int c = col; + // do not trust the values for QListViewItem* i and int col; // qDebug("KListView::emitContextMenu col"); - emit contextRequest( i, p, col ); - emit contextMenu (this, i, p); + if ( col == -1 ) { + QPoint pp = viewport()->mapFromGlobal(p); + item = itemAt( pp); + c = header()->sectionAt(pp.x() ); + } + emit contextRequest( item, p, c ); + emit contextMenu (this, item, p); } void KListView::setAcceptDrops (bool val) { QListView::setAcceptDrops (val); viewport()->setAcceptDrops (val); } int KListView::dropVisualizerWidth () const { return d->mDropVisualizerWidth; } void KListView::viewportPaintEvent(QPaintEvent *e) { QListView::viewportPaintEvent(e); if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) { QPainter painter(viewport()); // This is where we actually draw the drop-visualizer painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); } if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) { QPainter painter(viewport()); qDebug("KListView::viewportPaintEvent has to be verified"); // This is where we actually draw the drop-highlighter //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), //US QStyle::Style_FocusAtBorder); //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); } } void KListView::setFullWidth() { setFullWidth(true); } void KListView::setFullWidth(bool fullWidth) { d->fullWidth = fullWidth; //US header()->setStretchEnabled(fullWidth, columns()-1); } bool KListView::fullWidth() const { return d->fullWidth; } int KListView::addColumn(const QString& label, int width) { int result = QListView::addColumn(label, width); if (d->fullWidth) { //US header()->setStretchEnabled(false, columns()-2); //US header()->setStretchEnabled(true, columns()-1); } return result; } int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) { int result = QListView::addColumn(iconset, label, width); if (d->fullWidth) { //US header()->setStretchEnabled(false, columns()-2); //US header()->setStretchEnabled(true, columns()-1); } return result; } void KListView::removeColumn(int index) { QListView::removeColumn(index); //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); } void KListView::viewportResizeEvent(QResizeEvent* e) { QListView::viewportResizeEvent(e); } const QColor &KListView::alternateBackground() const { return d->alternateBackground; } void KListView::setAlternateBackground(const QColor &c) { d->alternateBackground = c; repaint(); } void KListView::saveLayout(KConfig *config, const QString &group) const { KConfigGroupSaver saver(config, group); QStringList widths, order; for (int i = 0; i < columns(); ++i) { widths << QString::number(columnWidth(i)); order << QString::number(header()->mapToIndex(i)); } config->writeEntry("ColumnWidths", widths); config->writeEntry("ColumnOrder", order); config->writeEntry("SortColumn", d->sortColumn); config->writeEntry("SortAscending", d->sortAscending); } void KListView::restoreLayout(KConfig *config, const QString &group) { KConfigGroupSaver saver(config, group); QStringList cols = config->readListEntry("ColumnWidths"); int i = 0; for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) setColumnWidth(i++, (*it).toInt()); cols = config->readListEntry("ColumnOrder"); i = 0; for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) header()->moveSection(i++, (*it).toInt()); /*US I changed the following code, because hasKey is not available. !!! check if my version is correct if (config->hasKey("SortColumn")) setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); */ QStringList langLst = config->readListEntry( "SortColumn" ); if (!langLst.isEmpty()) setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); } void KListView::setSorting(int column, bool ascending) { d->sortColumn = column; d->sortAscending = ascending; QListView::setSorting(column, ascending); } int KListView::columnSorted(void) const { return d->sortColumn; } bool KListView::ascendingSort(void) const { return d->sortAscending; } KListViewItem::KListViewItem(QListView *parent) : QListViewItem(parent) { init(); } KListViewItem::KListViewItem(QListViewItem *parent) : QListViewItem(parent) { init(); } KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) : QListViewItem(parent, after) { init(); } KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) : QListViewItem(parent, after) { init(); } KListViewItem::KListViewItem(QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } KListViewItem::KListViewItem(QListViewItem *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } KListViewItem::~KListViewItem() { } void KListViewItem::init() { m_known = false; } const QColor &KListViewItem::backgroundColor() { if (isAlternate()) return static_cast< KListView* >(listView())->alternateBackground(); return listView()->viewport()->colorGroup().base(); } bool KListViewItem::isAlternate() { KListView *lv = static_cast<KListView *>(listView()); if (lv && lv->alternateBackground().isValid()) { KListViewItem *above = 0; //US above = dynamic_cast<KListViewItem *>(itemAbove()); above = (KListViewItem *)(itemAbove()); m_known = above ? above->m_known : true; if (m_known) { m_odd = above ? !above->m_odd : false; } else { KListViewItem *item; bool previous = true; if (parent()) { //US item = dynamic_cast<KListViewItem *>(parent()); item = (KListViewItem *)(parent()); if (item) previous = item->m_odd; //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); item = (KListViewItem *)(parent()->firstChild()); } else { //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); item = (KListViewItem *)(lv->firstChild()); } while(item) { item->m_odd = previous = !previous; item->m_known = true; //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); item = (KListViewItem *)(item->nextSibling()); } } return m_odd; } return false; } void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup _cg = cg; const QPixmap *pm = listView()->viewport()->backgroundPixmap(); if (pm && !pm->isNull()) { _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); QPoint o = p->brushOrigin(); p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); } else if (isAlternate()) { //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); else _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); } QListViewItem::paintCell(p, _cg, column, width, alignment); } //US we do not have a "global KDE" variable to setup singleClick functionality void KListView::setSingleClick(bool s) { d->bUseSingle = s; slotSettingsChanged(1); // qDebug("KListView::setSingleClick: single %i", d->bUseSingle); } void KListView::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } //US #include "klistview.moc" //US #include "klistviewlineedit.moc" // vim: ts=2 sw=2 et @@ -1 +1 @@ -version = "1.9.19"; +version = "1.9.20"; |