summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/filebrowser/Makefile.in2
-rw-r--r--noncore/unsupported/filebrowser/filePermissions.cpp274
-rw-r--r--noncore/unsupported/filebrowser/filePermissions.h56
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.cpp422
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.h12
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.pro7
6 files changed, 566 insertions, 207 deletions
diff --git a/noncore/unsupported/filebrowser/Makefile.in b/noncore/unsupported/filebrowser/Makefile.in
index c00d0f5..d1f80b7 100644
--- a/noncore/unsupported/filebrowser/Makefile.in
+++ b/noncore/unsupported/filebrowser/Makefile.in
@@ -119,6 +119,8 @@ inlineedit.o: inlineedit.cpp \
main.o: main.cpp \
filebrowser.h \
$(OPIEDIR)/include/qpe/qpeapplication.h \
+ $(OPIEDIR)/include/qpedecoration_qws.h \
+ $(OPIEDIR)/include/timestring.h \
$(OPIEDIR)/include/qpe/mimetype.h
moc_inlineedit.o: moc_inlineedit.cpp \
diff --git a/noncore/unsupported/filebrowser/filePermissions.cpp b/noncore/unsupported/filebrowser/filePermissions.cpp
new file mode 100644
index 0000000..1938b84
--- a/dev/null
+++ b/noncore/unsupported/filebrowser/filePermissions.cpp
@@ -0,0 +1,274 @@
+/****************************************************************************
+** copyright 2002 ljp ljp@llornkcor.com
+** Created: Sat Feb 23 19:44:40 2002 L.J. Potter
+**
+** 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 "filePermissions.h"
+
+#include <qfile.h>
+#include <qfileinfo.h>
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qmessagebox.h>
+
+#include <unistd.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+
+filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName )
+ : QDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "filePermissions" );
+ qDebug("FilePermissions "+fileName);
+ resize( 236, 210 );
+ setMaximumSize( QSize( 236, 210 ) );
+ setCaption( tr( "Set File Permissions" ) );
+
+ TextLabel1 = new QLabel( this, "TextLabel1" );
+ TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) );
+ TextLabel1->setText( tr( "Set file permissions for:" ) );
+
+ LineEdit1 = new QLineEdit( this, "LineEdit1" );
+ LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) );
+ LineEdit1->setReadOnly(true);
+
+ TextLabel4 = new QLabel( this, "TextLabel4" );
+ TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) );
+ TextLabel4->setText( tr( "owner" ) );
+
+ TextLabel4_2 = new QLabel( this, "TextLabel4_2" );
+ TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) );
+ TextLabel4_2->setText( tr( "group" ) );
+
+ TextLabel4_3 = new QLabel( this, "TextLabel4_3" );
+ TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) );
+ TextLabel4_3->setText( tr( "others" ) );
+
+ CheckBox1 = new QCheckBox( this, "CheckBox1" );
+ CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) );
+ connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck()));
+
+ CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" );
+ CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) );
+ connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck()));
+
+ CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" );
+ CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) );
+ connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck()));
+
+ CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" );
+ CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) );
+ connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck()));
+
+ CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" );
+ CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) );
+ connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck()));
+
+ CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" );
+ CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) );
+ connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck()));
+
+ CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" );
+ CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) );
+ connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck()));
+
+ CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" );
+ CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) );
+ connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck()));
+
+ CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" );
+ CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) );
+ connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck()));
+
+ GroupLineEdit = new QLineEdit( this, "GroupLineEdit" );
+ GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) );
+
+ OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" );
+ OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) );
+
+ TextLabel5 = new QLabel( this, "TextLabel5" );
+ TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) );
+ TextLabel5->setText( tr( "Owner" ) );
+
+ TextLabel5_2 = new QLabel( this, "TextLabel5_2" );
+ TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) );
+ TextLabel5_2->setText( tr( "Group" ) );
+
+ ModeLine = new QLineEdit( this, "TextLabelMode" );
+ ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) );
+
+ TextLabel3_2 = new QLabel( this, "TextLabel3_2" );
+ TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) );
+ TextLabel3_2->setText( tr( "read" ) );
+ TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
+
+ TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" );
+ TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) );
+ TextLabel3_2_2->setText( tr( "write" ) );
+ TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
+
+ TextLabel3 = new QLabel( this, "TextLabel3" );
+ TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) );
+ TextLabel3->setText( tr( "execute" ) );
+ TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
+
+ struct stat buf;
+ mode_t mode;
+ file = fileName;
+ QFileInfo fi(file);
+
+ LineEdit1->setText( file);
+ OwnerLineEdit->setText( fi.owner());
+ GroupLineEdit->setText( fi.group());
+
+ if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); }
+ if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); }
+ if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); }
+
+ if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); }
+ if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); }
+ if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); }
+
+ if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); }
+ if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); }
+ if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); }
+
+ lstat(file.latin1(), &buf);
+ mode = buf.st_mode;
+ modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) );
+ ModeLine->setText(modeStr);
+ bool ok;
+ i_mode = modeStr.toInt(&ok,10);
+
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+filePermissions::~filePermissions()
+{
+}
+
+
+// might this be better as a callback routine???
+void filePermissions::ownReadCheck() {
+ if(CheckBox1->isChecked()) { i_mode +=400; }
+ else i_mode -=400;
+ modeStr.sprintf("0%d",i_mode);
+ ModeLine->setText( modeStr);
+// 0400
+}
+
+void filePermissions::ownWriteCheck() {
+ if(CheckBox1_2->isChecked()) { i_mode +=200; }
+ else i_mode -=200;
+ modeStr.sprintf("0%d",i_mode);
+ ModeLine->setText(modeStr);
+// 0200
+}
+
+void filePermissions::ownExeCheck() {
+ if(CheckBox1_3->isChecked()) { i_mode +=100; }
+ else i_mode -=100;
+ modeStr.sprintf("0%d",i_mode);
+ ModeLine->setText(modeStr);
+// 0100
+}
+
+void filePermissions::grpReadCheck() {
+ if(CheckBox1_4->isChecked()) { i_mode +=40; }
+ else i_mode -=40;
+ modeStr.sprintf("0%d",i_mode);
+ ModeLine->setText(modeStr);
+// 0040
+}
+
+void filePermissions::grpWriteCheck() {
+ if(CheckBox1_5->isChecked()) { i_mode +=20; }
+ else i_mode -=20;
+ modeStr.sprintf("0%d",i_mode);
+ ModeLine->setText(modeStr);
+// 0020
+}
+
+void filePermissions::grpExeCheck() {
+ if(CheckBox1_6->isChecked()) { i_mode +=10; }
+ else i_mode -=10;
+ modeStr.sprintf("0%d",i_mode);
+ ModeLine->setText(modeStr);
+// 0010
+}
+
+void filePermissions::wrldReadCheck() {
+ if(CheckBox1_7->isChecked()) { i_mode +=4; }
+ else i_mode -=4;
+ modeStr.sprintf("0%d",i_mode);
+ ModeLine->setText(modeStr);
+// 0004
+}
+
+void filePermissions::wrldWriteCheck() {
+ if(CheckBox1_8->isChecked()) { i_mode +=2; }
+ else i_mode -=2;
+ modeStr.sprintf("0%d",i_mode);
+ ModeLine->setText(modeStr);
+// 0002
+}
+
+void filePermissions::wrldExeCheck() {
+ if(CheckBox1_8_2->isChecked()) { i_mode +=1; }
+ else i_mode -=1;
+ modeStr.sprintf("0%d",i_mode);
+ ModeLine->setText(modeStr);
+// 0001
+}
+
+void filePermissions::accept() {
+
+ QFileInfo fi(file);
+ struct passwd *pwd=0;
+ struct group *grp=0;
+ pwd = getpwnam(OwnerLineEdit->text().latin1() );
+ if(pwd == NULL) {
+ perror("getpwnam");
+ QMessageBox::warning(this,"Warning","Error- no user");
+ return;
+ } else {
+ grp = getgrnam(GroupLineEdit->text().latin1());
+ if(grp==NULL) {
+ perror("getgrnam");
+ QMessageBox::warning(this,"Warning","Error- no group");
+ return;
+ }
+ if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) {
+ perror("chown");
+ QMessageBox::warning(this,"Warning","Error setting ownership or group");
+ return;
+ }
+ bool ok;
+ uint moder = modeStr.toUInt(&ok,8);
+ if( chmod( file.latin1(), moder) < 0) {
+ perror("chmod");
+ QMessageBox::warning(this,"Warning","Error setting mode");
+ return;
+ }
+ }
+ close();
+}
diff --git a/noncore/unsupported/filebrowser/filePermissions.h b/noncore/unsupported/filebrowser/filePermissions.h
new file mode 100644
index 0000000..880304f
--- a/dev/null
+++ b/noncore/unsupported/filebrowser/filePermissions.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+** copyright 2002 ljp ljp@llornkcor.com
+** Created: Sat Feb 23 19:44:17 2002
+**
+** 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.
+**
+****************************************************************************/
+#ifndef FILEPERMISSIONS_H
+#define FILEPERMISSIONS_H
+
+#include <qvariant.h>
+#include <qdialog.h>
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QCheckBox;
+class QLabel;
+class QLineEdit;
+class QString;
+
+class filePermissions : public QDialog
+{
+ Q_OBJECT
+
+public:
+ filePermissions( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 , const QString & fileName ="");
+ ~filePermissions();
+
+ QLineEdit *LineEdit1, *ModeLine;
+ QLabel *TextLabel1, *TextLabel4, *TextLabel4_2, *TextLabel4_3, *TextLabel3_2_2, *TextLabel3_2, *TextLabel3, *TextLabel5_2, *TextLabel5;
+ QCheckBox*CheckBox1, *CheckBox1_3, *CheckBox1_2, *CheckBox1_4, *CheckBox1_5, *CheckBox1_6, *CheckBox1_7, *CheckBox1_8, *CheckBox1_8_2;
+ QLineEdit*GroupLineEdit, *OwnerLineEdit;
+ QString modeStr, file;
+ int i_mode;
+private slots:
+ void ownReadCheck();
+ void ownWriteCheck();
+ void ownExeCheck();
+
+ void grpReadCheck();
+ void grpWriteCheck();
+ void grpExeCheck();
+
+ void wrldReadCheck();
+ void wrldWriteCheck();
+ void wrldExeCheck();
+ void accept();
+};
+
+#endif // FILEPERMISSIONS_H
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp
index 9439bb8..384d7da 100644
--- a/noncore/unsupported/filebrowser/filebrowser.cpp
+++ b/noncore/unsupported/filebrowser/filebrowser.cpp
@@ -20,7 +20,7 @@
#include "inlineedit.h"
#include "filebrowser.h"
-
+#include "filePermissions.h"
#include <qpe/resource.h>
#include <qpe/global.h>
#include <qpe/mimetype.h>
@@ -60,27 +60,27 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi )
MimeType mt(fi.filePath());
if( fi.isDir() )
- setText( 3, "directory" );
+ setText( 3, "directory" );
else if( isLib() )
- setText( 3, "library" );
+ setText( 3, "library" );
else
- setText( 3, mt.description() );
+ setText( 3, mt.description() );
QPixmap pm;
if( fi.isDir() ){
- if( !QDir( fi.filePath() ).isReadable() )
- pm = Resource::loadPixmap( "lockedfolder" );
- else
- pm = Resource::loadPixmap( "folder" );
+ if( !QDir( fi.filePath() ).isReadable() )
+ pm = Resource::loadPixmap( "lockedfolder" );
+ else
+ pm = Resource::loadPixmap( "folder" );
}
else if( !fi.isReadable() )
- pm = Resource::loadPixmap( "locked" );
+ pm = Resource::loadPixmap( "locked" );
else if( isLib() )
- pm = Resource::loadPixmap( "library" );
+ pm = Resource::loadPixmap( "library" );
else
- pm = mt.pixmap();
+ pm = mt.pixmap();
if ( pm.isNull() )
- pm = Resource::loadPixmap("UnknownDocument-14");
+ pm = Resource::loadPixmap("UnknownDocument-14");
setPixmap(0,pm);
}
@@ -89,13 +89,13 @@ QString FileItem::sizeString( unsigned int s )
double size = s;
if ( size > 1024 * 1024 * 1024 )
- return QString().sprintf( "%.1f", size / ( 1024 * 1024 * 1024 ) ) + "G";
+ return QString().sprintf( "%.1f", size / ( 1024 * 1024 * 1024 ) ) + "G";
else if ( size > 1024 * 1024 )
- return QString().sprintf( "%.1f", size / ( 1024 * 1024 ) ) + "M";
+ return QString().sprintf( "%.1f", size / ( 1024 * 1024 ) ) + "M";
else if ( size > 1024 )
- return QString().sprintf( "%.1f", size / ( 1024 ) ) + "K";
+ return QString().sprintf( "%.1f", size / ( 1024 ) ) + "K";
else
- return QString::number( size ) + "B";
+ return QString::number( size ) + "B";
}
QString FileItem::key( int column, bool ascending ) const
@@ -105,17 +105,17 @@ QString FileItem::key( int column, bool ascending ) const
ascending = ascending;
if( (column == 0) && fileInfo.isDir() ){ // Sort by name
- // We want the directories to appear at the top of the list
- tmp = (char) 0;
- return (tmp + text( column ).lower());
+ // We want the directories to appear at the top of the list
+ tmp = (char) 0;
+ return (tmp + text( column ).lower());
}
else if( column == 2 ) { // Sort by date
- QDateTime epoch( QDate( 1980, 1, 1 ) );
+ QDateTime epoch( QDate( 1980, 1, 1 ) );
tmp.sprintf( "%08d", epoch.secsTo( fileInfo.lastModified() ) );
- return tmp;
+ return tmp;
}
else if( column == 1 ) { // Sort by size
- return tmp.sprintf( "%08d", fileInfo.size() );
+ return tmp.sprintf( "%08d", fileInfo.size() );
}
return text( column ).lower();
@@ -125,11 +125,11 @@ bool FileItem::isLib()
{
// This is of course not foolproof
if( !qstrncmp("lib", fileInfo.baseName(), 3) &&
- ( fileInfo.extension().contains( "so" ) ||
- fileInfo.extension().contains( "a" ) ) )
- return TRUE;
+ ( fileInfo.extension().contains( "so" ) ||
+ fileInfo.extension().contains( "a" ) ) )
+ return TRUE;
else
- return FALSE;
+ return FALSE;
}
int FileItem::launch()
@@ -145,25 +145,25 @@ bool FileItem::rename( const QString & name )
QString oldpath, newpath;
if ( name.isEmpty() )
- return FALSE;
+ return FALSE;
if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) )
- return FALSE;
+ return FALSE;
oldpath = fileInfo.filePath();
newpath = fileInfo.dirPath() + "/" + name;
if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 )
- return FALSE;
+ return FALSE;
else
- return TRUE;
+ return TRUE;
}
//
// FileView
//
FileView::FileView( const QString & dir, QWidget * parent,
- const char * name )
+ const char * name )
: QListView( parent, name ),
menuTimer( this ),
le( NULL ),
@@ -186,9 +186,9 @@ FileView::FileView( const QString & dir, QWidget * parent,
generateDir( dir );
connect( this, SIGNAL( clicked( QListViewItem * )),
- SLOT( itemClicked( QListViewItem * )) );
+ SLOT( itemClicked( QListViewItem * )) );
connect( this, SIGNAL( doubleClicked( QListViewItem * )),
- SLOT( itemDblClicked( QListViewItem * )) );
+ SLOT( itemDblClicked( QListViewItem * )) );
connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
}
@@ -210,9 +210,9 @@ void FileView::updateDir()
void FileView::setDir( const QString & dir )
{
if ( dir.startsWith( "/dev" ) ) {
- QMessageBox::warning( this, tr( "File Manager" ),
- tr( "Can't show /dev/ directory." ), tr( "&Ok" ) );
- return;
+ QMessageBox::warning( this, tr( "File Manager" ),
+ tr( "Can't show /dev/ directory." ), tr( "&Ok" ) );
+ return;
}
dirHistory += currentDir;
generateDir( dir );
@@ -228,7 +228,7 @@ void FileView::generateDir( const QString & dir )
d.setFilter( QDir::Dirs | QDir::Files );
d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase |
- QDir::Reversed );
+ QDir::Reversed );
const QFileInfoList * list = d.entryInfoList();
QFileInfoListIterator it( *list );
@@ -236,12 +236,12 @@ void FileView::generateDir( const QString & dir )
clear();
while( (fi = it.current()) ){
- if( (fi->fileName() == ".") || (fi->fileName() == "..") ){
- ++it;
- continue;
- }
- (void) new FileItem( (QListView *) this, *fi );
- ++it;
+ if( (fi->fileName() == ".") || (fi->fileName() == "..") ){
+ ++it;
+ continue;
+ }
+ (void) new FileItem( (QListView *) this, *fi );
+ ++it;
}
emit dirChanged();
@@ -256,9 +256,9 @@ void FileView::rename()
if( itemToRename == NULL ) return;
if( ( pm = itemToRename->pixmap( 0 ) ) == NULL )
- pmw = 0;
+ pmw = 0;
else
- pmw = pm->width();
+ pmw = pm->width();
ensureItemVisible( itemToRename );
horizontalScrollBar()->setValue( 0 );
@@ -269,9 +269,9 @@ void FileView::rename()
setSelected( itemToRename, FALSE );
if( le == NULL ){
- le = new InlineEdit( this );
- le->setFrame( FALSE );
- connect( le, SIGNAL( lostFocus() ), SLOT( endRenaming() ) );
+ le = new InlineEdit( this );
+ le->setFrame( FALSE );
+ connect( le, SIGNAL( lostFocus() ), SLOT( endRenaming() ) );
}
QRect r = itemRect( itemToRename );
@@ -290,18 +290,18 @@ void FileView::rename()
void FileView::endRenaming()
{
if( le && itemToRename ){
- le->hide();
- setSelected( itemToRename, selected );
+ le->hide();
+ setSelected( itemToRename, selected );
- if( !itemToRename->rename( le->text() ) ){
- QMessageBox::warning( this, tr( "Rename file" ),
- tr( "Rename failed!" ), tr( "&Ok" ) );
- } else {
- updateDir();
- }
- itemToRename = NULL;
- horizontalScrollBar()->setEnabled( TRUE );
- verticalScrollBar()->setEnabled( TRUE );
+ if( !itemToRename->rename( le->text() ) ){
+ QMessageBox::warning( this, tr( "Rename file" ),
+ tr( "Rename failed!" ), tr( "&Ok" ) );
+ } else {
+ updateDir();
+ }
+ itemToRename = NULL;
+ horizontalScrollBar()->setEnabled( TRUE );
+ verticalScrollBar()->setEnabled( TRUE );
}
}
@@ -318,10 +318,10 @@ void FileView::copy()
flist.clear();
while( i ){
- if( i->isSelected() /*&& !i->isDir()*/ ){
- flist += i->getFilePath();
- }
- i = (FileItem *) i->nextSibling();
+ if( i->isSelected() /*&& !i->isDir()*/ ){
+ flist += i->getFilePath();
+ }
+ i = (FileItem *) i->nextSibling();
}
}
@@ -333,49 +333,49 @@ void FileView::paste()
if(cd == "/") cd = "";
for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) {
- basename = (*it).mid((*it).findRev("/") + 1, (*it).length());
-
- dest = cd + "/" + basename;
- if( QFile( dest ).exists() ){
- i = 1;
- dest = cd + "/Copy of " + basename;
- while( QFile( dest ).exists() ){
- dest.sprintf( "%s/Copy (%d) of %s", (const char *) cd, i++,
- (const char *) basename );
- }
- }
-
- //
- // Copy a directory recursively using the "cp" command -
- // may have to be changed
- //
- if( QFileInfo( (*it) ).isDir() ){
- cmd = "/bin/cp -fpR \"" + (*it) +"\" " + "\"" + dest + "\"";
- err = system( (const char *) cmd );
- } else if( !copyFile( dest, (*it) ) ){
- err = -1;
- } else {
- err = 0;
- }
-
- if ( err != 0 ) {
- QMessageBox::warning( this, tr("Paste file"), tr("Paste failed!"),
- tr("Ok") );
- break;
- } else {
- updateDir();
- QListViewItem * i = firstChild();
- basename = dest.mid( dest.findRev("/") + 1, dest.length() );
-
- while( i ){
- if( i->text(0) == basename ){
- setCurrentItem( i );
- ensureItemVisible( i );
- break;
- }
- i = i->nextSibling();
- }
- }
+ basename = (*it).mid((*it).findRev("/") + 1, (*it).length());
+
+ dest = cd + "/" + basename;
+ if( QFile( dest ).exists() ){
+ i = 1;
+ dest = cd + "/Copy of " + basename;
+ while( QFile( dest ).exists() ){
+ dest.sprintf( "%s/Copy (%d) of %s", (const char *) cd, i++,
+ (const char *) basename );
+ }
+ }
+
+ //
+ // Copy a directory recursively using the "cp" command -
+ // may have to be changed
+ //
+ if( QFileInfo( (*it) ).isDir() ){
+ cmd = "/bin/cp -fpR \"" + (*it) +"\" " + "\"" + dest + "\"";
+ err = system( (const char *) cmd );
+ } else if( !copyFile( dest, (*it) ) ){
+ err = -1;
+ } else {
+ err = 0;
+ }
+
+ if ( err != 0 ) {
+ QMessageBox::warning( this, tr("Paste file"), tr("Paste failed!"),
+ tr("Ok") );
+ break;
+ } else {
+ updateDir();
+ QListViewItem * i = firstChild();
+ basename = dest.mid( dest.findRev("/") + 1, dest.length() );
+
+ while( i ){
+ if( i->text(0) == basename ){
+ setCurrentItem( i );
+ ensureItemVisible( i );
+ break;
+ }
+ i = i->nextSibling();
+ }
+ }
}
}
@@ -390,26 +390,26 @@ bool FileView::copyFile( const QString & dest, const QString & src )
QFile d( dest );
if( s.open( IO_ReadOnly | IO_Raw ) &&
- d.open( IO_WriteOnly | IO_Raw ) )
+ d.open( IO_WriteOnly | IO_Raw ) )
{
- while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) ==
- sizeof( bf ) )
- {
- if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
- success = FALSE;
- break;
- }
- }
- if( success && (bytesRead > 0) ){
- d.writeBlock( bf, bytesRead );
- }
+ while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) ==
+ sizeof( bf ) )
+ {
+ if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
+ success = FALSE;
+ break;
+ }
+ }
+ if( success && (bytesRead > 0) ){
+ d.writeBlock( bf, bytesRead );
+ }
} else {
- success = FALSE;
+ success = FALSE;
}
// Set file permissions
if( stat( (const char *) src, &status ) == 0 ){
- chmod( (const char *) dest, status.st_mode );
+ chmod( (const char *) dest, status.st_mode );
}
return success;
@@ -421,13 +421,13 @@ void FileView::cut()
// ##### a better inmplementation might be to rename the CUT file
// ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it.
QString cmd, dest, basename, cd = "/tmp/qpemoving";
- QStringList newflist;
- newflist.clear();
-
- cmd = "rm -rf " + cd;
- system ( (const char *) cmd );
- cmd = "mkdir " + cd;
- system( (const char *) cmd );
+ QStringList newflist;
+ newflist.clear();
+
+ cmd = "rm -rf " + cd;
+ system ( (const char *) cmd );
+ cmd = "mkdir " + cd;
+ system( (const char *) cmd );
// get the names of the files to cut
FileItem * item;
@@ -448,7 +448,7 @@ void FileView::cut()
dest = cd + "/" + basename;
- newflist += dest;
+ newflist += dest;
cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\"";
err = system( (const char *) cmd );
@@ -473,8 +473,8 @@ void FileView::cut()
}
}
- // update the filelist to point to tmp dir so paste works nicely
- flist = newflist;
+ // update the filelist to point to tmp dir so paste works nicely
+ flist = newflist;
}
void FileView::del()
@@ -487,29 +487,29 @@ void FileView::del()
if((i = (FileItem *) firstChild()) == 0) return;
while( i ){
- if( i->isSelected() ){
- fl += i->getFilePath();
- }
- i = (FileItem *) i->nextSibling();
+ if( i->isSelected() ){
+ fl += i->getFilePath();
+ }
+ i = (FileItem *) i->nextSibling();
}
if( fl.count() < 1 ) return;
if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"),
- tr("Yes"), tr("No") ) == 0)
+ tr("Yes"), tr("No") ) == 0)
{
- //
- // Dependant upon the "rm" command - will probably have to be replaced
- //
- for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) {
- cmd = "/bin/rm -rf \"" + (*it) + "\"";
- err = system( (const char *) cmd );
- if ( err != 0 ) {
- QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"),
- tr("Ok") );
- break;
- }
- }
- updateDir();
+ //
+ // Dependant upon the "rm" command - will probably have to be replaced
+ //
+ for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) {
+ cmd = "/bin/rm -rf \"" + (*it) + "\"";
+ err = system( (const char *) cmd );
+ if ( err != 0 ) {
+ QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"),
+ tr("Ok") );
+ break;
+ }
+ }
+ updateDir();
}
}
@@ -520,26 +520,26 @@ void FileView::newFolder()
QString nd = currentDir + "/NewFolder";
while( QFile( nd ).exists() ){
- nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ );
+ nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ );
}
if( mkdir( (const char *) nd, 0777 ) != 0){
- QMessageBox::warning( this, tr( "New folder" ),
- tr( "Folder creation failed!" ),
- tr( "Ok" ) );
- return;
+ QMessageBox::warning( this, tr( "New folder" ),
+ tr( "Folder creation failed!" ),
+ tr( "Ok" ) );
+ return;
}
updateDir();
if((i = (FileItem *) firstChild()) == 0) return;
while( i ){
- if( i->isDir() && ( i->getFilePath() == nd ) ){
- setCurrentItem( i );
- rename();
- break;
- }
- i = (FileItem *) i->nextSibling();
+ if( i->isDir() && ( i->getFilePath() == nd ) ){
+ setCurrentItem( i );
+ rename();
+ break;
+ }
+ i = (FileItem *) i->nextSibling();
}
}
@@ -555,7 +555,7 @@ void FileView::itemClicked( QListViewItem * i)
if( t == NULL ) return;
if( t->isDir() ){
- setDir( t->getFilePath() );
+ setDir( t->getFilePath() );
}
}
@@ -565,8 +565,8 @@ void FileView::itemDblClicked( QListViewItem * i)
if(t == NULL) return;
if(t->launch() == -1){
- QMessageBox::warning( this, tr( "Launch Application" ),
- tr( "Launch failed!" ), tr( "Ok" ) );
+ QMessageBox::warning( this, tr( "Launch Application" ),
+ tr( "Launch failed!" ), tr( "Ok" ) );
}
}
@@ -599,7 +599,7 @@ void FileView::contentsMouseReleaseEvent( QMouseEvent * e )
void FileView::cancelMenuTimer()
{
if( menuTimer.isActive() )
- menuTimer.stop();
+ menuTimer.stop();
}
void FileView::addToDocuments()
@@ -623,37 +623,38 @@ void FileView::showFileMenu()
{
FileItem * i = (FileItem *) currentItem();
if ( !i )
- return;
+ return;
QPopupMenu * m = new QPopupMenu( this );
if ( !i->isDir() ) {
- m->insertItem( tr( "Add to Documents" ), this, SLOT( addToDocuments() ) );
- m->insertSeparator();
+ m->insertItem( tr( "Add to Documents" ), this, SLOT( addToDocuments() ) );
+ m->insertSeparator();
}
MimeType mt(i->getFilePath());
const AppLnk* app = mt.application();
if ( !i->isDir() ) {
- if ( app )
- m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( run() ) );
- else if( i->isExecutable() )
- m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) );
+ if ( app )
+ m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( run() ) );
+ else if( i->isExecutable() )
+ m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) );
- m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ),
- this, SLOT( viewAsText() ) );
+ m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ),
+ this, SLOT( viewAsText() ) );
- m->insertSeparator();
+ m->insertSeparator();
}
m->insertItem( tr( "Rename" ), this, SLOT( rename() ) );
m->insertItem( Resource::loadPixmap("cut"),
- tr( "Cut" ), this, SLOT( cut() ) );
+ tr( "Cut" ), this, SLOT( cut() ) );
m->insertItem( Resource::loadPixmap("copy"),
- tr( "Copy" ), this, SLOT( copy() ) );
+ tr( "Copy" ), this, SLOT( copy() ) );
m->insertItem( Resource::loadPixmap("paste"),
- tr( "Paste" ), this, SLOT( paste() ) );
+ tr( "Paste" ), this, SLOT( paste() ) );
+ m->insertItem( tr( "change permissions" ), this, SLOT( chPerm() ) );
m->insertItem( tr( "Delete" ), this, SLOT( del() ) );
m->insertSeparator();
m->insertItem( tr( "Select all" ), this, SLOT( selectAll() ) );
@@ -666,14 +667,14 @@ void FileView::showFileMenu()
//
FileBrowser::FileBrowser( QWidget * parent,
- const char * name, WFlags f ) :
+ const char * name, WFlags f ) :
QMainWindow( parent, name, f )
{
init( QDir::current().canonicalPath() );
}
FileBrowser::FileBrowser( const QString & dir, QWidget * parent,
- const char * name, WFlags f ) :
+ const char * name, WFlags f ) :
QMainWindow( parent, name, f )
{
init( dir );
@@ -712,33 +713,33 @@ void FileBrowser::init(const QString & dir)
toolBar = new QPEToolBar( this );
lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ),
- QString::null, 0, this, 0 );
+ QString::null, 0, this, 0 );
connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) );
lastAction->addTo( toolBar );
lastAction->setEnabled( FALSE );
upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ),
- QString::null, 0, this, 0 );
+ QString::null, 0, this, 0 );
connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) );
upAction->addTo( toolBar );
QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ),
- QString::null, 0, this, 0 );
+ QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) );
a->addTo( toolBar );
a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ),
- QString::null, 0, this, 0 );
+ QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) );
a->addTo( toolBar );
a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ),
- QString::null, 0, this, 0 );
+ QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) );
a->addTo( toolBar );
pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ),
- QString::null, 0, this, 0 );
+ QString::null, 0, this, 0 );
connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) );
pasteAction->addTo( toolBar );
@@ -748,13 +749,13 @@ void FileBrowser::init(const QString & dir)
QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this );
connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) );
+ this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) );
}
void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &)
{
if ( msg == "mtabChanged()" ) {
- // ## Only really needed if current dir is on a card
+ // ## Only really needed if current dir is on a card
fileView->updateDir();
}
}
@@ -766,9 +767,9 @@ void FileBrowser::dirSelected( int id )
// Bulid target dir from menu
while( (j = dirMenu->idAt( i )) != id ){
- dir += dirMenu->text( j ).stripWhiteSpace();
- if( dirMenu->text( j ) != "/" ) dir += "/";
- i++;
+ dir += dirMenu->text( j ).stripWhiteSpace();
+ if( dirMenu->text( j ) != "/" ) dir += "/";
+ i++;
}
dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace();
@@ -785,9 +786,9 @@ void FileBrowser::updateDirMenu()
dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) );
for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
- spc.fill( ' ', i++);
- dirMenu->insertItem( spc + (*it), this,
- SLOT( dirSelected(int) ) );
+ spc.fill( ' ', i++);
+ dirMenu->insertItem( spc + (*it), this,
+ SLOT( dirSelected(int) ) );
}
dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE );
@@ -840,11 +841,40 @@ void FileBrowser::updateSorting()
sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) )
- sortName();
+ sortName();
else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) )
- sortSize();
+ sortSize();
else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) )
- sortDate();
+ sortDate();
else
- sortType();
+ sortType();
+}
+
+void FileView::chPerm() {
+ FileItem * i;
+ QStringList fl;
+ QString cmd;
+ int err;
+
+ if((i = (FileItem *) firstChild()) == 0) return;
+
+ while( i ){
+ if( i->isSelected() ){
+ fl += i->getFilePath();
+ }
+ i = (FileItem *) i->nextSibling();
+ }
+ if( fl.count() < 1 ) return;
+ if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"),
+ tr("Yes"), tr("No") ) == 0) {
+ for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) {
+ filePermissions *filePerm;
+ filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it));
+ filePerm->exec();
+ if( filePerm)
+ delete filePerm;
+ break;
+ }
+ updateDir();
+ }
}
diff --git a/noncore/unsupported/filebrowser/filebrowser.h b/noncore/unsupported/filebrowser/filebrowser.h
index 2e9e444..c214dbe 100644
--- a/noncore/unsupported/filebrowser/filebrowser.h
+++ b/noncore/unsupported/filebrowser/filebrowser.h
@@ -54,7 +54,7 @@ class FileView : public QListView
public:
FileView( const QString & dir, QWidget * parent = 0,
- const char * name = 0 );
+ const char * name = 0 );
void setDir( const QString & dir );
QString cd(){ return currentDir; }
QStringList history() const { return dirHistory; }
@@ -71,7 +71,7 @@ public slots:
void cut();
void newFolder();
void viewAsText();
-
+ void chPerm();
protected:
void generateDir( const QString & dir );
void resizeEvent( QResizeEvent* );
@@ -111,17 +111,17 @@ class FileBrowser : public QMainWindow
public:
FileBrowser( QWidget * parent = 0,
- const char * name = 0, WFlags f = 0 );
+ const char * name = 0, WFlags f = 0 );
FileBrowser( const QString & dir, QWidget * parent = 0,
- const char * name = 0, WFlags f = 0 );
+ const char * name = 0, WFlags f = 0 );
private:
void init(const QString & dir);
QString fileToCopy;
QPopupMenu * dirMenu, * sortMenu;
FileView * fileView;
QAction * pasteAction;
- QAction *lastAction;
- QAction *upAction;
+ QAction *lastAction;
+ QAction *upAction;
bool copyFile( const QString & dest, const QString & src );
diff --git a/noncore/unsupported/filebrowser/filebrowser.pro b/noncore/unsupported/filebrowser/filebrowser.pro
index 5d8f140..65e51a5 100644
--- a/noncore/unsupported/filebrowser/filebrowser.pro
+++ b/noncore/unsupported/filebrowser/filebrowser.pro
@@ -1,11 +1,8 @@
TEMPLATE = app
CONFIG = qt warn_on release
DESTDIR = $(OPIEDIR)/bin
-HEADERS = inlineedit.h \
- filebrowser.h
-SOURCES = filebrowser.cpp \
- inlineedit.cpp \
- main.cpp
+HEADERS = inlineedit.h filebrowser.h filePermissions.h
+SOURCES = filebrowser.cpp inlineedit.cpp filePermissions.cpp main.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe