/**********************************************************************

	--- Qt Architect generated file ---

	File: PropertyDlg.cc
	Last generated: Mon Feb 8 16:52:10 1999

	DO NOT EDIT!!!  This file will be automatically
	regenerated by qtarch.  All changes will be lost.

 *********************************************************************/

#include "PropertyDlg.h"

#define Inherited QDialog

#include <qbttngrp.h>
#include <qchkbox.h>
#include <qpushbt.h>
#include <kapp.h>

PropertyDlg::PropertyDlg
(
	FileInfo *fi,
	QWidget* parent,
	const char* name
)
	:
	Inherited( parent, name, TRUE, 0 ), Changed(FALSE)
{
	Info = fi;

	QButtonGroup* dlgedit_GroupPerm;
	dlgedit_GroupPerm = new QButtonGroup( this, "GroupPerm" );
	dlgedit_GroupPerm->setGeometry( 10, 160, 310, 150 );
	dlgedit_GroupPerm->setMinimumSize( 10, 10 );
	dlgedit_GroupPerm->setMaximumSize( 32767, 32767 );
	dlgedit_GroupPerm->setFrameStyle( 49 );
	dlgedit_GroupPerm->setTitle( i18n("Permissions") );
	dlgedit_GroupPerm->setAlignment( 1 );

	QLabel* dlgedit_LabelName;
	dlgedit_LabelName = new QLabel( this, "LabelName" );
	dlgedit_LabelName->setGeometry( 30, 20, 100, 20 );
	dlgedit_LabelName->setMinimumSize( 10, 10 );
	dlgedit_LabelName->setMaximumSize( 32767, 32767 );
	dlgedit_LabelName->setText( i18n("Name :") );
	dlgedit_LabelName->setAlignment( 290 );
	dlgedit_LabelName->setMargin( -1 );

	QLabel* dlgedit_LabelPath;
	dlgedit_LabelPath = new QLabel( this, "LabelPath" );
	dlgedit_LabelPath->setGeometry( 30, 40, 100, 20 );
	dlgedit_LabelPath->setMinimumSize( 10, 10 );
	dlgedit_LabelPath->setMaximumSize( 32767, 32767 );
	dlgedit_LabelPath->setText( i18n("Path :") );
	dlgedit_LabelPath->setAlignment( 290 );
	dlgedit_LabelPath->setMargin( -1 );

	if (fi->isSymLink()) {
		QLabel* dlgedit_LabelLink;
		dlgedit_LabelLink = new QLabel( this, "LabelLink" );
		dlgedit_LabelLink->setGeometry( 30, 100, 100, 20 );
		dlgedit_LabelLink->setMinimumSize( 10, 10 );
		dlgedit_LabelLink->setMaximumSize( 32767, 32767 );
		dlgedit_LabelLink->setText( i18n("Symbolic link :") );
		dlgedit_LabelLink->setAlignment( 290 );
		dlgedit_LabelLink->setMargin( -1 );

		QLabel* dlgedit_FileLink;
		dlgedit_FileLink = new QLabel( this, "FileLink" );
		dlgedit_FileLink->setGeometry( 140, 100, 190, 20 );
		dlgedit_FileLink->setMinimumSize( 10, 10 );
		dlgedit_FileLink->setMaximumSize( 32767, 32767 );
		dlgedit_FileLink->setText( fi->readLink().data() );
		dlgedit_FileLink->setAlignment( 289 );
		dlgedit_FileLink->setMargin( -1 );
	}

	QLabel* dlgedit_LabelType;
	dlgedit_LabelType = new QLabel( this, "LabelType" );
	dlgedit_LabelType->setGeometry( 30, 60, 100, 20 );
	dlgedit_LabelType->setMinimumSize( 10, 10 );
	dlgedit_LabelType->setMaximumSize( 32767, 32767 );
	dlgedit_LabelType->setText( i18n("Type :") );
	dlgedit_LabelType->setAlignment( 290 );
	dlgedit_LabelType->setMargin( -1 );

	QLabel* dlgedit_LabelSize;
	dlgedit_LabelSize = new QLabel( this, "LabelSize" );
	dlgedit_LabelSize->setGeometry( 30, 80, 100, 20 );
	dlgedit_LabelSize->setMinimumSize( 10, 10 );
	dlgedit_LabelSize->setMaximumSize( 32767, 32767 );
	dlgedit_LabelSize->setText( i18n("Size :") );
	dlgedit_LabelSize->setAlignment( 290 );
	dlgedit_LabelSize->setMargin( -1 );

	if (fi->isDir()) {
		dlgedit_Content = new QPushButton( this, "Content" );
		dlgedit_Content->setGeometry( 250, 80, 80, 20 );
		dlgedit_Content->setMinimumSize( 10, 10 );
		dlgedit_Content->setMaximumSize( 32767, 32767 );
		dlgedit_Content->setText( i18n("Content") );
		dlgedit_Content->setAutoRepeat( FALSE );
		dlgedit_Content->setAutoResize( FALSE );
		dlgedit_Content->setToggleButton( TRUE );
		connect(dlgedit_Content,SIGNAL(clicked()),SLOT(contentToggled()));
	}

	QLabel* dlgedit_LabelRead;
	dlgedit_LabelRead = new QLabel( this, "LabelRead" );
	dlgedit_LabelRead->setGeometry( 100, 180, 70, 20 );
	dlgedit_LabelRead->setMinimumSize( 10, 10 );
	dlgedit_LabelRead->setMaximumSize( 32767, 32767 );
	dlgedit_LabelRead->setText( i18n("Read") );
	dlgedit_LabelRead->setAlignment( 292 );
	dlgedit_LabelRead->setMargin( -1 );

	QLabel* dlgedit_LabelWrite;
	dlgedit_LabelWrite = new QLabel( this, "LabelWrite" );
	dlgedit_LabelWrite->setGeometry( 160, 180, 70, 20 );
	dlgedit_LabelWrite->setMinimumSize( 10, 10 );
	dlgedit_LabelWrite->setMaximumSize( 32767, 32767 );
	dlgedit_LabelWrite->setText( i18n("Write") );
	dlgedit_LabelWrite->setAlignment( 292 );
	dlgedit_LabelWrite->setMargin( -1 );

	QLabel* dlgedit_LabelExecute;
	dlgedit_LabelExecute = new QLabel( this, "LabelExecute" );
	dlgedit_LabelExecute->setGeometry( 220, 180, 80, 20 );
	dlgedit_LabelExecute->setMinimumSize( 10, 10 );
	dlgedit_LabelExecute->setMaximumSize( 32767, 32767 );
	dlgedit_LabelExecute->setText( i18n("Execute") );
	dlgedit_LabelExecute->setAlignment( 292 );
	dlgedit_LabelExecute->setMargin( -1 );

	QLabel* dlgedit_LabelOwnerPerm;
	dlgedit_LabelOwnerPerm = new QLabel( this, "LabelOwnerPerm" );
	dlgedit_LabelOwnerPerm->setGeometry( 20, 210, 80, 20 );
	dlgedit_LabelOwnerPerm->setMinimumSize( 10, 10 );
	dlgedit_LabelOwnerPerm->setMaximumSize( 32767, 32767 );
	dlgedit_LabelOwnerPerm->setText( i18n("Owner") );
	dlgedit_LabelOwnerPerm->setAlignment( 292 );
	dlgedit_LabelOwnerPerm->setMargin( -1 );

	QLabel* dlgedit_LabelGroupPerm;
	dlgedit_LabelGroupPerm = new QLabel( this, "LabelGroupPerm" );
	dlgedit_LabelGroupPerm->setGeometry( 20, 240, 80, 20 );
	dlgedit_LabelGroupPerm->setMinimumSize( 10, 10 );
	dlgedit_LabelGroupPerm->setMaximumSize( 32767, 32767 );
	dlgedit_LabelGroupPerm->setText( i18n("Group") );
	dlgedit_LabelGroupPerm->setAlignment( 292 );
	dlgedit_LabelGroupPerm->setMargin( -1 );

	QLabel* dlgedit_LabelOthersPerm;
	dlgedit_LabelOthersPerm = new QLabel( this, "LabelOthersPerm" );
	dlgedit_LabelOthersPerm->setGeometry( 20, 270, 80, 20 );
	dlgedit_LabelOthersPerm->setMinimumSize( 10, 10 );
	dlgedit_LabelOthersPerm->setMaximumSize( 32767, 32767 );
	dlgedit_LabelOthersPerm->setText( i18n("Others") );
	dlgedit_LabelOthersPerm->setAlignment( 292 );
	dlgedit_LabelOthersPerm->setMargin( -1 );

	QLabel* dlgedit_LabelOwner;
	dlgedit_LabelOwner = new QLabel( this, "LabelOwner" );
	dlgedit_LabelOwner->setGeometry( 10, 130, 90, 20 );
	dlgedit_LabelOwner->setMinimumSize( 10, 10 );
	dlgedit_LabelOwner->setMaximumSize( 32767, 32767 );
	dlgedit_LabelOwner->setText( i18n("Owner :") );
	dlgedit_LabelOwner->setAlignment( 289 );
	dlgedit_LabelOwner->setMargin( -1 );

	QLabel* dlgedit_LabelGroup;
	dlgedit_LabelGroup = new QLabel( this, "LabelGroup" );
	dlgedit_LabelGroup->setGeometry( 160, 130, 90, 20 );
	dlgedit_LabelGroup->setMinimumSize( 10, 10 );
	dlgedit_LabelGroup->setMaximumSize( 32767, 32767 );
	dlgedit_LabelGroup->setText( i18n("Group :") );
	dlgedit_LabelGroup->setAlignment( 289 );
	dlgedit_LabelGroup->setMargin( -1 );

	dlgedit_CheckRO = new QCheckBox( this, "CheckRO" );
	dlgedit_CheckRO->setGeometry( 130, 205, 20, 30 );
	dlgedit_CheckRO->setMinimumSize( 10, 10 );
	dlgedit_CheckRO->setMaximumSize( 32767, 32767 );
	dlgedit_CheckRO->setText( "" );
	dlgedit_CheckRO->setAutoRepeat( FALSE );
	dlgedit_CheckRO->setAutoResize( FALSE );
	dlgedit_CheckRO->setChecked(fi->permissions(S_IRUSR));

	dlgedit_CheckWO = new QCheckBox( this, "CheckWO" );
	dlgedit_CheckWO->setGeometry( 190, 205, 20, 30 );
	dlgedit_CheckWO->setMinimumSize( 10, 10 );
	dlgedit_CheckWO->setMaximumSize( 32767, 32767 );
	dlgedit_CheckWO->setText( "" );
	dlgedit_CheckWO->setAutoRepeat( FALSE );
	dlgedit_CheckWO->setAutoResize( FALSE );
	dlgedit_CheckWO->setChecked(fi->permissions(S_IWUSR));

	dlgedit_CheckXO = new QCheckBox( this, "CheckXO" );
	dlgedit_CheckXO->setGeometry( 250, 205, 20, 30 );
	dlgedit_CheckXO->setMinimumSize( 10, 10 );
	dlgedit_CheckXO->setMaximumSize( 32767, 32767 );
	dlgedit_CheckXO->setText( "" );
	dlgedit_CheckXO->setAutoRepeat( FALSE );
	dlgedit_CheckXO->setAutoResize( FALSE );
	dlgedit_CheckXO->setChecked(fi->permissions(S_IXUSR));

	dlgedit_CheckRG = new QCheckBox( this, "CheckRG" );
	dlgedit_CheckRG->setGeometry( 130, 235, 20, 30 );
	dlgedit_CheckRG->setMinimumSize( 10, 10 );
	dlgedit_CheckRG->setMaximumSize( 32767, 32767 );
	dlgedit_CheckRG->setText( "" );
	dlgedit_CheckRG->setAutoRepeat( FALSE );
	dlgedit_CheckRG->setAutoResize( FALSE );
	dlgedit_CheckRG->setChecked(fi->permissions(S_IRGRP));

	dlgedit_CheckWG = new QCheckBox( this, "CheckWG" );
	dlgedit_CheckWG->setGeometry( 190, 235, 20, 30 );
	dlgedit_CheckWG->setMinimumSize( 10, 10 );
	dlgedit_CheckWG->setMaximumSize( 32767, 32767 );
	dlgedit_CheckWG->setText( "" );
	dlgedit_CheckWG->setAutoRepeat( FALSE );
	dlgedit_CheckWG->setAutoResize( FALSE );
	dlgedit_CheckWG->setChecked(fi->permissions(S_IWGRP));

	dlgedit_CheckXG = new QCheckBox( this, "CheckXG" );
	dlgedit_CheckXG->setGeometry( 250, 235, 20, 30 );
	dlgedit_CheckXG->setMinimumSize( 10, 10 );
	dlgedit_CheckXG->setMaximumSize( 32767, 32767 );
	dlgedit_CheckXG->setText( "" );
	dlgedit_CheckXG->setAutoRepeat( FALSE );
	dlgedit_CheckXG->setAutoResize( FALSE );
	dlgedit_CheckXG->setChecked(fi->permissions(S_IXGRP));

	dlgedit_CheckRW = new QCheckBox( this, "CheckRW" );
	dlgedit_CheckRW->setGeometry( 130, 265, 20, 30 );
	dlgedit_CheckRW->setMinimumSize( 10, 10 );
	dlgedit_CheckRW->setMaximumSize( 32767, 32767 );
	dlgedit_CheckRW->setText( "" );
	dlgedit_CheckRW->setAutoRepeat( FALSE );
	dlgedit_CheckRW->setAutoResize( FALSE );
	dlgedit_CheckRW->setChecked(fi->permissions(S_IROTH));

	dlgedit_CheckWW = new QCheckBox( this, "CheckWW" );
	dlgedit_CheckWW->setGeometry( 190, 265, 20, 30 );
	dlgedit_CheckWW->setMinimumSize( 10, 10 );
	dlgedit_CheckWW->setMaximumSize( 32767, 32767 );
	dlgedit_CheckWW->setText( "" );
	dlgedit_CheckWW->setAutoRepeat( FALSE );
	dlgedit_CheckWW->setAutoResize( FALSE );
	dlgedit_CheckWW->setChecked(fi->permissions(S_IWOTH));

	dlgedit_CheckXW = new QCheckBox( this, "CheckXW" );
	dlgedit_CheckXW->setGeometry( 250, 265, 20, 30 );
	dlgedit_CheckXW->setMinimumSize( 10, 10 );
	dlgedit_CheckXW->setMaximumSize( 32767, 32767 );
	dlgedit_CheckXW->setText( "" );
	dlgedit_CheckXW->setAutoRepeat( FALSE );
	dlgedit_CheckXW->setAutoResize( FALSE );
	dlgedit_CheckXW->setChecked(fi->permissions(S_IXOTH));

	QLabel* dlgedit_FileName;
	dlgedit_FileName = new QLabel( this, "FileName" );
	dlgedit_FileName->setGeometry( 140, 20, 190, 20 );
	dlgedit_FileName->setMinimumSize( 10, 10 );
	dlgedit_FileName->setMaximumSize( 32767, 32767 );
	dlgedit_FileName->setText( fi->fileName().data() );
	dlgedit_FileName->setAlignment( 289 );
	dlgedit_FileName->setMargin( -1 );

	QLabel* dlgedit_FilePath;
	dlgedit_FilePath = new QLabel( this, "FilePath" );
	dlgedit_FilePath->setGeometry( 140, 40, 190, 20 );
	dlgedit_FilePath->setMinimumSize( 10, 10 );
	dlgedit_FilePath->setMaximumSize( 32767, 32767 );
	dlgedit_FilePath->setText( fi->absFilePath().data() );
	dlgedit_FilePath->setAlignment( 289 );
	dlgedit_FilePath->setMargin( -1 );

	QLabel* dlgedit_FileType;
	dlgedit_FileType = new QLabel( this, "FileType" );
	dlgedit_FileType->setGeometry( 140, 60, 190, 20 );
	dlgedit_FileType->setMinimumSize( 10, 10 );
	dlgedit_FileType->setMaximumSize( 32767, 32767 );
	dlgedit_FileType->setText( fi->description() );
	dlgedit_FileType->setAlignment( 289 );
	dlgedit_FileType->setMargin( -1 );

	dlgedit_FileSize = new QLabel( this, "FileSize" );
	dlgedit_FileSize->setGeometry( 140, 80, 110, 20 );
	dlgedit_FileSize->setMinimumSize( 10, 10 );
	dlgedit_FileSize->setMaximumSize( 32767, 32767 );
	QString	str;
	str.setNum(fi->size());
	dlgedit_FileSize->setText( str.data() );
	dlgedit_FileSize->setAlignment( 289 );
	dlgedit_FileSize->setMargin( -1 );

	QLabel* dlgedit_FileOwner;
	dlgedit_FileOwner = new QLabel( this, "FileOwner" );
	dlgedit_FileOwner->setGeometry( 100, 130, 60, 20 );
	dlgedit_FileOwner->setMinimumSize( 10, 10 );
	dlgedit_FileOwner->setMaximumSize( 32767, 32767 );
	dlgedit_FileOwner->setText( fi->owner() );
	dlgedit_FileOwner->setAlignment( 289 );
	dlgedit_FileOwner->setMargin( -1 );

	QLabel* dlgedit_FileGroup;
	dlgedit_FileGroup = new QLabel( this, "FileGroup" );
	dlgedit_FileGroup->setGeometry( 250, 130, 60, 20 );
	dlgedit_FileGroup->setMinimumSize( 10, 10 );
	dlgedit_FileGroup->setMaximumSize( 32767, 32767 );
	dlgedit_FileGroup->setText( fi->group() );
	dlgedit_FileGroup->setAlignment( 289 );
	dlgedit_FileGroup->setMargin( -1 );

	QLabel* dlgedit_FileIcon;
	dlgedit_FileIcon = new QLabel( this, "FileIcon" );
	dlgedit_FileIcon->setGeometry( 20, 40, 50, 50 );
	dlgedit_FileIcon->setMinimumSize( 10, 10 );
	dlgedit_FileIcon->setMaximumSize( 32767, 32767 );
	dlgedit_FileIcon->setText( "" );
	dlgedit_FileIcon->setAlignment( 289 );
	dlgedit_FileIcon->setMargin( -1 );
	if (fi->icon()) dlgedit_FileIcon->setPixmap(*(fi->icon()));

	QPushButton* dlgedit_ButtonCancel;
	dlgedit_ButtonCancel = new QPushButton( this, "ButtonCancel" );
	dlgedit_ButtonCancel->setGeometry( 230, 320, 90, 30 );
	dlgedit_ButtonCancel->setMinimumSize( 10, 10 );
	dlgedit_ButtonCancel->setMaximumSize( 32767, 32767 );
	connect( dlgedit_ButtonCancel, SIGNAL(clicked()), SLOT(reject()) );
	dlgedit_ButtonCancel->setText( i18n("Cancel") );
	dlgedit_ButtonCancel->setAutoRepeat( FALSE );
	dlgedit_ButtonCancel->setAutoResize( FALSE );

	QPushButton* dlgedit_ButtonOk;
	dlgedit_ButtonOk = new QPushButton( this, "ButtonOk" );
	dlgedit_ButtonOk->setGeometry( 130, 320, 90, 30 );
	dlgedit_ButtonOk->setMinimumSize( 10, 10 );
	dlgedit_ButtonOk->setMaximumSize( 32767, 32767 );
	connect( dlgedit_ButtonOk, SIGNAL(clicked()), SLOT(accept()) );
	dlgedit_ButtonOk->setText( i18n("Ok") );
	dlgedit_ButtonOk->setAutoRepeat( FALSE );
	dlgedit_ButtonOk->setAutoResize( FALSE );

	dlgedit_GroupPerm->insert( dlgedit_CheckRO );
	dlgedit_GroupPerm->insert( dlgedit_CheckWO );
	dlgedit_GroupPerm->insert( dlgedit_CheckXO );
	dlgedit_GroupPerm->insert( dlgedit_CheckRG );
	dlgedit_GroupPerm->insert( dlgedit_CheckWG );
	dlgedit_GroupPerm->insert( dlgedit_CheckXG );
	dlgedit_GroupPerm->insert( dlgedit_CheckRW );
	dlgedit_GroupPerm->insert( dlgedit_CheckWW );
	dlgedit_GroupPerm->insert( dlgedit_CheckXW );
	connect(dlgedit_CheckRO,SIGNAL(clicked()),SLOT(changed()));
	connect(dlgedit_CheckWO,SIGNAL(clicked()),SLOT(changed()));
	connect(dlgedit_CheckXO,SIGNAL(clicked()),SLOT(changed()));
	connect(dlgedit_CheckRG,SIGNAL(clicked()),SLOT(changed()));
	connect(dlgedit_CheckWG,SIGNAL(clicked()),SLOT(changed()));
	connect(dlgedit_CheckXG,SIGNAL(clicked()),SLOT(changed()));
	connect(dlgedit_CheckRW,SIGNAL(clicked()),SLOT(changed()));
	connect(dlgedit_CheckWW,SIGNAL(clicked()),SLOT(changed()));
	connect(dlgedit_CheckXW,SIGNAL(clicked()),SLOT(changed()));

	resize( 340,360 );
	setCaption(i18n("File properties"));
	setMinimumSize( 0, 0 );
	setMaximumSize( 32767, 32767 );
}


