-rw-r--r-- | libopie/libopie.pro | 3 | ||||
-rw-r--r-- | libopie/libopie1.control | 4 | ||||
-rw-r--r-- | libopie/odevice.cpp | 103 | ||||
-rw-r--r-- | libopie/ofiledialog.cc | 81 | ||||
-rw-r--r-- | libopie/ofiledialog.h | 3 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 1310 | ||||
-rw-r--r-- | libopie/ofileselector.cpp | 856 | ||||
-rw-r--r-- | libopie/ofileselector.h | 308 | ||||
-rw-r--r-- | libopie/ofileselector_p.h | 151 | ||||
-rw-r--r-- | libopie/orecurrancewidget.cpp | 50 | ||||
-rw-r--r-- | libopie/oticker.h | 4 | ||||
-rw-r--r-- | libopie/todayplugininterface.h | 42 |
12 files changed, 1285 insertions, 1630 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index 4535c4e..6fbd449 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro @@ -3,6 +3,7 @@ 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 \ @@ -49,7 +50,7 @@ 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 \ diff --git a/libopie/libopie1.control b/libopie/libopie1.control index 1e75df3..76e4c7a 100644 --- a/libopie/libopie1.control +++ b/libopie/libopie1.control @@ -4,8 +4,8 @@ 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 @@ -472,6 +472,9 @@ void ODevice::initButtons ( ) ODevice::~ODevice ( ) { +// we leak m_devicebuttons and m_cpu_frequency +// but it's a singleton and it is not so importantant +// -zecke delete d; } @@ -920,11 +923,9 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); } -void ODevice::virtual_hook( int id, void* data ) { - Q_UNUSED(id); - Q_UNUSED(data); -} +void ODevice::virtual_hook(int, void* ){ +} /************************************************** @@ -1648,7 +1649,6 @@ int Zaurus::displayBrightnessResolution ( ) const return 5; } - /************************************************** * * SIMpad @@ -1889,7 +1889,7 @@ bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm ::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; } @@ -1911,10 +1911,8 @@ bool SIMpad::setDisplayStatus ( bool on ) 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 ); - } + return res; } @@ -1927,7 +1925,7 @@ bool SIMpad::setDisplayBrightness ( int bright ) if ( bright > 255 ) bright = 255; - if ( bright < 0 ) + if ( bright < 1 ) bright = 0; if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { @@ -1946,16 +1944,7 @@ bool SIMpad::setDisplayBrightness ( int bright ) 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 } /************************************************** @@ -1974,8 +1963,7 @@ void Ramses::init() d->m_modelstr = "Ramses"; d->m_model = Model_Ramses_MNCI; - d->m_rotation = Rot180; - d->m_direction = CW; + d->m_rotation = Rot0; d->m_holdtime = 1000; f.setName("/etc/oz_version"); @@ -2034,24 +2022,45 @@ void Ramses::timerEvent(QTimerEvent *) 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); } + else + perror("/dev/apm_bios or /dev/misc/apm_bios"); + return res; +#else + return true; +#endif +} + +bool Ramses::suspend ( ) +{ + qDebug("Ramses::suspend"); + return false; } /** @@ -2059,15 +2068,19 @@ bool Ramses::suspend() */ 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 } @@ -2076,7 +2089,7 @@ bool Ramses::setDisplayStatus(bool on) */ bool Ramses::setDisplayBrightness(int bright) { - //qDebug("Ramses::setDisplayBrightness(%d)", bright); + qDebug("Ramses::setDisplayBrightness(%d)", bright); bool res = false; int fd; @@ -2096,8 +2109,9 @@ bool Ramses::setDisplayBrightness(int bright) } // 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); @@ -2109,12 +2123,12 @@ bool Ramses::setDisplayBrightness(int bright) 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; @@ -2124,9 +2138,10 @@ bool Ramses::setDisplayContrast(int contr) 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); @@ -2139,5 +2154,5 @@ bool Ramses::setDisplayContrast(int contr) 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,6 +1,6 @@ /* =. 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 @@ -27,12 +27,48 @@ */ #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 * @@ -64,12 +100,15 @@ OFileDialog::OFileDialog(const QString &caption, 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 @@ -108,18 +147,25 @@ DocLnk OFileDialog::selectedDocument()const * @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; } @@ -129,18 +175,24 @@ QString OFileDialog::getOpenFileName(int selector, * @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; } @@ -149,8 +201,15 @@ 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 @@ -44,7 +44,7 @@ * <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, @@ -96,5 +96,6 @@ class OFileDialog : public QDialog { 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 ¤tPath, 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 @@ -5,7 +5,7 @@ =. 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 @@ -31,284 +31,120 @@ */ -#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 + friend class OFileViewInterface; + friend class OFileViewFileListView; 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 }; + 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}; - /** - * 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, + OFileSelector(QWidget* parent, int mode, int selector, const QString &dirName, - const QString &fileName = QString::null, - const MimeTypes &mimetypes = MimeTypes() ); + const QString& fileName, + const MimeTypes& mimetypes = MimeTypes(), + bool newVisible = FALSE, bool closeVisible = FALSE ); - - /** - * This is a QPE compatible c'tor - */ OFileSelector(const QString &mimeFilter, QWidget *parent, - const char *name, bool newVisible = TRUE, - bool closeVisible = FALSE ); - + const char* name = 0, 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 ); - - - 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; + + 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 dirSelected(const QString &dir ); + void newSelected( const DocLnk& ); 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(); +/* used by the ViewInterface */ private: - void init(); - void updateMimes(); - - protected: + bool showNew()const; + bool showClose()const; + MimeTypes mimeTypes()const; + QStringList currentMimeType()const; 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; + /* inits the Widgets */ + void initUI(); + /* inits the MimeType ComboBox content + connects signals and slots */ + void initMime(); + /* init the Views :) */ + void initViews(); - QLineEdit *m_edit; - QLabel *m_fnLabel; +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; - 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; +private slots: + void slotMimeTypeChanged(); - 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 @@ -8,19 +8,36 @@ #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) @@ -46,6 +63,9 @@ ORecurranceWidget::ORecurranceWidget( bool startOnMonday, currInterval( None ), startWeekOnMonday( startOnMonday ) { + if (strDayTemplate.isEmpty() ) + fillStrings(); + init(); fraType->setButton( currInterval ); chkNoEnd->setChecked( TRUE ); @@ -71,6 +91,8 @@ ORecurranceWidget::ORecurranceWidget( bool startOnMonday, end( rp.endDate() ), startWeekOnMonday( startOnMonday ) { + if (strDayTemplate.isEmpty() ) + fillStrings(); // do some stuff with the repeat pattern init(); setRecurrence( rp ); @@ -84,7 +106,6 @@ ORecurranceWidget::~ORecurranceWidget() { * @param date the new start date */ void ORecurranceWidget::setStartDate( const QDate& date ) { - qWarning("ORecurranceWidget::setStartDate"); setRecurrence( recurrence(), date ); } /** @@ -367,7 +388,8 @@ void ORecurranceWidget::slotWeekLabel() { str += ", " + *itStr; } } - str = str.prepend( "on " ); + str = str.prepend( tr("on ") ); + lblWeekVar->setText( str ); } void ORecurranceWidget::slotMonthLabel(int type) { diff --git a/libopie/oticker.h b/libopie/oticker.h index 0b88919..4026eb5 100644 --- a/libopie/oticker.h +++ b/libopie/oticker.h @@ -73,14 +73,14 @@ public: */ 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 * diff --git a/libopie/todayplugininterface.h b/libopie/todayplugininterface.h index 532f492..5dfeaa8 100644 --- a/libopie/todayplugininterface.h +++ b/libopie/todayplugininterface.h @@ -1,3 +1,33 @@ +/* + 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 @@ -80,20 +110,14 @@ public: /** * 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() {}; }; /** |