summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc134
-rw-r--r--libopie/ofileselector.h11
2 files changed, 111 insertions, 34 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 61ab2c4..1807575 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -53,2 +53,19 @@ QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
+namespace {
+
+ int indexByString( const QComboBox *box, const QString &str ){
+ int index= -1;
+ for(int i= 0; i < box->count(); i++ ){
+ qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() );
+ if( str == box->text(i ) ){
+ index= i;
+ break;
+ }
+ }
+ return index;
+ }
+
+};
+
+
OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
@@ -106,4 +123,5 @@ void OFileSelector::initPics()
{
+ qWarning("init pics" );
m_pixmaps = new QMap<QString,QPixmap>;
- QPixmap pm = Resource::loadPixmap( "folder " );
+ QPixmap pm = Resource::loadPixmap( "folder" );
QPixmap lnk = Resource::loadPixmap( "symlink" );
@@ -114,2 +132,8 @@ void OFileSelector::initPics()
+ QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
+ QPainter pen(&pm2 );
+ pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
+ pm2.setMask( pm2.createHeuristicMask( FALSE ) );
+ m_pixmaps->insert("symlinkedlocked", pm2 );
+
};
@@ -146,6 +170,14 @@ void OFileSelector::init()
m_stack = new QWidgetStack(this, "wstack" );
- m_select = new FileSelector(m_mimetypes.join(";"), m_stack, "fileselector", FALSE, FALSE );
- m_stack->addWidget(m_select, NORMAL );
- m_lay->addWidget(m_stack );
- m_stack->raiseWidget(NORMAL );
+ if( m_selector == NORMAL ){
+ QString currMime;
+ if( m_mimeCheck != 0 )
+ currMime = m_mimeCheck->currentText();
+ updateMimes();
+ m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE );
+ m_stack->addWidget(m_select, NORMAL );
+ m_lay->addWidget(m_stack );
+ m_stack->raiseWidget(NORMAL );
+ }else {
+ initializeListView();
+ }
@@ -281,3 +313,3 @@ QStringList OFileSelector::selectedNames()const
QStringList list;
-
+ return list;
}
@@ -367,2 +399,3 @@ void OFileSelector::reparse()
// set it to the current mimetype
+ m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
};
@@ -382,6 +415,6 @@ void OFileSelector::reparse()
qWarning("Symlink %s", fi->fileName().latin1() );
- QString file = fi->readLink();
+ QString file = fi->dirPath(true)+"/"+ fi->readLink();
qWarning("File ->%s", file.latin1() );
for(int i=0; i<=4; i++ ){ // prepend from dos
- QFileInfo info( fi->dirPath()+ "/"+file );
+ QFileInfo info( file );
if( !info.exists() ){
@@ -399,3 +432,3 @@ void OFileSelector::reparse()
}else if( info.isSymLink() ){
- file = info.readLink();
+ file = info.dirPath(true)+ "/"+ info.readLink();
qWarning("isSymlink again %s", file.latin1() );
@@ -495,4 +528,3 @@ void OFileSelector::slotMimeCheck(const QString &view ){
}else{
-
-
+ reparse();
}
@@ -560,3 +592,3 @@ void OFileSelector::updateMimes() // lets check which mode is active
// should be allreday updatet
-
+ ;
}
@@ -582,2 +614,9 @@ void OFileSelector::initializeListView()
};
+/* If a item is locked depends on the mode
+ if we're in OPEN !isReadable is locked
+ if we're in SAVE !isWriteable is locked
+
+
+ */
+
@@ -591,2 +630,5 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink )
MimeType type( info->filePath() );
+ QString name;
+ QString dir;
+ bool locked= false;
if(mime == "All" ){
@@ -599,12 +641,24 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink )
pix = Resource::loadPixmap( "UnknownDocument-14" );
- if( symlink ) // have a blended pic sometime
- new OFileSelectorItem( m_View, pix, info->fileName(),
- info->lastModified().toString(),
- QString::number(info->size() ),
- info->dirPath(true) );
- else
- new OFileSelectorItem( m_View, pix, info->fileName(),
- info->lastModified().toString(),
- QString::number(info->size() ),
- info->dirPath(true) );
+ dir = info->dirPath( true );
+ if( symlink ) { // check if the readLink is readable
+ // do it right later
+ name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
+ }else{ // keep track of the icons
+ name = info->fileName();
+ if( m_mode == OPEN ){
+ if( !info->isReadable() ){
+ locked = true;
+ pix = Resource::loadPixmap("locked" );
+ }
+ }else if( m_mode == SAVE ){
+ if( !info->isWritable() ){
+ locked = true;
+ pix = Resource::loadPixmap("locked" );
+ }
+ }
+ }
+ new OFileSelectorItem( m_View, pix, name,
+ info->lastModified().toString(),
+ QString::number( info->size() ),
+ dir, locked );
}
@@ -616,12 +670,30 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
{
+ bool locked;
+ QString name;
+ QPixmap pix;
+ if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
+ locked = true;
+ if( symlink ){
+ pix = (*m_pixmaps)["symlinkedlocked"];
+ }else{
+ pix = Resource::loadPixmap("lockedfolder" );
+ }
+ }else{
+ if( symlink ){
+ pix = (*m_pixmaps)["dirsymlink" ];
+ }else{
+ pix = Resource::loadPixmap("folder" );
+ }
+ }
if( symlink){
- QPixmap map = (*m_pixmaps)["dirsymlink" ];
- qWarning("Symlink" );
- new OFileSelectorItem(m_View, map,
- info->fileName(), info->lastModified().toString() ,
- QString::number(info->size() ),info->dirPath(true), true );
- }else
- new OFileSelectorItem(m_View, Resource::loadPixmap("folder" ),
- info->fileName(), info->lastModified().toString(),
- QString::number(info->size() ),info->dirPath(true), true );
+ name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink();
+
+ }else{
+ //if(info->isReadable() )
+ name = info->fileName();
+ }
+
+ new OFileSelectorItem(m_View, pix,
+ name, info->lastModified().toString(),
+ QString::number(info->size() ),info->dirPath(true), locked, true );
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 73674e2..6936773 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -70,3 +70,3 @@ class OFileSelectorItem : public QListViewItem {
const QString &date, const QString &size, const QString &mDir,
- bool isDir=false ): QListViewItem(view) {
+ bool isLocked=false, bool isDir=false ): QListViewItem(view) {
setPixmap(0, pixmap );
@@ -78,2 +78,6 @@ class OFileSelectorItem : public QListViewItem {
dir = isDir;
+ mLocked = isLocked;
+ }
+ bool locked() const{
+ return mLocked;
}
@@ -106,2 +110,3 @@ class OFileSelectorItem : public QListViewItem {
private:
+ bool mLocked:1;
bool dir:1;
@@ -138,3 +143,3 @@ class OFileSelector : public QWidget {
- const QListView* listview() { return m_View; };
+ const QListView* listView() { return m_View; };
@@ -171,3 +176,3 @@ class OFileSelector : public QWidget {
/* the user needs to delete it */
- QValueList<DocLnk> selectedDocuments();
+ QValueList<DocLnk> selectedDocuments()const;