author | zecke <zecke> | 2002-03-30 23:26:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-30 23:26:49 (UTC) |
commit | 5d12c8fb75458262f6414073759b4c610f615525 (patch) (side-by-side diff) | |
tree | 45a3158271b748c6e5ff98afcf7014a25cd447d8 /libopie | |
parent | f3376cde32aa6a03070fb8f2d1428cedcbe49425 (diff) | |
download | opie-5d12c8fb75458262f6414073759b4c610f615525.zip opie-5d12c8fb75458262f6414073759b4c610f615525.tar.gz opie-5d12c8fb75458262f6414073759b4c610f615525.tar.bz2 |
This time thanks to tronical (Simon Hausmann) for reviewing the interface
the selector is almost done so better start porting to it
A dialog will come when beeing done with the real widget
-rw-r--r-- | libopie/ofileselector.cc | 122 | ||||
-rw-r--r-- | libopie/ofileselector.h | 11 |
2 files changed, 105 insertions, 28 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,2 +123,3 @@ void OFileSelector::initPics() { + qWarning("init pics" ); m_pixmaps = new QMap<QString,QPixmap>; @@ -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,3 +170,8 @@ void OFileSelector::init() m_stack = new QWidgetStack(this, "wstack" ); - m_select = new FileSelector(m_mimetypes.join(";"), m_stack, "fileselector", FALSE, FALSE ); + 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 ); @@ -150,2 +179,5 @@ void OFileSelector::init() 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(), + 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() ), - info->dirPath(true) ); + 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){ - 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 ); + pix = (*m_pixmaps)["symlinkedlocked"]; + }else{ + pix = Resource::loadPixmap("lockedfolder" ); + } + }else{ + if( symlink ){ + pix = (*m_pixmaps)["dirsymlink" ]; + }else{ + pix = Resource::loadPixmap("folder" ); + } + } + if( symlink){ + 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; |