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.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 2275388..3e3cc3a 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -4,62 +4,71 @@
**
** 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.
**
****************************************************************************/
#include "fileBrowser.h"
#include <qpe/config.h>
+#include <qpe/resource.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <unistd.h>
fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "fileBrowser" );
- resize( 236, 280 );
+ resize( 240, 280 );
setCaption(tr( "Browse for file" ) );
filterStr=filter;
+
dirLabel = new QLabel(this, "DirLabel");
dirLabel->setText(currentDir.canonicalPath());
- dirLabel->setGeometry(10,4,230,30);
+ dirLabel->setGeometry(10,20,230,15);
+
+ QPushButton *homeButton;
+ homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
+ homeButton->setGeometry(200,4,25,25);
+ connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
+
ListView = new QListView( this, "ListView" );
ListView->addColumn( tr( "Name" ) );
ListView->setColumnWidth(0,140);
ListView->setSorting( 2, FALSE);
ListView->addColumn( tr( "Size" ) );
ListView->setColumnWidth(1,59);
// ListView->addColumn( tr( "" ) );
ListView->setColumnWidthMode(0,QListView::Manual);
ListView->setColumnAlignment(1,QListView::AlignRight);
// ListView->setMultiSelection(true);
// ListView->setSelectionMode(QListView::Extended);
ListView->setAllColumnsShowFocus( TRUE );
ListView->setGeometry( QRect( 10, 35, 220, 240 ) );
// signals and slots connections
connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
currentDir.setPath(QDir::currentDirPath());
populateList();
+ move(0,15);
}
fileBrowser::~fileBrowser()
{
}
void fileBrowser::populateList()
{
ListView->clear();
//qDebug(currentDir.canonicalPath());
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
@@ -85,25 +94,25 @@ void fileBrowser::populateList()
// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
fileS.sprintf( "%10li", fi->size() );
fileL.sprintf( "%s",fi->fileName().data() );
if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
// qDebug(currentDir.canonicalPath()+fileL);
}
}
item= new QListViewItem( ListView,fileL,fileS );
++it;
}
ListView->setSorting( 2, FALSE);
- dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath());
+ dirLabel->setText(currentDir.canonicalPath());
}
void fileBrowser::upDir()
{
// qDebug(currentDir.canonicalPath());
}
void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
{
}
// you may want to switch these 2 functions. I like single clicks
@@ -153,12 +162,19 @@ void fileBrowser::listClicked(QListViewItem *selectedItem)
void fileBrowser::OnOK()
{
QListViewItemIterator it1( ListView);
for ( ; it1.current(); ++it1 ) {
if ( it1.current()->isSelected() ) {
selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
qDebug("selected filename is "+selectedFileName);
fileList.append( selectedFileName );
}
}
accept();
}
+
+void fileBrowser::homeButtonPushed() {
+ chdir( QDir::homeDirPath().latin1() );
+ currentDir.cd( QDir::homeDirPath(), TRUE);
+ populateList();
+ update();
+}