PropertyDlg::~PropertyDlg()
{
}

#include <stdio.h>
#include <kurl.h>

void PropertyDlg::contentToggled()
{
	QString		str;
	if (dlgedit_Content->isOn()) {
		setCursor(waitCursor);
		int	size(0);
		KURL	url(Info->absFilePath());
		QString		cmd("du -sk ");
		if (strcmp(url.protocol(),"file") == 0) {
			cmd += url.path();
			FILE	*f = popen(cmd.data(),"r");
			int	result(0);
			while ((result = fscanf(f,"%d",&size)) == 0 && result != EOF) usleep(50000);
		}
		str.setNum(size);
		str += " Ko";
		dlgedit_FileSize->setText(str.data());
		setCursor(arrowCursor);
	}
	else {
		str.setNum(Info->size());
		dlgedit_FileSize->setText(str.data());
	}
}

int PropertyDlg::permissions()
{
	int	mode = 0;
	if (dlgedit_CheckRO->isChecked()) mode |= S_IRUSR;
	if (dlgedit_CheckWO->isChecked()) mode |= S_IWUSR;
	if (dlgedit_CheckXO->isChecked()) mode |= S_IXUSR;
	if (dlgedit_CheckRG->isChecked()) mode |= S_IRGRP;
	if (dlgedit_CheckWG->isChecked()) mode |= S_IWGRP;
	if (dlgedit_CheckXG->isChecked()) mode |= S_IXGRP;
	if (dlgedit_CheckRW->isChecked()) mode |= S_IROTH;
	if (dlgedit_CheckWW->isChecked()) mode |= S_IWOTH;
	if (dlgedit_CheckXW->isChecked()) mode |= S_IXOTH;
	return mode;
}
