summaryrefslogtreecommitdiff
path: root/libopie
Side-by-side diff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/libopie.pro3
-rw-r--r--libopie/libopie1.control4
-rw-r--r--libopie/odevice.cpp111
-rw-r--r--libopie/ofiledialog.cc81
-rw-r--r--libopie/ofiledialog.h3
-rw-r--r--libopie/ofileselector.cc1310
-rw-r--r--libopie/ofileselector.cpp856
-rw-r--r--libopie/ofileselector.h362
-rw-r--r--libopie/ofileselector_p.h151
-rw-r--r--libopie/orecurrancewidget.cpp56
-rw-r--r--libopie/oticker.h4
-rw-r--r--libopie/todayplugininterface.h42
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,120 +1,121 @@
TEMPLATE = lib
CONFIG += qte warn_on release
HEADERS = ofontmenu.h \
ocolorbutton.h \
ofiledialog.h ofileselector.h \
+ ofileselector_p.h \
ocheckitem.h \
xmltree.h \
colordialog.h colorpopupmenu.h \
oclickablelabel.h oprocctrl.h \
oprocess.h odevice.h odevicebutton.h \
otimepicker.h otabwidget.h \
otabbar.h otabinfo.h \
ofontselector.h \
pim/opimrecord.h \
pim/otodo.h \
pim/orecordlist.h \
pim/opimaccesstemplate.h \
pim/opimaccessbackend.h \
pim/otodoaccess.h \
pim/otodoaccessbackend.h \
pim/oconversion.h \
pim/ocontact.h \
pim/ocontactaccess.h \
pim/ocontactaccessbackend.h \
pim/ocontactaccessbackend_xml.h \
pim/ocontactaccessbackend_vcard.h \
pim/obackendfactory.h \
pim/opimcache.h \
pim/otodoaccessvcal.h \
pim/orecur.h \
pim/opimstate.h \
pim/opimxrefpartner.h \
pim/opimxref.h \
pim/opimxrefmanager.h \
pim/opimmaintainer.h \
pim/opimnotify.h \
pim/opimnotifymanager.h \
pim/opimmainwindow.h \
pim/opimresolver.h \
pim/oevent.h \
pim/otimezone.h \
pim/odatebookaccess.h \
pim/odatebookaccessbackend.h \
pim/odatebookaccessbackend_xml.h \
orecurrancewidget.h \
oticker.h owait.h
SOURCES = ofontmenu.cc \
ocolorbutton.cpp \
sharp_compat.cpp \
xmltree.cc \
- ofiledialog.cc ofileselector.cc \
+ ofiledialog.cc ofileselector.cpp \
ocheckitem.cpp \
colordialog.cpp \
colorpopupmenu.cpp oclickablelabel.cpp \
oprocctrl.cpp oprocess.cpp \
odevice.cpp odevicebutton.cpp otimepicker.cpp \
otabwidget.cpp otabbar.cpp \
ofontselector.cpp \
pim/otodo.cpp \
pim/opimrecord.cpp \
pim/otodoaccess.cpp \
pim/otodoaccessbackend.cpp \
pim/otodoaccessxml.cpp \
pim/oconversion.cpp \
pim/ocontact.cpp \
pim/ocontactaccess.cpp \
pim/ocontactaccessbackend_vcard.cpp \
pim/ocontactaccessbackend_xml.cpp \
pim/otodoaccessvcal.cpp \
pim/orecur.cpp \
pim/opimstate.cpp \
pim/opimxrefpartner.cpp \
pim/opimxref.cpp \
pim/opimxrefmanager.cpp \
pim/opimmaintainer.cpp \
pim/opimnotify.cpp \
pim/opimnotifymanager.cpp \
pim/opimmainwindow.cpp \
pim/opimresolver.cpp \
pim/oevent.cpp \
pim/otimezone.cpp \
pim/odatebookaccess.cpp \
pim/odatebookaccessbackend.cpp \
pim/odatebookaccessbackend_xml.cpp \
orecurrancewidget.cpp \
oticker.cpp owait.cpp
TARGET = opie
INCLUDEPATH += $(OPIEDIR)/include
DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
LIBS += -lqpe
# LIBS += -lopiesql
INTERFACES = otimepickerbase.ui orecurrancebase.ui
TARGET = opie
TRANSLATIONS = ../i18n/de/libopie.ts \
../i18n/nl/libopie.ts \
../i18n/xx/libopie.ts \
../i18n/en/libopie.ts \
../i18n/es/libopie.ts \
../i18n/fr/libopie.ts \
../i18n/hu/libopie.ts \
../i18n/ja/libopie.ts \
../i18n/ko/libopie.ts \
../i18n/no/libopie.ts \
../i18n/pl/libopie.ts \
../i18n/pt/libopie.ts \
../i18n/pt_BR/libopie.ts \
../i18n/sl/libopie.ts \
../i18n/zh_CN/libopie.ts \
../i18n/zh_TW/libopie.ts \
../i18n/da/libopie.ts
include ( $(OPIEDIR)/include.pro )
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 @@
Package: libopie1
Files: $OPIEDIR/lib/libopie.so.1.0.0 $OPIEDIR/lib/libopie.so.1.0 $OPIEDIR/lib/libopie.so.1
Priority: optional
Section: opie/system
Maintainer: Opie Team <opie@handhelds.org>
Architecture: arm
-Version: $QPE_VERSION-$SUB_VERSION.1
-Depends: libqte2 (>=$QTE_VERSION), libqpe1
+Depends: libqte2 (>=$QTE_VERSION), libqpe1, opie-pics
Provides: libopie
Replaces: libopie
Description: Opie library
+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
@@ -283,837 +283,838 @@ struct s_button {
uint model;
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
} simpad_buttons [] = {
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
"devicebuttons/simpad_lower_up",
"datebook", "nextView()",
"today", "raise()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
"devicebuttons/simpad_lower_down",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
"devicebuttons/simpad_lower_right",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
"devicebuttons/simpad_lower_left",
"mail", "raise()",
"mail", "newMail()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
"devicebuttons/simpad_upper_up",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
"devicebuttons/simpad_upper_down",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
"devicebuttons/simpad_upper_right",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
"devicebuttons/simpad_upper_left",
"QPE/Rotation", "flip()",
"QPE/Rotation", "flip()" },
/*
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
"devicebuttons/simpad_lower_upper",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
"devicebuttons/simpad_upper_lower",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
*/
};
struct r_button {
uint model;
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
} ramses_buttons [] = {
{ Model_Ramses_MNCI,
Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
"devicebuttons/z_menu",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Model_Ramses_MNCI,
Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
"devicebuttons/ipaq_home",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
};
static QCString makeChannel ( const char *str )
{
if ( str && !::strchr ( str, '/' ))
return QCString ( "QPE/Application/" ) + str;
else
return str;
}
static inline bool isQWS()
{
return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
}
ODevice *ODevice::inst ( )
{
static ODevice *dev = 0;
if ( !dev ) {
if ( QFile::exists ( "/proc/hal/model" ))
dev = new iPAQ ( );
else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
dev = new Zaurus ( );
else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
dev = new SIMpad ( );
else if ( QFile::exists ( "/proc/sys/board/name" ))
dev = new Ramses ( );
else
dev = new ODevice ( );
dev-> init ( );
}
return dev;
}
/**************************************************
*
* common
*
**************************************************/
ODevice::ODevice ( )
{
d = new ODeviceData;
d-> m_modelstr = "Unknown";
d-> m_model = Model_Unknown;
d-> m_vendorstr = "Unknown";
d-> m_vendor = Vendor_Unknown;
d-> m_systemstr = "Unknown";
d-> m_system = System_Unknown;
d-> m_sysverstr = "0.0";
d-> m_rotation = Rot0;
d-> m_direction = CW;
d-> m_holdtime = 1000; // 1000ms
d-> m_buttons = 0;
d-> m_cpu_frequencies = new QStrList;
}
void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
{
if ( msg == "deviceButtonMappingChanged()" ) {
reloadButtonMapping ( );
}
}
void ODevice::init ( )
{
}
/**
* This method initialises the button mapping
*/
void ODevice::initButtons ( )
{
if ( d-> m_buttons )
return;
// Simulation uses iPAQ 3660 device buttons
qDebug ( "init Buttons" );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
i_button *ib = ipaq_buttons + i;
ODeviceButton b;
if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
b. setKeycode ( ib-> code );
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
d-> m_buttons-> append ( b );
}
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
}
ODevice::~ODevice ( )
{
+// we leak m_devicebuttons and m_cpu_frequency
+// but it's a singleton and it is not so importantant
+// -zecke
delete d;
}
bool ODevice::setSoftSuspend ( bool /*soft*/ )
{
return false;
}
//#include <linux/apm_bios.h>
#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
/**
* This method will try to suspend the device
* It only works if the user is the QWS Server and the apm application
* is installed.
* It tries to suspend and then waits some time cause some distributions
* do have asynchronus apm implementations.
* This method will either fail and return false or it'll suspend the
* device and return once the device got woken up
*
* @return if the device got suspended
*/
bool ODevice::suspend ( )
{
qDebug("ODevice::suspend");
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
return false;
bool res = false;
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync ( ); // flush fs caches
res = ( ::system ( "apm --suspend" ) == 0 );
// This is needed because the iPAQ apm implementation is asynchronous and we
// can not be sure when exactly the device is really suspended
// This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
if ( res ) {
do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
::usleep ( 200 * 1000 );
::gettimeofday ( &tvn, 0 );
} while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
}
return res;
}
//#include <linux/fb.h> better not rely on kernel headers in userspace ...
#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
/* VESA Blanking Levels */
#define VESA_NO_BLANKING 0
#define VESA_VSYNC_SUSPEND 1
#define VESA_HSYNC_SUSPEND 2
#define VESA_POWERDOWN 3
/**
* This sets the display on or off
*/
bool ODevice::setDisplayStatus ( bool on )
{
qDebug("ODevice::setDisplayStatus(%d)", on);
if ( d-> m_model == Model_Unknown )
return false;
bool res = false;
int fd;
if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
::close ( fd );
}
return res;
}
/**
* This sets the display brightness
*
* @param p The brightness to be set on a scale from 0 to 255
* @return success or failure
*/
bool ODevice::setDisplayBrightness ( int p)
{
Q_UNUSED( p )
return false;
}
/**
* @return returns the number of steppings on the brightness slider
* in the Light-'n-Power settings.
*/
int ODevice::displayBrightnessResolution ( ) const
{
return 16;
}
/**
* This sets the display contrast
* @param p The contrast to be set on a scale from 0 to 255
* @return success or failure
*/
bool ODevice::setDisplayContrast ( int p)
{
Q_UNUSED( p )
return false;
}
/**
* @return return the max value for the brightness settings slider
* or 0 if the device doesn't support setting of a contrast
*/
int ODevice::displayContrastResolution ( ) const
{
return 0;
}
/**
* This returns the vendor as string
* @return Vendor as QString
*/
QString ODevice::vendorString ( ) const
{
return d-> m_vendorstr;
}
/**
* This returns the vendor as one of the values of OVendor
* @return OVendor
*/
OVendor ODevice::vendor ( ) const
{
return d-> m_vendor;
}
/**
* This returns the model as a string
* @return A string representing the model
*/
QString ODevice::modelString ( ) const
{
return d-> m_modelstr;
}
/**
* This does return the OModel used
*/
OModel ODevice::model ( ) const
{
return d-> m_model;
}
/**
* This does return the systen name
*/
QString ODevice::systemString ( ) const
{
return d-> m_systemstr;
}
/**
* Return System as OSystem value
*/
OSystem ODevice::system ( ) const
{
return d-> m_system;
}
/**
* @return the version string of the base system
*/
QString ODevice::systemVersionString ( ) const
{
return d-> m_sysverstr;
}
/**
* @return the current Transformation
*/
Transformation ODevice::rotation ( ) const
{
return d-> m_rotation;
}
/**
* @return the current rotation direction
*/
ODirection ODevice::direction ( ) const
{
return d-> m_direction;
}
/**
* This plays an alarmSound
*/
void ODevice::alarmSound ( )
{
#ifndef QT_NO_SOUND
static Sound snd ( "alarm" );
if ( snd. isFinished ( ))
snd. play ( );
#endif
}
/**
* This plays a key sound
*/
void ODevice::keySound ( )
{
#ifndef QT_NO_SOUND
static Sound snd ( "keysound" );
if ( snd. isFinished ( ))
snd. play ( );
#endif
}
/**
* This plays a touch sound
*/
void ODevice::touchSound ( )
{
#ifndef QT_NO_SOUND
static Sound snd ( "touchsound" );
if ( snd. isFinished ( ))
snd. play ( );
#endif
}
/**
* This method will return a list of leds
* available on this device
* @return a list of LEDs.
*/
QValueList <OLed> ODevice::ledList ( ) const
{
return QValueList <OLed> ( );
}
/**
* This does return the state of the LEDs
*/
QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
{
return QValueList <OLedState> ( );
}
/**
* @return the state for a given OLed
*/
OLedState ODevice::ledState ( OLed /*which*/ ) const
{
return Led_Off;
}
/**
* Set the state for a LED
* @param which Which OLed to use
* @param st The state to set
* @return success or failure
*/
bool ODevice::setLedState ( OLed which, OLedState st )
{
Q_UNUSED( which )
Q_UNUSED( st )
return false;
}
/**
* @return if the device has a light sensor
*/
bool ODevice::hasLightSensor ( ) const
{
return false;
}
/**
* @return a value from the light senso
*/
int ODevice::readLightSensor ( )
{
return -1;
}
/**
* @return the light sensor resolution whatever that is ;)
*/
int ODevice::lightSensorResolution ( ) const
{
return 0;
}
/**
* @return a list with CPU frequencies supported by the hardware
*/
const QStrList &ODevice::allowedCpuFrequencies ( ) const
{
return *d->m_cpu_frequencies;
}
/**
* Set desired CPU frequency
- *
+ *
* @param index index into d->m_cpu_frequencies of the frequency to be set
*/
bool ODevice::setCurrentCpuFrequency(uint index)
{
if (index >= d->m_cpu_frequencies->count())
return false;
char *freq = d->m_cpu_frequencies->at(index);
qWarning("set freq to %s", freq);
int fd;
if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
char writeCommand[50];
const int count = sprintf(writeCommand, "%s\n", freq);
int res = (::write(fd, writeCommand, count) != -1);
::close(fd);
return res;
}
return false;
}
/**
* @return a list of hardware buttons
*/
const QValueList <ODeviceButton> &ODevice::buttons ( )
{
initButtons ( );
return *d-> m_buttons;
}
/**
* @return The amount of time that would count as a hold
*/
uint ODevice::buttonHoldTime ( ) const
{
return d-> m_holdtime;
}
/**
* This method return a ODeviceButton for a key code
* or 0 if no special hardware button is available for the device
*
* @return The devicebutton or 0l
* @see ODeviceButton
*/
const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
{
initButtons ( );
for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
if ( (*it). keycode ( ) == code )
return &(*it);
}
return 0;
}
void ODevice::reloadButtonMapping ( )
{
initButtons ( );
Config cfg ( "ButtonSettings" );
for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
ODeviceButton &b = ( *d-> m_buttons ) [i];
QString group = "Button" + QString::number ( i );
QCString pch, hch;
QCString pm, hm;
QByteArray pdata, hdata;
if ( cfg. hasGroup ( group )) {
cfg. setGroup ( group );
pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
// pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
// hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
}
b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
}
}
void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
{
initButtons ( );
QString mb_chan;
if ( button >= (int) d-> m_buttons-> count ( ))
return;
ODeviceButton &b = ( *d-> m_buttons ) [button];
b. setPressedAction ( action );
mb_chan=b. pressedAction ( ). channel ( );
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
{
initButtons ( );
if ( button >= (int) d-> m_buttons-> count ( ))
return;
ODeviceButton &b = ( *d-> m_buttons ) [button];
b. setHeldAction ( action );
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
-void ODevice::virtual_hook( int id, void* data ) {
- Q_UNUSED(id);
- Q_UNUSED(data);
-}
+void ODevice::virtual_hook(int, void* ){
+}
/**************************************************
*
* iPAQ
*
**************************************************/
void iPAQ::init ( )
{
d-> m_vendorstr = "HP";
d-> m_vendor = Vendor_HP;
QFile f ( "/proc/hal/model" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
d-> m_modelstr = "H" + ts. readLine ( );
if ( d-> m_modelstr == "H3100" )
d-> m_model = Model_iPAQ_H31xx;
else if ( d-> m_modelstr == "H3600" )
d-> m_model = Model_iPAQ_H36xx;
else if ( d-> m_modelstr == "H3700" )
d-> m_model = Model_iPAQ_H37xx;
else if ( d-> m_modelstr == "H3800" )
d-> m_model = Model_iPAQ_H38xx;
else if ( d-> m_modelstr == "H3900" )
d-> m_model = Model_iPAQ_H39xx;
else
d-> m_model = Model_Unknown;
f. close ( );
}
switch ( d-> m_model ) {
case Model_iPAQ_H31xx:
case Model_iPAQ_H38xx:
d-> m_rotation = Rot90;
break;
case Model_iPAQ_H36xx:
case Model_iPAQ_H37xx:
case Model_iPAQ_H39xx:
default:
d-> m_rotation = Rot270;
break;
}
f. setName ( "/etc/familiar-version" );
if ( f. open ( IO_ReadOnly )) {
d-> m_systemstr = "Familiar";
d-> m_system = System_Familiar;
QTextStream ts ( &f );
d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
f. close ( );
} else {
f. setName ( "/etc/oz_version" );
if ( f. open ( IO_ReadOnly )) {
d-> m_systemstr = "OpenEmbedded/iPaq";
d-> m_system = System_Familiar;
QTextStream ts ( &f );
ts.setDevice ( &f );
d-> m_sysverstr = ts. readLine ( );
f. close ( );
}
}
m_leds [0] = m_leds [1] = Led_Off;
m_power_timer = 0;
}
void iPAQ::initButtons ( )
{
if ( d-> m_buttons )
return;
if ( isQWS( ) )
QWSServer::setKeyboardFilter ( this );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
i_button *ib = ipaq_buttons + i;
ODeviceButton b;
if (( ib-> model & d-> m_model ) == d-> m_model ) {
b. setKeycode ( ib-> code );
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
d-> m_buttons-> append ( b );
}
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
}
//#include <linux/h3600_ts.h> // including kernel headers is evil ...
typedef struct {
unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
unsigned char TotalTime; /* Units of 5 seconds */
unsigned char OnTime; /* units of 100m/s */
unsigned char OffTime; /* units of 100m/s */
} LED_IN;
typedef struct {
unsigned char mode;
unsigned char pwr;
unsigned char brightness;
} FLITE_IN;
#define LED_ON OD_IOW( 'f', 5, LED_IN )
#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
QValueList <OLed> iPAQ::ledList ( ) const
{
QValueList <OLed> vl;
vl << Led_Power;
if ( d-> m_model == Model_iPAQ_H38xx )
vl << Led_BlueTooth;
return vl;
}
QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
{
QValueList <OLedState> vl;
if ( l == Led_Power )
vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
vl << Led_Off; // << Led_On << ???
return vl;
}
OLedState iPAQ::ledState ( OLed l ) const
{
switch ( l ) {
case Led_Power:
return m_leds [0];
case Led_BlueTooth:
return m_leds [1];
default:
return Led_Off;
}
}
bool iPAQ::setLedState ( OLed l, OLedState st )
{
static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
if ( l == Led_Power ) {
if ( fd >= 0 ) {
LED_IN leds;
::memset ( &leds, 0, sizeof( leds ));
leds. TotalTime = 0;
leds. OnTime = 0;
leds. OffTime = 1;
leds. OffOnBlink = 2;
switch ( st ) {
case Led_Off : leds. OffOnBlink = 0; break;
case Led_On : leds. OffOnBlink = 1; break;
case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
}
if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
m_leds [0] = st;
return true;
}
}
}
@@ -1459,685 +1460,699 @@ void Zaurus::initButtons ( )
#define SHARP_BUZ_KEYSOUND 2 /* key sound */
#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
/* --- for SHARP_BUZZER device --- */
//#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
//#define SHARP_PDA_APPSTART 9 /* application start */
//#define SHARP_PDA_APPQUIT 10 /* application ends */
//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
//
#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
typedef struct sharp_led_status {
int which; /* select which LED status is wanted. */
int status; /* set new led status if you call SHARP_LED_SETSTATUS */
} sharp_led_status;
#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
// #include <asm/sharp_apm.h> // including kernel headers is evil ...
#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
#define APM_EVT_POWER_BUTTON (1 << 0)
#define FL_IOCTL_STEP_CONTRAST 100
void Zaurus::buzzer ( int sound )
{
int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
if ( fd >= 0 ) {
::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
::close ( fd );
}
}
void Zaurus::alarmSound ( )
{
buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
}
void Zaurus::touchSound ( )
{
buzzer ( SHARP_BUZ_TOUCHSOUND );
}
void Zaurus::keySound ( )
{
buzzer ( SHARP_BUZ_KEYSOUND );
}
QValueList <OLed> Zaurus::ledList ( ) const
{
QValueList <OLed> vl;
vl << Led_Mail;
return vl;
}
QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
{
QValueList <OLedState> vl;
if ( l == Led_Mail )
vl << Led_Off << Led_On << Led_BlinkSlow;
return vl;
}
OLedState Zaurus::ledState ( OLed which ) const
{
if ( which == Led_Mail )
return m_leds [0];
else
return Led_Off;
}
bool Zaurus::setLedState ( OLed which, OLedState st )
{
static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
if ( which == Led_Mail ) {
if ( fd >= 0 ) {
struct sharp_led_status leds;
::memset ( &leds, 0, sizeof( leds ));
leds. which = SHARP_LED_MAIL_EXISTS;
bool ok = true;
switch ( st ) {
case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
default : ok = false;
}
if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
m_leds [0] = st;
return true;
}
}
}
return false;
}
bool Zaurus::setSoftSuspend ( bool soft )
{
bool res = false;
int fd;
if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
(( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
if ( sources >= 0 ) {
if ( soft )
sources &= ~APM_EVT_POWER_BUTTON;
else
sources |= APM_EVT_POWER_BUTTON;
if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
res = true;
else
perror ( "APM_IOCGEVTSRC" );
}
else
perror ( "APM_IOCGEVTSRC" );
::close ( fd );
}
else
perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
return res;
}
bool Zaurus::setDisplayBrightness ( int bright )
{
bool res = false;
int fd;
if ( bright > 255 )
bright = 255;
if ( bright < 0 )
bright = 0;
if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
if ( bright && !bl )
bl = 1;
res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
::close ( fd );
}
return res;
}
int Zaurus::displayBrightnessResolution ( ) const
{
return 5;
}
-
/**************************************************
*
* SIMpad
*
**************************************************/
void SIMpad::init ( )
{
d-> m_vendorstr = "SIEMENS";
d-> m_vendor = Vendor_SIEMENS;
QFile f ( "/proc/hal/model" );
//TODO Implement model checking
//FIXME For now we assume an SL4
d-> m_modelstr = "SL4";
d-> m_model = Model_SIMpad_SL4;
switch ( d-> m_model ) {
default:
d-> m_rotation = Rot0;
d-> m_direction = CCW;
d-> m_holdtime = 1000; // 1000ms
break;
}
f. setName ( "/etc/familiar-version" );
if ( f. open ( IO_ReadOnly )) {
d-> m_systemstr = "Familiar";
d-> m_system = System_Familiar;
QTextStream ts ( &f );
d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
f. close ( );
} else {
f. setName ( "/etc/oz_version" );
if ( f. open ( IO_ReadOnly )) {
d-> m_systemstr = "OpenEmbedded/SIMpad";
d-> m_system = System_OpenZaurus;
QTextStream ts ( &f );
ts.setDevice ( &f );
d-> m_sysverstr = ts. readLine ( );
f. close ( );
}
}
m_leds [0] = m_leds [1] = Led_Off;
m_power_timer = 0;
}
void SIMpad::initButtons ( )
{
if ( d-> m_buttons )
return;
if ( isQWS( ) )
QWSServer::setKeyboardFilter ( this );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
s_button *sb = simpad_buttons + i;
ODeviceButton b;
if (( sb-> model & d-> m_model ) == d-> m_model ) {
b. setKeycode ( sb-> code );
b. setUserText ( QObject::tr ( "Button", sb-> utext ));
b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
d-> m_buttons-> append ( b );
}
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
}
// SIMpad boardcontrol register CS3
#define SIMPAD_BOARDCONTROL "/proc/cs3"
#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
#define SIMPAD_EN1 0x0004 // This is only for EPROM's
#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
#define SIMPAD_DISPLAY_ON 0x0010
#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
#define SIMPAD_MQ_RESET 0x0040
#define SIMPAD_PCMCIA_RESET 0x0080
#define SIMPAD_DECT_POWER_ON 0x0100
#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
#define SIMPAD_RS232_ON 0x0400
#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
#define SIMPAD_LED2_ON 0x1000
#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
#define SIMPAD_RESET_SIMCARD 0x8000
//SIMpad touchscreen backlight strength control
#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
#define SIMPAD_BACKLIGHT_MASK 0x00a10044
QValueList <OLed> SIMpad::ledList ( ) const
{
QValueList <OLed> vl;
vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
//vl << Led_Mail; //TODO find out if LED1 is accessible anyway
return vl;
}
QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
{
QValueList <OLedState> vl;
if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
vl << Led_Off << Led_On;
//else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
//vl << Led_Off;
return vl;
}
OLedState SIMpad::ledState ( OLed l ) const
{
switch ( l ) {
case Led_Power:
return m_leds [0];
//case Led_Mail:
// return m_leds [1];
default:
return Led_Off;
}
}
bool SIMpad::setLedState ( OLed l, OLedState st )
{
static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
if ( l == Led_Power ) {
if ( fd >= 0 ) {
LED_IN leds;
::memset ( &leds, 0, sizeof( leds ));
leds. TotalTime = 0;
leds. OnTime = 0;
leds. OffTime = 1;
leds. OffOnBlink = 2;
switch ( st ) {
case Led_Off : leds. OffOnBlink = 0; break;
case Led_On : leds. OffOnBlink = 1; break;
case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
}
{
/*TODO Implement this like that:
read from cs3
&& with SIMPAD_LED2_ON
write to cs3 */
m_leds [0] = st;
return true;
}
}
}
return false;
}
bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
{
//TODO
return false;
}
void SIMpad::timerEvent ( QTimerEvent * )
{
killTimer ( m_power_timer );
m_power_timer = 0;
QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
}
void SIMpad::alarmSound ( )
{
#ifndef QT_NO_SOUND
static Sound snd ( "alarm" );
int fd;
int vol;
bool vol_reset = false;
if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
Config cfg ( "qpe" );
cfg. setGroup ( "Volume" );
int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
if ( volalarm < 0 )
volalarm = 0;
else if ( volalarm > 100 )
volalarm = 100;
volalarm |= ( volalarm << 8 );
if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
vol_reset = true;
}
}
snd. play ( );
while ( !snd. isFinished ( ))
qApp-> processEvents ( );
if ( fd >= 0 ) {
if ( vol_reset )
::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
::close ( fd );
}
#endif
}
bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
{
qDebug( "ODevice for SIMpad: suspend()" );
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
bool res = false;
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync ( ); // flush fs caches
- res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :)
+ res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
return res;
}
bool SIMpad::setSoftSuspend ( bool soft )
{
qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
return false;
}
bool SIMpad::setDisplayStatus ( bool on )
{
qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
bool res = false;
int fd;
QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
- if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
- res = ( ::system( (const char*) cmdline ) == 0 );
- ::close ( fd );
- }
+ res = ( ::system( (const char*) cmdline ) == 0 );
+
return res;
}
bool SIMpad::setDisplayBrightness ( int bright )
{
qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
bool res = false;
int fd;
if ( bright > 255 )
bright = 255;
- if ( bright < 0 )
+ if ( bright < 1 )
bright = 0;
if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
int value = 255 - bright;
const int mask = SIMPAD_BACKLIGHT_MASK;
value = value << 8;
value += mask;
char writeCommand[100];
const int count = sprintf( writeCommand, "0x%x\n", value );
res = ( ::write ( fd, writeCommand, count ) != -1 );
::close ( fd );
}
return res;
}
int SIMpad::displayBrightnessResolution ( ) const
{
- switch ( model ( )) {
- case Model_SIMpad_CL4:
- case Model_SIMpad_SL4:
- case Model_SIMpad_SLC:
- case Model_SIMpad_TSinus:
- return 255; //TODO find out if this is save
-
- default:
- return 2;
- }
+ return 255; // All SIMpad models share the same display
}
/**************************************************
*
* Ramses
*
**************************************************/
void Ramses::init()
{
d->m_vendorstr = "M und N";
d->m_vendor = Vendor_MundN;
QFile f("/proc/sys/board/ramses");
d->m_modelstr = "Ramses";
d->m_model = Model_Ramses_MNCI;
- d->m_rotation = Rot180;
- d->m_direction = CW;
- d->m_holdtime = 1000;
+ d->m_rotation = Rot0;
+ d->m_holdtime = 1000;
f.setName("/etc/oz_version");
if (f.open(IO_ReadOnly)) {
d->m_systemstr = "OpenEmbedded/Ramses";
d->m_system = System_OpenZaurus;
QTextStream ts(&f);
ts.setDevice(&f);
d->m_sysverstr = ts.readLine();
f.close();
}
m_power_timer = 0;
#ifdef QT_QWS_ALLOW_OVERCLOCK
#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
#define OC(x...) x
#else
#define OC(x...)
#endif
// This table is true for a Intel XScale PXA 255
d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
OC( d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
OC( d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
OC( d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
OC( d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
}
bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
{
Q_UNUSED( keycode );
Q_UNUSED( modifiers );
Q_UNUSED( isPress );
Q_UNUSED( autoRepeat );
return false;
}
void Ramses::timerEvent(QTimerEvent *)
{
killTimer(m_power_timer);
m_power_timer = 0;
QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
}
bool Ramses::setSoftSuspend(bool soft)
{
- Q_UNUSED(soft);
- return true;
-}
-
-bool Ramses::suspend()
-{
- //qDebug("Ramses::suspend()");
- if ( !isQWS() ) // only qwsserver is allowed to suspend
- return false;
-
+ qDebug("Ramses::setSoftSuspend(%d)", soft);
+#if 0
bool res = false;
int fd;
- if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) {
- res = ( ::write ( fd, "1", 1 ) != -1 );
+ if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
+ ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
+
+ int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
+
+ if (sources >= 0) {
+ if (soft)
+ sources &= ~APM_EVT_POWER_BUTTON;
+ else
+ sources |= APM_EVT_POWER_BUTTON;
+
+ if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
+ res = true;
+ else
+ perror("APM_IOCGEVTSRC");
+ }
+ else
+ perror("APM_IOCGEVTSRC");
+
::close(fd);
}
- return res;
+ else
+ perror("/dev/apm_bios or /dev/misc/apm_bios");
+
+ return res;
+#else
+ return true;
+#endif
+}
+
+bool Ramses::suspend ( )
+{
+ qDebug("Ramses::suspend");
+ return false;
}
/**
* This sets the display on or off
*/
bool Ramses::setDisplayStatus(bool on)
{
- //qDebug("Ramses::setDisplayStatus(%d)", on);
+ qDebug("Ramses::setDisplayStatus(%d)", on);
+#if 0
bool res = false;
int fd;
- if ((fd = ::open ("/dev/fb/1", O_RDWR)) >= 0) {
+ if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
::close(fd);
}
return res;
+#else
+ return true;
+#endif
}
/*
* We get something between 0..255 into us
*/
bool Ramses::setDisplayBrightness(int bright)
{
- //qDebug("Ramses::setDisplayBrightness(%d)", bright);
+ qDebug("Ramses::setDisplayBrightness(%d)", bright);
bool res = false;
int fd;
// pwm1 brighness: 20 steps 500..0 (dunkel->hell)
if (bright > 255 )
bright = 255;
if (bright < 0)
bright = 0;
// Turn backlight completely off
if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
char writeCommand[10];
const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
res = (::write(fd, writeCommand, count) != -1);
::close(fd);
}
// scale backlight brightness to hardware
- if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) {
- //qDebug(" %d -> pwm1", bright);
+ bright = 500-(bright * 500 / 255);
+ if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
+ qDebug(" %d -> pwm1", bright);
char writeCommand[100];
const int count = sprintf(writeCommand, "%d\n", bright);
res = (::write(fd, writeCommand, count) != -1);
::close(fd);
}
return res;
}
int Ramses::displayBrightnessResolution() const
{
- return 256;
+ return 32;
}
bool Ramses::setDisplayContrast(int contr)
{
- //qDebug("Ramses::setDisplayContrast(%d)", contr);
+ qDebug("Ramses::setDisplayContrast(%d)", contr);
bool res = false;
int fd;
// pwm0 contrast: 20 steps 79..90 (dunkel->hell)
if (contr > 255 )
contr = 255;
if (contr < 0)
contr = 0;
+ contr = 90 - (contr * 20 / 255);
- if ((fd = ::open("/proc/sys/board/lcd_contrast", O_WRONLY)) >= 0) {
- //qDebug(" %d -> pwm0", contr);
+ if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
+ qDebug(" %d -> pwm0", contr);
char writeCommand[100];
const int count = sprintf(writeCommand, "%d\n", contr);
res = (::write(fd, writeCommand, count) != -1);
res = true;
::close(fd);
}
return res;
}
int Ramses::displayContrastResolution() const
{
- return 256;
+ return 20;
}
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 @@
/*
               =. This file is part of the OPIE Project
-             .=l. Copyright (c) 2002 <>
+             .=l. Copyright (c) 2002,2003 <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qpe/applnk.h>
+#include <qpe/config.h>
+#include <qpe/qpeapplication.h>
+
+#include <qfileinfo.h>
#include <qstring.h>
#include <qapplication.h>
#include <qlayout.h>
+
#include "ofiledialog.h"
+
+namespace {
+ /*
+ * helper functions to load the start dir
+ * and to save it
+ * helper to extract the dir out of a file name
+ */
+ /**
+ * This method will use Config( argv[0] );
+ * @param key The group key used
+ */
+ QString lastUsedDir( const QString& key ) {
+ if ( qApp->argc() < 1 )
+ return QString::null;
+
+ Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname
+ cfg.setGroup( key );
+ return cfg.readEntry("LastDir", QPEApplication::documentDir() );
+ }
+
+ void saveLastDir( const QString& key, const QString& file ) {
+ if ( qApp->argc() < 1 )
+ return;
+
+ Config cfg( QFileInfo(qApp->argv()[0]).fileName() );
+ cfg.setGroup( key );
+ QFileInfo inf( file );
+ cfg.writeEntry("LastDir", inf.dirPath( true ) );
+ }
+};
+
/**
* This constructs a modal dialog
*
* @param caption The caption of the dialog
* @param wid The parent widget
* @param mode The mode of the OFileSelector @see OFileSelector
* @param selector The selector of the OFileSelector
* @param dirName the dir or resource to start from
* @param fileName a proposed or existing filename
* @param mimetypes The mimeTypes
*/
OFileDialog::OFileDialog(const QString &caption,
QWidget *wid, int mode, int selector,
const QString &dirName,
const QString &fileName,
const QMap<QString,QStringList>& mimetypes )
: QDialog( wid, "OFileDialog", true )
{
// QVBoxLayout *lay = new QVBoxLayout(this);
//showMaximized();
QVBoxLayout *lay = new QVBoxLayout(this );
file = new OFileSelector(this , mode, selector,
dirName, fileName,
mimetypes );
lay->addWidget( file );
//lay->addWidget( file );
//showFullScreen();
setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
connect(file, SIGNAL(fileSelected(const QString&) ),
this, SLOT(slotFileSelected(const QString&) ) );
+ connect(file, SIGNAL(ok() ),
+ this, SLOT(slotSelectorOk()) ) ;
+ connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) );
+
+#if 0
connect(file, SIGNAL(dirSelected(const QString &) ),
this, SLOT(slotDirSelected(const QString &) ) );
-
-
- file->setYesCancelVisible( false ); // relayout
+#endif
}
/**
* @returns the mimetype of the selected
* currently it return QString::null
*/
QString OFileDialog::mimetype()const
{
return QString::null;
}
/**
* @return the fileName
*/
QString OFileDialog::fileName()const
{
return file->selectedName();
}
/**
* return a DocLnk to the current file
*/
DocLnk OFileDialog::selectedDocument()const
{
return file->selectedDocument();
}
/**
* This opens up a filedialog in Open mode
*
* @param selector the Selector Mode
* @param startDir Where to start from
* @param file A proposed filename
* @param mimes A list of MimeTypes
* @param wid the parent
* @param caption of the dialog if QString::null tr("Open") will be used
* @return the fileName or QString::null
*/
QString OFileDialog::getOpenFileName(int selector,
- const QString &startDir,
+ const QString &_startDir,
const QString &file,
const MimeTypes &mimes,
QWidget *wid,
const QString &caption )
{
QString ret;
+ QString startDir = _startDir;
+ if (startDir.isEmpty() )
+ startDir = lastUsedDir( "FileDialog-OPEN" );
+
+
OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
- wid, OFileSelector::OPEN, selector, startDir, file, mimes);
+ wid, OFileSelector::Open, selector, startDir, file, mimes);
dlg.showMaximized();
- if( dlg.exec() )
+ if( dlg.exec() ) {
ret = dlg.fileName();
+ saveLastDir( "FileDialog-OPEN", ret );
+ }
return ret;
}
/**
* This opens up a file dialog in save mode
* @see getOpenFileName
*/
QString OFileDialog::getSaveFileName(int selector,
- const QString &startDir,
+ const QString &_startDir,
const QString &file,
const MimeTypes &mimes,
QWidget *wid,
const QString &caption )
{
QString ret;
+ QString startDir = _startDir;
+ if (startDir.isEmpty() )
+ startDir = lastUsedDir( "FileDialog-SAVE" );
+
OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
- wid, OFileSelector::SAVE, selector, startDir, file, mimes);
+ wid, OFileSelector::Save, selector, startDir, file, mimes);
dlg.showMaximized();
- if( dlg.exec() )
+ if( dlg.exec() ) {
ret = dlg.fileName();
+ saveLastDir( "FileDialog-SAVE", ret );
+ }
return ret;
}
void OFileDialog::slotFileSelected(const QString & )
{
accept();
}
-void OFileDialog::slotDirSelected(const QString & )
+
+void OFileDialog::slotSelectorOk( )
+{
+ accept();
+}
+
+void OFileDialog::slotDirSelected(const QString &dir )
{
+ setCaption( dir );
// if mode
//accept();
}
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 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OpieFileDialog_h
#define OpieFileDialog_h
#include <qdialog.h>
#include <opie/ofileselector.h>
/**
* This class places a OFileSelector inside a QDialog.
* It provides static method for letting a user chose
* a file for either opening or saving.
* Most of the time the c'tor will not be used instead using
* the static member functions is prefered.
*
* <pre>
* QMap<QString, QStringList> mimeTypes;
* QStringList types;
- * types << "text/* ";
+ * types << "text[slash]* ";
* mimeTypes.insert( tr("Text"), types );
* mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment
* QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
* "foo","bar", mimeTypes);
* </pre>
*
* @short A small QDialog swalloing a FileSelector
* @see QDialog
* @see OFileSelector
* @version 0.1-unfinished
* @author Holger Freyther ( zecke@handhelds.org )
*/
class OFileDialog : public QDialog {
Q_OBJECT
public:
OFileDialog(const QString &caption,
QWidget *, int mode, int selector,
const QString &dirName,
const QString &fileName = QString::null,
const MimeTypes &mimetypes = MimeTypes() );
QString mimetype() const;
QString fileName() const;
DocLnk selectedDocument()const;
// static methods
static QString getOpenFileName(int selector,
const QString& startDir = QString::null,
const QString &fileName = QString::null,
const MimeTypes& mime = MimeTypes(),
QWidget *wid = 0,
const QString &caption = QString::null );
static QString getSaveFileName(int selector,
const QString& startDir = QString::null,
const QString& fileName = QString::null,
const MimeTypes& mimefilter = MimeTypes(),
QWidget *wid = 0,
const QString &caption = QString::null );
//let's OFileSelector catch up first
//static QString getExistingDirectory(const QString& startDir = QString::null,
// QWidget *parent = 0,
// const QString& caption = QString::null );
private:
class OFileDialogPrivate;
OFileDialogPrivate *d;
OFileSelector *file;
private slots:
void slotFileSelected( const QString & );
void slotDirSelected(const QString & );
+ void slotSelectorOk();
};
#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 @@
-
-
-#include <qwmatrix.h>
-#include <qcheckbox.h>
-#include <qcombobox.h>
-#include <qheader.h>
-#include <qlabel.h>
-#include <qabstractlayout.h>
-#include <qlayout.h>
-#include <qlineedit.h>
-#include <qlistview.h>
-#include <qmessagebox.h>
-#include <qpainter.h>
-#include <qpushbutton.h>
-#include <qwidgetstack.h>
-#include <qpopupmenu.h>
-#include <qdir.h>
-#include <qfile.h>
-#include <qfileinfo.h>
-#include <qtimer.h>
-
-#include <qpe/qpeapplication.h>
-#include <qpe/applnk.h>
-#include <qpe/fileselector.h>
-#include <qpe/global.h>
-#include <qpe/mimetype.h>
-#include <qpe/resource.h>
-#include <qpe/storage.h>
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-
-#include "ofileselector.h"
-
-
-QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
-
-namespace {
- int indexByString( const QComboBox *box, const QString &str ){
- int index= 0;
- for(int i= 0; i < box->count(); i++ ){
- if( str == box->text(i ) ){
- index= i;
- break;
- }
- }
- return index;
- }
- class OFileSelectorItem : public QListViewItem {
- public:
- OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path,
- const QString &date, const QString &size, const QString &mDir,
- bool isLocked=false, bool isDir=false ): QListViewItem(view) {
- setPixmap(0, pixmap );
- setText(1, path );
- setText(2, size );
- setText(3, date );
- //setText(4, mDir );
- m_dir = mDir;
- dir = isDir;
- mLocked = isLocked;
- }
- bool isLocked() const{
- return mLocked;
- }
- QString directory()const{
- return m_dir;
- }
- bool isDir()const{
- return dir;
- }
- QString path()const{
- return text(1 );
- }
- QString key(int id, bool )const {
- QString ke;
- if( id == 0 || id == 1 ){ // name
- if( dir ){
- ke.append("0" );
- ke.append( text(1) );
- }else{
- ke.append("1" );
- ke.append( text(1) );
- }
- }else if( id == 2 ){ // size
- return text(2);
- }else if( id == 3 ){ // date
- return text(3);
- }
- return ke;
- };
- private:
- bool mLocked:1;
- bool dir:1;
- QString m_dir;
- };
-};
-
-
-OFileSelector::OFileSelector( QWidget *wid, int mode, int selector,
- const QString &dirName,
- const QString &fileName,
- const QMap<QString,QStringList>& mimeTypes)
- : QWidget( wid, "OFileSelector")
-{
- m_mimetypes = mimeTypes;
- if (mode == SAVE )
- m_name = fileName;
- initVars();
- m_mode = mode;
- m_selector = selector;
- m_currentDir = dirName;
- init();
- //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) );
-}
-
-OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent,
- const char *name, bool newVisible,
- bool closeVisible )
- : QWidget( parent, name )
-{
- if (!mimeFilter.isEmpty() ) {
- QStringList list = QStringList::split(";", mimeFilter );
- m_mimetypes.insert(mimeFilter, list );
- }
- initVars();
- m_currentDir = QPEApplication::documentDir();
- m_mode = FILESELECTOR;
- m_selector = NORMAL;
- m_shClose = closeVisible;
- m_shNew = newVisible;
- m_shLne = false;
- m_shPerm = false;
- m_shYesNo = false;
- init();
-
-}
-
-OFileSelector::~OFileSelector()
-{
-
-
-}
-
-void OFileSelector::setNewVisible( bool visible )
-{
- m_shNew = visible;
- if( m_selector == NORMAL ){
- delete m_select;
- // we need to initialize but keep the selected mimetype
- QString mime = currentMimeType();
- m_select = new FileSelector( mime ,
- m_stack, "fileselector",
- m_shNew, m_shClose);
- connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
- this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
- connect(m_select, SIGNAL(closeMe() ),
- this, SIGNAL(closeMe() ) );
- //connect to close me and other signals as well
- m_stack->addWidget( m_select, NORMAL );
- }else{
- m_new->show();
- }
-}
-void OFileSelector::setCloseVisible( bool visible )
-{
- m_shClose = visible;
- if( m_selector == NORMAL ){
- setNewVisible( m_shNew ); // yeah baby
- }else{
- m_close->show();
- }
-}
-void OFileSelector::reread()
-{
- if( m_selector == NORMAL ){
- setNewVisible( m_shNew ); // make it a initializeSelector
- }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
- reparse();
- //}else{
- //;
- }
-}
-
-const DocLnk *OFileSelector::selected()
-{
- DocLnk *lnk = new DocLnk(selectedDocument() );
- return lnk;
-}
-
-void OFileSelector::setYesCancelVisible( bool show )
-{
- initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :(
- m_shYesNo = show;
- if( m_shYesNo )
- m_boxOk->show();
- else
- m_boxOk->hide();
-
-}
-void OFileSelector::setToolbarVisible( bool show )
-{
- m_shTool = show;
- initializeListView(); // FIXME see above waste of memory
- if(!m_shTool ){
- m_location->hide();
- m_up->hide();
- m_homeButton->hide();
- m_docButton->hide();
- }else{
- m_location->show();
- m_up->show();
- m_homeButton->show();
- m_docButton->show();
- }
-}
-void OFileSelector::setPermissionBarVisible( bool show )
-{
- m_shPerm = show;
- initializePerm();
- if( m_shPerm )
- m_checkPerm->show();
- else
- m_checkPerm->hide();
-}
-void OFileSelector::setLineEditVisible( bool show )
-{
- if( show ){
- initializeName();
- m_boxName->show();
- }else{
- if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go
- m_boxName->hide();
- }
- }
- m_shLne = show;
-}
-
-void OFileSelector::setChooserVisible( bool show )
-{
- m_shChooser = show;
- initializeChooser();
- if( m_shChooser ){
- m_boxView->hide();
- }else{
- m_boxView->show();
- }
-}
-
-QCheckBox* OFileSelector::permissionCheckbox()
-{
- if( m_selector == NORMAL )
- return 0l;
- else
- return m_checkPerm;
-}
-bool OFileSelector::setPermission()const
-{
- return m_checkPerm == 0 ? false : m_checkPerm->isChecked();
-}
-void OFileSelector::setPermissionChecked( bool check )
-{
- if( m_checkPerm )
- m_checkPerm->setChecked( check );
-}
-
-void OFileSelector::setMode(int mode) // FIXME do direct raising
-{
- m_mode = mode;
- if( m_selector == NORMAL )
- return;
-}
-void OFileSelector::setShowDirs(bool )
-{
- m_dir = true;
- reparse();
-}
-void OFileSelector::setCaseSensetive(bool caSe )
-{
- m_case = caSe;
- reparse();
-}
-void OFileSelector::setShowFiles(bool show )
-{
- m_files = show;
- reparse();
-}
-///
-bool OFileSelector::cd(const QString &path )
-{
- m_currentDir = path;
- reparse();
- return true;
-}
-void OFileSelector::setSelector(int mode )
-{
-QString text;
- switch( mode ){
- case NORMAL:
- text = tr("Documents");
- break;
- case EXTENDED:
- text = tr("Files");
- break;
- case EXTENDED_ALL:
- text = tr("All Files");
- break;
- }
- slotViewCheck( text );
-}
-
-void OFileSelector::setPopupMenu(QPopupMenu *popup )
-{
- m_custom = popup;
- m_showPopup = true;
-}
-
-//void OFileSelector::updateL
-
-QString OFileSelector::selectedName() const
-{
- QString name;
- if( m_selector == NORMAL ){
- DocLnk lnk = m_select->selectedDocument();
- name = lnk.file();
- }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
- if ( m_shLne ) {
- name = m_currentDir + "/" +m_edit->text();
- }else{
- QListViewItem *item = m_View->currentItem();
- if( item != 0 )
- name = m_currentDir + "/" + item->text( 1 );
- }
- }else { // installed view
- ;
- }
- return name;
-}
-QStringList OFileSelector::selectedNames()const
-{
- QStringList list;
- if( m_selector == NORMAL ){
- list << selectedName();
- }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
- list << selectedName(); // FIXME implement multiple Selections
- }
- return list;
-}
-/** If mode is set to the Dir selection this will return the selected path.
- *
- *
- */
-QString OFileSelector::selectedPath()const
-{
- QString path;
- if( m_selector == NORMAL ){
- path = QPEApplication::documentDir();
- }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
- ;
- }
- return path;
-}
-QStringList OFileSelector::selectedPaths() const
-{
- QStringList list;
- list << selectedPath();
- return list;
-}
-QString OFileSelector::directory()const
-{
- if( m_selector == NORMAL )
- return QPEApplication::documentDir();
-
- return QDir(m_currentDir).absPath();
-}
-
-int OFileSelector::fileCount() const
-{
- int count;
- switch( m_selector ){
- case NORMAL:
- count = m_select->fileCount();
- break;
- //case CUSTOM:
- case EXTENDED:
- case EXTENDED_ALL:
- default:
- count = m_View->childCount();
- break;
- }
- return count;
-}
-DocLnk OFileSelector::selectedDocument() const
-{
- DocLnk lnk;
- switch( m_selector ){
- case NORMAL:{
- lnk = m_select->selectedDocument();
- break;
- }
- case EXTENDED:
- case EXTENDED_ALL:
- default:
- lnk = DocLnk( selectedName() ); // new DocLnk
- break;
- }
- return lnk;
-}
-QValueList<DocLnk> OFileSelector::selectedDocuments() const
-{
- QValueList<DocLnk> docs;
- docs.append( selectedDocument() );
- return docs;
-}
-
-
-// slots internal
-
-void OFileSelector::slotOk()
-{
- emit ok();
-}
-void OFileSelector::slotCancel()
-{
- emit cancel();
-}
-void OFileSelector::slotViewCheck(const QString &sel)
-{
- if( sel == tr("Documents" ) ){
- if( m_select == 0 ){
- // autMime? fix cause now we use All and not the current
- // yes currentMime fixes that for us
- QString mime = currentMimeType();
- m_select = new FileSelector(mime,
- m_stack, "fileselector",
- m_shNew, m_shClose);
- connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
- this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
- connect(m_select, SIGNAL(closeMe() ),
- this, SIGNAL(closeMe() ) );
- //connect to close me and other signals as well
-
- m_stack->addWidget( m_select, NORMAL );
- }
- m_stack->raiseWidget( NORMAL );
- m_selector = NORMAL;
- }else if( sel == tr("Files") ){
- m_selector = EXTENDED;
- initializeListView();
- reparse();
- m_stack->raiseWidget( EXTENDED );
- }else if( sel == tr("All Files") ){
- m_selector = EXTENDED_ALL;
- initializeListView();
- reparse();
- m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter
- }
-}
-// not yet finished.....
-QString OFileSelector::currentMimeType() const{
- QString mime;
- QString currentText;
- if (m_shChooser )
- currentText = m_mimeCheck->currentText();
-
- if (tr("All") == currentText ) return QString::null;
- else if (currentText.isEmpty() ) {
- ;
- }else {
- QMap<QString, QStringList>::ConstIterator it;
- it = m_mimetypes.find( currentText );
- if ( it == m_mimetypes.end() ) {
- mime = it.data().join(";");
- }else{
- mime = currentText;
- }
- }
- return mime;
-}
-void OFileSelector::slotMimeCheck(const QString &mime)
-{
- if( m_selector == NORMAL ){
- //if( m_autoMime ){
- QString newMimeType;
- if (mime != tr("All") ) {
- QMap<QString, QStringList>::Iterator it;
- it = m_mimetypes.find(mime);
- if ( it != m_mimetypes.end() ) {
- newMimeType = it.data().join(";");
- }else{
- newMimeType = mime;
- }
- }
- delete m_select;
- m_select = new FileSelector( newMimeType,
- m_stack, "fileselector",
- m_shNew, m_shClose);
-
- connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
- this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
- connect(m_select, SIGNAL(closeMe() ),
- this, SIGNAL(closeMe() ) );
- //connect to close me and other signals as well
- m_stack->addWidget( m_select, NORMAL );
- m_stack->raiseWidget( NORMAL );
- updateMimes();
- updateMimeCheck();
- m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
- //}
- }else{ // others
- qWarning("Mime %s", mime.latin1() );
- if(m_shChooser ){
- qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
- //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
- }
- reparse();
- }
-
-}
-/*
- * Ok if a non dir gets inserted into this combobox
- * we need to change it
- * QFileInfo and dirPath will give us the right Dir
- */
-void OFileSelector::slotLocationActivated(const QString &file)
-{
- qWarning("slotLocationActivated");
- QString name = file.left( file.find("<-", 0, TRUE ) );
- QFileInfo info( name );
- if ( info.isFile() )
- cd(info.dirPath( TRUE ) ); //absolute
- else
- cd(name );
- reparse();
-}
-void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
-{
- QStringList pathList;
- bool underDog = FALSE;
- for(int i=0;i<count;i++) {
- pathList << m_location->text(i);
- if( m_location->text(i) == currentPath)
- underDog = TRUE;
- }
- if( !underDog) {
- m_location->clear();
- if( currentPath.left(2)=="//")
- pathList.append( currentPath.right(currentPath.length()-1) );
- else
- pathList.append( currentPath );
- m_location->insertStringList( pathList,-1);
- }
-}
-/*
- * Do not crash anymore
- * don't try to change dir to a file
- */
-void OFileSelector::locationComboChanged()
-{
- QFileInfo info( m_location->lineEdit()->text() );
- qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() );
- if (info.isFile() )
- cd(info.dirPath(TRUE) ); //absolute path
- else
- cd( m_location->lineEdit()->text() );
-
- reparse();
-}
-void OFileSelector::init()
-{
- m_lay = new QVBoxLayout( this );
- m_lay->setSpacing(0 );
-
- m_stack = new QWidgetStack( this );
- if( m_selector == NORMAL ){
- QString mime;
- if (!m_autoMime) {
- if (!m_mimetypes.isEmpty() ) {
- QMap<QString, QStringList>::Iterator it;
- it = m_mimetypes.begin(); // cause we're in the init
- mime = it.data().join(";");
- }
- }
- m_select = new FileSelector(mime,
- m_stack, "fileselector",
- m_shNew, m_shClose);
-
- connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
- this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
- connect(m_select, SIGNAL(closeMe() ),
- this, SIGNAL( closeMe() ) );
- //connect to close me and other signals as well
-
- m_stack->addWidget( m_select, NORMAL );
- m_stack->raiseWidget( NORMAL );
- }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL
- // and initializeListview will take care of those
- // toolbar get's generade in initializeListView
- initializeListView( ); // will raise the widget as well
- m_stack->raiseWidget( EXTENDED );
- }
- m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch
-
- if( m_shLne ) // the LineEdit with the current FileName
- initializeName();
-
- if( m_shPerm ) // the Permission QCheckBox
- initializePerm();
-
- if( m_shChooser ) // the Chooser for the view and Mimetypes
- initializeChooser();
-
- if( m_shYesNo ) // the Yes No button row
- initializeYes( );
-
- if (m_selector != NORMAL )
- reparse();
-}
-void OFileSelector::updateMimes()
-{
- if( m_autoMime ){
- m_mimetypes.clear();
- m_mimetypes.insert( tr("All"), QString::null );
- if( m_selector == NORMAL ){
- DocLnkSet set;
- Global::findDocuments(&set, QString::null );
- QListIterator<DocLnk> dit( set.children() );
- for( ; dit.current(); ++dit ){
- if( !m_mimetypes.contains( (*dit)->type() ) )
- m_mimetypes.insert( (*dit)->type(), (*dit)->type() );
- }
- }// else done in reparse
- }
-}
-void OFileSelector::initVars()
-{
- if( m_mimetypes.isEmpty() )
- m_autoMime = true;
- else
- m_autoMime = false;
- m_shClose = false;
- m_shNew = false;
- m_shTool = true;
- m_shPerm = false;
- m_shLne = true;
- m_shChooser = true;
- m_shYesNo = true;
- m_case = false;
- m_dir = true;
- m_files = true;
- m_showPopup = false;
- if(m_pixmaps == 0 ) // init the pixmaps
- initPics();
-
- // pointers
- m_location = 0;
- m_mimeCheck = 0;
- m_viewCheck = 0;
- m_homeButton = 0;
- m_docButton = 0;
- m_hideButton = 0;
- m_ok = 0;
- m_cancel = 0;
- m_reread = 0;
- m_up = 0;
- m_View = 0;
- m_checkPerm = 0;
- m_pseudo = 0;
- m_pseudoLayout = 0;
- m_select = 0;
- m_stack = 0;
- m_lay = 0;
- m_Oselector = 0;
- m_boxToolbar = 0;
- m_boxOk = 0;
- m_boxName = 0;
- m_boxView = 0;
- m_custom = 0;
- m_edit = 0;
- m_fnLabel = 0;
- m_new = 0;
- m_close = 0;
-}
-void OFileSelector::addFile(const QString &/*mime*/, QFileInfo *info, bool symlink)
-{
- if(!m_files)
- return;
- // if( !compliesMime(info->absFilePath(), mime ) )
- // return;
- MimeType type( info->absFilePath() );
- if (!compliesMime( type.id() ) )
- return;
-
- QPixmap pix = type.pixmap();
- QString dir;
- QString name;
- bool locked;
- if( pix.isNull() ) {
- //TODO make this scaled pixmap global, so we dont have to keep doing this
- QWMatrix matrix;
- QPixmap pixer(Resource::loadPixmap( "UnknownDocument" ));
- matrix.scale( .4, .4);
- pix = pixer.xForm(matrix);
-// pix = Resource::loadPixmap( "UnknownDocument-14");
- }
- dir = info->dirPath( true );
- if( symlink )
- name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
- else {
- name = info->fileName();
- if( ( m_mode == OPEN && !info->isReadable() )||
- ( m_mode == SAVE && !info->isWritable() ) ){
-
- locked = true; pix = Resource::loadPixmap("locked");
- }
- }
- new OFileSelectorItem( m_View, pix, name,
- info->lastModified().toString(),
- QString::number( info->size() ),
- dir, locked );
-}
-void OFileSelector::addDir(const QString &/*mime*/, QFileInfo *info, bool symlink )
-{
- if(!m_dir)
- return;
- if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){
- bool locked = false;
- QString name;
- QPixmap pix;
- if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
- locked = true;
- if( symlink )
- pix = (*m_pixmaps)["symlinkedlocked"];
- else
- pix = Resource::loadPixmap("lockedfolder");
- }else { // readable
- pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ;
- }
- name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ;
- new OFileSelectorItem( m_View, pix, name,
- info->lastModified().toString(),
- QString::number( info->size() ),
- info->dirPath( true ), locked,
- true );
-
- }// else CUSTOM View
-}
-void OFileSelector::delItems()
-{
-
-}
-void OFileSelector::initializeName()
-{
- /** Name Layout Line
- * This is the Layout line arranged in
- * horizontal way each components
- * are next to each other
- * but we will only do this if
- * we didn't initialize a while ago.
- */
- if( m_boxName == 0 ){
- m_boxName = new QHBox( this ); // remove this this? or use a QHBox
- m_fnLabel = new QLabel( m_boxName );
- m_fnLabel->setText( tr("Name:") );
- m_edit = new QLineEdit( m_boxName );
- m_edit->setText( m_name );
- //m_boxName->addWidget( m_fnLabel );
- m_boxName->setMargin( 5 );
- m_boxName->setSpacing( 8 );
- //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor
-
- m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout
- }// else we already initialized
- // maybe show the components?
- //
-}
-void OFileSelector::initializeYes()
-{
- /** The Save Cancel bar
- *
- */
- if( m_boxOk == 0 ){
- m_boxOk = new QHBox( this );
- m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" );
- m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" );
-
- //m_boxOk->addWidget( m_ok );
- //m_boxOk->addWidget( m_cancel );
- m_boxOk->setMargin( 5 );
- m_boxOk->setSpacing( 10 );
- m_lay->addWidget( m_boxOk, 0 );
-
- connect( m_ok, SIGNAL( clicked() ),
- this, SLOT(slotOk() ) );
- connect( m_cancel, SIGNAL( clicked() ),
- this, SLOT( slotCancel() ) );
- }
-}
-/*
- * OK m_mimeCheck is a QComboBox we now want to fill
- * out that combobox
- * if automime we need to update the mimetypes
- */
-void OFileSelector::updateMimeCheck() {
- m_mimeCheck->clear();
- if (m_autoMime ) {
- //m_mimeCheck->insertItem( tr("All") );
- updateMimes();
- }
-
- QMap<QString, QStringList>::Iterator it;
- for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) {
- m_mimeCheck->insertItem( it.key() );
- }
-}
-
-void OFileSelector::initializeChooser()
-{
- if( m_boxView == 0 ){
- m_boxView = new QHBox( this );
- m_viewCheck = new QComboBox( m_boxView, "view check");
- m_mimeCheck = new QComboBox( m_boxView, "mime check");
- m_boxView->setSpacing( 8 );
- m_lay->addWidget(m_boxView, 0 );
-
- m_viewCheck->insertItem( tr("Documents") );
- m_viewCheck->insertItem( tr("Files") );
- m_viewCheck->insertItem( tr("All Files") );
- updateMimeCheck();
-
- connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
- this, SLOT( slotViewCheck(const QString & ) ) );
- connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
- this, SLOT( slotMimeCheck( const QString & ) ) );
- }
-}
-void OFileSelector::initializeListView()
-{
- qWarning("initializeListView");
- if( m_pseudo == 0 ){
- qWarning("init");
- m_pseudo = new QWidget( m_stack, "Pseudo Widget");
- m_pseudoLayout = new QVBoxLayout( m_pseudo );
- // toolbar
- m_boxToolbar = new QHBox( m_pseudo );
- m_boxToolbar->setSpacing(0 ); // next to each other please
-
- // toolbar members
- {
- // location QComboBox
- m_location = new QComboBox( m_boxToolbar );
- m_location->setEditable( TRUE );
- m_location->setDuplicatesEnabled( FALSE );
- connect( m_location, SIGNAL(activated(const QString &) ),
- this, SLOT( slotLocationActivated(const QString &) ) );
- connect( m_location->lineEdit(), SIGNAL(returnPressed() ),
- this, SLOT(locationComboChanged() ) );
- // UP Button
- m_up = new QPushButton(Resource::loadIconSet("up"),"",
- m_boxToolbar,"cdUpButton");
- m_up->setFixedSize( QSize( 20, 20 ) );
- connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
- m_up->setFlat(TRUE);
-
- // Home Button
- m_homeButton = new QPushButton(Resource::loadIconSet("home") ,
- "", m_boxToolbar);
- m_homeButton->setFixedSize( QSize( 20, 20 ) );
- connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
- m_homeButton->setFlat(TRUE);
- // Documents Button
- m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",
- m_boxToolbar,"docsButton");
- m_docButton->setFixedSize( QSize( 20, 20 ) );
- connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
- m_docButton->setFlat(TRUE);
-
- // Close button
- m_close = new QPushButton( Resource::loadIconSet( "close"), "",
- m_boxToolbar );
- connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
- m_close->setFixedSize( 20, 20 );
-
- m_boxToolbar->setFixedHeight( 20 );
- m_pseudoLayout->addWidget(m_boxToolbar );
-
- // let;s fill the Location ComboBox
- StorageInfo storage;
- const QList<FileSystem> &fs = storage.fileSystems();
- QListIterator<FileSystem> it ( fs );
- for( ; it.current(); ++it ){
- const QString disk = (*it)->name();
- const QString path = (*it)->path();
- m_location->insertItem(path+ "<-"+disk );
- }
- int count = m_location->count();
- m_location->insertItem( m_currentDir );
- m_location->setCurrentItem( count );
- // due to the New and Close button we can not simply hide m_boxToolBar to not show it
- if( !m_shTool ){
- m_location->hide( );
- m_up->hide( );
- m_homeButton->hide( );
- m_docButton->hide( );
- }
- if(!m_shClose )
- m_close->hide();
- //if(!m_shNew)
- //m_close->hide();
-
- } // off toolbar
- // the Main ListView
- // make a QWidgetStack first so Views can share the Toolbar
- m_View = new QListView( m_pseudo, "Extended view");
- QPEApplication::setStylusOperation( m_View->viewport(),
- QPEApplication::RightOnHold);
- m_View->addColumn(" " );
- m_View->addColumn(tr("Name"), 135 );
- m_View->addColumn(tr("Size"), -1 );
- m_View->addColumn(tr("Date"), 60 );
- m_View->addColumn(tr("Mime Type"), -1 );
- QHeader *header = m_View->header();
- header->hide();
- m_View->setSorting( 1 );
- m_View->setAllColumnsShowFocus( TRUE );
-
- connect(m_View, SIGNAL(selectionChanged() ),
- this, SLOT(slotSelectionChanged() ) );
-
- connect(m_View, SIGNAL(clicked(QListViewItem *) ),
-// connect(m_View, SIGNAL(currentChanged(QListViewItem *) ),
- this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
-
- connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
- this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
-
- connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
- this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
-
- m_pseudoLayout->addWidget( m_View, 288 );
- m_stack->addWidget( m_pseudo, EXTENDED );
- }
-}
-void OFileSelector::initializePerm()
-{
- if( m_checkPerm == 0 ){
- m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm");
- m_checkPerm->setChecked( false );
- m_lay->addWidget( m_checkPerm );
-
- }
-}
-void OFileSelector::initPics()
-{
- m_pixmaps = new QMap<QString,QPixmap>;
- QPixmap pm = Resource::loadPixmap( "folder" );
- QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
- QPainter painter( &pm );
- painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
- pm.setMask( pm.createHeuristicMask( FALSE ) );
- m_pixmaps->insert("dirsymlink", pm );
-
- QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
- QPainter pen(&pm2 );
- pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
- pm2.setMask( pm2.createHeuristicMask( FALSE ) );
- m_pixmaps->insert("symlinkedlocked", pm2 );
-}
-// if a mime complies with the m_mimeCheck->currentItem
-bool OFileSelector::compliesMime( const QString &path, const QString &mime )
-{
- if( mime == "All" )
- return true;
- MimeType type( path );
- if( type.id() == mime )
- return true;
- return false;
-}
-/* check if the mimetype in mime
- * complies with the one which is current
- */
-/*
- * We've the mimetype of the file
- * We need to get the stringlist of the current mimetype
- *
- * mime = image/jpeg
- * QStringList = 'image/*'
- * or QStringList = image/jpeg;image/png;application/x-ogg
- * or QStringList = application/x-ogg;image/*;
- * with all these mime filters it should get acceptes
- * to do so we need to look if mime is contained inside
- * the stringlist
- * if it's contained return true
- * if not ( I'm no RegExp expert at all ) we'll look if a '/*'
- * is contained in the mimefilter and then we will
- * look if both are equal until the '/'
- */
-bool OFileSelector::compliesMime( const QString& mime ) {
- qWarning("mimetype is %s", mime.latin1() );
- QString currentText;
- if (m_shChooser )
- currentText = m_mimeCheck->currentText();
-
- qWarning("current text is %s", currentText.latin1() );
- QMap<QString, QStringList>::Iterator it;
- QStringList list;
- if ( currentText == tr("All") ) return true;
- else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) {
- it = m_mimetypes.begin();
- list = it.data();
- }else if ( currentText.isEmpty() ) return true;
- else{
- it = m_mimetypes.find(currentText );
- if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText;
- else qWarning("found"), list = it.data();
- }
- // dump it now
- //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
- // qWarning( "%s", (*it).latin1() );
- //}
-
-
- if ( list.contains(mime) ) return true;
- qWarning("list doesn't contain it ");
- QStringList::Iterator it2;
- int pos;
- for ( it2 = list.begin(); it2 != list.end(); ++it2 ) {
- pos = (*it2).findRev("/*");
- if ( pos >= 0 ) {
- if ( mime.contains( (*it2).left(pos) ) ) return true;
- }
- }
- return false;
-}
-void OFileSelector::slotFileSelected( const QString &string )
-{
- if( m_shLne )
- m_edit->setText( string );
- emit fileSelected( string );
-}
-void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
-{
- slotFileSelected( lnk.name() );
- emit fileSelected( lnk );
-}
-void OFileSelector::slotSelectionChanged()
-{
-
-}
-void OFileSelector::slotCurrentChanged(QListViewItem* item )
-{
- if( item == 0 )
- return;
- if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
- OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;)
- qWarning("current changed");
- if(!sel->isDir() ){
- if( m_shLne )
- m_edit->setText( sel->text(1) );
-
- if (m_mode == FILESELECTOR ) {
- QStringList str = QStringList::split("->", sel->text(1) );
- QString path =sel->directory() + "/" + str[0].stripWhiteSpace();
- emit fileSelected(path );
- DocLnk lnk( path );
- emit fileSelected(lnk );
- }
- }
- }
-}
-void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int)
-{
- if ( item == 0 )
- return;
-
- if( button != Qt::LeftButton )
- return;
-
- switch( m_selector ){
- default:
- break;
- case EXTENDED: // fall through
- case EXTENDED_ALL:{
- OFileSelectorItem *sel = (OFileSelectorItem*)item;
- if(!sel->isLocked() ){
- QStringList str = QStringList::split("->", sel->text(1) );
- if( sel->isDir() ){
- cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
- // if MODE Dir m_shLne set the Text
- }else{
- if( m_shLne )
- m_edit->setText( str[0].stripWhiteSpace() );
- qWarning("selected here in slot clicked");
- emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() );
- DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() );
- qWarning("file selected");
- emit fileSelected( lnk );
- }
- }
- break;
- }
- }
-}
-void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
-{
- if( item == 0 )
- return;
-
- if( button != Qt::RightButton )
- return;
- slotContextMenu( item );
-}
-void OFileSelector::slotContextMenu( QListViewItem * /*item*/)
-{
-
-}
-void OFileSelector::slotChangedDir()
-{
- OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
- if(sel->isDir() ){
- QStringList str = QStringList::split("->", sel->text(1) );
- cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
- }
-}
-void OFileSelector::slotOpen()
-{
- OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
- if(!sel->isDir() ){
- QStringList str = QStringList::split("->", sel->text(1) );
- slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() );
- qWarning("slot open");
- // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() );
- //emit fileSelected( lnk );
- }
-}
-void OFileSelector::slotRescan()
-{
-
-}
-void OFileSelector::slotRename()
-{
- reparse();
-}
-void OFileSelector::slotDelete()
-{
- OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
- QStringList list = QStringList::split("->", sel->text(1) );
- if( sel->isDir() ){
- QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
- switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
- tr("Yes"),tr("No"),0,1,1) ) {
- case 0:
- ::system(str.utf8().data() );
- break;
- }
- } else {
- QFile::remove( list[0] );
- }
- m_View->takeItem( sel );
- delete sel;
-}
-void OFileSelector::cdUP()
-{
- QDir dir( m_currentDir );
- dir.cdUp();
- if(dir.exists() ){
- m_currentDir = dir.absPath();
- reparse();
- int count = m_location->count();
- slotInsertLocationPath( m_currentDir, count);
- m_location->setCurrentItem( indexByString( m_location, m_currentDir));
- //this wont work in all instances
- // FIXME
- }
-}
-void OFileSelector::slotHome()
-{
- cd(QDir::homeDirPath() );
-}
-void OFileSelector::slotDoc()
-{
- cd(QPEApplication::documentDir() );
-}
-void OFileSelector::slotNavigate( )
-{
-
-}
-// fill the View with life
-void OFileSelector::reparse()
-{
- if( m_selector == NORMAL )
- return;
- if( m_selector == EXTENDED || m_selector == EXTENDED_ALL )
- m_View->clear();
- else // custom view
- ; // currentView()->clear();
- if( m_shChooser)
- qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
-
- QString currentMimeType;
- // let's update the mimetype
- if( m_autoMime ){
- m_mimetypes.clear();
- // ok we can change mimetype so we need to be able to give a selection
- if( m_shChooser ) {
- currentMimeType = m_mimeCheck->currentText();
- m_mimeCheck->clear();
-
- // let's find possible mimetypes
- QDir dir( m_currentDir );
- if( dir.exists() ){
- dir.setFilter( QDir::Files | QDir::Readable );
- dir.setSorting( QDir::Size );
- const QFileInfoList *list = dir.entryInfoList();
- QFileInfoListIterator it( *list );
- QFileInfo *fi;
- while( (fi=it.current() ) ) {
- if( fi->extension() == QString::fromLatin1("desktop") ){
- ++it;
- continue;
- }
- MimeType type( fi->absFilePath() );
- if( !m_mimetypes.contains( type.id() ) ){
- //qWarning("Type %s", type.id().latin1() );
- m_mimetypes.insert( type.id(), type.id() );
- }
-
- ++it;
- }
- // add them to the chooser
- updateMimeCheck();
- m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
- currentMimeType = m_mimeCheck->currentText();
- }
- }
- }else { // no autoMime
- // let the mimetype be set from out side the m_mimeCheck FEATURE
-
- if( m_shChooser ){
- currentMimeType = m_mimeCheck->currentText();
-// updateMimeCheck();
- }
- }
- // now we got our mimetypes we can add the files
-
- QDir dir( m_currentDir );
-
- if( dir.exists() ){
- int sort;
- if ( m_case )
- sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed);
- else
- sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed);
- dir.setSorting( sort );
-
- int filter;
- if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){
- filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
- }else
- filter = QDir::Files | QDir::Dirs | QDir::All;
- dir.setFilter( filter );
-
- // now go through all files
- const QFileInfoList *list = dir.entryInfoList();
- QFileInfoListIterator it( *list );
- QFileInfo *fi;
- while( (fi=it.current() ) ){
- //qWarning("True and only" );
- if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){
- //qWarning(".. or ." );
- ++it;
- continue;
- }
- if( fi->isSymLink() ){
- QString file = fi->dirPath( true ) + "/" + fi->readLink();
- for( int i = 0; i<=4; i++) { // 5 tries to prevent dos
- QFileInfo info( file );
- if( !info.exists() ){
- addSymlink( currentMimeType, fi, TRUE );
- break;
- }else if( info.isDir() ){
- addDir( currentMimeType, fi, TRUE );
- break;
- }else if( info.isFile() ){
- addFile( currentMimeType, fi, TRUE );
- break;
- }else if( info.isSymLink() ){
- file = info.dirPath(true ) + "/" + info.readLink() ;
- break;
- }else if( i == 4){
- addSymlink( currentMimeType, fi );
- }
- } // off for loop
- }else if( fi->isDir() ){
- addDir( currentMimeType, fi );
- }else if( fi->isFile() ){
- addFile( currentMimeType, fi );
- }
- //qWarning( "%s", fi->fileName().latin1() );
- ++it;
- } // of while loop
- } // if ( dir.exists() )
- m_View->sort();
- if( m_shTool ){
- m_location->insertItem( m_currentDir );
-
- }
- // reenable painting and updates
-}
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 @@
+#include <qcombobox.h>
+#include <qdir.h>
+#include <qhbox.h>
+#include <qheader.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlistview.h>
+#include <qpopupmenu.h>
+#include <qwidgetstack.h>
+#include <qregexp.h>
+#include <qobjectlist.h>
+
+/* hacky but we need to get FileSelector::filter */
+#define private public
+#include <qpe/fileselector.h>
+#undef private
+
+#include <qpe/qpeapplication.h>
+#include <qpe/mimetype.h>
+#include <qpe/resource.h>
+#include <qpe/storage.h>
+
+#include "ofileselector_p.h"
+#include "ofileselector.h"
+
+
+
+OFileViewInterface::OFileViewInterface( OFileSelector* selector )
+ : m_selector( selector ) {
+}
+OFileViewInterface::~OFileViewInterface() {
+}
+QString OFileViewInterface::name()const{
+ return m_name;
+}
+void OFileViewInterface::setName( const QString& name ) {
+ m_name = name;
+}
+OFileSelector* OFileViewInterface::selector()const {
+ return m_selector;
+}
+DocLnk OFileViewInterface::selectedDocument()const {
+ return DocLnk( selectedName() );
+}
+bool OFileViewInterface::showNew()const {
+ return selector()->showNew();
+}
+bool OFileViewInterface::showClose()const {
+ return selector()->showClose();
+}
+MimeTypes OFileViewInterface::mimeTypes()const {
+ return selector()->mimeTypes();
+}
+QStringList OFileViewInterface::currentMimeType()const {
+ return selector()->currentMimeType();
+}
+void OFileViewInterface::activate( const QString& ) {
+ // not implemented here
+}
+void OFileViewInterface::ok() {
+ emit selector()->ok();
+}
+void OFileViewInterface::cancel() {
+ emit selector()->cancel();
+}
+void OFileViewInterface::closeMe() {
+ emit selector()->closeMe();
+}
+void OFileViewInterface::fileSelected( const QString& str) {
+ emit selector()->fileSelected( str);
+}
+void OFileViewInterface::fileSelected( const DocLnk& lnk) {
+ emit selector()->fileSelected( lnk );
+}
+void OFileViewInterface::setCurrentFileName( const QString& str ) {
+ selector()->m_lneEdit->setText( str );
+}
+QString OFileViewInterface::currentFileName()const{
+ return selector()->m_lneEdit->text();
+}
+QString OFileViewInterface::startDirectory()const{
+ return selector()->m_startDir;
+}
+
+
+ODocumentFileView::ODocumentFileView( OFileSelector* selector )
+ : OFileViewInterface( selector ) {
+ m_selector = 0;
+ setName( QObject::tr("Documents") );
+}
+ODocumentFileView::~ODocumentFileView() {
+
+}
+QString ODocumentFileView::selectedName()const {
+ if (!m_selector)
+ return QString::null;
+
+ return m_selector->selectedDocument().file();
+}
+QString ODocumentFileView::selectedPath()const {
+ return QPEApplication::documentDir();
+}
+QString ODocumentFileView::directory()const {
+ return selectedPath();
+}
+void ODocumentFileView::reread() {
+ if (!m_selector)
+ return;
+
+ m_selector->setNewVisible( showNew() );
+ m_selector->setCloseVisible( showClose() );
+ m_selector->filter = currentMimeType().join(";");
+ m_selector->reread();
+}
+int ODocumentFileView::fileCount()const {
+ if (!m_selector)
+ return -1;
+
+ return m_selector->fileCount();
+}
+DocLnk ODocumentFileView::selectedDocument()const {
+ if (!m_selector)
+ return DocLnk();
+
+ return m_selector->selectedDocument();
+}
+QWidget* ODocumentFileView::widget( QWidget* parent ) {
+ if (!m_selector ) {
+ m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
+ QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ),
+ selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
+ QObject::connect(m_selector, SIGNAL(closeMe() ),
+ selector(), SIGNAL(closeMe() ) );
+ QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ),
+ selector(), SIGNAL(newSelected(const DocLnk& ) ) );
+ }
+
+ return m_selector;
+}
+
+/*
+ * This is the file system view used
+ * we use a QListView + QListViewItems for it
+ */
+
+OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
+ const QString& path, const QString& date,
+ const QString& size, const QString& dir,
+ bool isLocked, bool isDir )
+ : QListViewItem( view )
+{
+ setPixmap(0, pixmap );
+ setText(1, path );
+ setText(2, size );
+ setText(3, date );
+ m_isDir = isDir;
+ m_dir = dir;
+ m_locked = isLocked;
+}
+OFileSelectorItem::~OFileSelectorItem() {
+
+}
+bool OFileSelectorItem::isLocked()const {
+ return m_locked;
+}
+QString OFileSelectorItem::directory()const {
+ return m_dir;
+}
+bool OFileSelectorItem::isDir()const {
+ return m_isDir;
+}
+QString OFileSelectorItem::path()const {
+ return text( 1 );
+}
+QString OFileSelectorItem::key( int id, bool )const {
+ QString ke;
+ if( id == 0 || id == 1 ){ // name
+ if( m_isDir ){
+ ke.append("0" );
+ ke.append( text(1) );
+ }else{
+ ke.append("1" );
+ ke.append( text(1) );
+ }
+ return ke;
+ }else
+ return text( id );
+
+}
+
+OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir,
+ OFileSelector* sel)
+ : QWidget( parent ), m_sel( sel ) {
+ m_all = false;
+ QVBoxLayout* lay = new QVBoxLayout( this );
+ m_currentDir = startDir;
+
+ /*
+ * now we add a special bar
+ * One Button For Up
+ * Home
+ * Doc
+ * And a dropdown menu with FileSystems
+ * FUTURE: one to change dir with lineedit
+ * Bookmarks
+ * Create Dir
+ */
+ QHBox* box = new QHBox(this );
+ box->setBackgroundMode( PaletteButton );
+ box->setSpacing( 0 );
+
+ QToolButton *btn = new QToolButton( box );
+ btn->setIconSet( Resource::loadIconSet("up") );
+ connect(btn, SIGNAL(clicked() ),
+ this, SLOT( cdUP() ) );
+
+ btn = new QToolButton( box );
+ btn->setIconSet( Resource::loadIconSet("home") );
+ connect(btn, SIGNAL(clicked() ),
+ this, SLOT( cdHome() ) );
+
+ btn = new QToolButton( box );
+ btn->setIconSet( Resource::loadIconSet("DocsIcon") );
+ connect(btn, SIGNAL(clicked() ),
+ this, SLOT(cdDoc() ) );
+
+ m_btnNew = new QToolButton( box );
+ m_btnNew->setIconSet( Resource::loadIconSet("new") );
+ connect(m_btnNew, SIGNAL(clicked() ),
+ this, SLOT(slotNew() ) );
+
+
+ m_btnClose = new QToolButton( box );
+ m_btnClose->setIconSet( Resource::loadIconSet("close") );
+ connect(m_btnClose, SIGNAL(clicked() ),
+ selector(), SIGNAL(closeMe() ) );
+
+ btn = new QToolButton( box );
+ btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") );
+
+ /* let's fill device parts */
+ QPopupMenu* pop = new QPopupMenu(this);
+ connect(pop, SIGNAL( activated(int) ),
+ this, SLOT(slotFSActivated(int) ) );
+
+ StorageInfo storage;
+ const QList<FileSystem> &fs = storage.fileSystems();
+ QListIterator<FileSystem> it(fs);
+ for ( ; it.current(); ++it ) {
+ const QString disk = (*it)->name();
+ const QString path = (*it)->path();
+ m_dev.insert( disk, path );
+ pop->insertItem( disk );
+ }
+ m_fsPop = pop;
+
+
+ btn->setPopup( pop );
+
+ lay->addWidget( box );
+
+ m_view = new QListView( this );
+
+ m_view->installEventFilter(this);
+
+ QPEApplication::setStylusOperation( m_view->viewport(),
+ QPEApplication::RightOnHold);
+ m_view->addColumn(" " );
+ m_view->addColumn(tr("Name"), 135 );
+ m_view->addColumn(tr("Size"), -1 );
+ m_view->addColumn(tr("Date"), 60 );
+ m_view->addColumn(tr("Mime Type"), -1 );
+
+
+ m_view->setSorting( 1 );
+ m_view->setAllColumnsShowFocus( TRUE );
+
+ lay->addWidget( m_view, 1000 );
+ connectSlots();
+}
+OFileViewFileListView::~OFileViewFileListView() {
+}
+void OFileViewFileListView::slotNew() {
+ DocLnk lnk;
+ emit selector()->newSelected( lnk );
+}
+OFileSelectorItem* OFileViewFileListView::currentItem()const{
+ QListViewItem* item = m_view->currentItem();
+ if (!item )
+ return 0l;
+
+ return static_cast<OFileSelectorItem*>(item);
+}
+void OFileViewFileListView::reread( bool all ) {
+ m_view->clear();
+
+ if (selector()->showClose() )
+ m_btnClose->show();
+ else
+ m_btnClose->hide();
+
+ if (selector()->showNew() )
+ m_btnNew->show();
+ else
+ m_btnNew->hide();
+
+ m_mimes = selector()->currentMimeType();
+ m_all = all;
+
+ QDir dir( m_currentDir );
+ if (!dir.exists() )
+ return;
+
+ dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
+ int filter;
+ if (m_all )
+ filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
+ else
+ filter = QDir::Files | QDir::Dirs | QDir::All;
+ dir.setFilter( filter );
+
+ // now go through all files
+ const QFileInfoList *list = dir.entryInfoList();
+ if (!list) {
+ cdUP();
+ return;
+ }
+ QFileInfoListIterator it( *list );
+ QFileInfo *fi;
+ while( (fi=it.current() ) ){
+ if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){
+ ++it;
+ continue;
+ }
+
+ /*
+ * It is a symlink we try to resolve it now but don't let us attack by DOS
+ *
+ */
+ if( fi->isSymLink() ){
+ QString file = fi->dirPath( true ) + "/" + fi->readLink();
+ for( int i = 0; i<=4; i++) { // 5 tries to prevent dos
+ QFileInfo info( file );
+ if( !info.exists() ){
+ addSymlink( fi, TRUE );
+ break;
+ }else if( info.isDir() ){
+ addDir( fi, TRUE );
+ break;
+ }else if( info.isFile() ){
+ addFile( fi, TRUE );
+ break;
+ }else if( info.isSymLink() ){
+ file = info.dirPath(true ) + "/" + info.readLink() ;
+ break;
+ }else if( i == 4){ // couldn't resolve symlink add it as symlink
+ addSymlink( fi );
+ }
+ } // off for loop for symlink resolving
+ }else if( fi->isDir() )
+ addDir( fi );
+ else if( fi->isFile() )
+ addFile( fi );
+
+ ++it;
+ } // of while loop
+ m_view->sort();
+
+}
+int OFileViewFileListView::fileCount()const{
+ return m_view->childCount();
+}
+QString OFileViewFileListView::currentDir()const{
+ return m_currentDir;
+}
+OFileSelector* OFileViewFileListView::selector() {
+ return m_sel;
+}
+
+bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) {
+ if ( e->type() == QEvent::KeyPress ) {
+ QKeyEvent *k = (QKeyEvent *)e;
+ if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) {
+ slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
+ return true;
+ }
+ }
+ return false;
+}
+
+
+void OFileViewFileListView::connectSlots() {
+ connect(m_view, SIGNAL(clicked(QListViewItem*) ),
+ this, SLOT(slotCurrentChanged(QListViewItem*) ) );
+ connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ),
+ this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) );
+}
+void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) {
+ if (!item)
+ return;
+#if 0
+
+ OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
+
+ if (!sel->isDir() ) {
+ selector()->m_lneEdit->setText( sel->text(1) );
+ // if in fileselector mode we will emit selected
+ if ( selector()->mode() == OFileSelector::FileSelector ) {
+ qWarning("slot Current Changed");
+ QStringList str = QStringList::split("->", sel->text(1) );
+ QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
+ emit selector()->fileSelected( path );
+ DocLnk lnk( path );
+ emit selector()->fileSelected( lnk );
+ }
+ }
+#endif
+}
+void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) {
+ if (!item || ( button != Qt::LeftButton) )
+ return;
+
+ OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
+ if (!sel->isLocked() ) {
+ QStringList str = QStringList::split("->", sel->text(1) );
+ if (sel->isDir() ) {
+ m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
+ emit selector()->dirSelected( m_currentDir );
+ reread( m_all );
+ }else { // file
+ qWarning("slot Clicked");
+ selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
+ QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
+ emit selector()->fileSelected( path );
+ DocLnk lnk( path );
+ emit selector()->fileSelected( lnk );
+ }
+ } // not locked
+}
+void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) {
+ MimeType type( info->absFilePath() );
+ if (!compliesMime( type.id() ) )
+ return;
+
+ QPixmap pix = type.pixmap();
+ QString dir, name; bool locked;
+ if ( pix.isNull() ) {
+ QWMatrix matrix;
+ QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
+ matrix.scale( .4, .4 );
+ pix = pixer.xForm( matrix );
+ }
+ dir = info->dirPath( true );
+ locked = false;
+ if ( symlink )
+ name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
+ else{
+ name = info->fileName();
+ if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
+ ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) {
+ locked = true; pix = Resource::loadPixmap("locked");
+ }
+ }
+ (void)new OFileSelectorItem( m_view, pix, name,
+ info->lastModified().toString(), QString::number( info->size() ),
+ dir, locked );
+}
+void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) {
+ bool locked = false; QString name; QPixmap pix;
+
+ if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
+ ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) {
+ locked = true;
+ if ( symlink )
+ pix = Resource::loadPixmap( "opie/symlink" );
+ else
+ pix = Resource::loadPixmap( "lockedfolder" );
+ }else
+ pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder");
+
+ name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() :
+ info->fileName();
+
+ (void)new OFileSelectorItem( m_view, pix, name,
+ info->lastModified().toString(),
+ QString::number( info->size() ),
+ info->dirPath( true ), locked, true );
+
+
+}
+void OFileViewFileListView::addSymlink( QFileInfo* , bool ) {
+
+}
+void OFileViewFileListView::cdUP() {
+ QDir dir( m_currentDir );
+ dir.cdUp();
+
+ if (!dir.exists() )
+ m_currentDir = "/";
+ else
+ m_currentDir = dir.absPath();
+
+ emit selector()->dirSelected( m_currentDir );
+ reread( m_all );
+}
+void OFileViewFileListView::cdHome() {
+ m_currentDir = QDir::homeDirPath();
+ emit selector()->dirSelected( m_currentDir );
+ reread( m_all );
+}
+void OFileViewFileListView::cdDoc() {
+ m_currentDir = QPEApplication::documentDir();
+ emit selector()->dirSelected( m_currentDir );
+ reread( m_all );
+}
+void OFileViewFileListView::changeDir( const QString& dir ) {
+ m_currentDir = dir;
+ emit selector()->dirSelected( m_currentDir );
+ reread( m_all );
+}
+void OFileViewFileListView::slotFSActivated( int id ) {
+ changeDir ( m_dev[m_fsPop->text(id)] );
+}
+
+/* check if the mimetype in mime
+ * complies with the one which is current
+ */
+/*
+ * We've the mimetype of the file
+ * We need to get the stringlist of the current mimetype
+ *
+ * mime = image@slashjpeg
+ * QStringList = 'image@slash*'
+ * or QStringList = image/jpeg;image/png;application/x-ogg
+ * or QStringList = application/x-ogg;image@slash*;
+ * with all these mime filters it should get acceptes
+ * to do so we need to look if mime is contained inside
+ * the stringlist
+ * if it's contained return true
+ * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*'
+ * is contained in the mimefilter and then we will
+ * look if both are equal until the '/'
+ */
+bool OFileViewFileListView::compliesMime( const QString& str) {
+ if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() )
+ return true;
+
+ for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) {
+ QRegExp reg( (*it) );
+ reg.setWildcard( true );
+ if ( str.find( reg ) != -1 )
+ return true;
+
+ }
+ return false;
+}
+/*
+ * The listView giving access to the file system!
+ */
+class OFileViewFileSystem : public OFileViewInterface {
+public:
+ OFileViewFileSystem( OFileSelector* );
+ ~OFileViewFileSystem();
+
+ QString selectedName() const;
+ QString selectedPath() const;
+
+ QString directory()const;
+ void reread();
+ int fileCount()const;
+
+ QWidget* widget( QWidget* parent );
+ void activate( const QString& );
+private:
+ OFileViewFileListView* m_view;
+ bool m_all : 1;
+};
+OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel)
+ : OFileViewInterface( sel ) {
+ m_view = 0;
+ m_all = false;
+}
+OFileViewFileSystem::~OFileViewFileSystem() {
+}
+QString OFileViewFileSystem::selectedName()const{
+ if (!m_view )
+ return QString::null;
+
+ QString cFN=currentFileName();
+ if (cFN.startsWith("/")) return cFN;
+ return m_view->currentDir() + "/" + cFN;
+}
+QString OFileViewFileSystem::selectedPath()const{
+ return QString::null;
+}
+QString OFileViewFileSystem::directory()const{
+ if (!m_view)
+ return QString::null;
+
+ OFileSelectorItem* item = m_view->currentItem();
+ if (!item )
+ return QString::null;
+
+ return QDir(item->directory() ).absPath();
+}
+void OFileViewFileSystem::reread() {
+ if (!m_view)
+ return;
+
+ m_view->reread( m_all );
+}
+int OFileViewFileSystem::fileCount()const{
+ if (!m_view )
+ return -1;
+ return m_view->fileCount();
+}
+QWidget* OFileViewFileSystem::widget( QWidget* parent ) {
+ if (!m_view ) {
+ m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
+ }
+ return m_view;
+}
+void OFileViewFileSystem::activate( const QString& str) {
+ m_all = (str != QObject::tr("Files") );
+
+
+}
+
+/* Selector */
+OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
+ const QString& dirName, const QString& fileName,
+ const MimeTypes& mimetypes,
+ bool showNew, bool showClose)
+ : QWidget( parent, "OFileSelector" )
+{
+ m_current = 0;
+ m_shNew = showNew;
+ m_shClose = showClose;
+ m_mimeType = mimetypes;
+ m_startDir = dirName;
+
+ m_mode = mode;
+ m_selector = sel;
+
+ initUI();
+ m_lneEdit->setText( fileName );
+ initMime();
+ initViews();
+
+ QString str;
+ switch ( m_selector ) {
+ default:
+ case Normal:
+ str = QObject::tr("Documents");
+ m_cmbView->setCurrentItem( 0 );
+ break;
+ case Extended:
+ str = QObject::tr("Files");
+ m_cmbView->setCurrentItem( 1 );
+ break;
+ case ExtendedAll:
+ str = QObject::tr("All Files");
+ m_cmbView->setCurrentItem( 2 );
+ break;
+ }
+ slotViewChange( str );
+
+}
+OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name,
+ bool showNew, bool showClose )
+ : QWidget( parent, name )
+{
+ m_current = 0;
+ m_shNew = showNew;
+ m_shClose = showClose;
+ m_startDir = QPEApplication::documentDir();
+
+ if (!mimeFilter.isEmpty() )
+ m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) );
+
+ m_mode = OFileSelector::FileSelector;
+ m_selector = OFileSelector::Normal;
+
+ initUI();
+ initMime();
+ initViews();
+ m_cmbView->setCurrentItem( 0 );
+ slotViewChange( QObject::tr("Documents") );
+}
+/*
+ * INIT UI will set up the basic GUI
+ * Layout: Simple VBoxLayout
+ * On top a WidgetStack containing the Views...
+ * - List View
+ * - Document View
+ * Below we will have a Label + LineEdit
+ * Below we will have two ComoBoxes one for choosing the view one for
+ * choosing the mimetype
+ */
+void OFileSelector::initUI() {
+ QVBoxLayout* lay = new QVBoxLayout( this );
+
+ m_stack = new QWidgetStack( this );
+ lay->addWidget( m_stack, 1000 );
+
+ m_nameBox = new QHBox( this );
+ (void)new QLabel( tr("Name:"), m_nameBox );
+ m_lneEdit = new QLineEdit( m_nameBox );
+ m_lneEdit ->installEventFilter(this);
+ lay->addWidget( m_nameBox );
+
+ m_cmbBox = new QHBox( this );
+ m_cmbView = new QComboBox( m_cmbBox );
+ m_cmbMime = new QComboBox( m_cmbBox );
+ lay->addWidget( m_cmbBox );
+}
+
+/*
+ * This will make sure that the return key in the name edit causes dialogs to close
+ */
+
+bool OFileSelector::eventFilter (QObject *o, QEvent *e) {
+ if ( e->type() == QEvent::KeyPress ) {
+ QKeyEvent *k = (QKeyEvent *)e;
+ if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) {
+ emit ok();
+ return true;
+ }
+ }
+ return false;
+}
+
+/*
+ * This will insert the MimeTypes into the Combo Box
+ * And also connect the changed signal
+ *
+ * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes
+ */
+void OFileSelector::initMime() {
+ MimeTypes::Iterator it;
+ for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) {
+ m_cmbMime->insertItem( it.key() );
+ }
+ m_cmbMime->setCurrentItem( 0 );
+
+ connect( m_cmbMime, SIGNAL(activated(int) ),
+ this, SLOT(slotMimeTypeChanged() ) );
+
+}
+void OFileSelector::initViews() {
+ m_cmbView->insertItem( QObject::tr("Documents") );
+ m_cmbView->insertItem( QObject::tr("Files") );
+ m_cmbView->insertItem( QObject::tr("All Files") );
+ connect(m_cmbView, SIGNAL(activated( const QString& ) ),
+ this, SLOT(slotViewChange( const QString& ) ) );
+
+
+ m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
+
+ /* see above why add both */
+ OFileViewInterface* in = new OFileViewFileSystem( this );
+ m_views.insert( QObject::tr("Files"), in );
+ m_views.insert( QObject::tr("All Files"), in );
+}
+OFileSelector::~OFileSelector() {
+
+}
+const DocLnk* OFileSelector::selected() {
+ DocLnk* lnk = new DocLnk( currentView()->selectedDocument() );
+ return lnk;
+}
+QString OFileSelector::selectedName()const{
+ return currentView()->selectedName();
+}
+QString OFileSelector::selectedPath()const {
+ return currentView()->selectedPath();
+}
+QString OFileSelector::directory()const {
+ return currentView()->directory();
+}
+DocLnk OFileSelector::selectedDocument()const {
+ return currentView()->selectedDocument();
+}
+int OFileSelector::fileCount()const {
+ return currentView()->fileCount();
+}
+void OFileSelector::reread() {
+ return currentView()->reread();
+}
+OFileViewInterface* OFileSelector::currentView()const{
+ return m_current;
+}
+bool OFileSelector::showNew()const {
+ return m_shNew;
+}
+bool OFileSelector::showClose()const {
+ return m_shClose;
+}
+MimeTypes OFileSelector::mimeTypes()const {
+ return m_mimeType;
+}
+int OFileSelector::mode()const{
+ return m_mode;
+}
+int OFileSelector::selector()const{
+ return m_selector;
+}
+QStringList OFileSelector::currentMimeType()const {
+ return m_mimeType[m_cmbMime->currentText()];
+}
+void OFileSelector::slotMimeTypeChanged() {
+ reread();
+}
+void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) {
+ m_lneEdit->setText( lnk.name() );
+ emit fileSelected( lnk );
+ emit fileSelected( lnk.name() );
+}
+void OFileSelector::slotFileBridge( const QString& str) {
+ DocLnk lnk( str );
+ emit fileSelected( lnk );
+}
+void OFileSelector::slotViewChange( const QString& view ) {
+ OFileViewInterface* interface = m_views[view];
+ if (!interface)
+ return;
+
+ interface->activate( view );
+ if (m_current)
+ m_stack->removeWidget( m_current->widget( m_stack ) );
+
+ static int id = 1;
+
+ m_stack->addWidget( interface->widget(m_stack), id );
+ m_stack->raiseWidget( id );
+
+ interface->reread();
+ m_current = interface;
+
+ id++;
+}
+void OFileSelector::setNewVisible( bool b ) {
+ m_shNew = b;
+ currentView()->reread();
+}
+void OFileSelector::setCloseVisible( bool b ) {
+ m_shClose = b;
+ currentView()->reread();
+}
+void OFileSelector::setNameVisible( bool b ) {
+ if ( b )
+ m_nameBox->show();
+ else
+ m_nameBox->hide();
+}
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 @@
/*
This is based on code and ideas of
L. J. Potter ljp@llornkcor.com
Thanks a lot
               =. This file is part of the OPIE Project
-             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
+             .=l. Copyright (c) 2002,2003 Holger Freyther <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#ifndef opiefileselector_h
-#define opiefileselector_h
+#ifndef OPIE_OFILESELECTOR_FOO_H
+#define OPIE_OFILESELECTOR_FOO_H
+
+#include <qlist.h>
#include <qwidget.h>
-#include <qstring.h>
-#include <qpixmap.h>
-#include <qstringlist.h>
#include <qmap.h>
#include <qvaluelist.h>
+#include <qstringlist.h>
#include <qpe/applnk.h>
-#include <qlistview.h>
+typedef QMap<QString, QStringList> MimeTypes;
-class DocLnk;
-class QCheckBox;
-class QComboBox;
-class QPushButton;
-class FileSelector;
-class QGridLayout;
+class OFileViewInterface;
+class OFileViewFileListView;
class QLineEdit;
-class QLabel;
+class QComboBox;
class QWidgetStack;
-class QHBoxLayout;
-class QVBoxLayout;
-class QPopupMenu;
-class QFileInfo;
class QHBox;
-//
-
-typedef QMap< QString, QStringList> MimeTypes;
-
-/**
- * This is OPIEs FileDialog Widget. You can use it
- * as a dropin replacement of the fileselector and
- * or use any of the new features.
- * This is also a complete FileSave and FileLoad widget
- * If you look for a Dialog check OFileDialog
- *
- * NOTE THAT the API will change to be more extendable!
- */
class OFileSelector : public QWidget {
- Q_OBJECT
- public:
- /**
- * The mode of the file selector
- * Either open, save, fileselector or dir browsing mode
- *
- */
- enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 };
-
- /**
- * Selector. Either NORMAL for the one shipped with
- * libqpe or EXTENDED. for the EXTENDED
- * EXTENDED_ALL also shows 'hidden' files
- */
- enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 };
-
- /**
- * This is reserved for futrue views
- */
- enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 };
-
- /**
- * A c'tor which should be used for advanced mode
- * @param wid the parent
- * @param mode the Mode of the Selector
- * @param selector the current View of the Selector
- * @param dirName in which dir to start
- * @param fileName a proposed filename
- * @param mimetypes A list of mimetypes \
- * QString is for a identifier name like "Text files"
- * the coresponding QStringList is used for the mimetypes
- * if empty it'll fill the list of mimetypes depending
- * on the content of the current directory
- */
-
- OFileSelector(QWidget *wid, int mode, int selector,
- const QString &dirName,
- const QString &fileName = QString::null,
- const MimeTypes &mimetypes = MimeTypes() );
-
-
- /**
- * This is a QPE compatible c'tor
- */
- OFileSelector(const QString &mimeFilter, QWidget *parent,
- const char *name, bool newVisible = TRUE,
- bool closeVisible = FALSE );
-
- ~OFileSelector();
-
- // currently only for the FILESELECTOR Mode
- /**
- */
- void setNewVisible( bool /*b*/ );
- void setCloseVisible(bool /*b*/ );
-
- // end file selector mode
- // deprecated
- void reread();
- // make sure not to leak please
- const DocLnk *selected();
- // end deprecated
-
- bool isToolbarVisible() const { return m_shTool; };
- bool isPermissionBarVisible() const { return m_shPerm; };
- bool isLineEditVisible()const { return m_shLne; };
- bool isChooserVisible( )const { return m_shChooser; };
- bool isYesCancelVisible()const { return m_shYesNo; };
- void setYesCancelVisible( bool show );
- void setToolbarVisible( bool show );
- void setPermissionBarVisible( bool show );
- void setLineEditVisible(bool show) ;
- void setChooserVisible( bool chooser );
-
- QCheckBox* permissionCheckbox();
- bool setPermission() const;
- void setPermissionChecked( bool check );
-
- void setMode( int );
-
- bool showDirs()const { return m_dir; }
- void setShowDirs(bool );
-
- const QListView* listView() { return m_View; };
-
- bool isCaseSensetive()const { return m_case; }
- void setCaseSensetive(bool caSe );
-
- bool showFiles()const { return m_files; };
- void setShowFiles(bool );
- bool cd(const QString &path );
+ Q_OBJECT
+ friend class OFileViewInterface;
+ friend class OFileViewFileListView;
+public:
+ enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
+// enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
+ enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
+// enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
+
+ OFileSelector(QWidget* parent, int mode, int selector,
+ const QString& dirName,
+ const QString& fileName,
+ const MimeTypes& mimetypes = MimeTypes(),
+ bool newVisible = FALSE, bool closeVisible = FALSE );
+
+ OFileSelector(const QString& mimeFilter, QWidget* parent,
+ const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
+ ~OFileSelector();
+
+ const DocLnk* selected();
+
+ QString selectedName()const;
+ QString selectedPath()const;
+ QString directory()const;
+
+ DocLnk selectedDocument()const;
+
+ int fileCount()const;
+ void reread();
+
+ int mode()const;
+ int selector()const;
+
+
+ void setNewVisible( bool b );
+ void setCloseVisible( bool b );
+ void setNameVisible( bool b );
+
+signals:
+ void dirSelected( const QString& );
+ void fileSelected( const DocLnk& );
+ void fileSelected( const QString& );
+ void newSelected( const DocLnk& );
+ void closeMe();
+ void ok();
+ void cancel();
+
+/* used by the ViewInterface */
+private:
+ bool showNew()const;
+ bool showClose()const;
+ MimeTypes mimeTypes()const;
+ QStringList currentMimeType()const;
+
+private:
+ /* inits the Widgets */
+ void initUI();
+ /* inits the MimeType ComboBox content + connects signals and slots */
+ void initMime();
+ /* init the Views :) */
+ void initViews();
+
+private:
+ QLineEdit* m_lneEdit; // the LineEdit for the Name
+ QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
+ QWidgetStack* m_stack; // our widget stack which will contain the views
+ OFileViewInterface* currentView()const; // returns the currentView
+ OFileViewInterface* m_current; // here is the view saved
+ bool m_shNew : 1; // should we show New?
+ bool m_shClose : 1; // should we show Close?
+ MimeTypes m_mimeType; // list of mimetypes
+
+ QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
+ QHBox* m_nameBox; // the LineEdit + Label is hold here
+ QHBox* m_cmbBox; // this holds the two combo boxes
+
+ QString m_startDir;
+ int m_mode;
+ int m_selector;
+
+ struct Data; // used for future versions
+ Data *d;
+private slots:
+ void slotMimeTypeChanged();
- int mode()const { return m_mode; };
- int selector()const { return m_selector; };
- void setSelector( int );
-
- bool showPopup()const { return m_showPopup; };
- void setShowPopup( bool pop ) { m_showPopup = pop; };
- void setPopupMenu( QPopupMenu * );
-
- // void updateLay();
-
- void reparse(); // re reads the dir
-
- QString selectedName( )const;
- QStringList selectedNames()const;
-
- QString selectedPath() const;
- QStringList selectedPaths() const;
-
- QString directory()const;
- int fileCount() const;
-
- /* the user needs to delete it */
- DocLnk selectedDocument()const;
- /* the user needs to delete it */
- QValueList<DocLnk> selectedDocuments()const;
-
- signals:
- void fileSelected( const DocLnk & );
- void fileSelected( const QString & );
- void dirSelected(const QString &dir );
- void closeMe();
- void ok();
- void cancel();
- void contextMenu();
-
- private slots:
- void slotTest() { qWarning("slotTest" ); setLineEditVisible(false ); };
- void slotOk();
- void slotCancel();
- void slotViewCheck(const QString & );
- void slotMimeCheck(const QString & );
- void slotLocationActivated(const QString & );
- void slotInsertLocationPath(const QString &, int);
- void locationComboChanged();
-
- private:
- void init();
- void updateMimes();
-
- protected:
-
- private:
- int m_mode, m_selector;
- QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
- QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
- QPushButton *m_reread, *m_up, *m_new, *m_close;
- QListView *m_View;
- QCheckBox *m_checkPerm;
- QWidget *m_pseudo;
- QVBoxLayout *m_pseudoLayout;
-
- QString m_currentDir;
- QString m_name;
-// QStringList m_mimetypes;
- QMap<QString, QStringList> m_mimetypes;
-
- FileSelector *m_select;
- QWidgetStack *m_stack;
- QVBoxLayout *m_lay;
- QGridLayout *m_Oselector;
-
- QHBox *m_boxToolbar;
- QHBox *m_boxOk; // (no layout anymore) wait
- QHBox *m_boxName; // (no Layout anymore) wait
- QHBox *m_boxView;
-
- QPopupMenu *m_custom;
-
- QLineEdit *m_edit;
- QLabel *m_fnLabel;
-
- bool m_shClose : 1;
- bool m_shNew : 1;
- bool m_shTool : 1;
- bool m_shPerm : 1;
- bool m_shLne : 1;
- bool m_shChooser : 1;
- bool m_shYesNo : 1;
- bool m_boCheckPerm : 1;
- bool m_autoMime : 1;
- bool m_case : 1;
- bool m_dir : 1;
- bool m_files : 1;
- bool m_showPopup : 1;
-
- void initVars();
- virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE );
- virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE );
- virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){};
- void delItems();
- void initializeName();
- void initializeYes();
- void initializeChooser();
- void initializeListView();
- void initializePerm();
- void initPics();
- bool compliesMime(const QString &path,
- const QString &mime);
- bool compliesMime(const QString& mime );
- /**
- * Updates the QComboBox with the current mimetypes
- */
- void updateMimeCheck();
+ /* will set the text of the lineedit and emit a fileChanged signal */
+ void slotDocLnkBridge( const DocLnk& );
+ void slotFileBridge( const QString& );
+ void slotViewChange( const QString& );
- /**
- * Returns the current mimetype
- */
- QString currentMimeType()const;
- class OFileSelectorPrivate;
- OFileSelectorPrivate *d;
- static QMap<QString,QPixmap> *m_pixmaps;
+ bool eventFilter (QObject *o, QEvent *e);
-private slots:
- void slotFileSelected(const QString & ); // not really meant to be a slot
- void slotFileBridgeSelected( const DocLnk & );
- virtual void slotSelectionChanged();
- virtual void slotCurrentChanged(QListViewItem* );
- virtual void slotClicked( int, QListViewItem *item, const QPoint &, int);
- virtual void slotRightButton(int, QListViewItem *, const QPoint &, int );
- virtual void slotContextMenu( QListViewItem *item);
- // listview above
- // popup below
- virtual void slotChangedDir();
- virtual void slotOpen();
- virtual void slotRescan();
- virtual void slotRename();
- virtual void slotDelete();
- virtual void cdUP();
- virtual void slotHome();
- virtual void slotDoc();
- virtual void slotNavigate( );
};
-
#endif
-
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 @@
+#ifndef OPIE_OFILE_SELECTOR_PRIVATE_H
+#define OPIE_OFILE_SELECTOR_PRIVATE_H
+
+#include <qmap.h>
+#include <qstringlist.h>
+#include <qwidget.h>
+#include <qlistview.h>
+
+#include <qpe/applnk.h>
+#include <qpe/fileselector.h>
+
+
+/*
+ * How to avoid having really two different objects
+ * for Extended and ExtendedAll
+ * The only difference is the Lister...
+ * a) static object?
+ * b) leave some object inside the OFileSelector which can be used?
+ * c) when switching views tell which view we want o have.. internally we can switch then
+ *
+ * I'll take c) -zecke
+ */
+
+
+/* the View Interface */
+class OFileSelector;
+typedef QMap<QString, QStringList> MimeTypes;
+class QFileInfo;
+class QToolButton;
+class OFileViewInterface {
+public:
+ OFileViewInterface( OFileSelector* selector );
+ virtual ~OFileViewInterface();
+ virtual QString selectedName()const = 0;
+ virtual QString selectedPath()const = 0;
+ virtual QString directory()const = 0;
+ virtual void reread() = 0;
+ virtual int fileCount()const = 0;
+ virtual DocLnk selectedDocument()const;
+ virtual QWidget* widget( QWidget* parent) = 0;
+ virtual void activate( const QString& );
+ QString name()const;
+protected:
+ OFileSelector* selector()const;
+ void setName( const QString& );
+ bool showNew()const;
+ bool showClose()const;
+ MimeTypes mimeTypes()const;
+ QStringList currentMimeType()const;
+ QString startDirectory()const;
+protected:
+ void ok();
+ void cancel();
+ void closeMe();
+ void fileSelected( const QString& );
+ void fileSelected( const DocLnk& );
+ void setCurrentFileName( const QString& );
+ QString currentFileName()const;
+
+private:
+ QString m_name;
+ OFileSelector* m_selector;
+};
+
+
+/* THE Document View hosting a FileSelector*/
+class ODocumentFileView : public OFileViewInterface {
+public:
+ ODocumentFileView( OFileSelector* selector );
+ ~ODocumentFileView();
+
+ QString selectedName() const;
+ QString selectedPath() const;
+
+ QString directory() const;
+ void reread();
+ int fileCount()const;
+ DocLnk selectedDocument()const;
+
+ QWidget* widget( QWidget* parent );
+
+private:
+ mutable FileSelector* m_selector;
+
+};
+
+class OFileSelectorItem : public QListViewItem {
+public:
+ OFileSelectorItem( QListView* view, const QPixmap& pixmap,
+ const QString& path, const QString& date,
+ const QString& size, const QString& mDir,
+ bool isLocked = false, bool isDir = false );
+ ~OFileSelectorItem();
+ bool isLocked()const;
+ bool isDir()const;
+ QString directory()const;
+ QString path()const;
+ QString key(int id, bool )const;
+
+private:
+ bool m_locked : 1;
+ bool m_isDir : 1;
+ QString m_dir;
+};
+
+class OFileViewFileListView : public QWidget {
+ Q_OBJECT
+public:
+ OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector );
+ ~OFileViewFileListView();
+
+ OFileSelectorItem* currentItem()const;
+ void reread( bool all = false );
+ int fileCount()const;
+ QString currentDir()const;
+protected:
+ bool eventFilter (QObject *o, QEvent *e);
+private slots:
+ void slotNew(); // will emit newSelected
+ void cdUP();
+ void cdHome();
+ void cdDoc();
+ void changeDir( const QString& );
+ void slotCurrentChanged( QListViewItem* );
+ void slotClicked(int, QListViewItem*, const QPoint&, int );
+ void slotFSActivated(int);
+
+protected:
+
+ OFileSelector* selector();
+
+private:
+ QMap<QString, QString> m_dev;
+ bool m_all : 1;
+ OFileSelector* m_sel;
+ QPopupMenu* m_fsPop;
+ bool compliesMime( const QString& );
+ QStringList m_mimes; // used in compy mime
+ QString m_currentDir;
+ QToolButton *m_btnNew, *m_btnClose;
+ void connectSlots();
+ void addFile( QFileInfo* info, bool symlink = FALSE );
+ void addDir ( QFileInfo* info, bool symlink = FALSE );
+ void addSymlink( QFileInfo* info, bool = FALSE );
+
+
+private:
+ QListView* m_view;
+};
+
+#endif
diff --git a/libopie/orecurrancewidget.cpp b/libopie/orecurrancewidget.cpp
index 471249d..be8ec30 100644
--- a/libopie/orecurrancewidget.cpp
+++ b/libopie/orecurrancewidget.cpp
@@ -1,573 +1,595 @@
#include <qapplication.h>
#include <qlabel.h>
#include <qpopupmenu.h>
#include <qspinbox.h>
#include <qpe/timestring.h>
#include "orecurrancewidget.h"
// Global Templates for use in setting up the repeat label...
-const QString strDayTemplate = QObject::tr("Every");
-const QString strYearTemplate = QObject::tr("%1 %2 every ");
-const QString strMonthDateTemplate = QObject::tr("The %1 every ");
-const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every");
-const QString strWeekTemplate = QObject::tr("Every ");
-const QString dayLabel[] = { QObject::tr("Monday"),
- QObject::tr("Tuesday"),
- QObject::tr("Wednesday"),
- QObject::tr("Thursday"),
- QObject::tr("Friday"),
- QObject::tr("Saturday"),
- QObject::tr("Sunday") };
+// the problem is these strings get initialized before QPEApplication can install the translator -zecke
+namespace {
+QString strDayTemplate;
+QString strYearTemplate;
+QString strMonthDateTemplate;
+QString strMonthDayTemplate;
+QString strWeekTemplate;
+QString dayLabel[7];
+}
+/*
+ * static linkage to not polute the symbol table...
+ * The problem is that const and static linkage are resolved prior to installing a translator
+ * leading to that the above strings are translted but to the original we delay the init of these strings...
+ * -zecke
+ */
+static void fillStrings() {
+ strDayTemplate = QObject::tr("Every");
+ strYearTemplate = QObject::tr("%1 %2 every ");
+ strMonthDateTemplate = QObject::tr("The %1 every ");
+ strMonthDayTemplate = QObject::tr("The %1 %2 of every");
+ strWeekTemplate = QObject::tr("Every ");
+ dayLabel[0] = QObject::tr("Monday");
+ dayLabel[1] = QObject::tr("Tuesday");
+ dayLabel[2] = QObject::tr("Wednesday");
+ dayLabel[3] = QObject::tr("Thursday");
+ dayLabel[4] = QObject::tr("Friday");
+ dayLabel[5] = QObject::tr("Saturday");
+ dayLabel[6] = QObject::tr("Sunday");
+}
static QString numberPlacing( int x ); // return the proper word format for
// x (1st, 2nd, etc)
static int week( const QDate &dt ); // what week in the month is dt?
/**
* Constructs the Widget
* @param startOnMonday Does the week start on monday
* @param newStart The start date of the recurrence
* @param parent The parent widget
* @param name the name of object
* @param modal if the dialog should be modal
* @param fl Additional window flags
*/
ORecurranceWidget::ORecurranceWidget( bool startOnMonday,
const QDate& newStart,
QWidget* parent,
const char* name,
bool modal,
WFlags fl )
: ORecurranceBase( parent, name, modal, fl ),
start( newStart ),
currInterval( None ),
startWeekOnMonday( startOnMonday )
{
+ if (strDayTemplate.isEmpty() )
+ fillStrings();
+
init();
fraType->setButton( currInterval );
chkNoEnd->setChecked( TRUE );
setupNone();
}
/**
* Different constructor
* @param startOnMonday Does the week start on monday?
* @param rp Already set ORecur object
* @param startDate The start date
* @param parent The parent widget
* @param name The name of the object
* @param modal
* @param fl The flags for window
*/
ORecurranceWidget::ORecurranceWidget( bool startOnMonday,
const ORecur& rp, const QDate& startDate,
QWidget* parent, const char* name,
bool modal, WFlags fl)
: ORecurranceBase( parent, name, modal, fl ),
start( startDate ),
end( rp.endDate() ),
startWeekOnMonday( startOnMonday )
{
+ if (strDayTemplate.isEmpty() )
+ fillStrings();
// do some stuff with the repeat pattern
init();
setRecurrence( rp );
}
ORecurranceWidget::~ORecurranceWidget() {
}
/**
* set the start date
* @param date the new start date
*/
void ORecurranceWidget::setStartDate( const QDate& date ) {
- qWarning("ORecurranceWidget::setStartDate");
setRecurrence( recurrence(), date );
}
/**
* set the recurrence
* @param rp The ORecur object with the new recurrence rules
*/
void ORecurranceWidget::setRecurrence( const ORecur& rp ) {
setRecurrence( rp, start );
}
/**
* overloaded method taking ORecur and a new start date
* @param rp Recurrence rule
* @param date The new start date
*/
void ORecurranceWidget::setRecurrence( const ORecur& rp, const QDate& date ) {
start = date;
end = rp.endDate();
switch ( rp.type() ) {
default:
case ORecur::NoRepeat:
currInterval = None;
setupNone();
break;
case ORecur::Daily:
currInterval = Day;
setupDaily();
break;
case ORecur::Weekly:
currInterval = Week;
setupWeekly();
int day, buttons;
for ( day = 0x01, buttons = 0; buttons < 7;
day = day << 1, buttons++ ) {
if ( rp.days() & day ) {
if ( startWeekOnMonday )
fraExtra->setButton( buttons );
else {
if ( buttons == 7 )
fraExtra->setButton( 0 );
else
fraExtra->setButton( buttons + 1 );
}
}
}
slotWeekLabel();
break;
case ORecur::MonthlyDay:
currInterval = Month;
setupMonthly();
fraExtra->setButton( 0 );
slotMonthLabel( 0 );
break;
case ORecur::MonthlyDate:
currInterval = Month;
setupMonthly();
fraExtra->setButton( 1 );
slotMonthLabel( 1 );
break;
case ORecur::Yearly:
currInterval = Year;
setupYearly();
break;
}
fraType->setButton( currInterval );
spinFreq->setValue( rp.frequency() );
if ( !rp.hasEndDate() ) {
cmdEnd->setText( tr("No End Date") );
chkNoEnd->setChecked( TRUE );
} else
cmdEnd->setText( TimeString::shortDate( end ) );
}
/**
* the user selected recurrence rule.
* @return The recurrence rule.
*/
ORecur ORecurranceWidget::recurrence()const {
QListIterator<QToolButton> it( listRTypeButtons );
QListIterator<QToolButton> itExtra( listExtra );
ORecur rpTmp;
int i;
for ( i = 0; *it; ++it, i++ ) {
if ( (*it)->isOn() ) {
switch ( i ) {
case None:
rpTmp.setType( ORecur::NoRepeat );
break;
case Day:
rpTmp.setType( ORecur::Daily );
break;
case Week:{
rpTmp.setType( ORecur::Weekly );
int day;
int day2 = 0;
for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
if ( (*itExtra)->isOn() ) {
if ( startWeekOnMonday )
day2 |= day;
else {
if ( day == 1 )
day2 |= Event::SUN;
else
day2 |= day >> 1;
}
}
}
rpTmp.setDays( day2 );
}
break;
case Month:
if ( cmdExtra1->isOn() )
rpTmp.setType( ORecur::MonthlyDay );
else if ( cmdExtra2->isOn() )
rpTmp.setType( ORecur::MonthlyDate );
// figure out the montly day...
rpTmp.setPosition( week( start ) );
break;
case Year:
rpTmp.setType( ORecur::Yearly );
break;
}
break; // no need to keep looking!
}
}
rpTmp.setFrequency(spinFreq->value() );
rpTmp.setHasEndDate( !chkNoEnd->isChecked() );
if ( rpTmp.hasEndDate() ) {
rpTmp.setEndDate( end );
}
// timestamp it...
// rpTmp.setCreateTime( ); current DateTime is already set -zecke
return rpTmp;
}
/**
* Return the end date of the recurrence. This is only
* valid if the recurrence rule does contain an enddate
*/
QDate ORecurranceWidget::endDate()const {
return end;
}
void ORecurranceWidget::slotSetRType(int rtype) {
// now call the right function based on the type...
currInterval = static_cast<repeatButtons>(rtype);
switch ( currInterval ) {
case None:
setupNone();
break;
case Day:
setupDaily();
break;
case Week:
setupWeekly();
slotWeekLabel();
break;
case Month:
setupMonthly();
cmdExtra2->setOn( TRUE );
slotMonthLabel( 1 );
break;
case Year:
setupYearly();
break;
}
}
void ORecurranceWidget::endDateChanged(int y, int m, int d) {
end.setYMD( y, m, d );
if ( end < start )
end = start;
cmdEnd->setText( TimeString::shortDate( end ) );
repeatPicker->setDate( end.year(), end.month(), end.day() );
}
void ORecurranceWidget::slotNoEnd( bool unused) {
// if the item was toggled, then go ahead and set it to the maximum date
if ( unused ) {
end.setYMD( 3000, 12, 31 );
cmdEnd->setText( tr("No End Date") );
} else {
end = start;
cmdEnd->setText( TimeString::shortDate(end) );
}
}
void ORecurranceWidget::setupRepeatLabel( const QString& s) {
lblVar1->setText( s );
}
void ORecurranceWidget::setupRepeatLabel( int x) {
// change the spelling based on the value of x
QString strVar2;
if ( x > 1 )
lblVar1->show();
else
lblVar1->hide();
switch ( currInterval ) {
case None:
break;
case Day:
if ( x > 1 )
strVar2 = tr( "days" );
else
strVar2 = tr( "day" );
break;
case Week:
if ( x > 1 )
strVar2 = tr( "weeks" );
else
strVar2 = tr( "week" );
break;
case Month:
if ( x > 1 )
strVar2 = tr( "months" );
else
strVar2 = tr( "month" );
break;
case Year:
if ( x > 1 )
strVar2 = tr( "years" );
else
strVar2 = tr( "year" );
break;
}
if ( !strVar2.isNull() )
lblVar2->setText( strVar2 );
}
void ORecurranceWidget::slotWeekLabel() {
QString str;
QListIterator<QToolButton> it( listExtra );
unsigned int i;
unsigned int keepMe;
bool bNeedCarriage = FALSE;
// don't do something we'll regret!!!
if ( currInterval != Week )
return;
if ( startWeekOnMonday )
keepMe = start.dayOfWeek() - 1;
else
keepMe = start.dayOfWeek() % 7;
QStringList list;
for ( i = 0; *it; ++it, i++ ) {
// a crazy check, if you are repeating weekly, the current day
// must be selected!!!
if ( i == keepMe && !( (*it)->isOn() ) )
(*it)->setOn( TRUE );
if ( (*it)->isOn() ) {
if ( startWeekOnMonday )
list.append( dayLabel[i] );
else {
if ( i == 0 )
list.append( dayLabel[6] );
else
list.append( dayLabel[i - 1] );
}
}
}
QStringList::Iterator itStr;
for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) {
if ( i == 3 )
bNeedCarriage = TRUE;
else
bNeedCarriage = FALSE;
if ( str.isNull() )
str = *itStr;
else if ( i == list.count() - 1 ) {
if ( i < 2 )
str += tr(" and ") + *itStr;
else {
if ( bNeedCarriage )
str += tr( ",\nand " ) + *itStr;
else
str += tr( ", and " ) + *itStr;
}
} else {
if ( bNeedCarriage )
str += ",\n" + *itStr;
else
str += ", " + *itStr;
}
}
- str = str.prepend( "on " );
+ str = str.prepend( tr("on ") );
+
lblWeekVar->setText( str );
}
void ORecurranceWidget::slotMonthLabel(int type) {
QString str;
if ( currInterval != Month || type > 1 )
return;
if ( type == 1 )
- str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
+ str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
else
- str = strMonthDayTemplate.arg( numberPlacing(week(start)))
- .arg( dayLabel[start.dayOfWeek() - 1] );
+ str = strMonthDayTemplate.arg( numberPlacing(week(start)))
+ .arg( dayLabel[start.dayOfWeek() - 1] );
lblRepeat->setText( str );
}
void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) {
startWeekOnMonday = onMonday;
// we need to make this unintrusive as possible...
int saveSpin = spinFreq->value();
char days = 0;
int day;
QListIterator<QToolButton> itExtra( listExtra );
for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
if ( (*itExtra)->isOn() ) {
if ( !startWeekOnMonday )
days |= day;
else {
if ( day == 1 )
days |= ORecur::SUN;
else
days |= day >> 1;
}
}
}
setupWeekly();
spinFreq->setValue( saveSpin );
int buttons;
for ( day = 0x01, buttons = 0; buttons < 7;
day = day << 1, buttons++ ) {
if ( days & day ) {
if ( startWeekOnMonday )
fraExtra->setButton( buttons );
else {
if ( buttons == 7 )
fraExtra->setButton( 0 );
else
fraExtra->setButton( buttons + 1 );
}
}
}
slotWeekLabel();
}
void ORecurranceWidget::setupNone() {
lblRepeat->setText( tr("No Repeat") );
lblVar1->hide();
lblVar2->hide();
hideExtras();
cmdEnd->hide();
lblFreq->hide();
lblEvery->hide();
lblFreq->hide();
spinFreq->hide();
lblEnd->hide();
lblWeekVar->hide();
}
void ORecurranceWidget::setupDaily() {
hideExtras();
lblWeekVar->hide();
spinFreq->setValue( 1 );
lblFreq->setText( tr("day(s)") );
lblVar2->show();
showRepeatStuff();
lblRepeat->setText( strDayTemplate );
setupRepeatLabel( 1 );
}
void ORecurranceWidget::setupWeekly() {
// reshow the buttons...
fraExtra->setTitle( tr("Repeat On") );
fraExtra->setExclusive( FALSE );
fraExtra->show();
if ( startWeekOnMonday ) {
cmdExtra1->setText( tr("Mon") );
cmdExtra2->setText( tr("Tue") );
cmdExtra3->setText( tr("Wed") );
cmdExtra4->setText( tr("Thu") );
cmdExtra5->setText( tr("Fri") );
cmdExtra6->setText( tr("Sat") );
cmdExtra7->setText( tr("Sun") );
} else {
cmdExtra1->setText( tr("Sun") );
cmdExtra2->setText( tr("Mon") );
cmdExtra3->setText( tr("Tue") );
cmdExtra4->setText( tr("Wed") );
cmdExtra5->setText( tr("Thu") );
cmdExtra6->setText( tr("Fri") );
cmdExtra7->setText( tr("Sat") );
}
// I hope clustering these improve performance....
cmdExtra1->setOn( FALSE );
cmdExtra2->setOn( FALSE );
cmdExtra3->setOn( FALSE );
cmdExtra4->setOn( FALSE );
cmdExtra5->setOn( FALSE );
cmdExtra6->setOn( FALSE );
cmdExtra7->setOn( FALSE );
cmdExtra1->show();
cmdExtra2->show();
cmdExtra3->show();
cmdExtra4->show();
cmdExtra5->show();
cmdExtra6->show();
cmdExtra7->show();
lblWeekVar->show();
spinFreq->setValue( 1 );
// might as well set the day too...
if ( startWeekOnMonday ) {
fraExtra->setButton( start.dayOfWeek() - 1 );
} else {
fraExtra->setButton( start.dayOfWeek() % 7 );
}
lblFreq->setText( tr("week(s)") );
lblVar2->show();
showRepeatStuff();
setupRepeatLabel( 1 );
}
void ORecurranceWidget::setupMonthly() {
hideExtras();
lblWeekVar->hide();
fraExtra->setTitle( tr("Repeat By") );
fraExtra->setExclusive( TRUE );
fraExtra->show();
cmdExtra1->setText( tr("Day") );
cmdExtra1->show();
cmdExtra2->setText( tr("Date") );
cmdExtra2->show();
spinFreq->setValue( 1 );
lblFreq->setText( tr("month(s)") );
lblVar2->show();
showRepeatStuff();
setupRepeatLabel( 1 );
}
void ORecurranceWidget::setupYearly() {
hideExtras();
lblWeekVar->hide();
spinFreq->setValue( 1 );
lblFreq->setText( tr("year(s)") );
lblFreq->show();
lblFreq->show();
showRepeatStuff();
lblVar2->show();
QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) );
lblRepeat->setText( strEvery );
setupRepeatLabel( 1 );
}
void ORecurranceWidget::init() {
QPopupMenu *m1 = new QPopupMenu( this );
repeatPicker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( repeatPicker );
cmdEnd->setPopup( m1 );
cmdEnd->setPopupDelay( 0 );
QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)),
this, SLOT(endDateChanged(int, int, int)) );
QObject::connect( qApp, SIGNAL(weekChanged(bool)),
this, SLOT(slotChangeStartOfWeek(bool)) );
listRTypeButtons.setAutoDelete( TRUE );
listRTypeButtons.append( cmdNone );
listRTypeButtons.append( cmdDay );
listRTypeButtons.append( cmdWeek );
listRTypeButtons.append( cmdMonth );
listRTypeButtons.append( cmdYear );
listExtra.setAutoDelete( TRUE );
listExtra.append( cmdExtra1 );
listExtra.append( cmdExtra2 );
listExtra.append( cmdExtra3 );
listExtra.append( cmdExtra4 );
listExtra.append( cmdExtra5 );
listExtra.append( cmdExtra6 );
listExtra.append( cmdExtra7 );
}
void ORecurranceWidget::hideExtras() {
// hide the extra buttons...
fraExtra->hide();
chkNoEnd->hide();
QListIterator<QToolButton> it( listExtra );
for ( ; *it; ++it ) {
(*it)->hide();
(*it)->setOn( FALSE );
}
}
void ORecurranceWidget::showRepeatStuff() {
cmdEnd->show();
chkNoEnd->show();
lblFreq->show();
lblEvery->show();
lblFreq->show();
spinFreq->show();
lblEnd->show();
lblRepeat->setText( tr("Every") );
}
diff --git a/libopie/oticker.h b/libopie/oticker.h
index 0b88919..4026eb5 100644
--- a/libopie/oticker.h
+++ b/libopie/oticker.h
@@ -1,146 +1,146 @@
/*
                This file is part of the Opie Project
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OTICKER_H
#define OTICKER_H
#include <qwidget.h>
#include <qpainter.h>
#include <qdrawutil.h>
#include <qpixmap.h>
#include <qstring.h>
#include <qslider.h>
#include <qlabel.h>
#include <qframe.h>
#include <qcolor.h>
/**
* @class OTicker
* @brief The OTicker class provides a QLabel widget that scroll its contents
*
*/
class OTicker : public QLabel {
Q_OBJECT
public:
/*!
* @fn OTicker( QWidget* parent = 0 )
* @brief Object constructor.
*
* @param parent Pointer to parent of this control.
* Constructs a new OTicker control with parent
*/
OTicker( QWidget* parent=0 );
/*!
* @fn ~OTicker()
* @brief Object destructor.
*/
~OTicker();
/*!
* @fn setText(const QString& )
* @brief sets text to be displayed
* @param text QString text to be displayed.
*
*/
void setText( const QString& text ) ;
/*!
- * @fn setBackgroundColor(QColor color)
+ * @fn setBackgroundColor(const QColor& color)
* @brief sets color of the ticker's background
* @param color QColor color to be set.
*
*/
void setBackgroundColor(const QColor& color);
/*!
- * @fn setForegroundColor(QColor color)
+ * @fn setForegroundColor(const QColor& color)
* @brief sets color of text
* @param color QColor color of text
*
*/
void setForegroundColor(const QColor& color);
/*!
* @fn setFrame(int style)
* @brief sets frame style
* @param style int Frame style to be see. See Qt::WidgetFlags.
*
*/
void setFrame(int style);
/*!
* @fn setUpdateTime(int timeout)
* @brief sets time of update
* @param timeout int time in milliseconds between updates.
*
*/
void setUpdateTime(int timeout);
/*!
* @fn setScrollLength(int length)
* @brief sets amount of scrolling default is 1
* @param length int scroll length.
*
*/
void setScrollLength(int length);
signals:
/*!
* @fn mousePressed()
* @brief signal mouse press event
*
*/
void mousePressed();
protected:
/*!
* @fn timerEvent( QTimerEvent * e)
* @brief timer timeout event
* @param e QEvent see QEvent.
*
*/
void timerEvent( QTimerEvent * e);
/*!
* @fn drawContents( QPainter *p )
* @brief draws widget contents
* @param p QPainter. see QPainter
*
*/
void drawContents( QPainter *p );
/*!
* @fn mouseReleaseEvent( QMouseEvent *e)
* @brief mouse release event
* @param e QMouseEvent. see QMouseEvent.
*
*/
void mouseReleaseEvent( QMouseEvent *e);
private:
QColor backgroundcolor, foregroundcolor;
QString scrollText;
QPixmap scrollTextPixmap;
int pos, updateTimerTime, scrollLength;
};
#endif
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 @@
+/*
+                This file is part of the Opie Project
+ Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
#ifndef TODAY_PLUGIN_INTERFACE
#define TODAY_PLUGIN_INTERFACE
#include <qpe/qcom.h>
#include "todayconfigwidget.h"
class QString;
class QWidget;
#ifndef IID_TodayPluginInterface
#define IID_TodayPluginInterface QUuid( 0x70481804, 0x2b50, 0x4fba, 0x80, 0xbb, 0x0b, 0xf8, 0xdc, 0x72, 0x04, 0x14)
#endif
/**
*
* A TodayPluginObject is the base for all Today Plugins.
* A plugin author needs to inherit this class and implement
* the pure virtual methods
*
* @short base class for today plugins
* @author Maximilian Reiss
*
*/
class TodayPluginObject {
public:
virtual ~TodayPluginObject() {};
/**
* The name if the plugin
* @return The plugin should return its name here
*/
virtual QString pluginName() const = 0;
/**
* Version numbering
* @return The plugin should return the version number
*/
virtual double versionNumber() const = 0;
/**
* @return the pixmap name widget?! -- FIXME
*/
virtual QString pixmapNameWidget() const = 0;
/**
* widget for the today view
* It _needs_ a parent here.
* Plugin authors need to take parent as parent!
*/
virtual QWidget* widget( QWidget *parent ) = 0;
/**
* Pixmap used in the config widget
*/
virtual QString pixmapNameConfig() const = 0;
/**
* Config plugin widget - optional
* If the plugin has a config widget, it _needs_ a parent here.
* may return 0 if no config widget is needed
*/
virtual TodayConfigWidget* configWidget( QWidget * ) = 0;
/**
* The application that should be assigned to the button (pixmap)
* Today will show the plugin icon. On click it tries to execute the
* plugin related application.
*/
virtual QString appName() const = 0;
/**
* If the plugin should take part in the periodic refresh
*/
virtual bool excludeFromRefresh() const = 0;
/**
* Refresh that plugins view. For updating the plugins
- *
*/
virtual void refresh() {};
/**
- * minimum height the plugin at least should have
+ * reread the plugins config and act apropiate
+ * This is for example used when returning from the config dialog
*/
- // virtual int minHeight() const = 0;
-
- /**
- * maximum height that should be used before starting scrolling
- */
- // virtual int maxHeight() const = 0;
-
+ virtual void reinitialize() {};
};
/**
* This is part of the QCOM works. See example plugins how to do it right
*/
struct TodayPluginInterface : public QUnknownInterface {
/**
* return the TodayPluginObject implementation
*/
virtual TodayPluginObject *guiPart() = 0;
};
#endif