summaryrefslogtreecommitdiff
path: root/core/apps/textedit/fileBrowser.cpp
Side-by-side diff
Diffstat (limited to 'core/apps/textedit/fileBrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 8ea8067..652f830 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -2,25 +2,25 @@
** copyright 2001 ljp ljp@llornkcor.com
** Created: Fri Dec 14 08:16:46 2001
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
-#define QTOPIA_INTERNAL_MIMEEXT
+//#define QTOPIA_INTERNAL_MIMEEXT
#include "fileBrowser.h"
//#include "inputDialog.h"
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/fileselector.h>
#include <qpe/qpeapplication.h>
#include <qpe/menubutton.h>
#include <qpe/mimetype.h>
#include <qdict.h>
#include <qwidgetstack.h>
@@ -41,43 +41,50 @@
static int u_id = 1;
static int get_unique_id()
{
return u_id++;
}
fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "fileBrowser" );
setCaption(tr( name ) );
- mimeType = mimeFilter;
- MimeType mt( mimeType);
- if( mt.extension().isEmpty())
- filterStr = "*";
- else
- filterStr = "*."+ mt.extension();
+// mimeType = mimeFilter;
+// MimeType mt( mimeType);
+// if( mt.extension().isEmpty())
+ QStringList filterList;
+ filterList=QStringList::split(";",mimeFilter,FALSE);
+ for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) {
+ printf( "%s \n", (*it).latin1() );
+ }
+
+ filterStr = mimeFilter.right(mimeFilter.length()- mimeFilter.find("/",0,TRUE) - 1);// "*";
+ qDebug(filterStr);
+// else
+// filterStr = "*."+ mt.extension();
// qDebug("description "+mt.description());
// qDebug( "id "+mt.id());
// qDebug("extension "+mt.extension());
// channel = new QCopChannel( "QPE/fileDialog", this );
// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
// this, SLOT(receive(const QCString&, const QByteArray&)) );
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 4 );
layout->setMargin( 4 );
- dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" );
+ dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" );
dirPathCombo->setEditable(TRUE);
connect( dirPathCombo, SIGNAL( activated( const QString & ) ),
this, SLOT( dirPathComboActivated( const QString & ) ) );
connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ),
this, SLOT( dirPathEditPressed( ) ) );
dirPathStringList << "/";
// we can get the storage here
layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 );
@@ -121,25 +128,26 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold);
connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
FileStack->addWidget( ListView, get_unique_id() );
fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
- connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
+ connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
+ this, SLOT( docOpen( const DocLnk & ) ) );
layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 );
SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" );
SelectionCombo->insertItem( tr( "Documents" ) );
SelectionCombo->insertItem( tr( "All files" ) );
SelectionCombo->insertItem( tr( "Hidden files" ) );
// SelectionCombo->setMaximumWidth(120);
layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 );
connect( SelectionCombo, SIGNAL( activated( const QString & ) ),
this, SLOT( selectionChanged( const QString & ) ) );
@@ -207,25 +215,25 @@ void fileBrowser::populateList()
if(isDir || fileL.find("/",0,TRUE) != -1) {
if( !QDir( fi->filePath() ).isReadable())
pm = Resource::loadPixmap( "lockedfolder" );
else
pm= Resource::loadPixmap( "folder" );
item->setPixmap( 0,pm );
} else {
if( !fi->isReadable() )
pm = Resource::loadPixmap( "locked" );
else {
MimeType mt(fi->filePath());
- pm=mt.pixmap();
+ pm=mt.pixmap();// sets the pixmap for the mimetype
if(pm.isNull())
pm = Resource::loadPixmap( "UnknownDocument-14" );
item->setPixmap( 0,pm);
}
}
if( fileL.find("->",0,TRUE) != -1) {
// overlay link image
pm= Resource::loadPixmap( "folder" );
QPixmap lnk = Resource::loadPixmap( "symlink" );
QPainter painter( &pm );
painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
pm.setMask( pm.createHeuristicMask( FALSE ) );
@@ -408,25 +416,25 @@ void fileBrowser::makDir() {
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
qDebug("Make dir");
currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
}
populateList();
}
void fileBrowser::localRename() {
QString curFile = ListView->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,"Rename",TRUE, 0);
- fileDlg->inputText = curFile;
+ fileDlg->setTextEdit((const QString &) curFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString oldname = currentDir.canonicalPath() + "/" + curFile;
QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
if( rename(oldname.latin1(), newName.latin1())== -1)
QMessageBox::message("Note","Could not rename");
}
populateList();
}
void fileBrowser::localDelete() {
QString f = ListView->currentItem()->text(0);
@@ -483,32 +491,32 @@ void fileBrowser::updateMimeTypeMenu() {
void fileBrowser::showType(const QString &t) {
qDebug(t);
if(t.find("All",0,TRUE) != -1) {
filterStr = "*";
} else {
QStringList list = mimetypes.grep( t,TRUE);
QString ext;
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
mimeType =(*it);
MimeType mt( mimeType);
- qDebug("mime "+mimeType);
+// qDebug("mime "+mimeType);
// qDebug("description "+mt.description());
// qDebug( "id "+mt.id());
- qDebug("extension "+mt.extension());
- if( mt.extension().isEmpty())
+// qDebug("extension "+mt.extension());
+// if( mt.extension().isEmpty())
filterStr = "*";
- else
- filterStr = "*."+ mt.extension()+" ";
+// else
+// filterStr = "*."+ mt.extension()+" ";
// printf( "%s \n", (*it).latin1() );
}
}
currentDir.setNameFilter(filterStr);
populateList();
update();
// if(fileSelector) {
// disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
// delete fileSelector;
// }
// fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
@@ -602,12 +610,15 @@ InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags
setCaption( tr(name ) );
LineEdit1 = new QLineEdit( this, "LineEdit1" );
LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
}
InputDialog::~InputDialog()
{
inputText= LineEdit1->text();
}
+void InputDialog::setTextEdit(const QString &string) {
+ LineEdit1->setText(string);
+}