author | eilers <eilers> | 2003-08-08 15:09:29 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-08 15:09:29 (UTC) |
commit | b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16 (patch) (unidiff) | |
tree | b0f96db67cfb1b9d2476530ecec9a2ba6eacbab1 | |
parent | 14d394e6c107b037a09a31a92605034fe50f7813 (diff) | |
download | opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.zip opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.gz opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.bz2 |
Merging all changes from BRANCH_1_0.
-rw-r--r-- | libopie/libopie.pro | 3 | ||||
-rw-r--r-- | libopie/libopie1.control | 4 | ||||
-rw-r--r-- | libopie/odevice.cpp | 111 | ||||
-rw-r--r-- | libopie/ofiledialog.cc | 81 | ||||
-rw-r--r-- | libopie/ofiledialog.h | 3 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 1310 | ||||
-rw-r--r-- | libopie/ofileselector.cpp | 856 | ||||
-rw-r--r-- | libopie/ofileselector.h | 362 | ||||
-rw-r--r-- | libopie/ofileselector_p.h | 151 | ||||
-rw-r--r-- | libopie/orecurrancewidget.cpp | 56 | ||||
-rw-r--r-- | libopie/oticker.h | 4 | ||||
-rw-r--r-- | libopie/todayplugininterface.h | 42 |
12 files changed, 1319 insertions, 1664 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index 4535c4e..6fbd449 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro | |||
@@ -1,100 +1,101 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = ofontmenu.h \ | 3 | HEADERS = ofontmenu.h \ |
4 | ocolorbutton.h \ | 4 | ocolorbutton.h \ |
5 | ofiledialog.h ofileselector.h \ | 5 | ofiledialog.h ofileselector.h \ |
6 | ofileselector_p.h \ | ||
6 | ocheckitem.h \ | 7 | ocheckitem.h \ |
7 | xmltree.h \ | 8 | xmltree.h \ |
8 | colordialog.h colorpopupmenu.h \ | 9 | colordialog.h colorpopupmenu.h \ |
9 | oclickablelabel.h oprocctrl.h \ | 10 | oclickablelabel.h oprocctrl.h \ |
10 | oprocess.h odevice.h odevicebutton.h \ | 11 | oprocess.h odevice.h odevicebutton.h \ |
11 | otimepicker.h otabwidget.h \ | 12 | otimepicker.h otabwidget.h \ |
12 | otabbar.h otabinfo.h \ | 13 | otabbar.h otabinfo.h \ |
13 | ofontselector.h \ | 14 | ofontselector.h \ |
14 | pim/opimrecord.h \ | 15 | pim/opimrecord.h \ |
15 | pim/otodo.h \ | 16 | pim/otodo.h \ |
16 | pim/orecordlist.h \ | 17 | pim/orecordlist.h \ |
17 | pim/opimaccesstemplate.h \ | 18 | pim/opimaccesstemplate.h \ |
18 | pim/opimaccessbackend.h \ | 19 | pim/opimaccessbackend.h \ |
19 | pim/otodoaccess.h \ | 20 | pim/otodoaccess.h \ |
20 | pim/otodoaccessbackend.h \ | 21 | pim/otodoaccessbackend.h \ |
21 | pim/oconversion.h \ | 22 | pim/oconversion.h \ |
22 | pim/ocontact.h \ | 23 | pim/ocontact.h \ |
23 | pim/ocontactaccess.h \ | 24 | pim/ocontactaccess.h \ |
24 | pim/ocontactaccessbackend.h \ | 25 | pim/ocontactaccessbackend.h \ |
25 | pim/ocontactaccessbackend_xml.h \ | 26 | pim/ocontactaccessbackend_xml.h \ |
26 | pim/ocontactaccessbackend_vcard.h \ | 27 | pim/ocontactaccessbackend_vcard.h \ |
27 | pim/obackendfactory.h \ | 28 | pim/obackendfactory.h \ |
28 | pim/opimcache.h \ | 29 | pim/opimcache.h \ |
29 | pim/otodoaccessvcal.h \ | 30 | pim/otodoaccessvcal.h \ |
30 | pim/orecur.h \ | 31 | pim/orecur.h \ |
31 | pim/opimstate.h \ | 32 | pim/opimstate.h \ |
32 | pim/opimxrefpartner.h \ | 33 | pim/opimxrefpartner.h \ |
33 | pim/opimxref.h \ | 34 | pim/opimxref.h \ |
34 | pim/opimxrefmanager.h \ | 35 | pim/opimxrefmanager.h \ |
35 | pim/opimmaintainer.h \ | 36 | pim/opimmaintainer.h \ |
36 | pim/opimnotify.h \ | 37 | pim/opimnotify.h \ |
37 | pim/opimnotifymanager.h \ | 38 | pim/opimnotifymanager.h \ |
38 | pim/opimmainwindow.h \ | 39 | pim/opimmainwindow.h \ |
39 | pim/opimresolver.h \ | 40 | pim/opimresolver.h \ |
40 | pim/oevent.h \ | 41 | pim/oevent.h \ |
41 | pim/otimezone.h \ | 42 | pim/otimezone.h \ |
42 | pim/odatebookaccess.h \ | 43 | pim/odatebookaccess.h \ |
43 | pim/odatebookaccessbackend.h \ | 44 | pim/odatebookaccessbackend.h \ |
44 | pim/odatebookaccessbackend_xml.h \ | 45 | pim/odatebookaccessbackend_xml.h \ |
45 | orecurrancewidget.h \ | 46 | orecurrancewidget.h \ |
46 | oticker.h owait.h | 47 | oticker.h owait.h |
47 | 48 | ||
48 | SOURCES = ofontmenu.cc \ | 49 | SOURCES = ofontmenu.cc \ |
49 | ocolorbutton.cpp \ | 50 | ocolorbutton.cpp \ |
50 | sharp_compat.cpp \ | 51 | sharp_compat.cpp \ |
51 | xmltree.cc \ | 52 | xmltree.cc \ |
52 | ofiledialog.cc ofileselector.cc \ | 53 | ofiledialog.cc ofileselector.cpp \ |
53 | ocheckitem.cpp \ | 54 | ocheckitem.cpp \ |
54 | colordialog.cpp \ | 55 | colordialog.cpp \ |
55 | colorpopupmenu.cpp oclickablelabel.cpp \ | 56 | colorpopupmenu.cpp oclickablelabel.cpp \ |
56 | oprocctrl.cpp oprocess.cpp \ | 57 | oprocctrl.cpp oprocess.cpp \ |
57 | odevice.cpp odevicebutton.cpp otimepicker.cpp \ | 58 | odevice.cpp odevicebutton.cpp otimepicker.cpp \ |
58 | otabwidget.cpp otabbar.cpp \ | 59 | otabwidget.cpp otabbar.cpp \ |
59 | ofontselector.cpp \ | 60 | ofontselector.cpp \ |
60 | pim/otodo.cpp \ | 61 | pim/otodo.cpp \ |
61 | pim/opimrecord.cpp \ | 62 | pim/opimrecord.cpp \ |
62 | pim/otodoaccess.cpp \ | 63 | pim/otodoaccess.cpp \ |
63 | pim/otodoaccessbackend.cpp \ | 64 | pim/otodoaccessbackend.cpp \ |
64 | pim/otodoaccessxml.cpp \ | 65 | pim/otodoaccessxml.cpp \ |
65 | pim/oconversion.cpp \ | 66 | pim/oconversion.cpp \ |
66 | pim/ocontact.cpp \ | 67 | pim/ocontact.cpp \ |
67 | pim/ocontactaccess.cpp \ | 68 | pim/ocontactaccess.cpp \ |
68 | pim/ocontactaccessbackend_vcard.cpp \ | 69 | pim/ocontactaccessbackend_vcard.cpp \ |
69 | pim/ocontactaccessbackend_xml.cpp \ | 70 | pim/ocontactaccessbackend_xml.cpp \ |
70 | pim/otodoaccessvcal.cpp \ | 71 | pim/otodoaccessvcal.cpp \ |
71 | pim/orecur.cpp \ | 72 | pim/orecur.cpp \ |
72 | pim/opimstate.cpp \ | 73 | pim/opimstate.cpp \ |
73 | pim/opimxrefpartner.cpp \ | 74 | pim/opimxrefpartner.cpp \ |
74 | pim/opimxref.cpp \ | 75 | pim/opimxref.cpp \ |
75 | pim/opimxrefmanager.cpp \ | 76 | pim/opimxrefmanager.cpp \ |
76 | pim/opimmaintainer.cpp \ | 77 | pim/opimmaintainer.cpp \ |
77 | pim/opimnotify.cpp \ | 78 | pim/opimnotify.cpp \ |
78 | pim/opimnotifymanager.cpp \ | 79 | pim/opimnotifymanager.cpp \ |
79 | pim/opimmainwindow.cpp \ | 80 | pim/opimmainwindow.cpp \ |
80 | pim/opimresolver.cpp \ | 81 | pim/opimresolver.cpp \ |
81 | pim/oevent.cpp \ | 82 | pim/oevent.cpp \ |
82 | pim/otimezone.cpp \ | 83 | pim/otimezone.cpp \ |
83 | pim/odatebookaccess.cpp \ | 84 | pim/odatebookaccess.cpp \ |
84 | pim/odatebookaccessbackend.cpp \ | 85 | pim/odatebookaccessbackend.cpp \ |
85 | pim/odatebookaccessbackend_xml.cpp \ | 86 | pim/odatebookaccessbackend_xml.cpp \ |
86 | orecurrancewidget.cpp \ | 87 | orecurrancewidget.cpp \ |
87 | oticker.cpp owait.cpp | 88 | oticker.cpp owait.cpp |
88 | 89 | ||
89 | TARGET = opie | 90 | TARGET = opie |
90 | INCLUDEPATH += $(OPIEDIR)/include | 91 | INCLUDEPATH += $(OPIEDIR)/include |
91 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | 92 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) |
92 | 93 | ||
93 | LIBS += -lqpe | 94 | LIBS += -lqpe |
94 | 95 | ||
95 | # LIBS += -lopiesql | 96 | # LIBS += -lopiesql |
96 | 97 | ||
97 | INTERFACES = otimepickerbase.ui orecurrancebase.ui | 98 | INTERFACES = otimepickerbase.ui orecurrancebase.ui |
98 | TARGET = opie | 99 | TARGET = opie |
99 | 100 | ||
100 | TRANSLATIONS = ../i18n/de/libopie.ts \ | 101 | TRANSLATIONS = ../i18n/de/libopie.ts \ |
diff --git a/libopie/libopie1.control b/libopie/libopie1.control index 1e75df3..76e4c7a 100644 --- a/libopie/libopie1.control +++ b/libopie/libopie1.control | |||
@@ -1,11 +1,11 @@ | |||
1 | Package: libopie1 | 1 | Package: libopie1 |
2 | Files: $OPIEDIR/lib/libopie.so.1.0.0 $OPIEDIR/lib/libopie.so.1.0 $OPIEDIR/lib/libopie.so.1 | 2 | Files: $OPIEDIR/lib/libopie.so.1.0.0 $OPIEDIR/lib/libopie.so.1.0 $OPIEDIR/lib/libopie.so.1 |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/system | 4 | Section: opie/system |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION.1 | 7 | Depends: libqte2 (>=$QTE_VERSION), libqpe1, opie-pics |
8 | Depends: libqte2 (>=$QTE_VERSION), libqpe1 | ||
9 | Provides: libopie | 8 | Provides: libopie |
10 | Replaces: libopie | 9 | Replaces: libopie |
11 | Description: Opie library | 10 | Description: Opie library |
11 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 62dc9d4..17ae389 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -427,96 +427,99 @@ ODevice::ODevice ( ) | |||
427 | d-> m_cpu_frequencies = new QStrList; | 427 | d-> m_cpu_frequencies = new QStrList; |
428 | } | 428 | } |
429 | 429 | ||
430 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 430 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
431 | { | 431 | { |
432 | if ( msg == "deviceButtonMappingChanged()" ) { | 432 | if ( msg == "deviceButtonMappingChanged()" ) { |
433 | reloadButtonMapping ( ); | 433 | reloadButtonMapping ( ); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | void ODevice::init ( ) | 437 | void ODevice::init ( ) |
438 | { | 438 | { |
439 | } | 439 | } |
440 | 440 | ||
441 | /** | 441 | /** |
442 | * This method initialises the button mapping | 442 | * This method initialises the button mapping |
443 | */ | 443 | */ |
444 | void ODevice::initButtons ( ) | 444 | void ODevice::initButtons ( ) |
445 | { | 445 | { |
446 | if ( d-> m_buttons ) | 446 | if ( d-> m_buttons ) |
447 | return; | 447 | return; |
448 | 448 | ||
449 | // Simulation uses iPAQ 3660 device buttons | 449 | // Simulation uses iPAQ 3660 device buttons |
450 | 450 | ||
451 | qDebug ( "init Buttons" ); | 451 | qDebug ( "init Buttons" ); |
452 | d-> m_buttons = new QValueList <ODeviceButton>; | 452 | d-> m_buttons = new QValueList <ODeviceButton>; |
453 | 453 | ||
454 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 454 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
455 | i_button *ib = ipaq_buttons + i; | 455 | i_button *ib = ipaq_buttons + i; |
456 | ODeviceButton b; | 456 | ODeviceButton b; |
457 | 457 | ||
458 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 458 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
459 | b. setKeycode ( ib-> code ); | 459 | b. setKeycode ( ib-> code ); |
460 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 460 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
461 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 461 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
462 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 462 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
463 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 463 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
464 | d-> m_buttons-> append ( b ); | 464 | d-> m_buttons-> append ( b ); |
465 | } | 465 | } |
466 | } | 466 | } |
467 | reloadButtonMapping ( ); | 467 | reloadButtonMapping ( ); |
468 | 468 | ||
469 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 469 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
470 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 470 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
471 | } | 471 | } |
472 | 472 | ||
473 | ODevice::~ODevice ( ) | 473 | ODevice::~ODevice ( ) |
474 | { | 474 | { |
475 | // we leak m_devicebuttons and m_cpu_frequency | ||
476 | // but it's a singleton and it is not so importantant | ||
477 | // -zecke | ||
475 | delete d; | 478 | delete d; |
476 | } | 479 | } |
477 | 480 | ||
478 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 481 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
479 | { | 482 | { |
480 | return false; | 483 | return false; |
481 | } | 484 | } |
482 | 485 | ||
483 | //#include <linux/apm_bios.h> | 486 | //#include <linux/apm_bios.h> |
484 | 487 | ||
485 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 488 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
486 | 489 | ||
487 | /** | 490 | /** |
488 | * This method will try to suspend the device | 491 | * This method will try to suspend the device |
489 | * It only works if the user is the QWS Server and the apm application | 492 | * It only works if the user is the QWS Server and the apm application |
490 | * is installed. | 493 | * is installed. |
491 | * It tries to suspend and then waits some time cause some distributions | 494 | * It tries to suspend and then waits some time cause some distributions |
492 | * do have asynchronus apm implementations. | 495 | * do have asynchronus apm implementations. |
493 | * This method will either fail and return false or it'll suspend the | 496 | * This method will either fail and return false or it'll suspend the |
494 | * device and return once the device got woken up | 497 | * device and return once the device got woken up |
495 | * | 498 | * |
496 | * @return if the device got suspended | 499 | * @return if the device got suspended |
497 | */ | 500 | */ |
498 | bool ODevice::suspend ( ) | 501 | bool ODevice::suspend ( ) |
499 | { | 502 | { |
500 | qDebug("ODevice::suspend"); | 503 | qDebug("ODevice::suspend"); |
501 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 504 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
502 | return false; | 505 | return false; |
503 | 506 | ||
504 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 507 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
505 | return false; | 508 | return false; |
506 | 509 | ||
507 | bool res = false; | 510 | bool res = false; |
508 | 511 | ||
509 | struct timeval tvs, tvn; | 512 | struct timeval tvs, tvn; |
510 | ::gettimeofday ( &tvs, 0 ); | 513 | ::gettimeofday ( &tvs, 0 ); |
511 | 514 | ||
512 | ::sync ( ); // flush fs caches | 515 | ::sync ( ); // flush fs caches |
513 | res = ( ::system ( "apm --suspend" ) == 0 ); | 516 | res = ( ::system ( "apm --suspend" ) == 0 ); |
514 | 517 | ||
515 | // This is needed because the iPAQ apm implementation is asynchronous and we | 518 | // This is needed because the iPAQ apm implementation is asynchronous and we |
516 | // can not be sure when exactly the device is really suspended | 519 | // can not be sure when exactly the device is really suspended |
517 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 520 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
518 | 521 | ||
519 | if ( res ) { | 522 | if ( res ) { |
520 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 523 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
521 | ::usleep ( 200 * 1000 ); | 524 | ::usleep ( 200 * 1000 ); |
522 | ::gettimeofday ( &tvn, 0 ); | 525 | ::gettimeofday ( &tvn, 0 ); |
@@ -740,97 +743,97 @@ OLedState ODevice::ledState ( OLed /*which*/ ) const | |||
740 | /** | 743 | /** |
741 | * Set the state for a LED | 744 | * Set the state for a LED |
742 | * @param which Which OLed to use | 745 | * @param which Which OLed to use |
743 | * @param st The state to set | 746 | * @param st The state to set |
744 | * @return success or failure | 747 | * @return success or failure |
745 | */ | 748 | */ |
746 | bool ODevice::setLedState ( OLed which, OLedState st ) | 749 | bool ODevice::setLedState ( OLed which, OLedState st ) |
747 | { | 750 | { |
748 | Q_UNUSED( which ) | 751 | Q_UNUSED( which ) |
749 | Q_UNUSED( st ) | 752 | Q_UNUSED( st ) |
750 | return false; | 753 | return false; |
751 | } | 754 | } |
752 | 755 | ||
753 | /** | 756 | /** |
754 | * @return if the device has a light sensor | 757 | * @return if the device has a light sensor |
755 | */ | 758 | */ |
756 | bool ODevice::hasLightSensor ( ) const | 759 | bool ODevice::hasLightSensor ( ) const |
757 | { | 760 | { |
758 | return false; | 761 | return false; |
759 | } | 762 | } |
760 | 763 | ||
761 | /** | 764 | /** |
762 | * @return a value from the light senso | 765 | * @return a value from the light senso |
763 | */ | 766 | */ |
764 | int ODevice::readLightSensor ( ) | 767 | int ODevice::readLightSensor ( ) |
765 | { | 768 | { |
766 | return -1; | 769 | return -1; |
767 | } | 770 | } |
768 | 771 | ||
769 | /** | 772 | /** |
770 | * @return the light sensor resolution whatever that is ;) | 773 | * @return the light sensor resolution whatever that is ;) |
771 | */ | 774 | */ |
772 | int ODevice::lightSensorResolution ( ) const | 775 | int ODevice::lightSensorResolution ( ) const |
773 | { | 776 | { |
774 | return 0; | 777 | return 0; |
775 | } | 778 | } |
776 | 779 | ||
777 | /** | 780 | /** |
778 | * @return a list with CPU frequencies supported by the hardware | 781 | * @return a list with CPU frequencies supported by the hardware |
779 | */ | 782 | */ |
780 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 783 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
781 | { | 784 | { |
782 | return *d->m_cpu_frequencies; | 785 | return *d->m_cpu_frequencies; |
783 | } | 786 | } |
784 | 787 | ||
785 | 788 | ||
786 | /** | 789 | /** |
787 | * Set desired CPU frequency | 790 | * Set desired CPU frequency |
788 | * | 791 | * |
789 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 792 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
790 | */ | 793 | */ |
791 | bool ODevice::setCurrentCpuFrequency(uint index) | 794 | bool ODevice::setCurrentCpuFrequency(uint index) |
792 | { | 795 | { |
793 | if (index >= d->m_cpu_frequencies->count()) | 796 | if (index >= d->m_cpu_frequencies->count()) |
794 | return false; | 797 | return false; |
795 | 798 | ||
796 | char *freq = d->m_cpu_frequencies->at(index); | 799 | char *freq = d->m_cpu_frequencies->at(index); |
797 | qWarning("set freq to %s", freq); | 800 | qWarning("set freq to %s", freq); |
798 | 801 | ||
799 | int fd; | 802 | int fd; |
800 | 803 | ||
801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 804 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
802 | char writeCommand[50]; | 805 | char writeCommand[50]; |
803 | const int count = sprintf(writeCommand, "%s\n", freq); | 806 | const int count = sprintf(writeCommand, "%s\n", freq); |
804 | int res = (::write(fd, writeCommand, count) != -1); | 807 | int res = (::write(fd, writeCommand, count) != -1); |
805 | ::close(fd); | 808 | ::close(fd); |
806 | return res; | 809 | return res; |
807 | } | 810 | } |
808 | 811 | ||
809 | return false; | 812 | return false; |
810 | } | 813 | } |
811 | 814 | ||
812 | 815 | ||
813 | /** | 816 | /** |
814 | * @return a list of hardware buttons | 817 | * @return a list of hardware buttons |
815 | */ | 818 | */ |
816 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 819 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
817 | { | 820 | { |
818 | initButtons ( ); | 821 | initButtons ( ); |
819 | 822 | ||
820 | return *d-> m_buttons; | 823 | return *d-> m_buttons; |
821 | } | 824 | } |
822 | 825 | ||
823 | /** | 826 | /** |
824 | * @return The amount of time that would count as a hold | 827 | * @return The amount of time that would count as a hold |
825 | */ | 828 | */ |
826 | uint ODevice::buttonHoldTime ( ) const | 829 | uint ODevice::buttonHoldTime ( ) const |
827 | { | 830 | { |
828 | return d-> m_holdtime; | 831 | return d-> m_holdtime; |
829 | } | 832 | } |
830 | 833 | ||
831 | /** | 834 | /** |
832 | * This method return a ODeviceButton for a key code | 835 | * This method return a ODeviceButton for a key code |
833 | * or 0 if no special hardware button is available for the device | 836 | * or 0 if no special hardware button is available for the device |
834 | * | 837 | * |
835 | * @return The devicebutton or 0l | 838 | * @return The devicebutton or 0l |
836 | * @see ODeviceButton | 839 | * @see ODeviceButton |
@@ -875,101 +878,99 @@ void ODevice::reloadButtonMapping ( ) | |||
875 | 878 | ||
876 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 879 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
877 | } | 880 | } |
878 | } | 881 | } |
879 | 882 | ||
880 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 883 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
881 | { | 884 | { |
882 | initButtons ( ); | 885 | initButtons ( ); |
883 | 886 | ||
884 | QString mb_chan; | 887 | QString mb_chan; |
885 | 888 | ||
886 | if ( button >= (int) d-> m_buttons-> count ( )) | 889 | if ( button >= (int) d-> m_buttons-> count ( )) |
887 | return; | 890 | return; |
888 | 891 | ||
889 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 892 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
890 | b. setPressedAction ( action ); | 893 | b. setPressedAction ( action ); |
891 | 894 | ||
892 | mb_chan=b. pressedAction ( ). channel ( ); | 895 | mb_chan=b. pressedAction ( ). channel ( ); |
893 | 896 | ||
894 | Config buttonFile ( "ButtonSettings" ); | 897 | Config buttonFile ( "ButtonSettings" ); |
895 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 898 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
896 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 899 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
897 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 900 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
898 | 901 | ||
899 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 902 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
900 | 903 | ||
901 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 904 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
902 | } | 905 | } |
903 | 906 | ||
904 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 907 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
905 | { | 908 | { |
906 | initButtons ( ); | 909 | initButtons ( ); |
907 | 910 | ||
908 | if ( button >= (int) d-> m_buttons-> count ( )) | 911 | if ( button >= (int) d-> m_buttons-> count ( )) |
909 | return; | 912 | return; |
910 | 913 | ||
911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 914 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
912 | b. setHeldAction ( action ); | 915 | b. setHeldAction ( action ); |
913 | 916 | ||
914 | Config buttonFile ( "ButtonSettings" ); | 917 | Config buttonFile ( "ButtonSettings" ); |
915 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 918 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 919 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 920 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
918 | 921 | ||
919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 922 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
920 | 923 | ||
921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 924 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
922 | } | 925 | } |
923 | void ODevice::virtual_hook( int id, void* data ) { | 926 | void ODevice::virtual_hook(int, void* ){ |
924 | Q_UNUSED(id); | ||
925 | Q_UNUSED(data); | ||
926 | } | ||
927 | 927 | ||
928 | } | ||
928 | 929 | ||
929 | 930 | ||
930 | /************************************************** | 931 | /************************************************** |
931 | * | 932 | * |
932 | * iPAQ | 933 | * iPAQ |
933 | * | 934 | * |
934 | **************************************************/ | 935 | **************************************************/ |
935 | 936 | ||
936 | void iPAQ::init ( ) | 937 | void iPAQ::init ( ) |
937 | { | 938 | { |
938 | d-> m_vendorstr = "HP"; | 939 | d-> m_vendorstr = "HP"; |
939 | d-> m_vendor = Vendor_HP; | 940 | d-> m_vendor = Vendor_HP; |
940 | 941 | ||
941 | QFile f ( "/proc/hal/model" ); | 942 | QFile f ( "/proc/hal/model" ); |
942 | 943 | ||
943 | if ( f. open ( IO_ReadOnly )) { | 944 | if ( f. open ( IO_ReadOnly )) { |
944 | QTextStream ts ( &f ); | 945 | QTextStream ts ( &f ); |
945 | 946 | ||
946 | d-> m_modelstr = "H" + ts. readLine ( ); | 947 | d-> m_modelstr = "H" + ts. readLine ( ); |
947 | 948 | ||
948 | if ( d-> m_modelstr == "H3100" ) | 949 | if ( d-> m_modelstr == "H3100" ) |
949 | d-> m_model = Model_iPAQ_H31xx; | 950 | d-> m_model = Model_iPAQ_H31xx; |
950 | else if ( d-> m_modelstr == "H3600" ) | 951 | else if ( d-> m_modelstr == "H3600" ) |
951 | d-> m_model = Model_iPAQ_H36xx; | 952 | d-> m_model = Model_iPAQ_H36xx; |
952 | else if ( d-> m_modelstr == "H3700" ) | 953 | else if ( d-> m_modelstr == "H3700" ) |
953 | d-> m_model = Model_iPAQ_H37xx; | 954 | d-> m_model = Model_iPAQ_H37xx; |
954 | else if ( d-> m_modelstr == "H3800" ) | 955 | else if ( d-> m_modelstr == "H3800" ) |
955 | d-> m_model = Model_iPAQ_H38xx; | 956 | d-> m_model = Model_iPAQ_H38xx; |
956 | else if ( d-> m_modelstr == "H3900" ) | 957 | else if ( d-> m_modelstr == "H3900" ) |
957 | d-> m_model = Model_iPAQ_H39xx; | 958 | d-> m_model = Model_iPAQ_H39xx; |
958 | else | 959 | else |
959 | d-> m_model = Model_Unknown; | 960 | d-> m_model = Model_Unknown; |
960 | 961 | ||
961 | f. close ( ); | 962 | f. close ( ); |
962 | } | 963 | } |
963 | 964 | ||
964 | switch ( d-> m_model ) { | 965 | switch ( d-> m_model ) { |
965 | case Model_iPAQ_H31xx: | 966 | case Model_iPAQ_H31xx: |
966 | case Model_iPAQ_H38xx: | 967 | case Model_iPAQ_H38xx: |
967 | d-> m_rotation = Rot90; | 968 | d-> m_rotation = Rot90; |
968 | break; | 969 | break; |
969 | case Model_iPAQ_H36xx: | 970 | case Model_iPAQ_H36xx: |
970 | case Model_iPAQ_H37xx: | 971 | case Model_iPAQ_H37xx: |
971 | case Model_iPAQ_H39xx: | 972 | case Model_iPAQ_H39xx: |
972 | default: | 973 | default: |
973 | d-> m_rotation = Rot270; | 974 | d-> m_rotation = Rot270; |
974 | break; | 975 | break; |
975 | } | 976 | } |
@@ -1603,97 +1604,96 @@ bool Zaurus::setSoftSuspend ( bool soft ) | |||
1603 | if ( soft ) | 1604 | if ( soft ) |
1604 | sources &= ~APM_EVT_POWER_BUTTON; | 1605 | sources &= ~APM_EVT_POWER_BUTTON; |
1605 | else | 1606 | else |
1606 | sources |= APM_EVT_POWER_BUTTON; | 1607 | sources |= APM_EVT_POWER_BUTTON; |
1607 | 1608 | ||
1608 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1609 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1609 | res = true; | 1610 | res = true; |
1610 | else | 1611 | else |
1611 | perror ( "APM_IOCGEVTSRC" ); | 1612 | perror ( "APM_IOCGEVTSRC" ); |
1612 | } | 1613 | } |
1613 | else | 1614 | else |
1614 | perror ( "APM_IOCGEVTSRC" ); | 1615 | perror ( "APM_IOCGEVTSRC" ); |
1615 | 1616 | ||
1616 | ::close ( fd ); | 1617 | ::close ( fd ); |
1617 | } | 1618 | } |
1618 | else | 1619 | else |
1619 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1620 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1620 | 1621 | ||
1621 | return res; | 1622 | return res; |
1622 | } | 1623 | } |
1623 | 1624 | ||
1624 | 1625 | ||
1625 | bool Zaurus::setDisplayBrightness ( int bright ) | 1626 | bool Zaurus::setDisplayBrightness ( int bright ) |
1626 | { | 1627 | { |
1627 | bool res = false; | 1628 | bool res = false; |
1628 | int fd; | 1629 | int fd; |
1629 | 1630 | ||
1630 | if ( bright > 255 ) | 1631 | if ( bright > 255 ) |
1631 | bright = 255; | 1632 | bright = 255; |
1632 | if ( bright < 0 ) | 1633 | if ( bright < 0 ) |
1633 | bright = 0; | 1634 | bright = 0; |
1634 | 1635 | ||
1635 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1636 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1636 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1637 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1637 | if ( bright && !bl ) | 1638 | if ( bright && !bl ) |
1638 | bl = 1; | 1639 | bl = 1; |
1639 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1640 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1640 | ::close ( fd ); | 1641 | ::close ( fd ); |
1641 | } | 1642 | } |
1642 | return res; | 1643 | return res; |
1643 | } | 1644 | } |
1644 | 1645 | ||
1645 | 1646 | ||
1646 | int Zaurus::displayBrightnessResolution ( ) const | 1647 | int Zaurus::displayBrightnessResolution ( ) const |
1647 | { | 1648 | { |
1648 | return 5; | 1649 | return 5; |
1649 | } | 1650 | } |
1650 | 1651 | ||
1651 | |||
1652 | /************************************************** | 1652 | /************************************************** |
1653 | * | 1653 | * |
1654 | * SIMpad | 1654 | * SIMpad |
1655 | * | 1655 | * |
1656 | **************************************************/ | 1656 | **************************************************/ |
1657 | 1657 | ||
1658 | void SIMpad::init ( ) | 1658 | void SIMpad::init ( ) |
1659 | { | 1659 | { |
1660 | d-> m_vendorstr = "SIEMENS"; | 1660 | d-> m_vendorstr = "SIEMENS"; |
1661 | d-> m_vendor = Vendor_SIEMENS; | 1661 | d-> m_vendor = Vendor_SIEMENS; |
1662 | 1662 | ||
1663 | QFile f ( "/proc/hal/model" ); | 1663 | QFile f ( "/proc/hal/model" ); |
1664 | 1664 | ||
1665 | //TODO Implement model checking | 1665 | //TODO Implement model checking |
1666 | //FIXME For now we assume an SL4 | 1666 | //FIXME For now we assume an SL4 |
1667 | 1667 | ||
1668 | d-> m_modelstr = "SL4"; | 1668 | d-> m_modelstr = "SL4"; |
1669 | d-> m_model = Model_SIMpad_SL4; | 1669 | d-> m_model = Model_SIMpad_SL4; |
1670 | 1670 | ||
1671 | switch ( d-> m_model ) { | 1671 | switch ( d-> m_model ) { |
1672 | default: | 1672 | default: |
1673 | d-> m_rotation = Rot0; | 1673 | d-> m_rotation = Rot0; |
1674 | d-> m_direction = CCW; | 1674 | d-> m_direction = CCW; |
1675 | d-> m_holdtime = 1000; // 1000ms | 1675 | d-> m_holdtime = 1000; // 1000ms |
1676 | 1676 | ||
1677 | break; | 1677 | break; |
1678 | } | 1678 | } |
1679 | 1679 | ||
1680 | f. setName ( "/etc/familiar-version" ); | 1680 | f. setName ( "/etc/familiar-version" ); |
1681 | if ( f. open ( IO_ReadOnly )) { | 1681 | if ( f. open ( IO_ReadOnly )) { |
1682 | d-> m_systemstr = "Familiar"; | 1682 | d-> m_systemstr = "Familiar"; |
1683 | d-> m_system = System_Familiar; | 1683 | d-> m_system = System_Familiar; |
1684 | 1684 | ||
1685 | QTextStream ts ( &f ); | 1685 | QTextStream ts ( &f ); |
1686 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 1686 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
1687 | 1687 | ||
1688 | f. close ( ); | 1688 | f. close ( ); |
1689 | } else { | 1689 | } else { |
1690 | f. setName ( "/etc/oz_version" ); | 1690 | f. setName ( "/etc/oz_version" ); |
1691 | 1691 | ||
1692 | if ( f. open ( IO_ReadOnly )) { | 1692 | if ( f. open ( IO_ReadOnly )) { |
1693 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 1693 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
1694 | d-> m_system = System_OpenZaurus; | 1694 | d-> m_system = System_OpenZaurus; |
1695 | 1695 | ||
1696 | QTextStream ts ( &f ); | 1696 | QTextStream ts ( &f ); |
1697 | ts.setDevice ( &f ); | 1697 | ts.setDevice ( &f ); |
1698 | d-> m_sysverstr = ts. readLine ( ); | 1698 | d-> m_sysverstr = ts. readLine ( ); |
1699 | f. close ( ); | 1699 | f. close ( ); |
@@ -1844,300 +1844,315 @@ void SIMpad::alarmSound ( ) | |||
1844 | #ifndef QT_NO_SOUND | 1844 | #ifndef QT_NO_SOUND |
1845 | static Sound snd ( "alarm" ); | 1845 | static Sound snd ( "alarm" ); |
1846 | int fd; | 1846 | int fd; |
1847 | int vol; | 1847 | int vol; |
1848 | bool vol_reset = false; | 1848 | bool vol_reset = false; |
1849 | 1849 | ||
1850 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1850 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1851 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1851 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1852 | Config cfg ( "qpe" ); | 1852 | Config cfg ( "qpe" ); |
1853 | cfg. setGroup ( "Volume" ); | 1853 | cfg. setGroup ( "Volume" ); |
1854 | 1854 | ||
1855 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1855 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1856 | if ( volalarm < 0 ) | 1856 | if ( volalarm < 0 ) |
1857 | volalarm = 0; | 1857 | volalarm = 0; |
1858 | else if ( volalarm > 100 ) | 1858 | else if ( volalarm > 100 ) |
1859 | volalarm = 100; | 1859 | volalarm = 100; |
1860 | volalarm |= ( volalarm << 8 ); | 1860 | volalarm |= ( volalarm << 8 ); |
1861 | 1861 | ||
1862 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1862 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1863 | vol_reset = true; | 1863 | vol_reset = true; |
1864 | } | 1864 | } |
1865 | } | 1865 | } |
1866 | 1866 | ||
1867 | snd. play ( ); | 1867 | snd. play ( ); |
1868 | while ( !snd. isFinished ( )) | 1868 | while ( !snd. isFinished ( )) |
1869 | qApp-> processEvents ( ); | 1869 | qApp-> processEvents ( ); |
1870 | 1870 | ||
1871 | if ( fd >= 0 ) { | 1871 | if ( fd >= 0 ) { |
1872 | if ( vol_reset ) | 1872 | if ( vol_reset ) |
1873 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1873 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1874 | ::close ( fd ); | 1874 | ::close ( fd ); |
1875 | } | 1875 | } |
1876 | #endif | 1876 | #endif |
1877 | } | 1877 | } |
1878 | 1878 | ||
1879 | 1879 | ||
1880 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | 1880 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm |
1881 | { | 1881 | { |
1882 | qDebug( "ODevice for SIMpad: suspend()" ); | 1882 | qDebug( "ODevice for SIMpad: suspend()" ); |
1883 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 1883 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
1884 | return false; | 1884 | return false; |
1885 | 1885 | ||
1886 | bool res = false; | 1886 | bool res = false; |
1887 | 1887 | ||
1888 | struct timeval tvs, tvn; | 1888 | struct timeval tvs, tvn; |
1889 | ::gettimeofday ( &tvs, 0 ); | 1889 | ::gettimeofday ( &tvs, 0 ); |
1890 | 1890 | ||
1891 | ::sync ( ); // flush fs caches | 1891 | ::sync ( ); // flush fs caches |
1892 | res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) | 1892 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
1893 | 1893 | ||
1894 | return res; | 1894 | return res; |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | 1897 | ||
1898 | bool SIMpad::setSoftSuspend ( bool soft ) | 1898 | bool SIMpad::setSoftSuspend ( bool soft ) |
1899 | { | 1899 | { |
1900 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 1900 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
1901 | return false; | 1901 | return false; |
1902 | } | 1902 | } |
1903 | 1903 | ||
1904 | 1904 | ||
1905 | bool SIMpad::setDisplayStatus ( bool on ) | 1905 | bool SIMpad::setDisplayStatus ( bool on ) |
1906 | { | 1906 | { |
1907 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 1907 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
1908 | 1908 | ||
1909 | bool res = false; | 1909 | bool res = false; |
1910 | int fd; | 1910 | int fd; |
1911 | 1911 | ||
1912 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 1912 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
1913 | 1913 | ||
1914 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 1914 | res = ( ::system( (const char*) cmdline ) == 0 ); |
1915 | res = ( ::system( (const char*) cmdline ) == 0 ); | 1915 | |
1916 | ::close ( fd ); | ||
1917 | } | ||
1918 | return res; | 1916 | return res; |
1919 | } | 1917 | } |
1920 | 1918 | ||
1921 | 1919 | ||
1922 | bool SIMpad::setDisplayBrightness ( int bright ) | 1920 | bool SIMpad::setDisplayBrightness ( int bright ) |
1923 | { | 1921 | { |
1924 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 1922 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
1925 | bool res = false; | 1923 | bool res = false; |
1926 | int fd; | 1924 | int fd; |
1927 | 1925 | ||
1928 | if ( bright > 255 ) | 1926 | if ( bright > 255 ) |
1929 | bright = 255; | 1927 | bright = 255; |
1930 | if ( bright < 0 ) | 1928 | if ( bright < 1 ) |
1931 | bright = 0; | 1929 | bright = 0; |
1932 | 1930 | ||
1933 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 1931 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
1934 | int value = 255 - bright; | 1932 | int value = 255 - bright; |
1935 | const int mask = SIMPAD_BACKLIGHT_MASK; | 1933 | const int mask = SIMPAD_BACKLIGHT_MASK; |
1936 | value = value << 8; | 1934 | value = value << 8; |
1937 | value += mask; | 1935 | value += mask; |
1938 | char writeCommand[100]; | 1936 | char writeCommand[100]; |
1939 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 1937 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
1940 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 1938 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
1941 | ::close ( fd ); | 1939 | ::close ( fd ); |
1942 | } | 1940 | } |
1943 | return res; | 1941 | return res; |
1944 | } | 1942 | } |
1945 | 1943 | ||
1946 | 1944 | ||
1947 | int SIMpad::displayBrightnessResolution ( ) const | 1945 | int SIMpad::displayBrightnessResolution ( ) const |
1948 | { | 1946 | { |
1949 | switch ( model ( )) { | 1947 | return 255; // All SIMpad models share the same display |
1950 | case Model_SIMpad_CL4: | ||
1951 | case Model_SIMpad_SL4: | ||
1952 | case Model_SIMpad_SLC: | ||
1953 | case Model_SIMpad_TSinus: | ||
1954 | return 255; //TODO find out if this is save | ||
1955 | |||
1956 | default: | ||
1957 | return 2; | ||
1958 | } | ||
1959 | } | 1948 | } |
1960 | 1949 | ||
1961 | /************************************************** | 1950 | /************************************************** |
1962 | * | 1951 | * |
1963 | * Ramses | 1952 | * Ramses |
1964 | * | 1953 | * |
1965 | **************************************************/ | 1954 | **************************************************/ |
1966 | 1955 | ||
1967 | void Ramses::init() | 1956 | void Ramses::init() |
1968 | { | 1957 | { |
1969 | d->m_vendorstr = "M und N"; | 1958 | d->m_vendorstr = "M und N"; |
1970 | d->m_vendor = Vendor_MundN; | 1959 | d->m_vendor = Vendor_MundN; |
1971 | 1960 | ||
1972 | QFile f("/proc/sys/board/ramses"); | 1961 | QFile f("/proc/sys/board/ramses"); |
1973 | 1962 | ||
1974 | d->m_modelstr = "Ramses"; | 1963 | d->m_modelstr = "Ramses"; |
1975 | d->m_model = Model_Ramses_MNCI; | 1964 | d->m_model = Model_Ramses_MNCI; |
1976 | 1965 | ||
1977 | d->m_rotation = Rot180; | 1966 | d->m_rotation = Rot0; |
1978 | d->m_direction = CW; | 1967 | d->m_holdtime = 1000; |
1979 | d->m_holdtime = 1000; | ||
1980 | 1968 | ||
1981 | f.setName("/etc/oz_version"); | 1969 | f.setName("/etc/oz_version"); |
1982 | 1970 | ||
1983 | if (f.open(IO_ReadOnly)) { | 1971 | if (f.open(IO_ReadOnly)) { |
1984 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1972 | d->m_systemstr = "OpenEmbedded/Ramses"; |
1985 | d->m_system = System_OpenZaurus; | 1973 | d->m_system = System_OpenZaurus; |
1986 | 1974 | ||
1987 | QTextStream ts(&f); | 1975 | QTextStream ts(&f); |
1988 | ts.setDevice(&f); | 1976 | ts.setDevice(&f); |
1989 | d->m_sysverstr = ts.readLine(); | 1977 | d->m_sysverstr = ts.readLine(); |
1990 | f.close(); | 1978 | f.close(); |
1991 | } | 1979 | } |
1992 | 1980 | ||
1993 | m_power_timer = 0; | 1981 | m_power_timer = 0; |
1994 | 1982 | ||
1995 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 1983 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
1996 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** | 1984 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
1997 | #define OC(x...) x | 1985 | #define OC(x...) x |
1998 | #else | 1986 | #else |
1999 | #define OC(x...) | 1987 | #define OC(x...) |
2000 | #endif | 1988 | #endif |
2001 | 1989 | ||
2002 | 1990 | ||
2003 | // This table is true for a Intel XScale PXA 255 | 1991 | // This table is true for a Intel XScale PXA 255 |
2004 | 1992 | ||
2005 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 1993 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
2006 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 1994 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
2007 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 1995 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
2008 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 1996 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
2009 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 1997 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
2010 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 1998 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
2011 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 1999 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
2012 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 2000 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
2013 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 2001 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
2014 | 2002 | ||
2015 | } | 2003 | } |
2016 | 2004 | ||
2017 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 2005 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
2018 | { | 2006 | { |
2019 | Q_UNUSED( keycode ); | 2007 | Q_UNUSED( keycode ); |
2020 | Q_UNUSED( modifiers ); | 2008 | Q_UNUSED( modifiers ); |
2021 | Q_UNUSED( isPress ); | 2009 | Q_UNUSED( isPress ); |
2022 | Q_UNUSED( autoRepeat ); | 2010 | Q_UNUSED( autoRepeat ); |
2023 | return false; | 2011 | return false; |
2024 | } | 2012 | } |
2025 | 2013 | ||
2026 | void Ramses::timerEvent(QTimerEvent *) | 2014 | void Ramses::timerEvent(QTimerEvent *) |
2027 | { | 2015 | { |
2028 | killTimer(m_power_timer); | 2016 | killTimer(m_power_timer); |
2029 | m_power_timer = 0; | 2017 | m_power_timer = 0; |
2030 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2018 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
2031 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2019 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
2032 | } | 2020 | } |
2033 | 2021 | ||
2034 | 2022 | ||
2035 | bool Ramses::setSoftSuspend(bool soft) | 2023 | bool Ramses::setSoftSuspend(bool soft) |
2036 | { | 2024 | { |
2037 | Q_UNUSED(soft); | 2025 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
2038 | return true; | 2026 | #if 0 |
2039 | } | ||
2040 | |||
2041 | bool Ramses::suspend() | ||
2042 | { | ||
2043 | //qDebug("Ramses::suspend()"); | ||
2044 | if ( !isQWS() ) // only qwsserver is allowed to suspend | ||
2045 | return false; | ||
2046 | |||
2047 | bool res = false; | 2027 | bool res = false; |
2048 | int fd; | 2028 | int fd; |
2049 | 2029 | ||
2050 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { | 2030 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
2051 | res = ( ::write ( fd, "1", 1 ) != -1 ); | 2031 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
2032 | |||
2033 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | ||
2034 | |||
2035 | if (sources >= 0) { | ||
2036 | if (soft) | ||
2037 | sources &= ~APM_EVT_POWER_BUTTON; | ||
2038 | else | ||
2039 | sources |= APM_EVT_POWER_BUTTON; | ||
2040 | |||
2041 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | ||
2042 | res = true; | ||
2043 | else | ||
2044 | perror("APM_IOCGEVTSRC"); | ||
2045 | } | ||
2046 | else | ||
2047 | perror("APM_IOCGEVTSRC"); | ||
2048 | |||
2052 | ::close(fd); | 2049 | ::close(fd); |
2053 | } | 2050 | } |
2054 | return res; | 2051 | else |
2052 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | ||
2053 | |||
2054 | return res; | ||
2055 | #else | ||
2056 | return true; | ||
2057 | #endif | ||
2058 | } | ||
2059 | |||
2060 | bool Ramses::suspend ( ) | ||
2061 | { | ||
2062 | qDebug("Ramses::suspend"); | ||
2063 | return false; | ||
2055 | } | 2064 | } |
2056 | 2065 | ||
2057 | /** | 2066 | /** |
2058 | * This sets the display on or off | 2067 | * This sets the display on or off |
2059 | */ | 2068 | */ |
2060 | bool Ramses::setDisplayStatus(bool on) | 2069 | bool Ramses::setDisplayStatus(bool on) |
2061 | { | 2070 | { |
2062 | //qDebug("Ramses::setDisplayStatus(%d)", on); | 2071 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2072 | #if 0 | ||
2063 | bool res = false; | 2073 | bool res = false; |
2064 | int fd; | 2074 | int fd; |
2065 | 2075 | ||
2066 | if ((fd = ::open ("/dev/fb/1", O_RDWR)) >= 0) { | 2076 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2067 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2077 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2068 | ::close(fd); | 2078 | ::close(fd); |
2069 | } | 2079 | } |
2070 | return res; | 2080 | return res; |
2081 | #else | ||
2082 | return true; | ||
2083 | #endif | ||
2071 | } | 2084 | } |
2072 | 2085 | ||
2073 | 2086 | ||
2074 | /* | 2087 | /* |
2075 | * We get something between 0..255 into us | 2088 | * We get something between 0..255 into us |
2076 | */ | 2089 | */ |
2077 | bool Ramses::setDisplayBrightness(int bright) | 2090 | bool Ramses::setDisplayBrightness(int bright) |
2078 | { | 2091 | { |
2079 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2092 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2080 | bool res = false; | 2093 | bool res = false; |
2081 | int fd; | 2094 | int fd; |
2082 | 2095 | ||
2083 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2096 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2084 | 2097 | ||
2085 | if (bright > 255 ) | 2098 | if (bright > 255 ) |
2086 | bright = 255; | 2099 | bright = 255; |
2087 | if (bright < 0) | 2100 | if (bright < 0) |
2088 | bright = 0; | 2101 | bright = 0; |
2089 | 2102 | ||
2090 | // Turn backlight completely off | 2103 | // Turn backlight completely off |
2091 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 2104 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
2092 | char writeCommand[10]; | 2105 | char writeCommand[10]; |
2093 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 2106 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
2094 | res = (::write(fd, writeCommand, count) != -1); | 2107 | res = (::write(fd, writeCommand, count) != -1); |
2095 | ::close(fd); | 2108 | ::close(fd); |
2096 | } | 2109 | } |
2097 | 2110 | ||
2098 | // scale backlight brightness to hardware | 2111 | // scale backlight brightness to hardware |
2099 | if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { | 2112 | bright = 500-(bright * 500 / 255); |
2100 | //qDebug(" %d -> pwm1", bright); | 2113 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2114 | qDebug(" %d -> pwm1", bright); | ||
2101 | char writeCommand[100]; | 2115 | char writeCommand[100]; |
2102 | const int count = sprintf(writeCommand, "%d\n", bright); | 2116 | const int count = sprintf(writeCommand, "%d\n", bright); |
2103 | res = (::write(fd, writeCommand, count) != -1); | 2117 | res = (::write(fd, writeCommand, count) != -1); |
2104 | ::close(fd); | 2118 | ::close(fd); |
2105 | } | 2119 | } |
2106 | return res; | 2120 | return res; |
2107 | } | 2121 | } |
2108 | 2122 | ||
2109 | 2123 | ||
2110 | int Ramses::displayBrightnessResolution() const | 2124 | int Ramses::displayBrightnessResolution() const |
2111 | { | 2125 | { |
2112 | return 256; | 2126 | return 32; |
2113 | } | 2127 | } |
2114 | 2128 | ||
2115 | bool Ramses::setDisplayContrast(int contr) | 2129 | bool Ramses::setDisplayContrast(int contr) |
2116 | { | 2130 | { |
2117 | //qDebug("Ramses::setDisplayContrast(%d)", contr); | 2131 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2118 | bool res = false; | 2132 | bool res = false; |
2119 | int fd; | 2133 | int fd; |
2120 | 2134 | ||
2121 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2135 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2122 | 2136 | ||
2123 | if (contr > 255 ) | 2137 | if (contr > 255 ) |
2124 | contr = 255; | 2138 | contr = 255; |
2125 | if (contr < 0) | 2139 | if (contr < 0) |
2126 | contr = 0; | 2140 | contr = 0; |
2141 | contr = 90 - (contr * 20 / 255); | ||
2127 | 2142 | ||
2128 | if ((fd = ::open("/proc/sys/board/lcd_contrast", O_WRONLY)) >= 0) { | 2143 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2129 | //qDebug(" %d -> pwm0", contr); | 2144 | qDebug(" %d -> pwm0", contr); |
2130 | char writeCommand[100]; | 2145 | char writeCommand[100]; |
2131 | const int count = sprintf(writeCommand, "%d\n", contr); | 2146 | const int count = sprintf(writeCommand, "%d\n", contr); |
2132 | res = (::write(fd, writeCommand, count) != -1); | 2147 | res = (::write(fd, writeCommand, count) != -1); |
2133 | res = true; | 2148 | res = true; |
2134 | ::close(fd); | 2149 | ::close(fd); |
2135 | } | 2150 | } |
2136 | return res; | 2151 | return res; |
2137 | } | 2152 | } |
2138 | 2153 | ||
2139 | 2154 | ||
2140 | int Ramses::displayContrastResolution() const | 2155 | int Ramses::displayContrastResolution() const |
2141 | { | 2156 | { |
2142 | return 256; | 2157 | return 20; |
2143 | } | 2158 | } |
diff --git a/libopie/ofiledialog.cc b/libopie/ofiledialog.cc index 9e725c2..5511b24 100644 --- a/libopie/ofiledialog.cc +++ b/libopie/ofiledialog.cc | |||
@@ -1,156 +1,215 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002,2003 <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/config.h> | ||
31 | #include <qpe/qpeapplication.h> | ||
32 | |||
33 | #include <qfileinfo.h> | ||
30 | #include <qstring.h> | 34 | #include <qstring.h> |
31 | #include <qapplication.h> | 35 | #include <qapplication.h> |
32 | #include <qlayout.h> | 36 | #include <qlayout.h> |
33 | 37 | ||
38 | |||
34 | #include "ofiledialog.h" | 39 | #include "ofiledialog.h" |
35 | 40 | ||
41 | |||
42 | namespace { | ||
43 | /* | ||
44 | * helper functions to load the start dir | ||
45 | * and to save it | ||
46 | * helper to extract the dir out of a file name | ||
47 | */ | ||
48 | /** | ||
49 | * This method will use Config( argv[0] ); | ||
50 | * @param key The group key used | ||
51 | */ | ||
52 | QString lastUsedDir( const QString& key ) { | ||
53 | if ( qApp->argc() < 1 ) | ||
54 | return QString::null; | ||
55 | |||
56 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname | ||
57 | cfg.setGroup( key ); | ||
58 | return cfg.readEntry("LastDir", QPEApplication::documentDir() ); | ||
59 | } | ||
60 | |||
61 | void saveLastDir( const QString& key, const QString& file ) { | ||
62 | if ( qApp->argc() < 1 ) | ||
63 | return; | ||
64 | |||
65 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); | ||
66 | cfg.setGroup( key ); | ||
67 | QFileInfo inf( file ); | ||
68 | cfg.writeEntry("LastDir", inf.dirPath( true ) ); | ||
69 | } | ||
70 | }; | ||
71 | |||
36 | /** | 72 | /** |
37 | * This constructs a modal dialog | 73 | * This constructs a modal dialog |
38 | * | 74 | * |
39 | * @param caption The caption of the dialog | 75 | * @param caption The caption of the dialog |
40 | * @param wid The parent widget | 76 | * @param wid The parent widget |
41 | * @param mode The mode of the OFileSelector @see OFileSelector | 77 | * @param mode The mode of the OFileSelector @see OFileSelector |
42 | * @param selector The selector of the OFileSelector | 78 | * @param selector The selector of the OFileSelector |
43 | * @param dirName the dir or resource to start from | 79 | * @param dirName the dir or resource to start from |
44 | * @param fileName a proposed or existing filename | 80 | * @param fileName a proposed or existing filename |
45 | * @param mimetypes The mimeTypes | 81 | * @param mimetypes The mimeTypes |
46 | */ | 82 | */ |
47 | OFileDialog::OFileDialog(const QString &caption, | 83 | OFileDialog::OFileDialog(const QString &caption, |
48 | QWidget *wid, int mode, int selector, | 84 | QWidget *wid, int mode, int selector, |
49 | const QString &dirName, | 85 | const QString &dirName, |
50 | const QString &fileName, | 86 | const QString &fileName, |
51 | const QMap<QString,QStringList>& mimetypes ) | 87 | const QMap<QString,QStringList>& mimetypes ) |
52 | : QDialog( wid, "OFileDialog", true ) | 88 | : QDialog( wid, "OFileDialog", true ) |
53 | { | 89 | { |
54 | // QVBoxLayout *lay = new QVBoxLayout(this); | 90 | // QVBoxLayout *lay = new QVBoxLayout(this); |
55 | //showMaximized(); | 91 | //showMaximized(); |
56 | QVBoxLayout *lay = new QVBoxLayout(this ); | 92 | QVBoxLayout *lay = new QVBoxLayout(this ); |
57 | file = new OFileSelector(this , mode, selector, | 93 | file = new OFileSelector(this , mode, selector, |
58 | dirName, fileName, | 94 | dirName, fileName, |
59 | mimetypes ); | 95 | mimetypes ); |
60 | lay->addWidget( file ); | 96 | lay->addWidget( file ); |
61 | 97 | ||
62 | //lay->addWidget( file ); | 98 | //lay->addWidget( file ); |
63 | //showFullScreen(); | 99 | //showFullScreen(); |
64 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); | 100 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); |
65 | connect(file, SIGNAL(fileSelected(const QString&) ), | 101 | connect(file, SIGNAL(fileSelected(const QString&) ), |
66 | this, SLOT(slotFileSelected(const QString&) ) ); | 102 | this, SLOT(slotFileSelected(const QString&) ) ); |
103 | connect(file, SIGNAL(ok() ), | ||
104 | this, SLOT(slotSelectorOk()) ) ; | ||
67 | 105 | ||
106 | connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); | ||
107 | |||
108 | #if 0 | ||
68 | connect(file, SIGNAL(dirSelected(const QString &) ), | 109 | connect(file, SIGNAL(dirSelected(const QString &) ), |
69 | this, SLOT(slotDirSelected(const QString &) ) ); | 110 | this, SLOT(slotDirSelected(const QString &) ) ); |
70 | 111 | #endif | |
71 | |||
72 | file->setYesCancelVisible( false ); // relayout | ||
73 | } | 112 | } |
74 | /** | 113 | /** |
75 | * @returns the mimetype of the selected | 114 | * @returns the mimetype of the selected |
76 | * currently it return QString::null | 115 | * currently it return QString::null |
77 | */ | 116 | */ |
78 | QString OFileDialog::mimetype()const | 117 | QString OFileDialog::mimetype()const |
79 | { | 118 | { |
80 | return QString::null; | 119 | return QString::null; |
81 | } | 120 | } |
82 | 121 | ||
83 | /** | 122 | /** |
84 | * @return the fileName | 123 | * @return the fileName |
85 | */ | 124 | */ |
86 | QString OFileDialog::fileName()const | 125 | QString OFileDialog::fileName()const |
87 | { | 126 | { |
88 | return file->selectedName(); | 127 | return file->selectedName(); |
89 | } | 128 | } |
90 | 129 | ||
91 | /** | 130 | /** |
92 | * return a DocLnk to the current file | 131 | * return a DocLnk to the current file |
93 | */ | 132 | */ |
94 | DocLnk OFileDialog::selectedDocument()const | 133 | DocLnk OFileDialog::selectedDocument()const |
95 | { | 134 | { |
96 | return file->selectedDocument(); | 135 | return file->selectedDocument(); |
97 | } | 136 | } |
98 | 137 | ||
99 | /** | 138 | /** |
100 | * This opens up a filedialog in Open mode | 139 | * This opens up a filedialog in Open mode |
101 | * | 140 | * |
102 | * @param selector the Selector Mode | 141 | * @param selector the Selector Mode |
103 | * @param startDir Where to start from | 142 | * @param startDir Where to start from |
104 | * @param file A proposed filename | 143 | * @param file A proposed filename |
105 | * @param mimes A list of MimeTypes | 144 | * @param mimes A list of MimeTypes |
106 | * @param wid the parent | 145 | * @param wid the parent |
107 | * @param caption of the dialog if QString::null tr("Open") will be used | 146 | * @param caption of the dialog if QString::null tr("Open") will be used |
108 | * @return the fileName or QString::null | 147 | * @return the fileName or QString::null |
109 | */ | 148 | */ |
110 | QString OFileDialog::getOpenFileName(int selector, | 149 | QString OFileDialog::getOpenFileName(int selector, |
111 | const QString &startDir, | 150 | const QString &_startDir, |
112 | const QString &file, | 151 | const QString &file, |
113 | const MimeTypes &mimes, | 152 | const MimeTypes &mimes, |
114 | QWidget *wid, | 153 | QWidget *wid, |
115 | const QString &caption ) | 154 | const QString &caption ) |
116 | { | 155 | { |
117 | QString ret; | 156 | QString ret; |
157 | QString startDir = _startDir; | ||
158 | if (startDir.isEmpty() ) | ||
159 | startDir = lastUsedDir( "FileDialog-OPEN" ); | ||
160 | |||
161 | |||
118 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, | 162 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, |
119 | wid, OFileSelector::OPEN, selector, startDir, file, mimes); | 163 | wid, OFileSelector::Open, selector, startDir, file, mimes); |
120 | dlg.showMaximized(); | 164 | dlg.showMaximized(); |
121 | if( dlg.exec() ) | 165 | if( dlg.exec() ) { |
122 | ret = dlg.fileName(); | 166 | ret = dlg.fileName(); |
167 | saveLastDir( "FileDialog-OPEN", ret ); | ||
168 | } | ||
123 | 169 | ||
124 | return ret; | 170 | return ret; |
125 | } | 171 | } |
126 | 172 | ||
127 | /** | 173 | /** |
128 | * This opens up a file dialog in save mode | 174 | * This opens up a file dialog in save mode |
129 | * @see getOpenFileName | 175 | * @see getOpenFileName |
130 | */ | 176 | */ |
131 | QString OFileDialog::getSaveFileName(int selector, | 177 | QString OFileDialog::getSaveFileName(int selector, |
132 | const QString &startDir, | 178 | const QString &_startDir, |
133 | const QString &file, | 179 | const QString &file, |
134 | const MimeTypes &mimes, | 180 | const MimeTypes &mimes, |
135 | QWidget *wid, | 181 | QWidget *wid, |
136 | const QString &caption ) | 182 | const QString &caption ) |
137 | { | 183 | { |
138 | QString ret; | 184 | QString ret; |
185 | QString startDir = _startDir; | ||
186 | if (startDir.isEmpty() ) | ||
187 | startDir = lastUsedDir( "FileDialog-SAVE" ); | ||
188 | |||
139 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, | 189 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, |
140 | wid, OFileSelector::SAVE, selector, startDir, file, mimes); | 190 | wid, OFileSelector::Save, selector, startDir, file, mimes); |
141 | dlg.showMaximized(); | 191 | dlg.showMaximized(); |
142 | if( dlg.exec() ) | 192 | if( dlg.exec() ) { |
143 | ret = dlg.fileName(); | 193 | ret = dlg.fileName(); |
194 | saveLastDir( "FileDialog-SAVE", ret ); | ||
195 | } | ||
144 | 196 | ||
145 | return ret; | 197 | return ret; |
146 | } | 198 | } |
147 | 199 | ||
148 | void OFileDialog::slotFileSelected(const QString & ) | 200 | void OFileDialog::slotFileSelected(const QString & ) |
149 | { | 201 | { |
150 | accept(); | 202 | accept(); |
151 | } | 203 | } |
152 | void OFileDialog::slotDirSelected(const QString & ) | 204 | |
205 | void OFileDialog::slotSelectorOk( ) | ||
206 | { | ||
207 | accept(); | ||
208 | } | ||
209 | |||
210 | void OFileDialog::slotDirSelected(const QString &dir ) | ||
153 | { | 211 | { |
212 | setCaption( dir ); | ||
154 | // if mode | 213 | // if mode |
155 | //accept(); | 214 | //accept(); |
156 | } | 215 | } |
diff --git a/libopie/ofiledialog.h b/libopie/ofiledialog.h index 309086b..91e0586 100644 --- a/libopie/ofiledialog.h +++ b/libopie/ofiledialog.h | |||
@@ -1,100 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | #ifndef OpieFileDialog_h | 30 | #ifndef OpieFileDialog_h |
31 | #define OpieFileDialog_h | 31 | #define OpieFileDialog_h |
32 | 32 | ||
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | 34 | ||
35 | #include <opie/ofileselector.h> | 35 | #include <opie/ofileselector.h> |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * This class places a OFileSelector inside a QDialog. | 38 | * This class places a OFileSelector inside a QDialog. |
39 | * It provides static method for letting a user chose | 39 | * It provides static method for letting a user chose |
40 | * a file for either opening or saving. | 40 | * a file for either opening or saving. |
41 | * Most of the time the c'tor will not be used instead using | 41 | * Most of the time the c'tor will not be used instead using |
42 | * the static member functions is prefered. | 42 | * the static member functions is prefered. |
43 | * | 43 | * |
44 | * <pre> | 44 | * <pre> |
45 | * QMap<QString, QStringList> mimeTypes; | 45 | * QMap<QString, QStringList> mimeTypes; |
46 | * QStringList types; | 46 | * QStringList types; |
47 | * types << "text/* "; | 47 | * types << "text[slash]* "; |
48 | * mimeTypes.insert( tr("Text"), types ); | 48 | * mimeTypes.insert( tr("Text"), types ); |
49 | * mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment | 49 | * mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment |
50 | * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 50 | * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
51 | * "foo","bar", mimeTypes); | 51 | * "foo","bar", mimeTypes); |
52 | * </pre> | 52 | * </pre> |
53 | * | 53 | * |
54 | * @short A small QDialog swalloing a FileSelector | 54 | * @short A small QDialog swalloing a FileSelector |
55 | * @see QDialog | 55 | * @see QDialog |
56 | * @see OFileSelector | 56 | * @see OFileSelector |
57 | * @version 0.1-unfinished | 57 | * @version 0.1-unfinished |
58 | * @author Holger Freyther ( zecke@handhelds.org ) | 58 | * @author Holger Freyther ( zecke@handhelds.org ) |
59 | */ | 59 | */ |
60 | class OFileDialog : public QDialog { | 60 | class OFileDialog : public QDialog { |
61 | Q_OBJECT | 61 | Q_OBJECT |
62 | public: | 62 | public: |
63 | OFileDialog(const QString &caption, | 63 | OFileDialog(const QString &caption, |
64 | QWidget *, int mode, int selector, | 64 | QWidget *, int mode, int selector, |
65 | const QString &dirName, | 65 | const QString &dirName, |
66 | const QString &fileName = QString::null, | 66 | const QString &fileName = QString::null, |
67 | const MimeTypes &mimetypes = MimeTypes() ); | 67 | const MimeTypes &mimetypes = MimeTypes() ); |
68 | QString mimetype() const; | 68 | QString mimetype() const; |
69 | QString fileName() const; | 69 | QString fileName() const; |
70 | DocLnk selectedDocument()const; | 70 | DocLnk selectedDocument()const; |
71 | 71 | ||
72 | // static methods | 72 | // static methods |
73 | static QString getOpenFileName(int selector, | 73 | static QString getOpenFileName(int selector, |
74 | const QString& startDir = QString::null, | 74 | const QString& startDir = QString::null, |
75 | const QString &fileName = QString::null, | 75 | const QString &fileName = QString::null, |
76 | const MimeTypes& mime = MimeTypes(), | 76 | const MimeTypes& mime = MimeTypes(), |
77 | QWidget *wid = 0, | 77 | QWidget *wid = 0, |
78 | const QString &caption = QString::null ); | 78 | const QString &caption = QString::null ); |
79 | 79 | ||
80 | static QString getSaveFileName(int selector, | 80 | static QString getSaveFileName(int selector, |
81 | const QString& startDir = QString::null, | 81 | const QString& startDir = QString::null, |
82 | const QString& fileName = QString::null, | 82 | const QString& fileName = QString::null, |
83 | const MimeTypes& mimefilter = MimeTypes(), | 83 | const MimeTypes& mimefilter = MimeTypes(), |
84 | QWidget *wid = 0, | 84 | QWidget *wid = 0, |
85 | const QString &caption = QString::null ); | 85 | const QString &caption = QString::null ); |
86 | 86 | ||
87 | //let's OFileSelector catch up first | 87 | //let's OFileSelector catch up first |
88 | //static QString getExistingDirectory(const QString& startDir = QString::null, | 88 | //static QString getExistingDirectory(const QString& startDir = QString::null, |
89 | // QWidget *parent = 0, | 89 | // QWidget *parent = 0, |
90 | // const QString& caption = QString::null ); | 90 | // const QString& caption = QString::null ); |
91 | private: | 91 | private: |
92 | class OFileDialogPrivate; | 92 | class OFileDialogPrivate; |
93 | OFileDialogPrivate *d; | 93 | OFileDialogPrivate *d; |
94 | OFileSelector *file; | 94 | OFileSelector *file; |
95 | 95 | ||
96 | private slots: | 96 | private slots: |
97 | void slotFileSelected( const QString & ); | 97 | void slotFileSelected( const QString & ); |
98 | void slotDirSelected(const QString & ); | 98 | void slotDirSelected(const QString & ); |
99 | void slotSelectorOk(); | ||
99 | }; | 100 | }; |
100 | #endif | 101 | #endif |
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc deleted file mode 100644 index 6748bec..0000000 --- a/libopie/ofileselector.cc +++ b/dev/null | |||
@@ -1,1310 +0,0 @@ | |||
1 | |||
2 | |||
3 | #include <qwmatrix.h> | ||
4 | #include <qcheckbox.h> | ||
5 | #include <qcombobox.h> | ||
6 | #include <qheader.h> | ||
7 | #include <qlabel.h> | ||
8 | #include <qabstractlayout.h> | ||
9 | #include <qlayout.h> | ||
10 | #include <qlineedit.h> | ||
11 | #include <qlistview.h> | ||
12 | #include <qmessagebox.h> | ||
13 | #include <qpainter.h> | ||
14 | #include <qpushbutton.h> | ||
15 | #include <qwidgetstack.h> | ||
16 | #include <qpopupmenu.h> | ||
17 | #include <qdir.h> | ||
18 | #include <qfile.h> | ||
19 | #include <qfileinfo.h> | ||
20 | #include <qtimer.h> | ||
21 | |||
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <qpe/applnk.h> | ||
24 | #include <qpe/fileselector.h> | ||
25 | #include <qpe/global.h> | ||
26 | #include <qpe/mimetype.h> | ||
27 | #include <qpe/resource.h> | ||
28 | #include <qpe/storage.h> | ||
29 | |||
30 | #include <unistd.h> | ||
31 | #include <stdlib.h> | ||
32 | #include <sys/stat.h> | ||
33 | |||
34 | #include "ofileselector.h" | ||
35 | |||
36 | |||
37 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | ||
38 | |||
39 | namespace { | ||
40 | int indexByString( const QComboBox *box, const QString &str ){ | ||
41 | int index= 0; | ||
42 | for(int i= 0; i < box->count(); i++ ){ | ||
43 | if( str == box->text(i ) ){ | ||
44 | index= i; | ||
45 | break; | ||
46 | } | ||
47 | } | ||
48 | return index; | ||
49 | } | ||
50 | class OFileSelectorItem : public QListViewItem { | ||
51 | public: | ||
52 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | ||
53 | const QString &date, const QString &size, const QString &mDir, | ||
54 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | ||
55 | setPixmap(0, pixmap ); | ||
56 | setText(1, path ); | ||
57 | setText(2, size ); | ||
58 | setText(3, date ); | ||
59 | //setText(4, mDir ); | ||
60 | m_dir = mDir; | ||
61 | dir = isDir; | ||
62 | mLocked = isLocked; | ||
63 | } | ||
64 | bool isLocked() const{ | ||
65 | return mLocked; | ||
66 | } | ||
67 | QString directory()const{ | ||
68 | return m_dir; | ||
69 | } | ||
70 | bool isDir()const{ | ||
71 | return dir; | ||
72 | } | ||
73 | QString path()const{ | ||
74 | return text(1 ); | ||
75 | } | ||
76 | QString key(int id, bool )const { | ||
77 | QString ke; | ||
78 | if( id == 0 || id == 1 ){ // name | ||
79 | if( dir ){ | ||
80 | ke.append("0" ); | ||
81 | ke.append( text(1) ); | ||
82 | }else{ | ||
83 | ke.append("1" ); | ||
84 | ke.append( text(1) ); | ||
85 | } | ||
86 | }else if( id == 2 ){ // size | ||
87 | return text(2); | ||
88 | }else if( id == 3 ){ // date | ||
89 | return text(3); | ||
90 | } | ||
91 | return ke; | ||
92 | }; | ||
93 | private: | ||
94 | bool mLocked:1; | ||
95 | bool dir:1; | ||
96 | QString m_dir; | ||
97 | }; | ||
98 | }; | ||
99 | |||
100 | |||
101 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | ||
102 | const QString &dirName, | ||
103 | const QString &fileName, | ||
104 | const QMap<QString,QStringList>& mimeTypes) | ||
105 | : QWidget( wid, "OFileSelector") | ||
106 | { | ||
107 | m_mimetypes = mimeTypes; | ||
108 | if (mode == SAVE ) | ||
109 | m_name = fileName; | ||
110 | initVars(); | ||
111 | m_mode = mode; | ||
112 | m_selector = selector; | ||
113 | m_currentDir = dirName; | ||
114 | init(); | ||
115 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); | ||
116 | } | ||
117 | |||
118 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | ||
119 | const char *name, bool newVisible, | ||
120 | bool closeVisible ) | ||
121 | : QWidget( parent, name ) | ||
122 | { | ||
123 | if (!mimeFilter.isEmpty() ) { | ||
124 | QStringList list = QStringList::split(";", mimeFilter ); | ||
125 | m_mimetypes.insert(mimeFilter, list ); | ||
126 | } | ||
127 | initVars(); | ||
128 | m_currentDir = QPEApplication::documentDir(); | ||
129 | m_mode = FILESELECTOR; | ||
130 | m_selector = NORMAL; | ||
131 | m_shClose = closeVisible; | ||
132 | m_shNew = newVisible; | ||
133 | m_shLne = false; | ||
134 | m_shPerm = false; | ||
135 | m_shYesNo = false; | ||
136 | init(); | ||
137 | |||
138 | } | ||
139 | |||
140 | OFileSelector::~OFileSelector() | ||
141 | { | ||
142 | |||
143 | |||
144 | } | ||
145 | |||
146 | void OFileSelector::setNewVisible( bool visible ) | ||
147 | { | ||
148 | m_shNew = visible; | ||
149 | if( m_selector == NORMAL ){ | ||
150 | delete m_select; | ||
151 | // we need to initialize but keep the selected mimetype | ||
152 | QString mime = currentMimeType(); | ||
153 | m_select = new FileSelector( mime , | ||
154 | m_stack, "fileselector", | ||
155 | m_shNew, m_shClose); | ||
156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
158 | connect(m_select, SIGNAL(closeMe() ), | ||
159 | this, SIGNAL(closeMe() ) ); | ||
160 | //connect to close me and other signals as well | ||
161 | m_stack->addWidget( m_select, NORMAL ); | ||
162 | }else{ | ||
163 | m_new->show(); | ||
164 | } | ||
165 | } | ||
166 | void OFileSelector::setCloseVisible( bool visible ) | ||
167 | { | ||
168 | m_shClose = visible; | ||
169 | if( m_selector == NORMAL ){ | ||
170 | setNewVisible( m_shNew ); // yeah baby | ||
171 | }else{ | ||
172 | m_close->show(); | ||
173 | } | ||
174 | } | ||
175 | void OFileSelector::reread() | ||
176 | { | ||
177 | if( m_selector == NORMAL ){ | ||
178 | setNewVisible( m_shNew ); // make it a initializeSelector | ||
179 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | ||
180 | reparse(); | ||
181 | //}else{ | ||
182 | //; | ||
183 | } | ||
184 | } | ||
185 | |||
186 | const DocLnk *OFileSelector::selected() | ||
187 | { | ||
188 | DocLnk *lnk = new DocLnk(selectedDocument() ); | ||
189 | return lnk; | ||
190 | } | ||
191 | |||
192 | void OFileSelector::setYesCancelVisible( bool show ) | ||
193 | { | ||
194 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | ||
195 | m_shYesNo = show; | ||
196 | if( m_shYesNo ) | ||
197 | m_boxOk->show(); | ||
198 | else | ||
199 | m_boxOk->hide(); | ||
200 | |||
201 | } | ||
202 | void OFileSelector::setToolbarVisible( bool show ) | ||
203 | { | ||
204 | m_shTool = show; | ||
205 | initializeListView(); // FIXME see above waste of memory | ||
206 | if(!m_shTool ){ | ||
207 | m_location->hide(); | ||
208 | m_up->hide(); | ||
209 | m_homeButton->hide(); | ||
210 | m_docButton->hide(); | ||
211 | }else{ | ||
212 | m_location->show(); | ||
213 | m_up->show(); | ||
214 | m_homeButton->show(); | ||
215 | m_docButton->show(); | ||
216 | } | ||
217 | } | ||
218 | void OFileSelector::setPermissionBarVisible( bool show ) | ||
219 | { | ||
220 | m_shPerm = show; | ||
221 | initializePerm(); | ||
222 | if( m_shPerm ) | ||
223 | m_checkPerm->show(); | ||
224 | else | ||
225 | m_checkPerm->hide(); | ||
226 | } | ||
227 | void OFileSelector::setLineEditVisible( bool show ) | ||
228 | { | ||
229 | if( show ){ | ||
230 | initializeName(); | ||
231 | m_boxName->show(); | ||
232 | }else{ | ||
233 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go | ||
234 | m_boxName->hide(); | ||
235 | } | ||
236 | } | ||
237 | m_shLne = show; | ||
238 | } | ||
239 | |||
240 | void OFileSelector::setChooserVisible( bool show ) | ||
241 | { | ||
242 | m_shChooser = show; | ||
243 | initializeChooser(); | ||
244 | if( m_shChooser ){ | ||
245 | m_boxView->hide(); | ||
246 | }else{ | ||
247 | m_boxView->show(); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | QCheckBox* OFileSelector::permissionCheckbox() | ||
252 | { | ||
253 | if( m_selector == NORMAL ) | ||
254 | return 0l; | ||
255 | else | ||
256 | return m_checkPerm; | ||
257 | } | ||
258 | bool OFileSelector::setPermission()const | ||
259 | { | ||
260 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | ||
261 | } | ||
262 | void OFileSelector::setPermissionChecked( bool check ) | ||
263 | { | ||
264 | if( m_checkPerm ) | ||
265 | m_checkPerm->setChecked( check ); | ||
266 | } | ||
267 | |||
268 | void OFileSelector::setMode(int mode) // FIXME do direct raising | ||
269 | { | ||
270 | m_mode = mode; | ||
271 | if( m_selector == NORMAL ) | ||
272 | return; | ||
273 | } | ||
274 | void OFileSelector::setShowDirs(bool ) | ||
275 | { | ||
276 | m_dir = true; | ||
277 | reparse(); | ||
278 | } | ||
279 | void OFileSelector::setCaseSensetive(bool caSe ) | ||
280 | { | ||
281 | m_case = caSe; | ||
282 | reparse(); | ||
283 | } | ||
284 | void OFileSelector::setShowFiles(bool show ) | ||
285 | { | ||
286 | m_files = show; | ||
287 | reparse(); | ||
288 | } | ||
289 | /// | ||
290 | bool OFileSelector::cd(const QString &path ) | ||
291 | { | ||
292 | m_currentDir = path; | ||
293 | reparse(); | ||
294 | return true; | ||
295 | } | ||
296 | void OFileSelector::setSelector(int mode ) | ||
297 | { | ||
298 | QString text; | ||
299 | switch( mode ){ | ||
300 | case NORMAL: | ||
301 | text = tr("Documents"); | ||
302 | break; | ||
303 | case EXTENDED: | ||
304 | text = tr("Files"); | ||
305 | break; | ||
306 | case EXTENDED_ALL: | ||
307 | text = tr("All Files"); | ||
308 | break; | ||
309 | } | ||
310 | slotViewCheck( text ); | ||
311 | } | ||
312 | |||
313 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) | ||
314 | { | ||
315 | m_custom = popup; | ||
316 | m_showPopup = true; | ||
317 | } | ||
318 | |||
319 | //void OFileSelector::updateL | ||
320 | |||
321 | QString OFileSelector::selectedName() const | ||
322 | { | ||
323 | QString name; | ||
324 | if( m_selector == NORMAL ){ | ||
325 | DocLnk lnk = m_select->selectedDocument(); | ||
326 | name = lnk.file(); | ||
327 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | ||
328 | if ( m_shLne ) { | ||
329 | name = m_currentDir + "/" +m_edit->text(); | ||
330 | }else{ | ||
331 | QListViewItem *item = m_View->currentItem(); | ||
332 | if( item != 0 ) | ||
333 | name = m_currentDir + "/" + item->text( 1 ); | ||
334 | } | ||
335 | }else { // installed view | ||
336 | ; | ||
337 | } | ||
338 | return name; | ||
339 | } | ||
340 | QStringList OFileSelector::selectedNames()const | ||
341 | { | ||
342 | QStringList list; | ||
343 | if( m_selector == NORMAL ){ | ||
344 | list << selectedName(); | ||
345 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | ||
346 | list << selectedName(); // FIXME implement multiple Selections | ||
347 | } | ||
348 | return list; | ||
349 | } | ||
350 | /** If mode is set to the Dir selection this will return the selected path. | ||
351 | * | ||
352 | * | ||
353 | */ | ||
354 | QString OFileSelector::selectedPath()const | ||
355 | { | ||
356 | QString path; | ||
357 | if( m_selector == NORMAL ){ | ||
358 | path = QPEApplication::documentDir(); | ||
359 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | ||
360 | ; | ||
361 | } | ||
362 | return path; | ||
363 | } | ||
364 | QStringList OFileSelector::selectedPaths() const | ||
365 | { | ||
366 | QStringList list; | ||
367 | list << selectedPath(); | ||
368 | return list; | ||
369 | } | ||
370 | QString OFileSelector::directory()const | ||
371 | { | ||
372 | if( m_selector == NORMAL ) | ||
373 | return QPEApplication::documentDir(); | ||
374 | |||
375 | return QDir(m_currentDir).absPath(); | ||
376 | } | ||
377 | |||
378 | int OFileSelector::fileCount() const | ||
379 | { | ||
380 | int count; | ||
381 | switch( m_selector ){ | ||
382 | case NORMAL: | ||
383 | count = m_select->fileCount(); | ||
384 | break; | ||
385 | //case CUSTOM: | ||
386 | case EXTENDED: | ||
387 | case EXTENDED_ALL: | ||
388 | default: | ||
389 | count = m_View->childCount(); | ||
390 | break; | ||
391 | } | ||
392 | return count; | ||
393 | } | ||
394 | DocLnk OFileSelector::selectedDocument() const | ||
395 | { | ||
396 | DocLnk lnk; | ||
397 | switch( m_selector ){ | ||
398 | case NORMAL:{ | ||
399 | lnk = m_select->selectedDocument(); | ||
400 | break; | ||
401 | } | ||
402 | case EXTENDED: | ||
403 | case EXTENDED_ALL: | ||
404 | default: | ||
405 | lnk = DocLnk( selectedName() ); // new DocLnk | ||
406 | break; | ||
407 | } | ||
408 | return lnk; | ||
409 | } | ||
410 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | ||
411 | { | ||
412 | QValueList<DocLnk> docs; | ||
413 | docs.append( selectedDocument() ); | ||
414 | return docs; | ||
415 | } | ||
416 | |||
417 | |||
418 | // slots internal | ||
419 | |||
420 | void OFileSelector::slotOk() | ||
421 | { | ||
422 | emit ok(); | ||
423 | } | ||
424 | void OFileSelector::slotCancel() | ||
425 | { | ||
426 | emit cancel(); | ||
427 | } | ||
428 | void OFileSelector::slotViewCheck(const QString &sel) | ||
429 | { | ||
430 | if( sel == tr("Documents" ) ){ | ||
431 | if( m_select == 0 ){ | ||
432 | // autMime? fix cause now we use All and not the current | ||
433 | // yes currentMime fixes that for us | ||
434 | QString mime = currentMimeType(); | ||
435 | m_select = new FileSelector(mime, | ||
436 | m_stack, "fileselector", | ||
437 | m_shNew, m_shClose); | ||
438 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
439 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
440 | connect(m_select, SIGNAL(closeMe() ), | ||
441 | this, SIGNAL(closeMe() ) ); | ||
442 | //connect to close me and other signals as well | ||
443 | |||
444 | m_stack->addWidget( m_select, NORMAL ); | ||
445 | } | ||
446 | m_stack->raiseWidget( NORMAL ); | ||
447 | m_selector = NORMAL; | ||
448 | }else if( sel == tr("Files") ){ | ||
449 | m_selector = EXTENDED; | ||
450 | initializeListView(); | ||
451 | reparse(); | ||
452 | m_stack->raiseWidget( EXTENDED ); | ||
453 | }else if( sel == tr("All Files") ){ | ||
454 | m_selector = EXTENDED_ALL; | ||
455 | initializeListView(); | ||
456 | reparse(); | ||
457 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter | ||
458 | } | ||
459 | } | ||
460 | // not yet finished..... | ||
461 | QString OFileSelector::currentMimeType() const{ | ||
462 | QString mime; | ||
463 | QString currentText; | ||
464 | if (m_shChooser ) | ||
465 | currentText = m_mimeCheck->currentText(); | ||
466 | |||
467 | if (tr("All") == currentText ) return QString::null; | ||
468 | else if (currentText.isEmpty() ) { | ||
469 | ; | ||
470 | }else { | ||
471 | QMap<QString, QStringList>::ConstIterator it; | ||
472 | it = m_mimetypes.find( currentText ); | ||
473 | if ( it == m_mimetypes.end() ) { | ||
474 | mime = it.data().join(";"); | ||
475 | }else{ | ||
476 | mime = currentText; | ||
477 | } | ||
478 | } | ||
479 | return mime; | ||
480 | } | ||
481 | void OFileSelector::slotMimeCheck(const QString &mime) | ||
482 | { | ||
483 | if( m_selector == NORMAL ){ | ||
484 | //if( m_autoMime ){ | ||
485 | QString newMimeType; | ||
486 | if (mime != tr("All") ) { | ||
487 | QMap<QString, QStringList>::Iterator it; | ||
488 | it = m_mimetypes.find(mime); | ||
489 | if ( it != m_mimetypes.end() ) { | ||
490 | newMimeType = it.data().join(";"); | ||
491 | }else{ | ||
492 | newMimeType = mime; | ||
493 | } | ||
494 | } | ||
495 | delete m_select; | ||
496 | m_select = new FileSelector( newMimeType, | ||
497 | m_stack, "fileselector", | ||
498 | m_shNew, m_shClose); | ||
499 | |||
500 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
501 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
502 | connect(m_select, SIGNAL(closeMe() ), | ||
503 | this, SIGNAL(closeMe() ) ); | ||
504 | //connect to close me and other signals as well | ||
505 | m_stack->addWidget( m_select, NORMAL ); | ||
506 | m_stack->raiseWidget( NORMAL ); | ||
507 | updateMimes(); | ||
508 | updateMimeCheck(); | ||
509 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | ||
510 | //} | ||
511 | }else{ // others | ||
512 | qWarning("Mime %s", mime.latin1() ); | ||
513 | if(m_shChooser ){ | ||
514 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | ||
515 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | ||
516 | } | ||
517 | reparse(); | ||
518 | } | ||
519 | |||
520 | } | ||
521 | /* | ||
522 | * Ok if a non dir gets inserted into this combobox | ||
523 | * we need to change it | ||
524 | * QFileInfo and dirPath will give us the right Dir | ||
525 | */ | ||
526 | void OFileSelector::slotLocationActivated(const QString &file) | ||
527 | { | ||
528 | qWarning("slotLocationActivated"); | ||
529 | QString name = file.left( file.find("<-", 0, TRUE ) ); | ||
530 | QFileInfo info( name ); | ||
531 | if ( info.isFile() ) | ||
532 | cd(info.dirPath( TRUE ) ); //absolute | ||
533 | else | ||
534 | cd(name ); | ||
535 | reparse(); | ||
536 | } | ||
537 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | ||
538 | { | ||
539 | QStringList pathList; | ||
540 | bool underDog = FALSE; | ||
541 | for(int i=0;i<count;i++) { | ||
542 | pathList << m_location->text(i); | ||
543 | if( m_location->text(i) == currentPath) | ||
544 | underDog = TRUE; | ||
545 | } | ||
546 | if( !underDog) { | ||
547 | m_location->clear(); | ||
548 | if( currentPath.left(2)=="//") | ||
549 | pathList.append( currentPath.right(currentPath.length()-1) ); | ||
550 | else | ||
551 | pathList.append( currentPath ); | ||
552 | m_location->insertStringList( pathList,-1); | ||
553 | } | ||
554 | } | ||
555 | /* | ||
556 | * Do not crash anymore | ||
557 | * don't try to change dir to a file | ||
558 | */ | ||
559 | void OFileSelector::locationComboChanged() | ||
560 | { | ||
561 | QFileInfo info( m_location->lineEdit()->text() ); | ||
562 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); | ||
563 | if (info.isFile() ) | ||
564 | cd(info.dirPath(TRUE) ); //absolute path | ||
565 | else | ||
566 | cd( m_location->lineEdit()->text() ); | ||
567 | |||
568 | reparse(); | ||
569 | } | ||
570 | void OFileSelector::init() | ||
571 | { | ||
572 | m_lay = new QVBoxLayout( this ); | ||
573 | m_lay->setSpacing(0 ); | ||
574 | |||
575 | m_stack = new QWidgetStack( this ); | ||
576 | if( m_selector == NORMAL ){ | ||
577 | QString mime; | ||
578 | if (!m_autoMime) { | ||
579 | if (!m_mimetypes.isEmpty() ) { | ||
580 | QMap<QString, QStringList>::Iterator it; | ||
581 | it = m_mimetypes.begin(); // cause we're in the init | ||
582 | mime = it.data().join(";"); | ||
583 | } | ||
584 | } | ||
585 | m_select = new FileSelector(mime, | ||
586 | m_stack, "fileselector", | ||
587 | m_shNew, m_shClose); | ||
588 | |||
589 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
590 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
591 | connect(m_select, SIGNAL(closeMe() ), | ||
592 | this, SIGNAL( closeMe() ) ); | ||
593 | //connect to close me and other signals as well | ||
594 | |||
595 | m_stack->addWidget( m_select, NORMAL ); | ||
596 | m_stack->raiseWidget( NORMAL ); | ||
597 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL | ||
598 | // and initializeListview will take care of those | ||
599 | // toolbar get's generade in initializeListView | ||
600 | initializeListView( ); // will raise the widget as well | ||
601 | m_stack->raiseWidget( EXTENDED ); | ||
602 | } | ||
603 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch | ||
604 | |||
605 | if( m_shLne ) // the LineEdit with the current FileName | ||
606 | initializeName(); | ||
607 | |||
608 | if( m_shPerm ) // the Permission QCheckBox | ||
609 | initializePerm(); | ||
610 | |||
611 | if( m_shChooser ) // the Chooser for the view and Mimetypes | ||
612 | initializeChooser(); | ||
613 | |||
614 | if( m_shYesNo ) // the Yes No button row | ||
615 | initializeYes( ); | ||
616 | |||
617 | if (m_selector != NORMAL ) | ||
618 | reparse(); | ||
619 | } | ||
620 | void OFileSelector::updateMimes() | ||
621 | { | ||
622 | if( m_autoMime ){ | ||
623 | m_mimetypes.clear(); | ||
624 | m_mimetypes.insert( tr("All"), QString::null ); | ||
625 | if( m_selector == NORMAL ){ | ||
626 | DocLnkSet set; | ||
627 | Global::findDocuments(&set, QString::null ); | ||
628 | QListIterator<DocLnk> dit( set.children() ); | ||
629 | for( ; dit.current(); ++dit ){ | ||
630 | if( !m_mimetypes.contains( (*dit)->type() ) ) | ||
631 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | ||
632 | } | ||
633 | }// else done in reparse | ||
634 | } | ||
635 | } | ||
636 | void OFileSelector::initVars() | ||
637 | { | ||
638 | if( m_mimetypes.isEmpty() ) | ||
639 | m_autoMime = true; | ||
640 | else | ||
641 | m_autoMime = false; | ||
642 | m_shClose = false; | ||
643 | m_shNew = false; | ||
644 | m_shTool = true; | ||
645 | m_shPerm = false; | ||
646 | m_shLne = true; | ||
647 | m_shChooser = true; | ||
648 | m_shYesNo = true; | ||
649 | m_case = false; | ||
650 | m_dir = true; | ||
651 | m_files = true; | ||
652 | m_showPopup = false; | ||
653 | if(m_pixmaps == 0 ) // init the pixmaps | ||
654 | initPics(); | ||
655 | |||
656 | // pointers | ||
657 | m_location = 0; | ||
658 | m_mimeCheck = 0; | ||
659 | m_viewCheck = 0; | ||
660 | m_homeButton = 0; | ||
661 | m_docButton = 0; | ||
662 | m_hideButton = 0; | ||
663 | m_ok = 0; | ||
664 | m_cancel = 0; | ||
665 | m_reread = 0; | ||
666 | m_up = 0; | ||
667 | m_View = 0; | ||
668 | m_checkPerm = 0; | ||
669 | m_pseudo = 0; | ||
670 | m_pseudoLayout = 0; | ||
671 | m_select = 0; | ||
672 | m_stack = 0; | ||
673 | m_lay = 0; | ||
674 | m_Oselector = 0; | ||
675 | m_boxToolbar = 0; | ||
676 | m_boxOk = 0; | ||
677 | m_boxName = 0; | ||
678 | m_boxView = 0; | ||
679 | m_custom = 0; | ||
680 | m_edit = 0; | ||
681 | m_fnLabel = 0; | ||
682 | m_new = 0; | ||
683 | m_close = 0; | ||
684 | } | ||
685 | void OFileSelector::addFile(const QString &/*mime*/, QFileInfo *info, bool symlink) | ||
686 | { | ||
687 | if(!m_files) | ||
688 | return; | ||
689 | // if( !compliesMime(info->absFilePath(), mime ) ) | ||
690 | // return; | ||
691 | MimeType type( info->absFilePath() ); | ||
692 | if (!compliesMime( type.id() ) ) | ||
693 | return; | ||
694 | |||
695 | QPixmap pix = type.pixmap(); | ||
696 | QString dir; | ||
697 | QString name; | ||
698 | bool locked; | ||
699 | if( pix.isNull() ) { | ||
700 | //TODO make this scaled pixmap global, so we dont have to keep doing this | ||
701 | QWMatrix matrix; | ||
702 | QPixmap pixer(Resource::loadPixmap( "UnknownDocument" )); | ||
703 | matrix.scale( .4, .4); | ||
704 | pix = pixer.xForm(matrix); | ||
705 | // pix = Resource::loadPixmap( "UnknownDocument-14"); | ||
706 | } | ||
707 | dir = info->dirPath( true ); | ||
708 | if( symlink ) | ||
709 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); | ||
710 | else { | ||
711 | name = info->fileName(); | ||
712 | if( ( m_mode == OPEN && !info->isReadable() )|| | ||
713 | ( m_mode == SAVE && !info->isWritable() ) ){ | ||
714 | |||
715 | locked = true; pix = Resource::loadPixmap("locked"); | ||
716 | } | ||
717 | } | ||
718 | new OFileSelectorItem( m_View, pix, name, | ||
719 | info->lastModified().toString(), | ||
720 | QString::number( info->size() ), | ||
721 | dir, locked ); | ||
722 | } | ||
723 | void OFileSelector::addDir(const QString &/*mime*/, QFileInfo *info, bool symlink ) | ||
724 | { | ||
725 | if(!m_dir) | ||
726 | return; | ||
727 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ | ||
728 | bool locked = false; | ||
729 | QString name; | ||
730 | QPixmap pix; | ||
731 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | ||
732 | locked = true; | ||
733 | if( symlink ) | ||
734 | pix = (*m_pixmaps)["symlinkedlocked"]; | ||
735 | else | ||
736 | pix = Resource::loadPixmap("lockedfolder"); | ||
737 | }else { // readable | ||
738 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; | ||
739 | } | ||
740 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; | ||
741 | new OFileSelectorItem( m_View, pix, name, | ||
742 | info->lastModified().toString(), | ||
743 | QString::number( info->size() ), | ||
744 | info->dirPath( true ), locked, | ||
745 | true ); | ||
746 | |||
747 | }// else CUSTOM View | ||
748 | } | ||
749 | void OFileSelector::delItems() | ||
750 | { | ||
751 | |||
752 | } | ||
753 | void OFileSelector::initializeName() | ||
754 | { | ||
755 | /** Name Layout Line | ||
756 | * This is the Layout line arranged in | ||
757 | * horizontal way each components | ||
758 | * are next to each other | ||
759 | * but we will only do this if | ||
760 | * we didn't initialize a while ago. | ||
761 | */ | ||
762 | if( m_boxName == 0 ){ | ||
763 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | ||
764 | m_fnLabel = new QLabel( m_boxName ); | ||
765 | m_fnLabel->setText( tr("Name:") ); | ||
766 | m_edit = new QLineEdit( m_boxName ); | ||
767 | m_edit->setText( m_name ); | ||
768 | //m_boxName->addWidget( m_fnLabel ); | ||
769 | m_boxName->setMargin( 5 ); | ||
770 | m_boxName->setSpacing( 8 ); | ||
771 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor | ||
772 | |||
773 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout | ||
774 | }// else we already initialized | ||
775 | // maybe show the components? | ||
776 | // | ||
777 | } | ||
778 | void OFileSelector::initializeYes() | ||
779 | { | ||
780 | /** The Save Cancel bar | ||
781 | * | ||
782 | */ | ||
783 | if( m_boxOk == 0 ){ | ||
784 | m_boxOk = new QHBox( this ); | ||
785 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); | ||
786 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); | ||
787 | |||
788 | //m_boxOk->addWidget( m_ok ); | ||
789 | //m_boxOk->addWidget( m_cancel ); | ||
790 | m_boxOk->setMargin( 5 ); | ||
791 | m_boxOk->setSpacing( 10 ); | ||
792 | m_lay->addWidget( m_boxOk, 0 ); | ||
793 | |||
794 | connect( m_ok, SIGNAL( clicked() ), | ||
795 | this, SLOT(slotOk() ) ); | ||
796 | connect( m_cancel, SIGNAL( clicked() ), | ||
797 | this, SLOT( slotCancel() ) ); | ||
798 | } | ||
799 | } | ||
800 | /* | ||
801 | * OK m_mimeCheck is a QComboBox we now want to fill | ||
802 | * out that combobox | ||
803 | * if automime we need to update the mimetypes | ||
804 | */ | ||
805 | void OFileSelector::updateMimeCheck() { | ||
806 | m_mimeCheck->clear(); | ||
807 | if (m_autoMime ) { | ||
808 | //m_mimeCheck->insertItem( tr("All") ); | ||
809 | updateMimes(); | ||
810 | } | ||
811 | |||
812 | QMap<QString, QStringList>::Iterator it; | ||
813 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { | ||
814 | m_mimeCheck->insertItem( it.key() ); | ||
815 | } | ||
816 | } | ||
817 | |||
818 | void OFileSelector::initializeChooser() | ||
819 | { | ||
820 | if( m_boxView == 0 ){ | ||
821 | m_boxView = new QHBox( this ); | ||
822 | m_viewCheck = new QComboBox( m_boxView, "view check"); | ||
823 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); | ||
824 | m_boxView->setSpacing( 8 ); | ||
825 | m_lay->addWidget(m_boxView, 0 ); | ||
826 | |||
827 | m_viewCheck->insertItem( tr("Documents") ); | ||
828 | m_viewCheck->insertItem( tr("Files") ); | ||
829 | m_viewCheck->insertItem( tr("All Files") ); | ||
830 | updateMimeCheck(); | ||
831 | |||
832 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | ||
833 | this, SLOT( slotViewCheck(const QString & ) ) ); | ||
834 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | ||
835 | this, SLOT( slotMimeCheck( const QString & ) ) ); | ||
836 | } | ||
837 | } | ||
838 | void OFileSelector::initializeListView() | ||
839 | { | ||
840 | qWarning("initializeListView"); | ||
841 | if( m_pseudo == 0 ){ | ||
842 | qWarning("init"); | ||
843 | m_pseudo = new QWidget( m_stack, "Pseudo Widget"); | ||
844 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); | ||
845 | // toolbar | ||
846 | m_boxToolbar = new QHBox( m_pseudo ); | ||
847 | m_boxToolbar->setSpacing(0 ); // next to each other please | ||
848 | |||
849 | // toolbar members | ||
850 | { | ||
851 | // location QComboBox | ||
852 | m_location = new QComboBox( m_boxToolbar ); | ||
853 | m_location->setEditable( TRUE ); | ||
854 | m_location->setDuplicatesEnabled( FALSE ); | ||
855 | connect( m_location, SIGNAL(activated(const QString &) ), | ||
856 | this, SLOT( slotLocationActivated(const QString &) ) ); | ||
857 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), | ||
858 | this, SLOT(locationComboChanged() ) ); | ||
859 | // UP Button | ||
860 | m_up = new QPushButton(Resource::loadIconSet("up"),"", | ||
861 | m_boxToolbar,"cdUpButton"); | ||
862 | m_up->setFixedSize( QSize( 20, 20 ) ); | ||
863 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | ||
864 | m_up->setFlat(TRUE); | ||
865 | |||
866 | // Home Button | ||
867 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , | ||
868 | "", m_boxToolbar); | ||
869 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); | ||
870 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | ||
871 | m_homeButton->setFlat(TRUE); | ||
872 | // Documents Button | ||
873 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", | ||
874 | m_boxToolbar,"docsButton"); | ||
875 | m_docButton->setFixedSize( QSize( 20, 20 ) ); | ||
876 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | ||
877 | m_docButton->setFlat(TRUE); | ||
878 | |||
879 | // Close button | ||
880 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | ||
881 | m_boxToolbar ); | ||
882 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | ||
883 | m_close->setFixedSize( 20, 20 ); | ||
884 | |||
885 | m_boxToolbar->setFixedHeight( 20 ); | ||
886 | m_pseudoLayout->addWidget(m_boxToolbar ); | ||
887 | |||
888 | // let;s fill the Location ComboBox | ||
889 | StorageInfo storage; | ||
890 | const QList<FileSystem> &fs = storage.fileSystems(); | ||
891 | QListIterator<FileSystem> it ( fs ); | ||
892 | for( ; it.current(); ++it ){ | ||
893 | const QString disk = (*it)->name(); | ||
894 | const QString path = (*it)->path(); | ||
895 | m_location->insertItem(path+ "<-"+disk ); | ||
896 | } | ||
897 | int count = m_location->count(); | ||
898 | m_location->insertItem( m_currentDir ); | ||
899 | m_location->setCurrentItem( count ); | ||
900 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it | ||
901 | if( !m_shTool ){ | ||
902 | m_location->hide( ); | ||
903 | m_up->hide( ); | ||
904 | m_homeButton->hide( ); | ||
905 | m_docButton->hide( ); | ||
906 | } | ||
907 | if(!m_shClose ) | ||
908 | m_close->hide(); | ||
909 | //if(!m_shNew) | ||
910 | //m_close->hide(); | ||
911 | |||
912 | } // off toolbar | ||
913 | // the Main ListView | ||
914 | // make a QWidgetStack first so Views can share the Toolbar | ||
915 | m_View = new QListView( m_pseudo, "Extended view"); | ||
916 | QPEApplication::setStylusOperation( m_View->viewport(), | ||
917 | QPEApplication::RightOnHold); | ||
918 | m_View->addColumn(" " ); | ||
919 | m_View->addColumn(tr("Name"), 135 ); | ||
920 | m_View->addColumn(tr("Size"), -1 ); | ||
921 | m_View->addColumn(tr("Date"), 60 ); | ||
922 | m_View->addColumn(tr("Mime Type"), -1 ); | ||
923 | QHeader *header = m_View->header(); | ||
924 | header->hide(); | ||
925 | m_View->setSorting( 1 ); | ||
926 | m_View->setAllColumnsShowFocus( TRUE ); | ||
927 | |||
928 | connect(m_View, SIGNAL(selectionChanged() ), | ||
929 | this, SLOT(slotSelectionChanged() ) ); | ||
930 | |||
931 | connect(m_View, SIGNAL(clicked(QListViewItem *) ), | ||
932 | // connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), | ||
933 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | ||
934 | |||
935 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | ||
936 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | ||
937 | |||
938 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | ||
939 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | ||
940 | |||
941 | m_pseudoLayout->addWidget( m_View, 288 ); | ||
942 | m_stack->addWidget( m_pseudo, EXTENDED ); | ||
943 | } | ||
944 | } | ||
945 | void OFileSelector::initializePerm() | ||
946 | { | ||
947 | if( m_checkPerm == 0 ){ | ||
948 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); | ||
949 | m_checkPerm->setChecked( false ); | ||
950 | m_lay->addWidget( m_checkPerm ); | ||
951 | |||
952 | } | ||
953 | } | ||
954 | void OFileSelector::initPics() | ||
955 | { | ||
956 | m_pixmaps = new QMap<QString,QPixmap>; | ||
957 | QPixmap pm = Resource::loadPixmap( "folder" ); | ||
958 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | ||
959 | QPainter painter( &pm ); | ||
960 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | ||
961 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | ||
962 | m_pixmaps->insert("dirsymlink", pm ); | ||
963 | |||
964 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | ||
965 | QPainter pen(&pm2 ); | ||
966 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | ||
967 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | ||
968 | m_pixmaps->insert("symlinkedlocked", pm2 ); | ||
969 | } | ||
970 | // if a mime complies with the m_mimeCheck->currentItem | ||
971 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | ||
972 | { | ||
973 | if( mime == "All" ) | ||
974 | return true; | ||
975 | MimeType type( path ); | ||
976 | if( type.id() == mime ) | ||
977 | return true; | ||
978 | return false; | ||
979 | } | ||
980 | /* check if the mimetype in mime | ||
981 | * complies with the one which is current | ||
982 | */ | ||
983 | /* | ||
984 | * We've the mimetype of the file | ||
985 | * We need to get the stringlist of the current mimetype | ||
986 | * | ||
987 | * mime = image/jpeg | ||
988 | * QStringList = 'image/*' | ||
989 | * or QStringList = image/jpeg;image/png;application/x-ogg | ||
990 | * or QStringList = application/x-ogg;image/*; | ||
991 | * with all these mime filters it should get acceptes | ||
992 | * to do so we need to look if mime is contained inside | ||
993 | * the stringlist | ||
994 | * if it's contained return true | ||
995 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' | ||
996 | * is contained in the mimefilter and then we will | ||
997 | * look if both are equal until the '/' | ||
998 | */ | ||
999 | bool OFileSelector::compliesMime( const QString& mime ) { | ||
1000 | qWarning("mimetype is %s", mime.latin1() ); | ||
1001 | QString currentText; | ||
1002 | if (m_shChooser ) | ||
1003 | currentText = m_mimeCheck->currentText(); | ||
1004 | |||
1005 | qWarning("current text is %s", currentText.latin1() ); | ||
1006 | QMap<QString, QStringList>::Iterator it; | ||
1007 | QStringList list; | ||
1008 | if ( currentText == tr("All") ) return true; | ||
1009 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { | ||
1010 | it = m_mimetypes.begin(); | ||
1011 | list = it.data(); | ||
1012 | }else if ( currentText.isEmpty() ) return true; | ||
1013 | else{ | ||
1014 | it = m_mimetypes.find(currentText ); | ||
1015 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; | ||
1016 | else qWarning("found"), list = it.data(); | ||
1017 | } | ||
1018 | // dump it now | ||
1019 | //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
1020 | // qWarning( "%s", (*it).latin1() ); | ||
1021 | //} | ||
1022 | |||
1023 | |||
1024 | if ( list.contains(mime) ) return true; | ||
1025 | qWarning("list doesn't contain it "); | ||
1026 | QStringList::Iterator it2; | ||
1027 | int pos; | ||
1028 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { | ||
1029 | pos = (*it2).findRev("/*"); | ||
1030 | if ( pos >= 0 ) { | ||
1031 | if ( mime.contains( (*it2).left(pos) ) ) return true; | ||
1032 | } | ||
1033 | } | ||
1034 | return false; | ||
1035 | } | ||
1036 | void OFileSelector::slotFileSelected( const QString &string ) | ||
1037 | { | ||
1038 | if( m_shLne ) | ||
1039 | m_edit->setText( string ); | ||
1040 | emit fileSelected( string ); | ||
1041 | } | ||
1042 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | ||
1043 | { | ||
1044 | slotFileSelected( lnk.name() ); | ||
1045 | emit fileSelected( lnk ); | ||
1046 | } | ||
1047 | void OFileSelector::slotSelectionChanged() | ||
1048 | { | ||
1049 | |||
1050 | } | ||
1051 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) | ||
1052 | { | ||
1053 | if( item == 0 ) | ||
1054 | return; | ||
1055 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | ||
1056 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) | ||
1057 | qWarning("current changed"); | ||
1058 | if(!sel->isDir() ){ | ||
1059 | if( m_shLne ) | ||
1060 | m_edit->setText( sel->text(1) ); | ||
1061 | |||
1062 | if (m_mode == FILESELECTOR ) { | ||
1063 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1064 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
1065 | emit fileSelected(path ); | ||
1066 | DocLnk lnk( path ); | ||
1067 | emit fileSelected(lnk ); | ||
1068 | } | ||
1069 | } | ||
1070 | } | ||
1071 | } | ||
1072 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) | ||
1073 | { | ||
1074 | if ( item == 0 ) | ||
1075 | return; | ||
1076 | |||
1077 | if( button != Qt::LeftButton ) | ||
1078 | return; | ||
1079 | |||
1080 | switch( m_selector ){ | ||
1081 | default: | ||
1082 | break; | ||
1083 | case EXTENDED: // fall through | ||
1084 | case EXTENDED_ALL:{ | ||
1085 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | ||
1086 | if(!sel->isLocked() ){ | ||
1087 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1088 | if( sel->isDir() ){ | ||
1089 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1090 | // if MODE Dir m_shLne set the Text | ||
1091 | }else{ | ||
1092 | if( m_shLne ) | ||
1093 | m_edit->setText( str[0].stripWhiteSpace() ); | ||
1094 | qWarning("selected here in slot clicked"); | ||
1095 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1096 | DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1097 | qWarning("file selected"); | ||
1098 | emit fileSelected( lnk ); | ||
1099 | } | ||
1100 | } | ||
1101 | break; | ||
1102 | } | ||
1103 | } | ||
1104 | } | ||
1105 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | ||
1106 | { | ||
1107 | if( item == 0 ) | ||
1108 | return; | ||
1109 | |||
1110 | if( button != Qt::RightButton ) | ||
1111 | return; | ||
1112 | slotContextMenu( item ); | ||
1113 | } | ||
1114 | void OFileSelector::slotContextMenu( QListViewItem * /*item*/) | ||
1115 | { | ||
1116 | |||
1117 | } | ||
1118 | void OFileSelector::slotChangedDir() | ||
1119 | { | ||
1120 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | ||
1121 | if(sel->isDir() ){ | ||
1122 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1123 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1124 | } | ||
1125 | } | ||
1126 | void OFileSelector::slotOpen() | ||
1127 | { | ||
1128 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | ||
1129 | if(!sel->isDir() ){ | ||
1130 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1131 | slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); | ||
1132 | qWarning("slot open"); | ||
1133 | // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1134 | //emit fileSelected( lnk ); | ||
1135 | } | ||
1136 | } | ||
1137 | void OFileSelector::slotRescan() | ||
1138 | { | ||
1139 | |||
1140 | } | ||
1141 | void OFileSelector::slotRename() | ||
1142 | { | ||
1143 | reparse(); | ||
1144 | } | ||
1145 | void OFileSelector::slotDelete() | ||
1146 | { | ||
1147 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | ||
1148 | QStringList list = QStringList::split("->", sel->text(1) ); | ||
1149 | if( sel->isDir() ){ | ||
1150 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry | ||
1151 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], | ||
1152 | tr("Yes"),tr("No"),0,1,1) ) { | ||
1153 | case 0: | ||
1154 | ::system(str.utf8().data() ); | ||
1155 | break; | ||
1156 | } | ||
1157 | } else { | ||
1158 | QFile::remove( list[0] ); | ||
1159 | } | ||
1160 | m_View->takeItem( sel ); | ||
1161 | delete sel; | ||
1162 | } | ||
1163 | void OFileSelector::cdUP() | ||
1164 | { | ||
1165 | QDir dir( m_currentDir ); | ||
1166 | dir.cdUp(); | ||
1167 | if(dir.exists() ){ | ||
1168 | m_currentDir = dir.absPath(); | ||
1169 | reparse(); | ||
1170 | int count = m_location->count(); | ||
1171 | slotInsertLocationPath( m_currentDir, count); | ||
1172 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); | ||
1173 | //this wont work in all instances | ||
1174 | // FIXME | ||
1175 | } | ||
1176 | } | ||
1177 | void OFileSelector::slotHome() | ||
1178 | { | ||
1179 | cd(QDir::homeDirPath() ); | ||
1180 | } | ||
1181 | void OFileSelector::slotDoc() | ||
1182 | { | ||
1183 | cd(QPEApplication::documentDir() ); | ||
1184 | } | ||
1185 | void OFileSelector::slotNavigate( ) | ||
1186 | { | ||
1187 | |||
1188 | } | ||
1189 | // fill the View with life | ||
1190 | void OFileSelector::reparse() | ||
1191 | { | ||
1192 | if( m_selector == NORMAL ) | ||
1193 | return; | ||
1194 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) | ||
1195 | m_View->clear(); | ||
1196 | else // custom view | ||
1197 | ; // currentView()->clear(); | ||
1198 | if( m_shChooser) | ||
1199 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); | ||
1200 | |||
1201 | QString currentMimeType; | ||
1202 | // let's update the mimetype | ||
1203 | if( m_autoMime ){ | ||
1204 | m_mimetypes.clear(); | ||
1205 | // ok we can change mimetype so we need to be able to give a selection | ||
1206 | if( m_shChooser ) { | ||
1207 | currentMimeType = m_mimeCheck->currentText(); | ||
1208 | m_mimeCheck->clear(); | ||
1209 | |||
1210 | // let's find possible mimetypes | ||
1211 | QDir dir( m_currentDir ); | ||
1212 | if( dir.exists() ){ | ||
1213 | dir.setFilter( QDir::Files | QDir::Readable ); | ||
1214 | dir.setSorting( QDir::Size ); | ||
1215 | const QFileInfoList *list = dir.entryInfoList(); | ||
1216 | QFileInfoListIterator it( *list ); | ||
1217 | QFileInfo *fi; | ||
1218 | while( (fi=it.current() ) ) { | ||
1219 | if( fi->extension() == QString::fromLatin1("desktop") ){ | ||
1220 | ++it; | ||
1221 | continue; | ||
1222 | } | ||
1223 | MimeType type( fi->absFilePath() ); | ||
1224 | if( !m_mimetypes.contains( type.id() ) ){ | ||
1225 | //qWarning("Type %s", type.id().latin1() ); | ||
1226 | m_mimetypes.insert( type.id(), type.id() ); | ||
1227 | } | ||
1228 | |||
1229 | ++it; | ||
1230 | } | ||
1231 | // add them to the chooser | ||
1232 | updateMimeCheck(); | ||
1233 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | ||
1234 | currentMimeType = m_mimeCheck->currentText(); | ||
1235 | } | ||
1236 | } | ||
1237 | }else { // no autoMime | ||
1238 | // let the mimetype be set from out side the m_mimeCheck FEATURE | ||
1239 | |||
1240 | if( m_shChooser ){ | ||
1241 | currentMimeType = m_mimeCheck->currentText(); | ||
1242 | // updateMimeCheck(); | ||
1243 | } | ||
1244 | } | ||
1245 | // now we got our mimetypes we can add the files | ||
1246 | |||
1247 | QDir dir( m_currentDir ); | ||
1248 | |||
1249 | if( dir.exists() ){ | ||
1250 | int sort; | ||
1251 | if ( m_case ) | ||
1252 | sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); | ||
1253 | else | ||
1254 | sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); | ||
1255 | dir.setSorting( sort ); | ||
1256 | |||
1257 | int filter; | ||
1258 | if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){ | ||
1259 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | ||
1260 | }else | ||
1261 | filter = QDir::Files | QDir::Dirs | QDir::All; | ||
1262 | dir.setFilter( filter ); | ||
1263 | |||
1264 | // now go through all files | ||
1265 | const QFileInfoList *list = dir.entryInfoList(); | ||
1266 | QFileInfoListIterator it( *list ); | ||
1267 | QFileInfo *fi; | ||
1268 | while( (fi=it.current() ) ){ | ||
1269 | //qWarning("True and only" ); | ||
1270 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | ||
1271 | //qWarning(".. or ." ); | ||
1272 | ++it; | ||
1273 | continue; | ||
1274 | } | ||
1275 | if( fi->isSymLink() ){ | ||
1276 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | ||
1277 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | ||
1278 | QFileInfo info( file ); | ||
1279 | if( !info.exists() ){ | ||
1280 | addSymlink( currentMimeType, fi, TRUE ); | ||
1281 | break; | ||
1282 | }else if( info.isDir() ){ | ||
1283 | addDir( currentMimeType, fi, TRUE ); | ||
1284 | break; | ||
1285 | }else if( info.isFile() ){ | ||
1286 | addFile( currentMimeType, fi, TRUE ); | ||
1287 | break; | ||
1288 | }else if( info.isSymLink() ){ | ||
1289 | file = info.dirPath(true ) + "/" + info.readLink() ; | ||
1290 | break; | ||
1291 | }else if( i == 4){ | ||
1292 | addSymlink( currentMimeType, fi ); | ||
1293 | } | ||
1294 | } // off for loop | ||
1295 | }else if( fi->isDir() ){ | ||
1296 | addDir( currentMimeType, fi ); | ||
1297 | }else if( fi->isFile() ){ | ||
1298 | addFile( currentMimeType, fi ); | ||
1299 | } | ||
1300 | //qWarning( "%s", fi->fileName().latin1() ); | ||
1301 | ++it; | ||
1302 | } // of while loop | ||
1303 | } // if ( dir.exists() ) | ||
1304 | m_View->sort(); | ||
1305 | if( m_shTool ){ | ||
1306 | m_location->insertItem( m_currentDir ); | ||
1307 | |||
1308 | } | ||
1309 | // reenable painting and updates | ||
1310 | } | ||
diff --git a/libopie/ofileselector.cpp b/libopie/ofileselector.cpp new file mode 100644 index 0000000..577e916 --- a/dev/null +++ b/libopie/ofileselector.cpp | |||
@@ -0,0 +1,856 @@ | |||
1 | #include <qcombobox.h> | ||
2 | #include <qdir.h> | ||
3 | #include <qhbox.h> | ||
4 | #include <qheader.h> | ||
5 | #include <qlabel.h> | ||
6 | #include <qlayout.h> | ||
7 | #include <qlineedit.h> | ||
8 | #include <qlistview.h> | ||
9 | #include <qpopupmenu.h> | ||
10 | #include <qwidgetstack.h> | ||
11 | #include <qregexp.h> | ||
12 | #include <qobjectlist.h> | ||
13 | |||
14 | /* hacky but we need to get FileSelector::filter */ | ||
15 | #define private public | ||
16 | #include <qpe/fileselector.h> | ||
17 | #undef private | ||
18 | |||
19 | #include <qpe/qpeapplication.h> | ||
20 | #include <qpe/mimetype.h> | ||
21 | #include <qpe/resource.h> | ||
22 | #include <qpe/storage.h> | ||
23 | |||
24 | #include "ofileselector_p.h" | ||
25 | #include "ofileselector.h" | ||
26 | |||
27 | |||
28 | |||
29 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) | ||
30 | : m_selector( selector ) { | ||
31 | } | ||
32 | OFileViewInterface::~OFileViewInterface() { | ||
33 | } | ||
34 | QString OFileViewInterface::name()const{ | ||
35 | return m_name; | ||
36 | } | ||
37 | void OFileViewInterface::setName( const QString& name ) { | ||
38 | m_name = name; | ||
39 | } | ||
40 | OFileSelector* OFileViewInterface::selector()const { | ||
41 | return m_selector; | ||
42 | } | ||
43 | DocLnk OFileViewInterface::selectedDocument()const { | ||
44 | return DocLnk( selectedName() ); | ||
45 | } | ||
46 | bool OFileViewInterface::showNew()const { | ||
47 | return selector()->showNew(); | ||
48 | } | ||
49 | bool OFileViewInterface::showClose()const { | ||
50 | return selector()->showClose(); | ||
51 | } | ||
52 | MimeTypes OFileViewInterface::mimeTypes()const { | ||
53 | return selector()->mimeTypes(); | ||
54 | } | ||
55 | QStringList OFileViewInterface::currentMimeType()const { | ||
56 | return selector()->currentMimeType(); | ||
57 | } | ||
58 | void OFileViewInterface::activate( const QString& ) { | ||
59 | // not implemented here | ||
60 | } | ||
61 | void OFileViewInterface::ok() { | ||
62 | emit selector()->ok(); | ||
63 | } | ||
64 | void OFileViewInterface::cancel() { | ||
65 | emit selector()->cancel(); | ||
66 | } | ||
67 | void OFileViewInterface::closeMe() { | ||
68 | emit selector()->closeMe(); | ||
69 | } | ||
70 | void OFileViewInterface::fileSelected( const QString& str) { | ||
71 | emit selector()->fileSelected( str); | ||
72 | } | ||
73 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { | ||
74 | emit selector()->fileSelected( lnk ); | ||
75 | } | ||
76 | void OFileViewInterface::setCurrentFileName( const QString& str ) { | ||
77 | selector()->m_lneEdit->setText( str ); | ||
78 | } | ||
79 | QString OFileViewInterface::currentFileName()const{ | ||
80 | return selector()->m_lneEdit->text(); | ||
81 | } | ||
82 | QString OFileViewInterface::startDirectory()const{ | ||
83 | return selector()->m_startDir; | ||
84 | } | ||
85 | |||
86 | |||
87 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | ||
88 | : OFileViewInterface( selector ) { | ||
89 | m_selector = 0; | ||
90 | setName( QObject::tr("Documents") ); | ||
91 | } | ||
92 | ODocumentFileView::~ODocumentFileView() { | ||
93 | |||
94 | } | ||
95 | QString ODocumentFileView::selectedName()const { | ||
96 | if (!m_selector) | ||
97 | return QString::null; | ||
98 | |||
99 | return m_selector->selectedDocument().file(); | ||
100 | } | ||
101 | QString ODocumentFileView::selectedPath()const { | ||
102 | return QPEApplication::documentDir(); | ||
103 | } | ||
104 | QString ODocumentFileView::directory()const { | ||
105 | return selectedPath(); | ||
106 | } | ||
107 | void ODocumentFileView::reread() { | ||
108 | if (!m_selector) | ||
109 | return; | ||
110 | |||
111 | m_selector->setNewVisible( showNew() ); | ||
112 | m_selector->setCloseVisible( showClose() ); | ||
113 | m_selector->filter = currentMimeType().join(";"); | ||
114 | m_selector->reread(); | ||
115 | } | ||
116 | int ODocumentFileView::fileCount()const { | ||
117 | if (!m_selector) | ||
118 | return -1; | ||
119 | |||
120 | return m_selector->fileCount(); | ||
121 | } | ||
122 | DocLnk ODocumentFileView::selectedDocument()const { | ||
123 | if (!m_selector) | ||
124 | return DocLnk(); | ||
125 | |||
126 | return m_selector->selectedDocument(); | ||
127 | } | ||
128 | QWidget* ODocumentFileView::widget( QWidget* parent ) { | ||
129 | if (!m_selector ) { | ||
130 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | ||
131 | QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), | ||
132 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | ||
133 | QObject::connect(m_selector, SIGNAL(closeMe() ), | ||
134 | selector(), SIGNAL(closeMe() ) ); | ||
135 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), | ||
136 | selector(), SIGNAL(newSelected(const DocLnk& ) ) ); | ||
137 | } | ||
138 | |||
139 | return m_selector; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * This is the file system view used | ||
144 | * we use a QListView + QListViewItems for it | ||
145 | */ | ||
146 | |||
147 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | ||
148 | const QString& path, const QString& date, | ||
149 | const QString& size, const QString& dir, | ||
150 | bool isLocked, bool isDir ) | ||
151 | : QListViewItem( view ) | ||
152 | { | ||
153 | setPixmap(0, pixmap ); | ||
154 | setText(1, path ); | ||
155 | setText(2, size ); | ||
156 | setText(3, date ); | ||
157 | m_isDir = isDir; | ||
158 | m_dir = dir; | ||
159 | m_locked = isLocked; | ||
160 | } | ||
161 | OFileSelectorItem::~OFileSelectorItem() { | ||
162 | |||
163 | } | ||
164 | bool OFileSelectorItem::isLocked()const { | ||
165 | return m_locked; | ||
166 | } | ||
167 | QString OFileSelectorItem::directory()const { | ||
168 | return m_dir; | ||
169 | } | ||
170 | bool OFileSelectorItem::isDir()const { | ||
171 | return m_isDir; | ||
172 | } | ||
173 | QString OFileSelectorItem::path()const { | ||
174 | return text( 1 ); | ||
175 | } | ||
176 | QString OFileSelectorItem::key( int id, bool )const { | ||
177 | QString ke; | ||
178 | if( id == 0 || id == 1 ){ // name | ||
179 | if( m_isDir ){ | ||
180 | ke.append("0" ); | ||
181 | ke.append( text(1) ); | ||
182 | }else{ | ||
183 | ke.append("1" ); | ||
184 | ke.append( text(1) ); | ||
185 | } | ||
186 | return ke; | ||
187 | }else | ||
188 | return text( id ); | ||
189 | |||
190 | } | ||
191 | |||
192 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, | ||
193 | OFileSelector* sel) | ||
194 | : QWidget( parent ), m_sel( sel ) { | ||
195 | m_all = false; | ||
196 | QVBoxLayout* lay = new QVBoxLayout( this ); | ||
197 | m_currentDir = startDir; | ||
198 | |||
199 | /* | ||
200 | * now we add a special bar | ||
201 | * One Button For Up | ||
202 | * Home | ||
203 | * Doc | ||
204 | * And a dropdown menu with FileSystems | ||
205 | * FUTURE: one to change dir with lineedit | ||
206 | * Bookmarks | ||
207 | * Create Dir | ||
208 | */ | ||
209 | QHBox* box = new QHBox(this ); | ||
210 | box->setBackgroundMode( PaletteButton ); | ||
211 | box->setSpacing( 0 ); | ||
212 | |||
213 | QToolButton *btn = new QToolButton( box ); | ||
214 | btn->setIconSet( Resource::loadIconSet("up") ); | ||
215 | connect(btn, SIGNAL(clicked() ), | ||
216 | this, SLOT( cdUP() ) ); | ||
217 | |||
218 | btn = new QToolButton( box ); | ||
219 | btn->setIconSet( Resource::loadIconSet("home") ); | ||
220 | connect(btn, SIGNAL(clicked() ), | ||
221 | this, SLOT( cdHome() ) ); | ||
222 | |||
223 | btn = new QToolButton( box ); | ||
224 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); | ||
225 | connect(btn, SIGNAL(clicked() ), | ||
226 | this, SLOT(cdDoc() ) ); | ||
227 | |||
228 | m_btnNew = new QToolButton( box ); | ||
229 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); | ||
230 | connect(m_btnNew, SIGNAL(clicked() ), | ||
231 | this, SLOT(slotNew() ) ); | ||
232 | |||
233 | |||
234 | m_btnClose = new QToolButton( box ); | ||
235 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); | ||
236 | connect(m_btnClose, SIGNAL(clicked() ), | ||
237 | selector(), SIGNAL(closeMe() ) ); | ||
238 | |||
239 | btn = new QToolButton( box ); | ||
240 | btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); | ||
241 | |||
242 | /* let's fill device parts */ | ||
243 | QPopupMenu* pop = new QPopupMenu(this); | ||
244 | connect(pop, SIGNAL( activated(int) ), | ||
245 | this, SLOT(slotFSActivated(int) ) ); | ||
246 | |||
247 | StorageInfo storage; | ||
248 | const QList<FileSystem> &fs = storage.fileSystems(); | ||
249 | QListIterator<FileSystem> it(fs); | ||
250 | for ( ; it.current(); ++it ) { | ||
251 | const QString disk = (*it)->name(); | ||
252 | const QString path = (*it)->path(); | ||
253 | m_dev.insert( disk, path ); | ||
254 | pop->insertItem( disk ); | ||
255 | } | ||
256 | m_fsPop = pop; | ||
257 | |||
258 | |||
259 | btn->setPopup( pop ); | ||
260 | |||
261 | lay->addWidget( box ); | ||
262 | |||
263 | m_view = new QListView( this ); | ||
264 | |||
265 | m_view->installEventFilter(this); | ||
266 | |||
267 | QPEApplication::setStylusOperation( m_view->viewport(), | ||
268 | QPEApplication::RightOnHold); | ||
269 | m_view->addColumn(" " ); | ||
270 | m_view->addColumn(tr("Name"), 135 ); | ||
271 | m_view->addColumn(tr("Size"), -1 ); | ||
272 | m_view->addColumn(tr("Date"), 60 ); | ||
273 | m_view->addColumn(tr("Mime Type"), -1 ); | ||
274 | |||
275 | |||
276 | m_view->setSorting( 1 ); | ||
277 | m_view->setAllColumnsShowFocus( TRUE ); | ||
278 | |||
279 | lay->addWidget( m_view, 1000 ); | ||
280 | connectSlots(); | ||
281 | } | ||
282 | OFileViewFileListView::~OFileViewFileListView() { | ||
283 | } | ||
284 | void OFileViewFileListView::slotNew() { | ||
285 | DocLnk lnk; | ||
286 | emit selector()->newSelected( lnk ); | ||
287 | } | ||
288 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ | ||
289 | QListViewItem* item = m_view->currentItem(); | ||
290 | if (!item ) | ||
291 | return 0l; | ||
292 | |||
293 | return static_cast<OFileSelectorItem*>(item); | ||
294 | } | ||
295 | void OFileViewFileListView::reread( bool all ) { | ||
296 | m_view->clear(); | ||
297 | |||
298 | if (selector()->showClose() ) | ||
299 | m_btnClose->show(); | ||
300 | else | ||
301 | m_btnClose->hide(); | ||
302 | |||
303 | if (selector()->showNew() ) | ||
304 | m_btnNew->show(); | ||
305 | else | ||
306 | m_btnNew->hide(); | ||
307 | |||
308 | m_mimes = selector()->currentMimeType(); | ||
309 | m_all = all; | ||
310 | |||
311 | QDir dir( m_currentDir ); | ||
312 | if (!dir.exists() ) | ||
313 | return; | ||
314 | |||
315 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | ||
316 | int filter; | ||
317 | if (m_all ) | ||
318 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | ||
319 | else | ||
320 | filter = QDir::Files | QDir::Dirs | QDir::All; | ||
321 | dir.setFilter( filter ); | ||
322 | |||
323 | // now go through all files | ||
324 | const QFileInfoList *list = dir.entryInfoList(); | ||
325 | if (!list) { | ||
326 | cdUP(); | ||
327 | return; | ||
328 | } | ||
329 | QFileInfoListIterator it( *list ); | ||
330 | QFileInfo *fi; | ||
331 | while( (fi=it.current() ) ){ | ||
332 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | ||
333 | ++it; | ||
334 | continue; | ||
335 | } | ||
336 | |||
337 | /* | ||
338 | * It is a symlink we try to resolve it now but don't let us attack by DOS | ||
339 | * | ||
340 | */ | ||
341 | if( fi->isSymLink() ){ | ||
342 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | ||
343 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | ||
344 | QFileInfo info( file ); | ||
345 | if( !info.exists() ){ | ||
346 | addSymlink( fi, TRUE ); | ||
347 | break; | ||
348 | }else if( info.isDir() ){ | ||
349 | addDir( fi, TRUE ); | ||
350 | break; | ||
351 | }else if( info.isFile() ){ | ||
352 | addFile( fi, TRUE ); | ||
353 | break; | ||
354 | }else if( info.isSymLink() ){ | ||
355 | file = info.dirPath(true ) + "/" + info.readLink() ; | ||
356 | break; | ||
357 | }else if( i == 4){ // couldn't resolve symlink add it as symlink | ||
358 | addSymlink( fi ); | ||
359 | } | ||
360 | } // off for loop for symlink resolving | ||
361 | }else if( fi->isDir() ) | ||
362 | addDir( fi ); | ||
363 | else if( fi->isFile() ) | ||
364 | addFile( fi ); | ||
365 | |||
366 | ++it; | ||
367 | } // of while loop | ||
368 | m_view->sort(); | ||
369 | |||
370 | } | ||
371 | int OFileViewFileListView::fileCount()const{ | ||
372 | return m_view->childCount(); | ||
373 | } | ||
374 | QString OFileViewFileListView::currentDir()const{ | ||
375 | return m_currentDir; | ||
376 | } | ||
377 | OFileSelector* OFileViewFileListView::selector() { | ||
378 | return m_sel; | ||
379 | } | ||
380 | |||
381 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { | ||
382 | if ( e->type() == QEvent::KeyPress ) { | ||
383 | QKeyEvent *k = (QKeyEvent *)e; | ||
384 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | ||
385 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | ||
386 | return true; | ||
387 | } | ||
388 | } | ||
389 | return false; | ||
390 | } | ||
391 | |||
392 | |||
393 | void OFileViewFileListView::connectSlots() { | ||
394 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | ||
395 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | ||
396 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), | ||
397 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); | ||
398 | } | ||
399 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { | ||
400 | if (!item) | ||
401 | return; | ||
402 | #if 0 | ||
403 | |||
404 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | ||
405 | |||
406 | if (!sel->isDir() ) { | ||
407 | selector()->m_lneEdit->setText( sel->text(1) ); | ||
408 | // if in fileselector mode we will emit selected | ||
409 | if ( selector()->mode() == OFileSelector::FileSelector ) { | ||
410 | qWarning("slot Current Changed"); | ||
411 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
412 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
413 | emit selector()->fileSelected( path ); | ||
414 | DocLnk lnk( path ); | ||
415 | emit selector()->fileSelected( lnk ); | ||
416 | } | ||
417 | } | ||
418 | #endif | ||
419 | } | ||
420 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { | ||
421 | if (!item || ( button != Qt::LeftButton) ) | ||
422 | return; | ||
423 | |||
424 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | ||
425 | if (!sel->isLocked() ) { | ||
426 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
427 | if (sel->isDir() ) { | ||
428 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
429 | emit selector()->dirSelected( m_currentDir ); | ||
430 | reread( m_all ); | ||
431 | }else { // file | ||
432 | qWarning("slot Clicked"); | ||
433 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | ||
434 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
435 | emit selector()->fileSelected( path ); | ||
436 | DocLnk lnk( path ); | ||
437 | emit selector()->fileSelected( lnk ); | ||
438 | } | ||
439 | } // not locked | ||
440 | } | ||
441 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { | ||
442 | MimeType type( info->absFilePath() ); | ||
443 | if (!compliesMime( type.id() ) ) | ||
444 | return; | ||
445 | |||
446 | QPixmap pix = type.pixmap(); | ||
447 | QString dir, name; bool locked; | ||
448 | if ( pix.isNull() ) { | ||
449 | QWMatrix matrix; | ||
450 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | ||
451 | matrix.scale( .4, .4 ); | ||
452 | pix = pixer.xForm( matrix ); | ||
453 | } | ||
454 | dir = info->dirPath( true ); | ||
455 | locked = false; | ||
456 | if ( symlink ) | ||
457 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | ||
458 | else{ | ||
459 | name = info->fileName(); | ||
460 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | ||
461 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { | ||
462 | locked = true; pix = Resource::loadPixmap("locked"); | ||
463 | } | ||
464 | } | ||
465 | (void)new OFileSelectorItem( m_view, pix, name, | ||
466 | info->lastModified().toString(), QString::number( info->size() ), | ||
467 | dir, locked ); | ||
468 | } | ||
469 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { | ||
470 | bool locked = false; QString name; QPixmap pix; | ||
471 | |||
472 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | ||
473 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { | ||
474 | locked = true; | ||
475 | if ( symlink ) | ||
476 | pix = Resource::loadPixmap( "opie/symlink" ); | ||
477 | else | ||
478 | pix = Resource::loadPixmap( "lockedfolder" ); | ||
479 | }else | ||
480 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); | ||
481 | |||
482 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : | ||
483 | info->fileName(); | ||
484 | |||
485 | (void)new OFileSelectorItem( m_view, pix, name, | ||
486 | info->lastModified().toString(), | ||
487 | QString::number( info->size() ), | ||
488 | info->dirPath( true ), locked, true ); | ||
489 | |||
490 | |||
491 | } | ||
492 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { | ||
493 | |||
494 | } | ||
495 | void OFileViewFileListView::cdUP() { | ||
496 | QDir dir( m_currentDir ); | ||
497 | dir.cdUp(); | ||
498 | |||
499 | if (!dir.exists() ) | ||
500 | m_currentDir = "/"; | ||
501 | else | ||
502 | m_currentDir = dir.absPath(); | ||
503 | |||
504 | emit selector()->dirSelected( m_currentDir ); | ||
505 | reread( m_all ); | ||
506 | } | ||
507 | void OFileViewFileListView::cdHome() { | ||
508 | m_currentDir = QDir::homeDirPath(); | ||
509 | emit selector()->dirSelected( m_currentDir ); | ||
510 | reread( m_all ); | ||
511 | } | ||
512 | void OFileViewFileListView::cdDoc() { | ||
513 | m_currentDir = QPEApplication::documentDir(); | ||
514 | emit selector()->dirSelected( m_currentDir ); | ||
515 | reread( m_all ); | ||
516 | } | ||
517 | void OFileViewFileListView::changeDir( const QString& dir ) { | ||
518 | m_currentDir = dir; | ||
519 | emit selector()->dirSelected( m_currentDir ); | ||
520 | reread( m_all ); | ||
521 | } | ||
522 | void OFileViewFileListView::slotFSActivated( int id ) { | ||
523 | changeDir ( m_dev[m_fsPop->text(id)] ); | ||
524 | } | ||
525 | |||
526 | /* check if the mimetype in mime | ||
527 | * complies with the one which is current | ||
528 | */ | ||
529 | /* | ||
530 | * We've the mimetype of the file | ||
531 | * We need to get the stringlist of the current mimetype | ||
532 | * | ||
533 | * mime = image@slashjpeg | ||
534 | * QStringList = 'image@slash*' | ||
535 | * or QStringList = image/jpeg;image/png;application/x-ogg | ||
536 | * or QStringList = application/x-ogg;image@slash*; | ||
537 | * with all these mime filters it should get acceptes | ||
538 | * to do so we need to look if mime is contained inside | ||
539 | * the stringlist | ||
540 | * if it's contained return true | ||
541 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | ||
542 | * is contained in the mimefilter and then we will | ||
543 | * look if both are equal until the '/' | ||
544 | */ | ||
545 | bool OFileViewFileListView::compliesMime( const QString& str) { | ||
546 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | ||
547 | return true; | ||
548 | |||
549 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { | ||
550 | QRegExp reg( (*it) ); | ||
551 | reg.setWildcard( true ); | ||
552 | if ( str.find( reg ) != -1 ) | ||
553 | return true; | ||
554 | |||
555 | } | ||
556 | return false; | ||
557 | } | ||
558 | /* | ||
559 | * The listView giving access to the file system! | ||
560 | */ | ||
561 | class OFileViewFileSystem : public OFileViewInterface { | ||
562 | public: | ||
563 | OFileViewFileSystem( OFileSelector* ); | ||
564 | ~OFileViewFileSystem(); | ||
565 | |||
566 | QString selectedName() const; | ||
567 | QString selectedPath() const; | ||
568 | |||
569 | QString directory()const; | ||
570 | void reread(); | ||
571 | int fileCount()const; | ||
572 | |||
573 | QWidget* widget( QWidget* parent ); | ||
574 | void activate( const QString& ); | ||
575 | private: | ||
576 | OFileViewFileListView* m_view; | ||
577 | bool m_all : 1; | ||
578 | }; | ||
579 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | ||
580 | : OFileViewInterface( sel ) { | ||
581 | m_view = 0; | ||
582 | m_all = false; | ||
583 | } | ||
584 | OFileViewFileSystem::~OFileViewFileSystem() { | ||
585 | } | ||
586 | QString OFileViewFileSystem::selectedName()const{ | ||
587 | if (!m_view ) | ||
588 | return QString::null; | ||
589 | |||
590 | QString cFN=currentFileName(); | ||
591 | if (cFN.startsWith("/")) return cFN; | ||
592 | return m_view->currentDir() + "/" + cFN; | ||
593 | } | ||
594 | QString OFileViewFileSystem::selectedPath()const{ | ||
595 | return QString::null; | ||
596 | } | ||
597 | QString OFileViewFileSystem::directory()const{ | ||
598 | if (!m_view) | ||
599 | return QString::null; | ||
600 | |||
601 | OFileSelectorItem* item = m_view->currentItem(); | ||
602 | if (!item ) | ||
603 | return QString::null; | ||
604 | |||
605 | return QDir(item->directory() ).absPath(); | ||
606 | } | ||
607 | void OFileViewFileSystem::reread() { | ||
608 | if (!m_view) | ||
609 | return; | ||
610 | |||
611 | m_view->reread( m_all ); | ||
612 | } | ||
613 | int OFileViewFileSystem::fileCount()const{ | ||
614 | if (!m_view ) | ||
615 | return -1; | ||
616 | return m_view->fileCount(); | ||
617 | } | ||
618 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { | ||
619 | if (!m_view ) { | ||
620 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | ||
621 | } | ||
622 | return m_view; | ||
623 | } | ||
624 | void OFileViewFileSystem::activate( const QString& str) { | ||
625 | m_all = (str != QObject::tr("Files") ); | ||
626 | |||
627 | |||
628 | } | ||
629 | |||
630 | /* Selector */ | ||
631 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | ||
632 | const QString& dirName, const QString& fileName, | ||
633 | const MimeTypes& mimetypes, | ||
634 | bool showNew, bool showClose) | ||
635 | : QWidget( parent, "OFileSelector" ) | ||
636 | { | ||
637 | m_current = 0; | ||
638 | m_shNew = showNew; | ||
639 | m_shClose = showClose; | ||
640 | m_mimeType = mimetypes; | ||
641 | m_startDir = dirName; | ||
642 | |||
643 | m_mode = mode; | ||
644 | m_selector = sel; | ||
645 | |||
646 | initUI(); | ||
647 | m_lneEdit->setText( fileName ); | ||
648 | initMime(); | ||
649 | initViews(); | ||
650 | |||
651 | QString str; | ||
652 | switch ( m_selector ) { | ||
653 | default: | ||
654 | case Normal: | ||
655 | str = QObject::tr("Documents"); | ||
656 | m_cmbView->setCurrentItem( 0 ); | ||
657 | break; | ||
658 | case Extended: | ||
659 | str = QObject::tr("Files"); | ||
660 | m_cmbView->setCurrentItem( 1 ); | ||
661 | break; | ||
662 | case ExtendedAll: | ||
663 | str = QObject::tr("All Files"); | ||
664 | m_cmbView->setCurrentItem( 2 ); | ||
665 | break; | ||
666 | } | ||
667 | slotViewChange( str ); | ||
668 | |||
669 | } | ||
670 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | ||
671 | bool showNew, bool showClose ) | ||
672 | : QWidget( parent, name ) | ||
673 | { | ||
674 | m_current = 0; | ||
675 | m_shNew = showNew; | ||
676 | m_shClose = showClose; | ||
677 | m_startDir = QPEApplication::documentDir(); | ||
678 | |||
679 | if (!mimeFilter.isEmpty() ) | ||
680 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | ||
681 | |||
682 | m_mode = OFileSelector::FileSelector; | ||
683 | m_selector = OFileSelector::Normal; | ||
684 | |||
685 | initUI(); | ||
686 | initMime(); | ||
687 | initViews(); | ||
688 | m_cmbView->setCurrentItem( 0 ); | ||
689 | slotViewChange( QObject::tr("Documents") ); | ||
690 | } | ||
691 | /* | ||
692 | * INIT UI will set up the basic GUI | ||
693 | * Layout: Simple VBoxLayout | ||
694 | * On top a WidgetStack containing the Views... | ||
695 | * - List View | ||
696 | * - Document View | ||
697 | * Below we will have a Label + LineEdit | ||
698 | * Below we will have two ComoBoxes one for choosing the view one for | ||
699 | * choosing the mimetype | ||
700 | */ | ||
701 | void OFileSelector::initUI() { | ||
702 | QVBoxLayout* lay = new QVBoxLayout( this ); | ||
703 | |||
704 | m_stack = new QWidgetStack( this ); | ||
705 | lay->addWidget( m_stack, 1000 ); | ||
706 | |||
707 | m_nameBox = new QHBox( this ); | ||
708 | (void)new QLabel( tr("Name:"), m_nameBox ); | ||
709 | m_lneEdit = new QLineEdit( m_nameBox ); | ||
710 | m_lneEdit ->installEventFilter(this); | ||
711 | lay->addWidget( m_nameBox ); | ||
712 | |||
713 | m_cmbBox = new QHBox( this ); | ||
714 | m_cmbView = new QComboBox( m_cmbBox ); | ||
715 | m_cmbMime = new QComboBox( m_cmbBox ); | ||
716 | lay->addWidget( m_cmbBox ); | ||
717 | } | ||
718 | |||
719 | /* | ||
720 | * This will make sure that the return key in the name edit causes dialogs to close | ||
721 | */ | ||
722 | |||
723 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) { | ||
724 | if ( e->type() == QEvent::KeyPress ) { | ||
725 | QKeyEvent *k = (QKeyEvent *)e; | ||
726 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | ||
727 | emit ok(); | ||
728 | return true; | ||
729 | } | ||
730 | } | ||
731 | return false; | ||
732 | } | ||
733 | |||
734 | /* | ||
735 | * This will insert the MimeTypes into the Combo Box | ||
736 | * And also connect the changed signal | ||
737 | * | ||
738 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes | ||
739 | */ | ||
740 | void OFileSelector::initMime() { | ||
741 | MimeTypes::Iterator it; | ||
742 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) { | ||
743 | m_cmbMime->insertItem( it.key() ); | ||
744 | } | ||
745 | m_cmbMime->setCurrentItem( 0 ); | ||
746 | |||
747 | connect( m_cmbMime, SIGNAL(activated(int) ), | ||
748 | this, SLOT(slotMimeTypeChanged() ) ); | ||
749 | |||
750 | } | ||
751 | void OFileSelector::initViews() { | ||
752 | m_cmbView->insertItem( QObject::tr("Documents") ); | ||
753 | m_cmbView->insertItem( QObject::tr("Files") ); | ||
754 | m_cmbView->insertItem( QObject::tr("All Files") ); | ||
755 | connect(m_cmbView, SIGNAL(activated( const QString& ) ), | ||
756 | this, SLOT(slotViewChange( const QString& ) ) ); | ||
757 | |||
758 | |||
759 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); | ||
760 | |||
761 | /* see above why add both */ | ||
762 | OFileViewInterface* in = new OFileViewFileSystem( this ); | ||
763 | m_views.insert( QObject::tr("Files"), in ); | ||
764 | m_views.insert( QObject::tr("All Files"), in ); | ||
765 | } | ||
766 | OFileSelector::~OFileSelector() { | ||
767 | |||
768 | } | ||
769 | const DocLnk* OFileSelector::selected() { | ||
770 | DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); | ||
771 | return lnk; | ||
772 | } | ||
773 | QString OFileSelector::selectedName()const{ | ||
774 | return currentView()->selectedName(); | ||
775 | } | ||
776 | QString OFileSelector::selectedPath()const { | ||
777 | return currentView()->selectedPath(); | ||
778 | } | ||
779 | QString OFileSelector::directory()const { | ||
780 | return currentView()->directory(); | ||
781 | } | ||
782 | DocLnk OFileSelector::selectedDocument()const { | ||
783 | return currentView()->selectedDocument(); | ||
784 | } | ||
785 | int OFileSelector::fileCount()const { | ||
786 | return currentView()->fileCount(); | ||
787 | } | ||
788 | void OFileSelector::reread() { | ||
789 | return currentView()->reread(); | ||
790 | } | ||
791 | OFileViewInterface* OFileSelector::currentView()const{ | ||
792 | return m_current; | ||
793 | } | ||
794 | bool OFileSelector::showNew()const { | ||
795 | return m_shNew; | ||
796 | } | ||
797 | bool OFileSelector::showClose()const { | ||
798 | return m_shClose; | ||
799 | } | ||
800 | MimeTypes OFileSelector::mimeTypes()const { | ||
801 | return m_mimeType; | ||
802 | } | ||
803 | int OFileSelector::mode()const{ | ||
804 | return m_mode; | ||
805 | } | ||
806 | int OFileSelector::selector()const{ | ||
807 | return m_selector; | ||
808 | } | ||
809 | QStringList OFileSelector::currentMimeType()const { | ||
810 | return m_mimeType[m_cmbMime->currentText()]; | ||
811 | } | ||
812 | void OFileSelector::slotMimeTypeChanged() { | ||
813 | reread(); | ||
814 | } | ||
815 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) { | ||
816 | m_lneEdit->setText( lnk.name() ); | ||
817 | emit fileSelected( lnk ); | ||
818 | emit fileSelected( lnk.name() ); | ||
819 | } | ||
820 | void OFileSelector::slotFileBridge( const QString& str) { | ||
821 | DocLnk lnk( str ); | ||
822 | emit fileSelected( lnk ); | ||
823 | } | ||
824 | void OFileSelector::slotViewChange( const QString& view ) { | ||
825 | OFileViewInterface* interface = m_views[view]; | ||
826 | if (!interface) | ||
827 | return; | ||
828 | |||
829 | interface->activate( view ); | ||
830 | if (m_current) | ||
831 | m_stack->removeWidget( m_current->widget( m_stack ) ); | ||
832 | |||
833 | static int id = 1; | ||
834 | |||
835 | m_stack->addWidget( interface->widget(m_stack), id ); | ||
836 | m_stack->raiseWidget( id ); | ||
837 | |||
838 | interface->reread(); | ||
839 | m_current = interface; | ||
840 | |||
841 | id++; | ||
842 | } | ||
843 | void OFileSelector::setNewVisible( bool b ) { | ||
844 | m_shNew = b; | ||
845 | currentView()->reread(); | ||
846 | } | ||
847 | void OFileSelector::setCloseVisible( bool b ) { | ||
848 | m_shClose = b; | ||
849 | currentView()->reread(); | ||
850 | } | ||
851 | void OFileSelector::setNameVisible( bool b ) { | ||
852 | if ( b ) | ||
853 | m_nameBox->show(); | ||
854 | else | ||
855 | m_nameBox->hide(); | ||
856 | } | ||
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index d06aa0a..bdb3e56 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -1,314 +1,150 @@ | |||
1 | /* | 1 | /* |
2 | This is based on code and ideas of | 2 | This is based on code and ideas of |
3 | L. J. Potter ljp@llornkcor.com | 3 | L. J. Potter ljp@llornkcor.com |
4 | Thanks a lot | 4 | Thanks a lot |
5 | 5 | ||
6 | 6 | ||
7 | =. This file is part of the OPIE Project | 7 | =. This file is part of the OPIE Project |
8 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 8 | .=l. Copyright (c) 2002,2003 Holger Freyther <zecke@handhelds.org> |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This library is free software; you can | 10 | _;:, .> :=|. This library is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This library is distributed in the hope that | 17 | .i_,=:_. -<s. This library is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef opiefileselector_h | ||
35 | #define opiefileselector_h | ||
36 | 34 | ||
35 | #ifndef OPIE_OFILESELECTOR_FOO_H | ||
36 | #define OPIE_OFILESELECTOR_FOO_H | ||
37 | |||
38 | #include <qlist.h> | ||
37 | #include <qwidget.h> | 39 | #include <qwidget.h> |
38 | #include <qstring.h> | ||
39 | #include <qpixmap.h> | ||
40 | #include <qstringlist.h> | ||
41 | #include <qmap.h> | 40 | #include <qmap.h> |
42 | #include <qvaluelist.h> | 41 | #include <qvaluelist.h> |
42 | #include <qstringlist.h> | ||
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qlistview.h> | ||
46 | 45 | ||
46 | typedef QMap<QString, QStringList> MimeTypes; | ||
47 | 47 | ||
48 | class DocLnk; | 48 | class OFileViewInterface; |
49 | class QCheckBox; | 49 | class OFileViewFileListView; |
50 | class QComboBox; | ||
51 | class QPushButton; | ||
52 | class FileSelector; | ||
53 | class QGridLayout; | ||
54 | class QLineEdit; | 50 | class QLineEdit; |
55 | class QLabel; | 51 | class QComboBox; |
56 | class QWidgetStack; | 52 | class QWidgetStack; |
57 | class QHBoxLayout; | ||
58 | class QVBoxLayout; | ||
59 | class QPopupMenu; | ||
60 | class QFileInfo; | ||
61 | class QHBox; | 53 | class QHBox; |
62 | // | ||
63 | |||
64 | typedef QMap< QString, QStringList> MimeTypes; | ||
65 | |||
66 | /** | ||
67 | * This is OPIEs FileDialog Widget. You can use it | ||
68 | * as a dropin replacement of the fileselector and | ||
69 | * or use any of the new features. | ||
70 | * This is also a complete FileSave and FileLoad widget | ||
71 | * If you look for a Dialog check OFileDialog | ||
72 | * | ||
73 | * NOTE THAT the API will change to be more extendable! | ||
74 | */ | ||
75 | class OFileSelector : public QWidget { | 54 | class OFileSelector : public QWidget { |
76 | Q_OBJECT | 55 | Q_OBJECT |
77 | public: | 56 | friend class OFileViewInterface; |
78 | /** | 57 | friend class OFileViewFileListView; |
79 | * The mode of the file selector | 58 | public: |
80 | * Either open, save, fileselector or dir browsing mode | 59 | enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; |
81 | * | 60 | // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; |
82 | */ | 61 | enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; |
83 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; | 62 | // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; |
84 | 63 | ||
85 | /** | 64 | OFileSelector(QWidget* parent, int mode, int selector, |
86 | * Selector. Either NORMAL for the one shipped with | 65 | const QString& dirName, |
87 | * libqpe or EXTENDED. for the EXTENDED | 66 | const QString& fileName, |
88 | * EXTENDED_ALL also shows 'hidden' files | 67 | const MimeTypes& mimetypes = MimeTypes(), |
89 | */ | 68 | bool newVisible = FALSE, bool closeVisible = FALSE ); |
90 | enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 }; | 69 | |
91 | 70 | OFileSelector(const QString& mimeFilter, QWidget* parent, | |
92 | /** | 71 | const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); |
93 | * This is reserved for futrue views | 72 | ~OFileSelector(); |
94 | */ | 73 | |
95 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; | 74 | const DocLnk* selected(); |
96 | 75 | ||
97 | /** | 76 | QString selectedName()const; |
98 | * A c'tor which should be used for advanced mode | 77 | QString selectedPath()const; |
99 | * @param wid the parent | 78 | QString directory()const; |
100 | * @param mode the Mode of the Selector | 79 | |
101 | * @param selector the current View of the Selector | 80 | DocLnk selectedDocument()const; |
102 | * @param dirName in which dir to start | 81 | |
103 | * @param fileName a proposed filename | 82 | int fileCount()const; |
104 | * @param mimetypes A list of mimetypes \ | 83 | void reread(); |
105 | * QString is for a identifier name like "Text files" | 84 | |
106 | * the coresponding QStringList is used for the mimetypes | 85 | int mode()const; |
107 | * if empty it'll fill the list of mimetypes depending | 86 | int selector()const; |
108 | * on the content of the current directory | 87 | |
109 | */ | 88 | |
110 | 89 | void setNewVisible( bool b ); | |
111 | OFileSelector(QWidget *wid, int mode, int selector, | 90 | void setCloseVisible( bool b ); |
112 | const QString &dirName, | 91 | void setNameVisible( bool b ); |
113 | const QString &fileName = QString::null, | 92 | |
114 | const MimeTypes &mimetypes = MimeTypes() ); | 93 | signals: |
115 | 94 | void dirSelected( const QString& ); | |
116 | 95 | void fileSelected( const DocLnk& ); | |
117 | /** | 96 | void fileSelected( const QString& ); |
118 | * This is a QPE compatible c'tor | 97 | void newSelected( const DocLnk& ); |
119 | */ | 98 | void closeMe(); |
120 | OFileSelector(const QString &mimeFilter, QWidget *parent, | 99 | void ok(); |
121 | const char *name, bool newVisible = TRUE, | 100 | void cancel(); |
122 | bool closeVisible = FALSE ); | 101 | |
123 | 102 | /* used by the ViewInterface */ | |
124 | ~OFileSelector(); | 103 | private: |
125 | 104 | bool showNew()const; | |
126 | // currently only for the FILESELECTOR Mode | 105 | bool showClose()const; |
127 | /** | 106 | MimeTypes mimeTypes()const; |
128 | */ | 107 | QStringList currentMimeType()const; |
129 | void setNewVisible( bool /*b*/ ); | 108 | |
130 | void setCloseVisible(bool /*b*/ ); | 109 | private: |
131 | 110 | /* inits the Widgets */ | |
132 | // end file selector mode | 111 | void initUI(); |
133 | // deprecated | 112 | /* inits the MimeType ComboBox content + connects signals and slots */ |
134 | void reread(); | 113 | void initMime(); |
135 | // make sure not to leak please | 114 | /* init the Views :) */ |
136 | const DocLnk *selected(); | 115 | void initViews(); |
137 | // end deprecated | 116 | |
138 | 117 | private: | |
139 | bool isToolbarVisible() const { return m_shTool; }; | 118 | QLineEdit* m_lneEdit; // the LineEdit for the Name |
140 | bool isPermissionBarVisible() const { return m_shPerm; }; | 119 | QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType |
141 | bool isLineEditVisible()const { return m_shLne; }; | 120 | QWidgetStack* m_stack; // our widget stack which will contain the views |
142 | bool isChooserVisible( )const { return m_shChooser; }; | 121 | OFileViewInterface* currentView()const; // returns the currentView |
143 | bool isYesCancelVisible()const { return m_shYesNo; }; | 122 | OFileViewInterface* m_current; // here is the view saved |
144 | void setYesCancelVisible( bool show ); | 123 | bool m_shNew : 1; // should we show New? |
145 | void setToolbarVisible( bool show ); | 124 | bool m_shClose : 1; // should we show Close? |
146 | void setPermissionBarVisible( bool show ); | 125 | MimeTypes m_mimeType; // list of mimetypes |
147 | void setLineEditVisible(bool show) ; | 126 | |
148 | void setChooserVisible( bool chooser ); | 127 | QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr |
149 | 128 | QHBox* m_nameBox; // the LineEdit + Label is hold here | |
150 | QCheckBox* permissionCheckbox(); | 129 | QHBox* m_cmbBox; // this holds the two combo boxes |
151 | bool setPermission() const; | 130 | |
152 | void setPermissionChecked( bool check ); | 131 | QString m_startDir; |
153 | 132 | int m_mode; | |
154 | void setMode( int ); | 133 | int m_selector; |
155 | 134 | ||
156 | bool showDirs()const { return m_dir; } | 135 | struct Data; // used for future versions |
157 | void setShowDirs(bool ); | 136 | Data *d; |
158 | |||
159 | const QListView* listView() { return m_View; }; | ||
160 | |||
161 | bool isCaseSensetive()const { return m_case; } | ||
162 | void setCaseSensetive(bool caSe ); | ||
163 | |||
164 | bool showFiles()const { return m_files; }; | ||
165 | void setShowFiles(bool ); | ||
166 | bool cd(const QString &path ); | ||
167 | 137 | ||
138 | private slots: | ||
139 | void slotMimeTypeChanged(); | ||
168 | 140 | ||
169 | int mode()const { return m_mode; }; | 141 | /* will set the text of the lineedit and emit a fileChanged signal */ |
170 | int selector()const { return m_selector; }; | 142 | void slotDocLnkBridge( const DocLnk& ); |
171 | void setSelector( int ); | 143 | void slotFileBridge( const QString& ); |
172 | 144 | void slotViewChange( const QString& ); | |
173 | bool showPopup()const { return m_showPopup; }; | ||
174 | void setShowPopup( bool pop ) { m_showPopup = pop; }; | ||
175 | void setPopupMenu( QPopupMenu * ); | ||
176 | |||
177 | // void updateLay(); | ||
178 | |||
179 | void reparse(); // re reads the dir | ||
180 | |||
181 | QString selectedName( )const; | ||
182 | QStringList selectedNames()const; | ||
183 | |||
184 | QString selectedPath() const; | ||
185 | QStringList selectedPaths() const; | ||
186 | |||
187 | QString directory()const; | ||
188 | int fileCount() const; | ||
189 | |||
190 | /* the user needs to delete it */ | ||
191 | DocLnk selectedDocument()const; | ||
192 | /* the user needs to delete it */ | ||
193 | QValueList<DocLnk> selectedDocuments()const; | ||
194 | |||
195 | signals: | ||
196 | void fileSelected( const DocLnk & ); | ||
197 | void fileSelected( const QString & ); | ||
198 | void dirSelected(const QString &dir ); | ||
199 | void closeMe(); | ||
200 | void ok(); | ||
201 | void cancel(); | ||
202 | void contextMenu(); | ||
203 | |||
204 | private slots: | ||
205 | void slotTest() { qWarning("slotTest" ); setLineEditVisible(false ); }; | ||
206 | void slotOk(); | ||
207 | void slotCancel(); | ||
208 | void slotViewCheck(const QString & ); | ||
209 | void slotMimeCheck(const QString & ); | ||
210 | void slotLocationActivated(const QString & ); | ||
211 | void slotInsertLocationPath(const QString &, int); | ||
212 | void locationComboChanged(); | ||
213 | |||
214 | private: | ||
215 | void init(); | ||
216 | void updateMimes(); | ||
217 | |||
218 | protected: | ||
219 | |||
220 | private: | ||
221 | int m_mode, m_selector; | ||
222 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | ||
223 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | ||
224 | QPushButton *m_reread, *m_up, *m_new, *m_close; | ||
225 | QListView *m_View; | ||
226 | QCheckBox *m_checkPerm; | ||
227 | QWidget *m_pseudo; | ||
228 | QVBoxLayout *m_pseudoLayout; | ||
229 | |||
230 | QString m_currentDir; | ||
231 | QString m_name; | ||
232 | // QStringList m_mimetypes; | ||
233 | QMap<QString, QStringList> m_mimetypes; | ||
234 | |||
235 | FileSelector *m_select; | ||
236 | QWidgetStack *m_stack; | ||
237 | QVBoxLayout *m_lay; | ||
238 | QGridLayout *m_Oselector; | ||
239 | |||
240 | QHBox *m_boxToolbar; | ||
241 | QHBox *m_boxOk; // (no layout anymore) wait | ||
242 | QHBox *m_boxName; // (no Layout anymore) wait | ||
243 | QHBox *m_boxView; | ||
244 | |||
245 | QPopupMenu *m_custom; | ||
246 | |||
247 | QLineEdit *m_edit; | ||
248 | QLabel *m_fnLabel; | ||
249 | |||
250 | bool m_shClose : 1; | ||
251 | bool m_shNew : 1; | ||
252 | bool m_shTool : 1; | ||
253 | bool m_shPerm : 1; | ||
254 | bool m_shLne : 1; | ||
255 | bool m_shChooser : 1; | ||
256 | bool m_shYesNo : 1; | ||
257 | bool m_boCheckPerm : 1; | ||
258 | bool m_autoMime : 1; | ||
259 | bool m_case : 1; | ||
260 | bool m_dir : 1; | ||
261 | bool m_files : 1; | ||
262 | bool m_showPopup : 1; | ||
263 | |||
264 | void initVars(); | ||
265 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); | ||
266 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); | ||
267 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; | ||
268 | void delItems(); | ||
269 | void initializeName(); | ||
270 | void initializeYes(); | ||
271 | void initializeChooser(); | ||
272 | void initializeListView(); | ||
273 | void initializePerm(); | ||
274 | void initPics(); | ||
275 | bool compliesMime(const QString &path, | ||
276 | const QString &mime); | ||
277 | bool compliesMime(const QString& mime ); | ||
278 | /** | ||
279 | * Updates the QComboBox with the current mimetypes | ||
280 | */ | ||
281 | void updateMimeCheck(); | ||
282 | 145 | ||
283 | /** | 146 | bool eventFilter (QObject *o, QEvent *e); |
284 | * Returns the current mimetype | ||
285 | */ | ||
286 | QString currentMimeType()const; | ||
287 | class OFileSelectorPrivate; | ||
288 | OFileSelectorPrivate *d; | ||
289 | static QMap<QString,QPixmap> *m_pixmaps; | ||
290 | 147 | ||
291 | private slots: | ||
292 | void slotFileSelected(const QString & ); // not really meant to be a slot | ||
293 | void slotFileBridgeSelected( const DocLnk & ); | ||
294 | virtual void slotSelectionChanged(); | ||
295 | virtual void slotCurrentChanged(QListViewItem* ); | ||
296 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); | ||
297 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); | ||
298 | virtual void slotContextMenu( QListViewItem *item); | ||
299 | // listview above | ||
300 | // popup below | ||
301 | virtual void slotChangedDir(); | ||
302 | virtual void slotOpen(); | ||
303 | virtual void slotRescan(); | ||
304 | virtual void slotRename(); | ||
305 | virtual void slotDelete(); | ||
306 | virtual void cdUP(); | ||
307 | virtual void slotHome(); | ||
308 | virtual void slotDoc(); | ||
309 | virtual void slotNavigate( ); | ||
310 | }; | 148 | }; |
311 | 149 | ||
312 | |||
313 | #endif | 150 | #endif |
314 | |||
diff --git a/libopie/ofileselector_p.h b/libopie/ofileselector_p.h new file mode 100644 index 0000000..7fd0c50 --- a/dev/null +++ b/libopie/ofileselector_p.h | |||
@@ -0,0 +1,151 @@ | |||
1 | #ifndef OPIE_OFILE_SELECTOR_PRIVATE_H | ||
2 | #define OPIE_OFILE_SELECTOR_PRIVATE_H | ||
3 | |||
4 | #include <qmap.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qwidget.h> | ||
7 | #include <qlistview.h> | ||
8 | |||
9 | #include <qpe/applnk.h> | ||
10 | #include <qpe/fileselector.h> | ||
11 | |||
12 | |||
13 | /* | ||
14 | * How to avoid having really two different objects | ||
15 | * for Extended and ExtendedAll | ||
16 | * The only difference is the Lister... | ||
17 | * a) static object? | ||
18 | * b) leave some object inside the OFileSelector which can be used? | ||
19 | * c) when switching views tell which view we want o have.. internally we can switch then | ||
20 | * | ||
21 | * I'll take c) -zecke | ||
22 | */ | ||
23 | |||
24 | |||
25 | /* the View Interface */ | ||
26 | class OFileSelector; | ||
27 | typedef QMap<QString, QStringList> MimeTypes; | ||
28 | class QFileInfo; | ||
29 | class QToolButton; | ||
30 | class OFileViewInterface { | ||
31 | public: | ||
32 | OFileViewInterface( OFileSelector* selector ); | ||
33 | virtual ~OFileViewInterface(); | ||
34 | virtual QString selectedName()const = 0; | ||
35 | virtual QString selectedPath()const = 0; | ||
36 | virtual QString directory()const = 0; | ||
37 | virtual void reread() = 0; | ||
38 | virtual int fileCount()const = 0; | ||
39 | virtual DocLnk selectedDocument()const; | ||
40 | virtual QWidget* widget( QWidget* parent) = 0; | ||
41 | virtual void activate( const QString& ); | ||
42 | QString name()const; | ||
43 | protected: | ||
44 | OFileSelector* selector()const; | ||
45 | void setName( const QString& ); | ||
46 | bool showNew()const; | ||
47 | bool showClose()const; | ||
48 | MimeTypes mimeTypes()const; | ||
49 | QStringList currentMimeType()const; | ||
50 | QString startDirectory()const; | ||
51 | protected: | ||
52 | void ok(); | ||
53 | void cancel(); | ||
54 | void closeMe(); | ||
55 | void fileSelected( const QString& ); | ||
56 | void fileSelected( const DocLnk& ); | ||
57 | void setCurrentFileName( const QString& ); | ||
58 | QString currentFileName()const; | ||
59 | |||
60 | private: | ||
61 | QString m_name; | ||
62 | OFileSelector* m_selector; | ||
63 | }; | ||
64 | |||
65 | |||
66 | /* THE Document View hosting a FileSelector*/ | ||
67 | class ODocumentFileView : public OFileViewInterface { | ||
68 | public: | ||
69 | ODocumentFileView( OFileSelector* selector ); | ||
70 | ~ODocumentFileView(); | ||
71 | |||
72 | QString selectedName() const; | ||
73 | QString selectedPath() const; | ||
74 | |||
75 | QString directory() const; | ||
76 | void reread(); | ||
77 | int fileCount()const; | ||
78 | DocLnk selectedDocument()const; | ||
79 | |||
80 | QWidget* widget( QWidget* parent ); | ||
81 | |||
82 | private: | ||
83 | mutable FileSelector* m_selector; | ||
84 | |||
85 | }; | ||
86 | |||
87 | class OFileSelectorItem : public QListViewItem { | ||
88 | public: | ||
89 | OFileSelectorItem( QListView* view, const QPixmap& pixmap, | ||
90 | const QString& path, const QString& date, | ||
91 | const QString& size, const QString& mDir, | ||
92 | bool isLocked = false, bool isDir = false ); | ||
93 | ~OFileSelectorItem(); | ||
94 | bool isLocked()const; | ||
95 | bool isDir()const; | ||
96 | QString directory()const; | ||
97 | QString path()const; | ||
98 | QString key(int id, bool )const; | ||
99 | |||
100 | private: | ||
101 | bool m_locked : 1; | ||
102 | bool m_isDir : 1; | ||
103 | QString m_dir; | ||
104 | }; | ||
105 | |||
106 | class OFileViewFileListView : public QWidget { | ||
107 | Q_OBJECT | ||
108 | public: | ||
109 | OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); | ||
110 | ~OFileViewFileListView(); | ||
111 | |||
112 | OFileSelectorItem* currentItem()const; | ||
113 | void reread( bool all = false ); | ||
114 | int fileCount()const; | ||
115 | QString currentDir()const; | ||
116 | protected: | ||
117 | bool eventFilter (QObject *o, QEvent *e); | ||
118 | private slots: | ||
119 | void slotNew(); // will emit newSelected | ||
120 | void cdUP(); | ||
121 | void cdHome(); | ||
122 | void cdDoc(); | ||
123 | void changeDir( const QString& ); | ||
124 | void slotCurrentChanged( QListViewItem* ); | ||
125 | void slotClicked(int, QListViewItem*, const QPoint&, int ); | ||
126 | void slotFSActivated(int); | ||
127 | |||
128 | protected: | ||
129 | |||
130 | OFileSelector* selector(); | ||
131 | |||
132 | private: | ||
133 | QMap<QString, QString> m_dev; | ||
134 | bool m_all : 1; | ||
135 | OFileSelector* m_sel; | ||
136 | QPopupMenu* m_fsPop; | ||
137 | bool compliesMime( const QString& ); | ||
138 | QStringList m_mimes; // used in compy mime | ||
139 | QString m_currentDir; | ||
140 | QToolButton *m_btnNew, *m_btnClose; | ||
141 | void connectSlots(); | ||
142 | void addFile( QFileInfo* info, bool symlink = FALSE ); | ||
143 | void addDir ( QFileInfo* info, bool symlink = FALSE ); | ||
144 | void addSymlink( QFileInfo* info, bool = FALSE ); | ||
145 | |||
146 | |||
147 | private: | ||
148 | QListView* m_view; | ||
149 | }; | ||
150 | |||
151 | #endif | ||
diff --git a/libopie/orecurrancewidget.cpp b/libopie/orecurrancewidget.cpp index 471249d..be8ec30 100644 --- a/libopie/orecurrancewidget.cpp +++ b/libopie/orecurrancewidget.cpp | |||
@@ -1,135 +1,156 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qlabel.h> | 2 | #include <qlabel.h> |
3 | #include <qpopupmenu.h> | 3 | #include <qpopupmenu.h> |
4 | #include <qspinbox.h> | 4 | #include <qspinbox.h> |
5 | 5 | ||
6 | #include <qpe/timestring.h> | 6 | #include <qpe/timestring.h> |
7 | 7 | ||
8 | #include "orecurrancewidget.h" | 8 | #include "orecurrancewidget.h" |
9 | 9 | ||
10 | // Global Templates for use in setting up the repeat label... | 10 | // Global Templates for use in setting up the repeat label... |
11 | const QString strDayTemplate = QObject::tr("Every"); | 11 | // the problem is these strings get initialized before QPEApplication can install the translator -zecke |
12 | const QString strYearTemplate = QObject::tr("%1 %2 every "); | 12 | namespace { |
13 | const QString strMonthDateTemplate = QObject::tr("The %1 every "); | 13 | QString strDayTemplate; |
14 | const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every"); | 14 | QString strYearTemplate; |
15 | const QString strWeekTemplate = QObject::tr("Every "); | 15 | QString strMonthDateTemplate; |
16 | const QString dayLabel[] = { QObject::tr("Monday"), | 16 | QString strMonthDayTemplate; |
17 | QObject::tr("Tuesday"), | 17 | QString strWeekTemplate; |
18 | QObject::tr("Wednesday"), | 18 | QString dayLabel[7]; |
19 | QObject::tr("Thursday"), | 19 | } |
20 | QObject::tr("Friday"), | ||
21 | QObject::tr("Saturday"), | ||
22 | QObject::tr("Sunday") }; | ||
23 | 20 | ||
21 | /* | ||
22 | * static linkage to not polute the symbol table... | ||
23 | * The problem is that const and static linkage are resolved prior to installing a translator | ||
24 | * leading to that the above strings are translted but to the original we delay the init of these strings... | ||
25 | * -zecke | ||
26 | */ | ||
27 | static void fillStrings() { | ||
28 | strDayTemplate = QObject::tr("Every"); | ||
29 | strYearTemplate = QObject::tr("%1 %2 every "); | ||
30 | strMonthDateTemplate = QObject::tr("The %1 every "); | ||
31 | strMonthDayTemplate = QObject::tr("The %1 %2 of every"); | ||
32 | strWeekTemplate = QObject::tr("Every "); | ||
33 | dayLabel[0] = QObject::tr("Monday"); | ||
34 | dayLabel[1] = QObject::tr("Tuesday"); | ||
35 | dayLabel[2] = QObject::tr("Wednesday"); | ||
36 | dayLabel[3] = QObject::tr("Thursday"); | ||
37 | dayLabel[4] = QObject::tr("Friday"); | ||
38 | dayLabel[5] = QObject::tr("Saturday"); | ||
39 | dayLabel[6] = QObject::tr("Sunday"); | ||
40 | } | ||
24 | 41 | ||
25 | static QString numberPlacing( int x );// return the proper word format for | 42 | static QString numberPlacing( int x );// return the proper word format for |
26 | // x (1st, 2nd, etc) | 43 | // x (1st, 2nd, etc) |
27 | static int week( const QDate &dt ); // what week in the month is dt? | 44 | static int week( const QDate &dt ); // what week in the month is dt? |
28 | 45 | ||
29 | /** | 46 | /** |
30 | * Constructs the Widget | 47 | * Constructs the Widget |
31 | * @param startOnMonday Does the week start on monday | 48 | * @param startOnMonday Does the week start on monday |
32 | * @param newStart The start date of the recurrence | 49 | * @param newStart The start date of the recurrence |
33 | * @param parent The parent widget | 50 | * @param parent The parent widget |
34 | * @param name the name of object | 51 | * @param name the name of object |
35 | * @param modal if the dialog should be modal | 52 | * @param modal if the dialog should be modal |
36 | * @param fl Additional window flags | 53 | * @param fl Additional window flags |
37 | */ | 54 | */ |
38 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, | 55 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, |
39 | const QDate& newStart, | 56 | const QDate& newStart, |
40 | QWidget* parent, | 57 | QWidget* parent, |
41 | const char* name, | 58 | const char* name, |
42 | bool modal, | 59 | bool modal, |
43 | WFlags fl ) | 60 | WFlags fl ) |
44 | : ORecurranceBase( parent, name, modal, fl ), | 61 | : ORecurranceBase( parent, name, modal, fl ), |
45 | start( newStart ), | 62 | start( newStart ), |
46 | currInterval( None ), | 63 | currInterval( None ), |
47 | startWeekOnMonday( startOnMonday ) | 64 | startWeekOnMonday( startOnMonday ) |
48 | { | 65 | { |
66 | if (strDayTemplate.isEmpty() ) | ||
67 | fillStrings(); | ||
68 | |||
49 | init(); | 69 | init(); |
50 | fraType->setButton( currInterval ); | 70 | fraType->setButton( currInterval ); |
51 | chkNoEnd->setChecked( TRUE ); | 71 | chkNoEnd->setChecked( TRUE ); |
52 | setupNone(); | 72 | setupNone(); |
53 | } | 73 | } |
54 | 74 | ||
55 | /** | 75 | /** |
56 | * Different constructor | 76 | * Different constructor |
57 | * @param startOnMonday Does the week start on monday? | 77 | * @param startOnMonday Does the week start on monday? |
58 | * @param rp Already set ORecur object | 78 | * @param rp Already set ORecur object |
59 | * @param startDate The start date | 79 | * @param startDate The start date |
60 | * @param parent The parent widget | 80 | * @param parent The parent widget |
61 | * @param name The name of the object | 81 | * @param name The name of the object |
62 | * @param modal | 82 | * @param modal |
63 | * @param fl The flags for window | 83 | * @param fl The flags for window |
64 | */ | 84 | */ |
65 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, | 85 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, |
66 | const ORecur& rp, const QDate& startDate, | 86 | const ORecur& rp, const QDate& startDate, |
67 | QWidget* parent, const char* name, | 87 | QWidget* parent, const char* name, |
68 | bool modal, WFlags fl) | 88 | bool modal, WFlags fl) |
69 | : ORecurranceBase( parent, name, modal, fl ), | 89 | : ORecurranceBase( parent, name, modal, fl ), |
70 | start( startDate ), | 90 | start( startDate ), |
71 | end( rp.endDate() ), | 91 | end( rp.endDate() ), |
72 | startWeekOnMonday( startOnMonday ) | 92 | startWeekOnMonday( startOnMonday ) |
73 | { | 93 | { |
94 | if (strDayTemplate.isEmpty() ) | ||
95 | fillStrings(); | ||
74 | // do some stuff with the repeat pattern | 96 | // do some stuff with the repeat pattern |
75 | init(); | 97 | init(); |
76 | setRecurrence( rp ); | 98 | setRecurrence( rp ); |
77 | } | 99 | } |
78 | 100 | ||
79 | ORecurranceWidget::~ORecurranceWidget() { | 101 | ORecurranceWidget::~ORecurranceWidget() { |
80 | } | 102 | } |
81 | 103 | ||
82 | /** | 104 | /** |
83 | * set the start date | 105 | * set the start date |
84 | * @param date the new start date | 106 | * @param date the new start date |
85 | */ | 107 | */ |
86 | void ORecurranceWidget::setStartDate( const QDate& date ) { | 108 | void ORecurranceWidget::setStartDate( const QDate& date ) { |
87 | qWarning("ORecurranceWidget::setStartDate"); | ||
88 | setRecurrence( recurrence(), date ); | 109 | setRecurrence( recurrence(), date ); |
89 | } | 110 | } |
90 | /** | 111 | /** |
91 | * set the recurrence | 112 | * set the recurrence |
92 | * @param rp The ORecur object with the new recurrence rules | 113 | * @param rp The ORecur object with the new recurrence rules |
93 | */ | 114 | */ |
94 | void ORecurranceWidget::setRecurrence( const ORecur& rp ) { | 115 | void ORecurranceWidget::setRecurrence( const ORecur& rp ) { |
95 | setRecurrence( rp, start ); | 116 | setRecurrence( rp, start ); |
96 | } | 117 | } |
97 | 118 | ||
98 | /** | 119 | /** |
99 | * overloaded method taking ORecur and a new start date | 120 | * overloaded method taking ORecur and a new start date |
100 | * @param rp Recurrence rule | 121 | * @param rp Recurrence rule |
101 | * @param date The new start date | 122 | * @param date The new start date |
102 | */ | 123 | */ |
103 | void ORecurranceWidget::setRecurrence( const ORecur& rp, const QDate& date ) { | 124 | void ORecurranceWidget::setRecurrence( const ORecur& rp, const QDate& date ) { |
104 | start = date; | 125 | start = date; |
105 | end = rp.endDate(); | 126 | end = rp.endDate(); |
106 | switch ( rp.type() ) { | 127 | switch ( rp.type() ) { |
107 | default: | 128 | default: |
108 | case ORecur::NoRepeat: | 129 | case ORecur::NoRepeat: |
109 | currInterval = None; | 130 | currInterval = None; |
110 | setupNone(); | 131 | setupNone(); |
111 | break; | 132 | break; |
112 | case ORecur::Daily: | 133 | case ORecur::Daily: |
113 | currInterval = Day; | 134 | currInterval = Day; |
114 | setupDaily(); | 135 | setupDaily(); |
115 | break; | 136 | break; |
116 | case ORecur::Weekly: | 137 | case ORecur::Weekly: |
117 | currInterval = Week; | 138 | currInterval = Week; |
118 | setupWeekly(); | 139 | setupWeekly(); |
119 | int day, buttons; | 140 | int day, buttons; |
120 | for ( day = 0x01, buttons = 0; buttons < 7; | 141 | for ( day = 0x01, buttons = 0; buttons < 7; |
121 | day = day << 1, buttons++ ) { | 142 | day = day << 1, buttons++ ) { |
122 | if ( rp.days() & day ) { | 143 | if ( rp.days() & day ) { |
123 | if ( startWeekOnMonday ) | 144 | if ( startWeekOnMonday ) |
124 | fraExtra->setButton( buttons ); | 145 | fraExtra->setButton( buttons ); |
125 | else { | 146 | else { |
126 | if ( buttons == 7 ) | 147 | if ( buttons == 7 ) |
127 | fraExtra->setButton( 0 ); | 148 | fraExtra->setButton( 0 ); |
128 | else | 149 | else |
129 | fraExtra->setButton( buttons + 1 ); | 150 | fraExtra->setButton( buttons + 1 ); |
130 | } | 151 | } |
131 | } | 152 | } |
132 | } | 153 | } |
133 | slotWeekLabel(); | 154 | slotWeekLabel(); |
134 | break; | 155 | break; |
135 | case ORecur::MonthlyDay: | 156 | case ORecur::MonthlyDay: |
@@ -322,108 +343,109 @@ void ORecurranceWidget::slotWeekLabel() { | |||
322 | return; | 343 | return; |
323 | 344 | ||
324 | if ( startWeekOnMonday ) | 345 | if ( startWeekOnMonday ) |
325 | keepMe = start.dayOfWeek() - 1; | 346 | keepMe = start.dayOfWeek() - 1; |
326 | else | 347 | else |
327 | keepMe = start.dayOfWeek() % 7; | 348 | keepMe = start.dayOfWeek() % 7; |
328 | 349 | ||
329 | QStringList list; | 350 | QStringList list; |
330 | for ( i = 0; *it; ++it, i++ ) { | 351 | for ( i = 0; *it; ++it, i++ ) { |
331 | // a crazy check, if you are repeating weekly, the current day | 352 | // a crazy check, if you are repeating weekly, the current day |
332 | // must be selected!!! | 353 | // must be selected!!! |
333 | if ( i == keepMe && !( (*it)->isOn() ) ) | 354 | if ( i == keepMe && !( (*it)->isOn() ) ) |
334 | (*it)->setOn( TRUE ); | 355 | (*it)->setOn( TRUE ); |
335 | if ( (*it)->isOn() ) { | 356 | if ( (*it)->isOn() ) { |
336 | if ( startWeekOnMonday ) | 357 | if ( startWeekOnMonday ) |
337 | list.append( dayLabel[i] ); | 358 | list.append( dayLabel[i] ); |
338 | else { | 359 | else { |
339 | if ( i == 0 ) | 360 | if ( i == 0 ) |
340 | list.append( dayLabel[6] ); | 361 | list.append( dayLabel[6] ); |
341 | else | 362 | else |
342 | list.append( dayLabel[i - 1] ); | 363 | list.append( dayLabel[i - 1] ); |
343 | } | 364 | } |
344 | } | 365 | } |
345 | } | 366 | } |
346 | QStringList::Iterator itStr; | 367 | QStringList::Iterator itStr; |
347 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { | 368 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { |
348 | if ( i == 3 ) | 369 | if ( i == 3 ) |
349 | bNeedCarriage = TRUE; | 370 | bNeedCarriage = TRUE; |
350 | else | 371 | else |
351 | bNeedCarriage = FALSE; | 372 | bNeedCarriage = FALSE; |
352 | if ( str.isNull() ) | 373 | if ( str.isNull() ) |
353 | str = *itStr; | 374 | str = *itStr; |
354 | else if ( i == list.count() - 1 ) { | 375 | else if ( i == list.count() - 1 ) { |
355 | if ( i < 2 ) | 376 | if ( i < 2 ) |
356 | str += tr(" and ") + *itStr; | 377 | str += tr(" and ") + *itStr; |
357 | else { | 378 | else { |
358 | if ( bNeedCarriage ) | 379 | if ( bNeedCarriage ) |
359 | str += tr( ",\nand " ) + *itStr; | 380 | str += tr( ",\nand " ) + *itStr; |
360 | else | 381 | else |
361 | str += tr( ", and " ) + *itStr; | 382 | str += tr( ", and " ) + *itStr; |
362 | } | 383 | } |
363 | } else { | 384 | } else { |
364 | if ( bNeedCarriage ) | 385 | if ( bNeedCarriage ) |
365 | str += ",\n" + *itStr; | 386 | str += ",\n" + *itStr; |
366 | else | 387 | else |
367 | str += ", " + *itStr; | 388 | str += ", " + *itStr; |
368 | } | 389 | } |
369 | } | 390 | } |
370 | str = str.prepend( "on " ); | 391 | str = str.prepend( tr("on ") ); |
392 | |||
371 | lblWeekVar->setText( str ); | 393 | lblWeekVar->setText( str ); |
372 | } | 394 | } |
373 | void ORecurranceWidget::slotMonthLabel(int type) { | 395 | void ORecurranceWidget::slotMonthLabel(int type) { |
374 | QString str; | 396 | QString str; |
375 | if ( currInterval != Month || type > 1 ) | 397 | if ( currInterval != Month || type > 1 ) |
376 | return; | 398 | return; |
377 | if ( type == 1 ) | 399 | if ( type == 1 ) |
378 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); | 400 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); |
379 | else | 401 | else |
380 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) | 402 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) |
381 | .arg( dayLabel[start.dayOfWeek() - 1] ); | 403 | .arg( dayLabel[start.dayOfWeek() - 1] ); |
382 | lblRepeat->setText( str ); | 404 | lblRepeat->setText( str ); |
383 | } | 405 | } |
384 | void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { | 406 | void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { |
385 | startWeekOnMonday = onMonday; | 407 | startWeekOnMonday = onMonday; |
386 | // we need to make this unintrusive as possible... | 408 | // we need to make this unintrusive as possible... |
387 | int saveSpin = spinFreq->value(); | 409 | int saveSpin = spinFreq->value(); |
388 | char days = 0; | 410 | char days = 0; |
389 | int day; | 411 | int day; |
390 | QListIterator<QToolButton> itExtra( listExtra ); | 412 | QListIterator<QToolButton> itExtra( listExtra ); |
391 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 413 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
392 | if ( (*itExtra)->isOn() ) { | 414 | if ( (*itExtra)->isOn() ) { |
393 | if ( !startWeekOnMonday ) | 415 | if ( !startWeekOnMonday ) |
394 | days |= day; | 416 | days |= day; |
395 | else { | 417 | else { |
396 | if ( day == 1 ) | 418 | if ( day == 1 ) |
397 | days |= ORecur::SUN; | 419 | days |= ORecur::SUN; |
398 | else | 420 | else |
399 | days |= day >> 1; | 421 | days |= day >> 1; |
400 | } | 422 | } |
401 | } | 423 | } |
402 | } | 424 | } |
403 | setupWeekly(); | 425 | setupWeekly(); |
404 | spinFreq->setValue( saveSpin ); | 426 | spinFreq->setValue( saveSpin ); |
405 | int buttons; | 427 | int buttons; |
406 | for ( day = 0x01, buttons = 0; buttons < 7; | 428 | for ( day = 0x01, buttons = 0; buttons < 7; |
407 | day = day << 1, buttons++ ) { | 429 | day = day << 1, buttons++ ) { |
408 | if ( days & day ) { | 430 | if ( days & day ) { |
409 | if ( startWeekOnMonday ) | 431 | if ( startWeekOnMonday ) |
410 | fraExtra->setButton( buttons ); | 432 | fraExtra->setButton( buttons ); |
411 | else { | 433 | else { |
412 | if ( buttons == 7 ) | 434 | if ( buttons == 7 ) |
413 | fraExtra->setButton( 0 ); | 435 | fraExtra->setButton( 0 ); |
414 | else | 436 | else |
415 | fraExtra->setButton( buttons + 1 ); | 437 | fraExtra->setButton( buttons + 1 ); |
416 | } | 438 | } |
417 | } | 439 | } |
418 | } | 440 | } |
419 | slotWeekLabel(); | 441 | slotWeekLabel(); |
420 | } | 442 | } |
421 | void ORecurranceWidget::setupNone() { | 443 | void ORecurranceWidget::setupNone() { |
422 | lblRepeat->setText( tr("No Repeat") ); | 444 | lblRepeat->setText( tr("No Repeat") ); |
423 | lblVar1->hide(); | 445 | lblVar1->hide(); |
424 | lblVar2->hide(); | 446 | lblVar2->hide(); |
425 | hideExtras(); | 447 | hideExtras(); |
426 | cmdEnd->hide(); | 448 | cmdEnd->hide(); |
427 | lblFreq->hide(); | 449 | lblFreq->hide(); |
428 | lblEvery->hide(); | 450 | lblEvery->hide(); |
429 | lblFreq->hide(); | 451 | lblFreq->hide(); |
diff --git a/libopie/oticker.h b/libopie/oticker.h index 0b88919..4026eb5 100644 --- a/libopie/oticker.h +++ b/libopie/oticker.h | |||
@@ -28,104 +28,104 @@ | |||
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef OTICKER_H | 31 | #ifndef OTICKER_H |
32 | #define OTICKER_H | 32 | #define OTICKER_H |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qdrawutil.h> | 36 | #include <qdrawutil.h> |
37 | #include <qpixmap.h> | 37 | #include <qpixmap.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qslider.h> | 39 | #include <qslider.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qframe.h> | 41 | #include <qframe.h> |
42 | #include <qcolor.h> | 42 | #include <qcolor.h> |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * @class OTicker | 45 | * @class OTicker |
46 | * @brief The OTicker class provides a QLabel widget that scroll its contents | 46 | * @brief The OTicker class provides a QLabel widget that scroll its contents |
47 | * | 47 | * |
48 | */ | 48 | */ |
49 | class OTicker : public QLabel { | 49 | class OTicker : public QLabel { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | 51 | ||
52 | public: | 52 | public: |
53 | 53 | ||
54 | /*! | 54 | /*! |
55 | * @fn OTicker( QWidget* parent = 0 ) | 55 | * @fn OTicker( QWidget* parent = 0 ) |
56 | * @brief Object constructor. | 56 | * @brief Object constructor. |
57 | * | 57 | * |
58 | * @param parent Pointer to parent of this control. | 58 | * @param parent Pointer to parent of this control. |
59 | 59 | ||
60 | * Constructs a new OTicker control with parent | 60 | * Constructs a new OTicker control with parent |
61 | */ | 61 | */ |
62 | OTicker( QWidget* parent=0 ); | 62 | OTicker( QWidget* parent=0 ); |
63 | /*! | 63 | /*! |
64 | * @fn ~OTicker() | 64 | * @fn ~OTicker() |
65 | * @brief Object destructor. | 65 | * @brief Object destructor. |
66 | */ | 66 | */ |
67 | ~OTicker(); | 67 | ~OTicker(); |
68 | /*! | 68 | /*! |
69 | * @fn setText(const QString& ) | 69 | * @fn setText(const QString& ) |
70 | * @brief sets text to be displayed | 70 | * @brief sets text to be displayed |
71 | * @param text QString text to be displayed. | 71 | * @param text QString text to be displayed. |
72 | * | 72 | * |
73 | */ | 73 | */ |
74 | void setText( const QString& text ) ; | 74 | void setText( const QString& text ) ; |
75 | /*! | 75 | /*! |
76 | * @fn setBackgroundColor(QColor color) | 76 | * @fn setBackgroundColor(const QColor& color) |
77 | * @brief sets color of the ticker's background | 77 | * @brief sets color of the ticker's background |
78 | * @param color QColor color to be set. | 78 | * @param color QColor color to be set. |
79 | * | 79 | * |
80 | */ | 80 | */ |
81 | void setBackgroundColor(const QColor& color); | 81 | void setBackgroundColor(const QColor& color); |
82 | /*! | 82 | /*! |
83 | * @fn setForegroundColor(QColor color) | 83 | * @fn setForegroundColor(const QColor& color) |
84 | * @brief sets color of text | 84 | * @brief sets color of text |
85 | * @param color QColor color of text | 85 | * @param color QColor color of text |
86 | * | 86 | * |
87 | */ | 87 | */ |
88 | void setForegroundColor(const QColor& color); | 88 | void setForegroundColor(const QColor& color); |
89 | /*! | 89 | /*! |
90 | * @fn setFrame(int style) | 90 | * @fn setFrame(int style) |
91 | * @brief sets frame style | 91 | * @brief sets frame style |
92 | * @param style int Frame style to be see. See Qt::WidgetFlags. | 92 | * @param style int Frame style to be see. See Qt::WidgetFlags. |
93 | * | 93 | * |
94 | */ | 94 | */ |
95 | void setFrame(int style); | 95 | void setFrame(int style); |
96 | /*! | 96 | /*! |
97 | * @fn setUpdateTime(int timeout) | 97 | * @fn setUpdateTime(int timeout) |
98 | * @brief sets time of update | 98 | * @brief sets time of update |
99 | * @param timeout int time in milliseconds between updates. | 99 | * @param timeout int time in milliseconds between updates. |
100 | * | 100 | * |
101 | */ | 101 | */ |
102 | void setUpdateTime(int timeout); | 102 | void setUpdateTime(int timeout); |
103 | /*! | 103 | /*! |
104 | * @fn setScrollLength(int length) | 104 | * @fn setScrollLength(int length) |
105 | * @brief sets amount of scrolling default is 1 | 105 | * @brief sets amount of scrolling default is 1 |
106 | * @param length int scroll length. | 106 | * @param length int scroll length. |
107 | * | 107 | * |
108 | */ | 108 | */ |
109 | void setScrollLength(int length); | 109 | void setScrollLength(int length); |
110 | signals: | 110 | signals: |
111 | /*! | 111 | /*! |
112 | * @fn mousePressed() | 112 | * @fn mousePressed() |
113 | * @brief signal mouse press event | 113 | * @brief signal mouse press event |
114 | * | 114 | * |
115 | */ | 115 | */ |
116 | void mousePressed(); | 116 | void mousePressed(); |
117 | protected: | 117 | protected: |
118 | /*! | 118 | /*! |
119 | * @fn timerEvent( QTimerEvent * e) | 119 | * @fn timerEvent( QTimerEvent * e) |
120 | * @brief timer timeout event | 120 | * @brief timer timeout event |
121 | * @param e QEvent see QEvent. | 121 | * @param e QEvent see QEvent. |
122 | * | 122 | * |
123 | */ | 123 | */ |
124 | void timerEvent( QTimerEvent * e); | 124 | void timerEvent( QTimerEvent * e); |
125 | /*! | 125 | /*! |
126 | * @fn drawContents( QPainter *p ) | 126 | * @fn drawContents( QPainter *p ) |
127 | * @brief draws widget contents | 127 | * @brief draws widget contents |
128 | * @param p QPainter. see QPainter | 128 | * @param p QPainter. see QPainter |
129 | * | 129 | * |
130 | */ | 130 | */ |
131 | void drawContents( QPainter *p ); | 131 | void drawContents( QPainter *p ); |
diff --git a/libopie/todayplugininterface.h b/libopie/todayplugininterface.h index 532f492..5dfeaa8 100644 --- a/libopie/todayplugininterface.h +++ b/libopie/todayplugininterface.h | |||
@@ -1,109 +1,133 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> | ||
4 | =. | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | |||
29 | */ | ||
30 | |||
1 | 31 | ||
2 | #ifndef TODAY_PLUGIN_INTERFACE | 32 | #ifndef TODAY_PLUGIN_INTERFACE |
3 | #define TODAY_PLUGIN_INTERFACE | 33 | #define TODAY_PLUGIN_INTERFACE |
4 | 34 | ||
5 | #include <qpe/qcom.h> | 35 | #include <qpe/qcom.h> |
6 | #include "todayconfigwidget.h" | 36 | #include "todayconfigwidget.h" |
7 | 37 | ||
8 | class QString; | 38 | class QString; |
9 | class QWidget; | 39 | class QWidget; |
10 | 40 | ||
11 | #ifndef IID_TodayPluginInterface | 41 | #ifndef IID_TodayPluginInterface |
12 | #define IID_TodayPluginInterface QUuid( 0x70481804, 0x2b50, 0x4fba, 0x80, 0xbb, 0x0b, 0xf8, 0xdc, 0x72, 0x04, 0x14) | 42 | #define IID_TodayPluginInterface QUuid( 0x70481804, 0x2b50, 0x4fba, 0x80, 0xbb, 0x0b, 0xf8, 0xdc, 0x72, 0x04, 0x14) |
13 | #endif | 43 | #endif |
14 | 44 | ||
15 | /** | 45 | /** |
16 | * | 46 | * |
17 | * A TodayPluginObject is the base for all Today Plugins. | 47 | * A TodayPluginObject is the base for all Today Plugins. |
18 | * A plugin author needs to inherit this class and implement | 48 | * A plugin author needs to inherit this class and implement |
19 | * the pure virtual methods | 49 | * the pure virtual methods |
20 | * | 50 | * |
21 | * @short base class for today plugins | 51 | * @short base class for today plugins |
22 | * @author Maximilian Reiss | 52 | * @author Maximilian Reiss |
23 | * | 53 | * |
24 | */ | 54 | */ |
25 | class TodayPluginObject { | 55 | class TodayPluginObject { |
26 | 56 | ||
27 | public: | 57 | public: |
28 | 58 | ||
29 | virtual ~TodayPluginObject() {}; | 59 | virtual ~TodayPluginObject() {}; |
30 | 60 | ||
31 | /** | 61 | /** |
32 | * The name if the plugin | 62 | * The name if the plugin |
33 | * @return The plugin should return its name here | 63 | * @return The plugin should return its name here |
34 | */ | 64 | */ |
35 | virtual QString pluginName() const = 0; | 65 | virtual QString pluginName() const = 0; |
36 | 66 | ||
37 | /** | 67 | /** |
38 | * Version numbering | 68 | * Version numbering |
39 | * @return The plugin should return the version number | 69 | * @return The plugin should return the version number |
40 | */ | 70 | */ |
41 | virtual double versionNumber() const = 0; | 71 | virtual double versionNumber() const = 0; |
42 | 72 | ||
43 | 73 | ||
44 | /** | 74 | /** |
45 | * @return the pixmap name widget?! -- FIXME | 75 | * @return the pixmap name widget?! -- FIXME |
46 | */ | 76 | */ |
47 | virtual QString pixmapNameWidget() const = 0; | 77 | virtual QString pixmapNameWidget() const = 0; |
48 | 78 | ||
49 | /** | 79 | /** |
50 | * widget for the today view | 80 | * widget for the today view |
51 | * It _needs_ a parent here. | 81 | * It _needs_ a parent here. |
52 | * Plugin authors need to take parent as parent! | 82 | * Plugin authors need to take parent as parent! |
53 | */ | 83 | */ |
54 | virtual QWidget* widget( QWidget *parent ) = 0; | 84 | virtual QWidget* widget( QWidget *parent ) = 0; |
55 | 85 | ||
56 | /** | 86 | /** |
57 | * Pixmap used in the config widget | 87 | * Pixmap used in the config widget |
58 | */ | 88 | */ |
59 | virtual QString pixmapNameConfig() const = 0; | 89 | virtual QString pixmapNameConfig() const = 0; |
60 | 90 | ||
61 | /** | 91 | /** |
62 | * Config plugin widget - optional | 92 | * Config plugin widget - optional |
63 | * If the plugin has a config widget, it _needs_ a parent here. | 93 | * If the plugin has a config widget, it _needs_ a parent here. |
64 | * may return 0 if no config widget is needed | 94 | * may return 0 if no config widget is needed |
65 | */ | 95 | */ |
66 | virtual TodayConfigWidget* configWidget( QWidget * ) = 0; | 96 | virtual TodayConfigWidget* configWidget( QWidget * ) = 0; |
67 | 97 | ||
68 | /** | 98 | /** |
69 | * The application that should be assigned to the button (pixmap) | 99 | * The application that should be assigned to the button (pixmap) |
70 | * Today will show the plugin icon. On click it tries to execute the | 100 | * Today will show the plugin icon. On click it tries to execute the |
71 | * plugin related application. | 101 | * plugin related application. |
72 | */ | 102 | */ |
73 | virtual QString appName() const = 0; | 103 | virtual QString appName() const = 0; |
74 | 104 | ||
75 | 105 | ||
76 | /** | 106 | /** |
77 | * If the plugin should take part in the periodic refresh | 107 | * If the plugin should take part in the periodic refresh |
78 | */ | 108 | */ |
79 | virtual bool excludeFromRefresh() const = 0; | 109 | virtual bool excludeFromRefresh() const = 0; |
80 | 110 | ||
81 | /** | 111 | /** |
82 | * Refresh that plugins view. For updating the plugins | 112 | * Refresh that plugins view. For updating the plugins |
83 | * | ||
84 | */ | 113 | */ |
85 | virtual void refresh() {}; | 114 | virtual void refresh() {}; |
86 | 115 | ||
87 | /** | 116 | /** |
88 | * minimum height the plugin at least should have | 117 | * reread the plugins config and act apropiate |
118 | * This is for example used when returning from the config dialog | ||
89 | */ | 119 | */ |
90 | // virtual int minHeight() const = 0; | 120 | virtual void reinitialize() {}; |
91 | |||
92 | /** | ||
93 | * maximum height that should be used before starting scrolling | ||
94 | */ | ||
95 | // virtual int maxHeight() const = 0; | ||
96 | |||
97 | }; | 121 | }; |
98 | 122 | ||
99 | /** | 123 | /** |
100 | * This is part of the QCOM works. See example plugins how to do it right | 124 | * This is part of the QCOM works. See example plugins how to do it right |
101 | */ | 125 | */ |
102 | struct TodayPluginInterface : public QUnknownInterface { | 126 | struct TodayPluginInterface : public QUnknownInterface { |
103 | /** | 127 | /** |
104 | * return the TodayPluginObject implementation | 128 | * return the TodayPluginObject implementation |
105 | */ | 129 | */ |
106 | virtual TodayPluginObject *guiPart() = 0; | 130 | virtual TodayPluginObject *guiPart() = 0; |
107 | }; | 131 | }; |
108 | 132 | ||
109 | #endif | 133 | #endif |