-rw-r--r-- | libopie/libopie.pro | 2 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 1 | ||||
-rw-r--r-- | libopie/ofileview.h | 79 |
3 files changed, 81 insertions, 1 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index b2ecd07..ba64bda 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro @@ -1,8 +1,8 @@ TEMPLATE = lib CONFIG += qte warn_on release -HEADERS = ofontmenu.h ofileselector.h ofiledialog.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h colordialog.h colorpopupmenu.h +HEADERS = ofontmenu.h ofileselector.h ofiledialog.h ofileview.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h colordialog.h colorpopupmenu.h SOURCES = ofontmenu.cc ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp colordialog.cpp colorpopupmenu.cpp TARGET = opie INCLUDEPATH += $(OPIEDIR)/include DESTDIR = $(QTDIR)/lib$(PROJMAK) #VERSION = 1.0.0 diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 0a6e595..0e508af 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc @@ -1,444 +1,445 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 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. */ #include <qnamespace.h> #include <qpushbutton.h> #include <qcombobox.h> #include <qhbox.h> #include <qvbox.h> #include <qlayout.h> #include <qwidgetstack.h> #include <qlineedit.h> #include <qcheckbox.h> #include <qlabel.h> #include <qheader.h> #include <qdir.h> #include <qpainter.h> #include <qaction.h> #include <qpopupmenu.h> #include <qcursor.h> #include <qstringlist.h> #include <qmessagebox.h> #include <qpe/qpeapplication.h> #include <qpe/fileselector.h> #include <qpe/applnk.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" +//#include "ofileview.h" QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; namespace { int indexByString( const QComboBox *box, const QString &str ){ int index= -1; 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 QStringList &mimetypes ) : QWidget( wid ) { if(wid!=0) resize(wid->width(),wid->height()); m_selector = selector; m_currentDir = dirName; m_name = fileName; m_mimetypes = mimetypes; if( mimetypes.isEmpty() ) m_autoMime = true; qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() ); m_mode = mode; m_shTool = true; m_shPerm = true; m_shLne = true; m_shChooser = true; m_shYesNo = true; // for FILESELECTOR only view is interesting m_location = 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_select = 0; m_stack = 0; m_select = 0; m_stack = 0; m_lay = 0; m_boxToolbar = 0; m_boxOk = 0; m_edit = 0; m_fnLabel = 0; m_checkPerm = 0; m_mimeCheck = 0; m_viewCheck = 0; m_pseudo = 0; m_pseudoLayout = 0; m_dir = true; m_files = true; m_custom = 0; m_showPopup = true; if(m_pixmaps == 0 ) // init the pixmaps initPics(); m_lay = new QVBoxLayout(this); init(); m_edit->setText( fileName ); } void OFileSelector::initPics() { qWarning("init pics" ); 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 ); } // let's initialize the gui /** -------------------- | cmbBox Button | -------------------- | FileSlector | | or | | OSelector | | | | | ____________________ | LineEdit | ____________________ | Permission Bar | ____________________ | ViewChoose | ____________________ | Save Cancel| ____________________ */ void OFileSelector::delItems() { QLayoutIterator it = m_lay->iterator(); while ( it.current() != 0 ){ it.deleteCurrent(); } } void OFileSelector::init() { // qDebug("init"); m_stack = new QWidgetStack(this, "wstack" ); if( m_selector == NORMAL ){ QString currMime; if( m_mimeCheck != 0 ) currMime = m_mimeCheck->currentText(); updateMimes(); m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); m_stack->addWidget(m_select, NORMAL ); m_lay->addWidget(m_stack ); m_stack->raiseWidget(NORMAL ); connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); m_pseudoLayout = 0l; } else { initializeListView(); } if(m_shLne ){ initializeName(); } if(m_shPerm ){ m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); m_checkPerm->setChecked( false ); m_lay->addWidget(m_checkPerm ); } if( m_shChooser ) initializeChooser(); if(m_shYesNo ) initializeYes(); // m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) ); // reparse(); } void OFileSelector::setYesCancelVisible( bool show ) { if ( show == m_shYesNo ) return; m_shYesNo = show; if( !show ){ delete m_ok; delete m_cancel; m_ok = 0; m_cancel = 0; // delete m_boxOk; all ready deleted in delItems } updateLay(); // recreate it and save the other states } void OFileSelector::setToolbarVisible( bool show ) { if ( m_shTool == show ) return; if(!m_shTool ){ delete m_boxToolbar; delete m_homeButton; delete m_docButton; delete m_location; delete m_up; m_boxToolbar = 0; m_homeButton = 0; m_docButton = 0; m_location = 0; m_up = 0; }; updateLay();// overkill fix it } void OFileSelector::setPermissionBarVisible( bool show ) { if( show == m_shPerm ) return; m_shPerm = show; updateLay(); } void OFileSelector::setLineEditVisible( bool show ) { if( show == m_shLne ) return; m_shLne = show; if( !show ){ delete m_edit; delete m_fnLabel; m_edit = 0; m_fnLabel = 0; //delete m_boxName; will be deleted } updateLay(); } void OFileSelector::setChooserVisible( bool show ) { if( show = m_shChooser ) return; m_shChooser = show; if( !show ){ delete m_mimeCheck; delete m_viewCheck; m_mimeCheck = 0; m_viewCheck = 0; } updateLay(); } QCheckBox* OFileSelector::permissionCheckbox( ) { return m_checkPerm; } void OFileSelector::setCaseSensetive( bool caSe ) { m_case = caSe; reparse(); } void OFileSelector::setShowFiles(bool files ){ m_files = files; reparse(); } void OFileSelector::setPopupMenu(QPopupMenu *pop ) { //delete oldpopup; m_custom = pop; } bool OFileSelector::setPermission( ) const { if( m_checkPerm == 0 ) return false; else return m_checkPerm->isChecked(); } void OFileSelector::setPermissionChecked( bool check ) { if( m_checkPerm == 0 ) return; m_checkPerm->setChecked( check ); } QString OFileSelector::selectedName( )const { QString string; if( m_selector == NORMAL ){ const DocLnk *lnk = m_select->selected(); string = lnk->file(); }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { QListViewItem *item = m_View->currentItem(); if(item != 0 ){ string = m_currentDir + "/" + item->text( 1 ); } } return string; } QStringList OFileSelector::selectedNames()const { QStringList list; return list; } DocLnk OFileSelector::selectedDocument( )const { DocLnk lnk; return lnk; } void OFileSelector::updateLay() { /* if( m_shTool ) // else // hide */ // save the state bool check = false; if( m_checkPerm != 0 ) check = m_checkPerm->isChecked(); QString text; if( m_edit != 0 ) text = m_edit->text(); // save current mimetype delItems(); delete m_checkPerm; m_checkPerm = 0; delete m_edit; m_edit = 0; delete m_fnLabel; m_fnLabel = 0; delete m_ok; m_ok = 0; delete m_cancel; m_cancel = 0; delete m_mimeCheck; m_mimeCheck = 0; delete m_viewCheck; m_viewCheck = 0; delete m_select; // test diff --git a/libopie/ofileview.h b/libopie/ofileview.h new file mode 100644 index 0000000..48a71ca --- a/dev/null +++ b/libopie/ofileview.h @@ -0,0 +1,79 @@ +/* + =. 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 ofileview_h +#define ofileview_h + +#include <qobject.h> +#include <qwidget.h> + +class QFileInfo; +class QDir; +class DocLnk; +class OFileSelectorView : public QWidget { + Q_OBJECT + public: + OFileSelectorView(QWidget *widget, + const char *name ) + : QWidget(widget, name ) +{ }; + virtual ~OFileSelectorView(); + + virtual void addFile(const QString &mine, + QFileInfo *info, + bool isSymlink = FALSE ) = 0; + + virtual void addDir (const QString &mine, + QFileInfo *info, + bool isSymlink = FALSE ) = 0; + + virtual void addSymlink(const QString &mime, + QFileInfo *info, + bool isSymlink = FALSE ) = 0; + + virtual void cd(const QString &path ); + signals: + void fileSelected(const QString &); + void fileSelected(const DocLnk & ); + void contextMenu(); + void changedDir(const QString &); + void changedDir(const QDir & ); +}; + +class OFileViewFactory { + // Q_OBJECT + public: + OFileViewFactory() {} ; + virtual ~OFileViewFactory(); + + OFileSelectorView* newView(QWidget *parent, const char *name ); + QString name()const; +}; + + +#endif |