summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/TODO4
-rw-r--r--libopie/ofileselector.cc187
-rw-r--r--libopie/ofileselector.h9
3 files changed, 183 insertions, 17 deletions
diff --git a/libopie/TODO b/libopie/TODO
index c1bf6d1..a4e1ada 100644
--- a/libopie/TODO
+++ b/libopie/TODO
@@ -1,17 +1,19 @@
- xmltree done
- tododb
- set Alarms
- multiple categories
- Attendees
- OFileSelector
- - DocLnk when not in Document Mode
+ - DocLnk when not in Document Mode ( and vice versa )
+ - MultipleDocuments
- TreeView have a own OFileSelectorItem for this
- IconView add a QIconView to the widgetstack
- Move OFileSelectorItem to it's own files
- add functions to access the member variables
- debug
+ - new Dirs created inside the listview
- Clickable labels?
Harlekin you wanted them in the libs? \ No newline at end of file
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index b583125..14f035e 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -40,24 +40,25 @@
#include <qdir.h>
#include <qpainter.h>
#include <qaction.h>
#include <qpopupmenu.h>
#include <qcursor.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"
QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
namespace {
int indexByString( const QComboBox *box, const QString &str ){
@@ -107,27 +108,31 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
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>;
@@ -220,29 +225,37 @@ void OFileSelector::setYesCancelVisible( bool show )
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( show ){
-
- }else {
-
- }*/
+ 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 )
@@ -409,25 +422,43 @@ void OFileSelector::reparse()
if( !m_mimetypes.contains( type.id() ) )
m_mimetypes.append( type.id() );
++it;
}
m_mimetypes.prepend("All" );
m_mimeCheck->insertStringList(m_mimetypes );
// set it to the current mimetype
m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
};
QDir dir( m_currentDir );
//dir.setFilter(-1 );
- dir.setSorting(QDir::Name | QDir::DirsFirst | QDir::Reversed | QDir::IgnoreCase );
+ int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed;
+ if( m_case )
+ sort = QDir::IgnoreCase;
+ dir.setSorting( sort );
+
+ int filter;
+ /* if( m_dir && !m_files)
+ filter |= QDir::Dirs;
+ else if( !m_dir && m_files )
+ filter |= QDir::Files;
+ else
+ filter |= QDir::All;
+ */
+ if( m_selector == EXTENDED_ALL )
+ filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
+ else
+ filter = QDir::Files | QDir::Dirs | QDir::All;
+ dir.setFilter( filter );
+
const QFileInfoList *list = dir.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while( (fi=it.current()) ){
if(fi->fileName() == ".." || fi->fileName() == "." ){
++it;
continue;
}
qWarning("Test: %s", fi->fileName().latin1() );
if(fi->isSymLink() ){
qWarning("Symlink %s", fi->fileName().latin1() );
QString file = fi->dirPath(true)+"/"+ fi->readLink();
@@ -545,55 +576,102 @@ void OFileSelector::slotMimeCheck(const QString &view ){
}else{
reparse();
}
}
void OFileSelector::slotViewCheck(const QString &view ){
qWarning("changed: show %s", view.latin1() );
// if the current view is the one
QString currMime = m_mimeCheck->currentText();
if( view == QString::fromLatin1("Documents") ){
// get the mimetype now
// check if we're the current widget and return
- if( m_View != 0) // delete 0 shouldn't crash but it did :(
+ if( m_View != 0) { // delete 0 shouldn't crash but it did :(
delete m_View;
+ delete m_boxToolbar;
+ delete m_homeButton;
+ delete m_docButton;
+ delete m_location;
+ delete m_up;
+ delete m_pseudo;
+ delete m_pseudoLayout;
+ }
m_View = 0;
+ m_boxToolbar = 0;
+ m_homeButton = 0;
+ m_docButton = 0;
+ m_location = 0;
+ m_up = 0;
+ m_pseudo = 0;
+ m_pseudoLayout = 0;
+
delete m_select;
m_select = new FileSelector( currMime == "All" ? QString::null : currMime,
m_stack,"fileselector", FALSE, FALSE );
m_stack->addWidget( m_select, NORMAL );
m_mimeCheck->clear();
m_selector = NORMAL;
updateMimes();
m_mimeCheck->insertStringList( m_mimetypes );
m_stack->raiseWidget( NORMAL );
connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
}else if(view == QString::fromLatin1("Files") ){
// remove from the stack
delete m_select;
m_select = 0;
delete m_View;
m_View = 0;
+
+ delete m_boxToolbar;
+ delete m_homeButton;
+ delete m_docButton;
+ delete m_location;
+ delete m_up;
+ delete m_pseudo;
+ delete m_pseudoLayout;
+ m_boxToolbar = 0;
+ m_homeButton = 0;
+ m_docButton = 0;
+ m_location = 0;
+ m_up = 0;
+ m_pseudo = 0;
+ m_pseudoLayout = 0;
+
m_selector = EXTENDED;
// create the ListView or IconView
initializeListView();
reparse();
}else if(view == QString::fromLatin1("All Files") ) {
// remove from the stack
delete m_select;
m_select = 0;
delete m_View;
m_View = 0;
+ delete m_boxToolbar;
+ delete m_homeButton;
+ delete m_docButton;
+ delete m_location;
+ delete m_up;
+ delete m_pseudo;
+ delete m_pseudoLayout;
+ m_boxToolbar = 0;
+ m_homeButton = 0;
+ m_docButton = 0;
+ m_location = 0;
+ m_up = 0;
+ m_pseudo = 0;
+ m_pseudoLayout = 0;
+
m_selector = EXTENDED_ALL;
initializeListView();
reparse();
};
};
void OFileSelector::updateMimes() // lets check which mode is active
// check the current dir for items then
{
m_mimetypes.clear();
m_mimetypes.append("All" );
@@ -602,48 +680,109 @@ void OFileSelector::updateMimes() // lets check which mode is active
Global::findDocuments(&set, QString::null );
QListIterator<DocLnk> dit( set.children() );
for ( ; dit.current(); ++dit ) {
if( !m_mimetypes.contains((*dit)->type() ) )
m_mimetypes.append( (*dit)->type() );
}
}else{
// should be allreday updatet
;
}
};
void OFileSelector::initializeListView()
-{
- m_View = new QListView(m_stack, "Extended view" );
- m_stack->addWidget( m_View, EXTENDED );
+{
+ // just to make sure but clean it up better FIXME
+ delete m_View;
+ m_View = 0;
+ delete m_boxToolbar;
+ delete m_homeButton;
+ delete m_docButton;
+ delete m_location;
+ delete m_up;
+ delete m_pseudo;
+ delete m_pseudoLayout;
+ m_boxToolbar = 0;
+ m_homeButton = 0;
+ m_docButton = 0;
+ m_location = 0;
+ m_up = 0;
+ m_pseudo = 0;
+ m_pseudoLayout = 0;
+ // time for the toolbar
+ m_pseudo = new QWidget(m_stack, "Pseudo Widget");
+ m_pseudoLayout = new QVBoxLayout(m_pseudo );
+ if(m_shTool ){
+ m_boxToolbar = new QHBoxLayout( );
+ m_boxToolbar->setAutoAdd( true );
+ m_location = new QComboBox(m_pseudo );
+
+ m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton");
+ m_up->setMinimumSize( QSize( 20, 20 ) );
+ m_up->setMaximumSize( QSize( 20, 20 ) );
+ connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
+ m_up->setFlat(TRUE);
+
+ m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo);
+ m_homeButton->setMinimumSize( QSize( 20, 20 ) );
+ m_homeButton->setMaximumSize( QSize( 20, 20 ) );
+ connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
+ m_homeButton->setFlat(TRUE);
+
+ m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton");
+ m_docButton->setMinimumSize( QSize( 20, 20 ) );
+ m_docButton->setMaximumSize( QSize( 20, 20 ) );
+ connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
+ m_docButton->setFlat(TRUE);
+
+ m_boxToolbar->addWidget(m_location );
+ m_boxToolbar->addWidget(m_up );
+ m_boxToolbar->addWidget(m_homeButton );
+ m_boxToolbar->addWidget(m_docButton );
+ m_pseudoLayout->addLayout(m_boxToolbar );
+ // lets fill the 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 );
+ }
+ };
+ m_View = new QListView(m_pseudo, "Extended view" );
+ m_stack->addWidget( m_pseudo, EXTENDED );
m_stack->raiseWidget( EXTENDED );
+ m_pseudoLayout->addWidget(m_View );
QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold);
// set up the stuff
// Pixmap Name Date Size mime
//(m_View->header() )->hide();
//m_View->setRootIsDecorated(false);
m_View->addColumn(" ");
m_View->addColumn(tr("Name") );
m_View->addColumn(tr("Size") );
m_View->addColumn(tr("Date"), 60 );
m_View->addColumn(tr("Mime Type") );
QHeader *header = m_View->header();
header->hide();
m_View->setSorting(1 );
// connect now
connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) );
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 ) ) );
+
+
};
/* If a item is locked depends on the mode
if we're in OPEN !isReadable is locked
if we're in SAVE !isWriteable is locked
*/
void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){
qWarning("Add Files" );
if( !m_files ){
@@ -788,66 +927,78 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &
if(m_shLne )
m_edit->setText(str[0] );
emit fileSelected(str[0] );
// emit DocLnk need to do it
}
}else{
qWarning( "locked" );
}
};
}
void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
{
+ if (item == 0 )
+ return;
+
if( button != Qt::RightButton )
return;
qWarning("right button" );
slotContextMenu(item);
}
void OFileSelector::slotContextMenu(QListViewItem *item)
{
qWarning("context menu" );
+ if( item ==0 || !m_showPopup )
+ return;
+
if( m_custom !=0){
m_custom->exec();
}else{
QPopupMenu menu;
+ QAction up;
+ up.setText("cd up");
+ up.addTo( &menu );
+ connect(&up, SIGNAL(activated() ),
+ this, SLOT(cdUP() ) );
+
QAction act;
OFileSelectorItem *sel = (OFileSelectorItem*)item;
if(sel->isDir() ){
act.setText( tr("Change Directory") );
act.addTo(&menu );
connect(&act, SIGNAL(activated() ),
this, SLOT(slotChangedDir() ) );
}else{
act.setText( tr("Open file" ) );
act.addTo( &menu );
connect(&act, SIGNAL(activated() ),
this, SLOT(slotOpen() ) );
}
QAction rescan;
rescan.setText( tr("Rescan") );
rescan.addTo( &menu );
- connect(&act, SIGNAL(activated() ),
+ connect(&rescan, SIGNAL(activated() ),
this, SLOT(slotRescan() ) );
QAction rename;
rename.setText( tr("Rename") );
rename.addTo( &menu );
- connect(&act, SIGNAL(activated() ),
+ connect(&rename, SIGNAL(activated() ),
this, SLOT(slotRename() ) );
menu.insertSeparator();
QAction delItem;
delItem.setText( tr("Delete") );
delItem.addTo(&menu );
- connect(&act, SIGNAL(activated() ),
+ connect(&delItem, SIGNAL(activated() ),
this, SLOT(slotDelete() ) );
menu.exec(QCursor::pos() );
}
}
bool OFileSelector::cd(const QString &str )
{
qWarning(" dir %s", str.latin1() );
QDir dir( str);
if(dir.exists() ){
m_currentDir = str;
reparse();
@@ -886,15 +1037,23 @@ 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 ") + list[0];
::system(str.utf8().data() );
}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();
+ }
+}
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 458e552..b91c0ea 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -146,25 +146,26 @@ class OFileSelector : public QWidget {
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;
@@ -186,30 +187,32 @@ class OFileSelector : public QWidget {
protected slots:
void slotOk();
void slotCancel();
void slotViewCheck(const QString & );
void slotMimeCheck(const QString & );
protected:
void init();
void updateMimes();
protected:
private:
-int m_mode, m_selector;
+ 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;
QListView *m_View;
QCheckBox *m_checkPerm;
+ QWidget *m_pseudo;
+ QVBoxLayout *m_pseudoLayout;
QString m_currentDir;
QString m_name;
QStringList m_mimetypes;
FileSelector *m_select;
QWidgetStack *m_stack;
QVBoxLayout *m_lay;
QGridLayout *m_Oselector;
QHBoxLayout *m_boxToolbar;
QHBoxLayout *m_boxOk;
@@ -221,24 +224,25 @@ int m_mode, m_selector;
QLineEdit *m_edit;
QLabel *m_fnLabel;
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;
// implementation todo
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 initPics();
bool compliesMime(const QString &path, const QString &mime);
@@ -253,18 +257,19 @@ private slots:
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 crap see above
// PopupMenu crap
virtual void slotChangedDir();
virtual void slotOpen();
virtual void slotRescan();
virtual void slotRename();
virtual void slotDelete();
+ virtual void cdUP();
};
#endif