summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/ofileselector/ofiledialog.cpp4
-rw-r--r--libopie/ofileselector/ofilelistview.cpp43
-rw-r--r--libopie/ofileselector/ofileselector.cpp48
-rw-r--r--libopie/ofileselector/ofileselector.h2
-rw-r--r--libopie/ofileselector/ofileview.cpp3
-rw-r--r--libopie/ofileselector/ofileview.h2
6 files changed, 65 insertions, 37 deletions
diff --git a/libopie/ofileselector/ofiledialog.cpp b/libopie/ofileselector/ofiledialog.cpp
index 4783004..430def2 100644
--- a/libopie/ofileselector/ofiledialog.cpp
+++ b/libopie/ofileselector/ofiledialog.cpp
@@ -60,57 +60,57 @@ OFileDialog::OFileDialog(const QString &caption,
file->setYesCancelVisible( false ); // relayout
}
QString OFileDialog::mimetype()const
{
return QString::null;
}
QString OFileDialog::fileName()const
{
return file->selectedName();
}
DocLnk OFileDialog::selectedDocument()const
{
return file->selectedDocument();
}
QString OFileDialog::getOpenFileName(int selector,
const QString &startDir,
const QString &file,
const MimeTypes &mimes,
QWidget *wid,
const QString &caption )
{
QString ret;
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() )
ret = dlg.fileName();
return ret;
}
QString OFileDialog::getSaveFileName(int selector,
const QString &startDir,
const QString &file,
const MimeTypes &mimes,
QWidget *wid,
const QString &caption )
{
QString ret;
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() )
ret = dlg.fileName();
return ret;
}
void OFileDialog::slotFileSelected(const QString & )
{
accept();
}
void OFileDialog::slotDirSelected(const QString & )
{
// if mode
//accept();
}
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp
index 0c7d45b..7108a5b 100644
--- a/libopie/ofileselector/ofilelistview.cpp
+++ b/libopie/ofileselector/ofilelistview.cpp
@@ -1,118 +1,125 @@
+#include <qpe/mimetype.h>
+#include <qpe/resource.h>
+
#include "ofileselector.h"
#include "ofileselectoritem.h"
#include "ofilelistview.h"
OFileListView::OFileListView( QWidget* parent, OFileSelector* sel)
: QListView( parent ), OFileView( sel )
{
}
OFileListView::~OFileListView() {
}
void OFileListView::clear() {
QListView::clear();
}
-void OFileListView::addFile( const QString& mime,
+void OFileListView::addFile( const QString&,
QFileInfo* info,
bool isSymlink ) {
MimeType type( info->absFilePath() );
QPixmap pix = type.pixmap();
QString dir;
QString name;
bool locked = false;
if( pix.isNull() )
pix = Resource::loadPixmap( "UnknownDocument-14");
dir = info->dirPath( true );
if( isSymlink )
name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
else {
name = info->fileName();
- if( ( selector()->mode() == Open && !info->isReadable() )||
- ( selector()->mode() == Save && !info->isWritable() ) ){
+ if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) ||
+ ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){
locked = true; pix = Resource::loadPixmap("locked");
}
}
new OFileSelectorItem( this, pix, name,
info->lastModified().toString(),
QString::number( info->size() ),
dir, locked );
}
void OFileListView::addFile( const QString& /*mime*/, const QString& /*dir*/,
const QString& /*file*/, bool /*isSyml*/ ) {
}
-void OFileListView::addDir( const QString& mime,
- QFileInfo* info, bool isSym ) {
+void OFileListView::addDir( const QString&,
+ QFileInfo* info, bool symlink ) {
bool locked = false;
QString name;
QPixmap pix;
- if( ( selector()->mode() == Open && !info->isReadable() ) ||
- ( selector()->mode() == Save && !info->isWritable() ) ){
+ if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) ||
+ ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){
locked = true;
if( symlink )
pix = selector()->pixmap("symlinkedlocked");
else
pix = Resource::loadPixmap("lockedfolder");
}else { // readable
pix = symlink ? selector()->pixmap("dirsymlink") : Resource::loadPixmap("folder") ;
}
name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ;
new OFileSelectorItem( this, pix, name,
info->lastModified().toString(),
QString::number( info->size() ),
info->dirPath( true ), locked,
true );
}
-void OFileListView::addDir( const QString& mime, const QString& dir,
- const QString& file, bool ) {
+void OFileListView::addDir( const QString& /*mime*/, const QString& /*dir*/,
+ const QString& /*file*/, bool ) {
}
-void OFileListView::addSymlink( const QString& mime,
- QFileInfo* info,
- bool isSym ) {
+void OFileListView::addSymlink( const QString& /*mime*/,
+ QFileInfo* /*info*/,
+ bool /*isSym*/ ) {
}
-void OFileListView::addSymlink( const QString& mime, const QString& path,
- const QString& file, bool isSym ) {
+void OFileListView::addSymlink( const QString& /*mime*/, const QString& /*path*/,
+ const QString& /*file*/, bool /*isSym*/ ) {
}
void OFileListView::cd( const QString& ) {
}
QWidget* OFileListView::widget() {
return this;
}
QString OFileListView::selectedName()const{
QListViewItem *item = currentItem();
if (!item )
return QString::null;
return item->text( 1 );
}
QStringList OFileListView::selectedNames()const {
-
+ QStringList list;
+ list << selectedName();
+ return list;
}
QString OFileListView::selectedPath()const {
-
+ return QString::null;
}
-QString OFileListView::selectedPaths()const {
-
+QStringList OFileListView::selectedPaths()const {
+ QStringList list;
+ list << selectedPath();
+ return list;
}
int OFileListView::fileCount() {
return childCount();
}
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
index f655606..16ee3ee 100644
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -240,192 +240,193 @@ void OFileSelector::setShowFiles(bool show )
///
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 ExtendedAll:
text = tr("All Files");
break;
}
slotViewCheck( text );
}
-void OFileSelector::setPopupFactory(OPopupMenuFactory *popup )
+void OFileSelector::setPopupFactory(OPopupMenuFactory */*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 == ExtendedAll ){
+ }else {
if ( m_shLne ) {
name = m_currentDir + "/" +m_edit->text();
}else{
name = m_currentDir + "/" + currentView()->selectedName();
}
}
return name;
}
QStringList OFileSelector::selectedNames()const
{
QStringList list;
if( m_selector == Normal ){
list << selectedName();
}else {
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 == ExtendedAll ){
- ; //FIXME
- }
+ } /*else if( m_selector == Extended || m_selector == ExtendedAll ){
+ ;
+ }*/
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()
{
int count;
switch( m_selector ){
case Normal:
count = m_select->fileCount();
break;
case Extended:
case ExtendedAll:
default:
- count = currentView()->childCount();
+ count = currentView()->fileCount();
break;
}
return count;
}
DocLnk OFileSelector::selectedDocument() const
{
DocLnk lnk;
switch( m_selector ){
case Normal:{
lnk = m_select->selectedDocument();
break;
}
case Extended:
case ExtendedAll:
default:
- lnk = DocLnk( selectedName() ); // new DocLnk
+ lnk = DocLnk( selectedName() );
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();
}
+/* switch the views */
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 = ExtendedAll;
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 ){
@@ -610,60 +611,60 @@ void OFileSelector::initVars()
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)
+void OFileSelector::addFile(const QString &, QFileInfo *info, bool )
{
if(!m_files)
return;
// if( !compliesMime(info->absFilePath(), mime ) )
// return;
MimeType type( info->absFilePath() );
if (!compliesMime( type.id() ) )
return;
}
-void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
+void OFileSelector::addDir(const QString &, QFileInfo *, bool )
{
if(!m_dir)
return;
}
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 );
@@ -904,183 +905,191 @@ bool OFileSelector::compliesMime( const QString& mime ) {
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;
- int pos2;
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 )
+void OFileSelector::slotCurrentChanged(QListViewItem* /*item*/ )
{
+ /*
if( item == 0 )
return;
if( m_selector == Extended || m_selector == ExtendedAll ) {
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)
+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 ExtendedAll:{
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::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( )
@@ -1189,58 +1198,65 @@ void OFileSelector::reparse()
}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
m_View->sort();
if( m_shTool ){
m_location->insertItem( m_currentDir );
}
// reenable painting and updates
}
OFileView* OFileSelector::currentView() {
return 0l;
}
+OFileView* OFileSelector::currentView() const{
+ return 0l;
+}
int OFileSelector::filter() {
int filter;
if ( m_selector == ExtendedAll )
filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
else
filter = QDir::Files | QDir::Dirs | QDir::All ;
return filter;
}
int OFileSelector::sorting() {
int sort;
if (m_case )
sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed );
else
sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed );
return sort;
}
void OFileSelector::internFileSelected( const QString& s) {
emit fileSelected( s );
}
void OFileSelector::internFileSelected( const DocLnk& d ) {
emit fileSelected( d );
}
void OFileSelector::internContextMenu() {
emit contextMenu();
}
void OFileSelector::internChangedDir( const QString& s) {
emit dirSelected( s );
}
void OFileSelector::internChangedDir( const QDir& s) {
emit dirSelected( s );
}
+QPixmap OFileSelector::pixmap( const QString& s ) {
+
+ return (*m_pixmaps)[s];
+}
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h
index 937569d..12af732 100644
--- a/libopie/ofileselector/ofileselector.h
+++ b/libopie/ofileselector/ofileselector.h
@@ -315,50 +315,52 @@ class OFileSelector : public QWidget {
* return the complete to the file
*/
QString selectedPath() const;
/**
* return the completed paths
*/
QStringList selectedPaths() const;
/**
* the current directory
*/
QString directory()const;
/**
* fileCount
*/
int fileCount();
DocLnk selectedDocument()const;
QValueList<DocLnk> selectedDocuments()const;
OFileView* currentView();
+ OFileView* currentView()const;
int filter();
int sorting();
+ QPixmap pixmap( const QString& );
signals:
void fileSelected( const DocLnk & );
void fileSelected( const QString & );
void dirSelected(const QString &dir );
void dirSelected( const QDir& );
void closeMe();
void ok();
void cancel();
void contextMenu();
private slots:
void slotOk();
void slotCancel();
void slotViewCheck(const QString & );
void slotMimeCheck(const QString & );
void slotLocationActivated(const QString & );
void slotInsertLocationPath(const QString &, int);
void locationComboChanged();
private:
void init();
void updateMimes();
diff --git a/libopie/ofileselector/ofileview.cpp b/libopie/ofileselector/ofileview.cpp
index 71843c1..9bb40c9 100644
--- a/libopie/ofileselector/ofileview.cpp
+++ b/libopie/ofileselector/ofileview.cpp
@@ -5,24 +5,27 @@
#include "ofileview.h"
OFileView::OFileView( OFileSelector* sel)
: m_sel( sel )
{
}
OFileView::~OFileView() {
}
void OFileView::fileSelected( const QString& s ) {
m_sel->internFileSelected( s );
}
void OFileView::fileSelected( const DocLnk& s) {
m_sel->internFileSelected( s );
}
void OFileView::contextMenu() {
m_sel->internContextMenu();
}
void OFileView::changedDir( const QString& s) {
m_sel->internChangedDir( s );
}
void OFileView::changedDir( const QDir& d ) {
m_sel->internChangedDir( d );
}
+OFileSelector* OFileView::selector() const {
+ return m_sel;
+}
diff --git a/libopie/ofileselector/ofileview.h b/libopie/ofileselector/ofileview.h
index 997266a..1b397f5 100644
--- a/libopie/ofileselector/ofileview.h
+++ b/libopie/ofileselector/ofileview.h
@@ -69,41 +69,41 @@ public:
QFileInfo *info,
bool isSymlink = FALSE ) = 0;
virtual void addSymlink(const QString& mine,
const QString& path,
const QString& file,
bool isSymlink = FALSE ) = 0;
virtual void cd(const QString &path ) = 0;
virtual QWidget* widget() = 0;
virtual QString selectedName()const = 0;
virtual QStringList selectedNames()const = 0;
virtual QString selectedPath()const = 0;
virtual QStringList selectedPaths()const = 0;
virtual int fileCount() = 0;
/*signals:*/
protected:
void fileSelected(const QString &);
void fileSelected(const DocLnk & );
void contextMenu();
void changedDir(const QString &);
void changedDir(const QDir & );
- OFileSelector* selector();
+ OFileSelector* selector()const;
private:
OFileSelector* m_sel;
};
class OFileViewFactory {
public:
OFileViewFactory() {} ;
virtual ~OFileViewFactory() = 0;
OFileView* newView(QWidget *parent, const char *name );
QString name()const;
};
#endif