summaryrefslogtreecommitdiff
authorzecke <zecke>2002-03-30 23:26:49 (UTC)
committer zecke <zecke>2002-03-30 23:26:49 (UTC)
commit5d12c8fb75458262f6414073759b4c610f615525 (patch) (unidiff)
tree45a3158271b748c6e5ff98afcf7014a25cd447d8
parentf3376cde32aa6a03070fb8f2d1428cedcbe49425 (diff)
downloadopie-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
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;
53 53
54namespace {
55
56 int indexByString( const QComboBox *box, const QString &str ){
57 int index= -1;
58 for(int i= 0; i < box->count(); i++ ){
59 qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() );
60 if( str == box->text(i ) ){
61 index= i;
62 break;
63 }
64 }
65 return index;
66 }
67
68};
69
70
54OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 71OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
@@ -106,4 +123,5 @@ void OFileSelector::initPics()
106{ 123{
124 qWarning("init pics" );
107 m_pixmaps = new QMap<QString,QPixmap>; 125 m_pixmaps = new QMap<QString,QPixmap>;
108 QPixmap pm = Resource::loadPixmap( "folder " ); 126 QPixmap pm = Resource::loadPixmap( "folder" );
109 QPixmap lnk = Resource::loadPixmap( "symlink" ); 127 QPixmap lnk = Resource::loadPixmap( "symlink" );
@@ -114,2 +132,8 @@ void OFileSelector::initPics()
114 132
133 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
134 QPainter pen(&pm2 );
135 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
136 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
137 m_pixmaps->insert("symlinkedlocked", pm2 );
138
115}; 139};
@@ -146,6 +170,14 @@ void OFileSelector::init()
146 m_stack = new QWidgetStack(this, "wstack" ); 170 m_stack = new QWidgetStack(this, "wstack" );
147 m_select = new FileSelector(m_mimetypes.join(";"), m_stack, "fileselector", FALSE, FALSE ); 171 if( m_selector == NORMAL ){
148 m_stack->addWidget(m_select, NORMAL ); 172 QString currMime;
149 m_lay->addWidget(m_stack ); 173 if( m_mimeCheck != 0 )
150 m_stack->raiseWidget(NORMAL ); 174 currMime = m_mimeCheck->currentText();
175 updateMimes();
176 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE );
177 m_stack->addWidget(m_select, NORMAL );
178 m_lay->addWidget(m_stack );
179 m_stack->raiseWidget(NORMAL );
180 }else {
181 initializeListView();
182 }
151 183
@@ -281,3 +313,3 @@ QStringList OFileSelector::selectedNames()const
281 QStringList list; 313 QStringList list;
282 314 return list;
283} 315}
@@ -367,2 +399,3 @@ void OFileSelector::reparse()
367 // set it to the current mimetype 399 // set it to the current mimetype
400 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
368 }; 401 };
@@ -382,6 +415,6 @@ void OFileSelector::reparse()
382 qWarning("Symlink %s", fi->fileName().latin1() ); 415 qWarning("Symlink %s", fi->fileName().latin1() );
383 QString file = fi->readLink(); 416 QString file = fi->dirPath(true)+"/"+ fi->readLink();
384 qWarning("File ->%s", file.latin1() ); 417 qWarning("File ->%s", file.latin1() );
385 for(int i=0; i<=4; i++ ){ // prepend from dos 418 for(int i=0; i<=4; i++ ){ // prepend from dos
386 QFileInfo info( fi->dirPath()+ "/"+file ); 419 QFileInfo info( file );
387 if( !info.exists() ){ 420 if( !info.exists() ){
@@ -399,3 +432,3 @@ void OFileSelector::reparse()
399 }else if( info.isSymLink() ){ 432 }else if( info.isSymLink() ){
400 file = info.readLink(); 433 file = info.dirPath(true)+ "/"+ info.readLink();
401 qWarning("isSymlink again %s", file.latin1() ); 434 qWarning("isSymlink again %s", file.latin1() );
@@ -495,4 +528,3 @@ void OFileSelector::slotMimeCheck(const QString &view ){
495 }else{ 528 }else{
496 529 reparse();
497
498 } 530 }
@@ -560,3 +592,3 @@ void OFileSelector::updateMimes() // lets check which mode is active
560 // should be allreday updatet 592 // should be allreday updatet
561 593 ;
562 } 594 }
@@ -582,2 +614,9 @@ void OFileSelector::initializeListView()
582}; 614};
615/* If a item is locked depends on the mode
616 if we're in OPEN !isReadable is locked
617 if we're in SAVE !isWriteable is locked
618
619
620 */
621
583 622
@@ -591,2 +630,5 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink )
591 MimeType type( info->filePath() ); 630 MimeType type( info->filePath() );
631 QString name;
632 QString dir;
633 bool locked= false;
592 if(mime == "All" ){ 634 if(mime == "All" ){
@@ -599,12 +641,24 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink )
599 pix = Resource::loadPixmap( "UnknownDocument-14" ); 641 pix = Resource::loadPixmap( "UnknownDocument-14" );
600 if( symlink ) // have a blended pic sometime 642 dir = info->dirPath( true );
601 new OFileSelectorItem( m_View, pix, info->fileName(), 643 if( symlink ) { // check if the readLink is readable
602 info->lastModified().toString(), 644 // do it right later
603 QString::number(info->size() ), 645 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
604 info->dirPath(true) ); 646 }else{ // keep track of the icons
605 else 647 name = info->fileName();
606 new OFileSelectorItem( m_View, pix, info->fileName(), 648 if( m_mode == OPEN ){
607 info->lastModified().toString(), 649 if( !info->isReadable() ){
608 QString::number(info->size() ), 650 locked = true;
609 info->dirPath(true) ); 651 pix = Resource::loadPixmap("locked" );
652 }
653 }else if( m_mode == SAVE ){
654 if( !info->isWritable() ){
655 locked = true;
656 pix = Resource::loadPixmap("locked" );
657 }
658 }
659 }
660 new OFileSelectorItem( m_View, pix, name,
661 info->lastModified().toString(),
662 QString::number( info->size() ),
663 dir, locked );
610} 664}
@@ -616,12 +670,30 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
616 { 670 {
671 bool locked;
672 QString name;
673 QPixmap pix;
674 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
675 locked = true;
676 if( symlink ){
677 pix = (*m_pixmaps)["symlinkedlocked"];
678 }else{
679 pix = Resource::loadPixmap("lockedfolder" );
680 }
681 }else{
682 if( symlink ){
683 pix = (*m_pixmaps)["dirsymlink" ];
684 }else{
685 pix = Resource::loadPixmap("folder" );
686 }
687 }
617 if( symlink){ 688 if( symlink){
618 QPixmap map = (*m_pixmaps)["dirsymlink" ]; 689 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink();
619 qWarning("Symlink" ); 690
620 new OFileSelectorItem(m_View, map, 691 }else{
621 info->fileName(), info->lastModified().toString() , 692 //if(info->isReadable() )
622 QString::number(info->size() ),info->dirPath(true), true ); 693 name = info->fileName();
623 }else 694 }
624 new OFileSelectorItem(m_View, Resource::loadPixmap("folder" ), 695
625 info->fileName(), info->lastModified().toString(), 696 new OFileSelectorItem(m_View, pix,
626 QString::number(info->size() ),info->dirPath(true), true ); 697 name, info->lastModified().toString(),
698 QString::number(info->size() ),info->dirPath(true), locked, true );
627 699
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 {
70 const QString &date, const QString &size, const QString &mDir, 70 const QString &date, const QString &size, const QString &mDir,
71 bool isDir=false ): QListViewItem(view) { 71 bool isLocked=false, bool isDir=false ): QListViewItem(view) {
72 setPixmap(0, pixmap ); 72 setPixmap(0, pixmap );
@@ -78,2 +78,6 @@ class OFileSelectorItem : public QListViewItem {
78 dir = isDir; 78 dir = isDir;
79 mLocked = isLocked;
80 }
81 bool locked() const{
82 return mLocked;
79 } 83 }
@@ -106,2 +110,3 @@ class OFileSelectorItem : public QListViewItem {
106 private: 110 private:
111 bool mLocked:1;
107 bool dir:1; 112 bool dir:1;
@@ -138,3 +143,3 @@ class OFileSelector : public QWidget {
138 143
139 const QListView* listview() { return m_View; }; 144 const QListView* listView() { return m_View; };
140 145
@@ -171,3 +176,3 @@ class OFileSelector : public QWidget {
171 /* the user needs to delete it */ 176 /* the user needs to delete it */
172 QValueList<DocLnk> selectedDocuments(); 177 QValueList<DocLnk> selectedDocuments()const;
173 178