author | zecke <zecke> | 2002-03-30 23:26:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-30 23:26:49 (UTC) |
commit | 5d12c8fb75458262f6414073759b4c610f615525 (patch) (unidiff) | |
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 | |||
@@ -52,4 +52,21 @@ | |||
52 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 52 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
53 | 53 | ||
54 | namespace { | ||
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 | |||
54 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, | 71 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, |
55 | const QString &fileName, const QStringList mimetypes ) : QWidget( wid ) | 72 | const QString &fileName, const QStringList mimetypes ) : QWidget( wid ) |
@@ -105,4 +122,5 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString | |||
105 | void OFileSelector::initPics() | 122 | 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 " ); |
@@ -113,4 +131,10 @@ void OFileSelector::initPics() | |||
113 | m_pixmaps->insert("dirsymlink", pm ); | 131 | m_pixmaps->insert("dirsymlink", pm ); |
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 | }; |
116 | // let's initialize the gui | 140 | // let's initialize the gui |
@@ -145,8 +169,16 @@ void OFileSelector::init() | |||
145 | 169 | ||
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 ){ |
172 | QString currMime; | ||
173 | if( m_mimeCheck != 0 ) | ||
174 | currMime = m_mimeCheck->currentText(); | ||
175 | updateMimes(); | ||
176 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); | ||
148 | m_stack->addWidget(m_select, NORMAL ); | 177 | m_stack->addWidget(m_select, NORMAL ); |
149 | m_lay->addWidget(m_stack ); | 178 | m_lay->addWidget(m_stack ); |
150 | m_stack->raiseWidget(NORMAL ); | 179 | m_stack->raiseWidget(NORMAL ); |
180 | }else { | ||
181 | initializeListView(); | ||
182 | } | ||
151 | 183 | ||
152 | if(m_shLne ){ | 184 | if(m_shLne ){ |
@@ -280,5 +312,5 @@ QStringList OFileSelector::selectedNames()const | |||
280 | { | 312 | { |
281 | QStringList list; | 313 | QStringList list; |
282 | 314 | return list; | |
283 | } | 315 | } |
284 | DocLnk OFileSelector::selectedDocument( )const | 316 | DocLnk OFileSelector::selectedDocument( )const |
@@ -366,4 +398,5 @@ void OFileSelector::reparse() | |||
366 | m_mimeCheck->insertStringList(m_mimetypes ); | 398 | m_mimeCheck->insertStringList(m_mimetypes ); |
367 | // set it to the current mimetype | 399 | // set it to the current mimetype |
400 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | ||
368 | }; | 401 | }; |
369 | QDir dir( m_currentDir ); | 402 | QDir dir( m_currentDir ); |
@@ -381,8 +414,8 @@ void OFileSelector::reparse() | |||
381 | if(fi->isSymLink() ){ | 414 | if(fi->isSymLink() ){ |
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() ){ |
388 | qWarning("does not exist" ); | 421 | qWarning("does not exist" ); |
@@ -398,5 +431,5 @@ void OFileSelector::reparse() | |||
398 | break; | 431 | break; |
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() ); |
402 | }else if( i == 4 ){ // just insert it and have the symlink symbol | 435 | }else if( i == 4 ){ // just insert it and have the symlink symbol |
@@ -494,6 +527,5 @@ void OFileSelector::slotMimeCheck(const QString &view ){ | |||
494 | m_stack->raiseWidget( NORMAL ); | 527 | m_stack->raiseWidget( NORMAL ); |
495 | }else{ | 528 | }else{ |
496 | 529 | reparse(); | |
497 | |||
498 | } | 530 | } |
499 | } | 531 | } |
@@ -559,5 +591,5 @@ void OFileSelector::updateMimes() // lets check which mode is active | |||
559 | }else{ | 591 | }else{ |
560 | // should be allreday updatet | 592 | // should be allreday updatet |
561 | 593 | ; | |
562 | } | 594 | } |
563 | }; | 595 | }; |
@@ -581,4 +613,11 @@ void OFileSelector::initializeListView() | |||
581 | m_View->setSorting(1 ); | 613 | m_View->setSorting(1 ); |
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 | ||
584 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ | 623 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ |
@@ -590,4 +629,7 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ) | |||
590 | 629 | ||
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" ){ |
593 | ; | 635 | ; |
@@ -598,14 +640,26 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ) | |||
598 | if(pix.isNull() ) | 640 | if(pix.isNull() ) |
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 ){ |
649 | if( !info->isReadable() ){ | ||
650 | locked = 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, | ||
607 | info->lastModified().toString(), | 661 | info->lastModified().toString(), |
608 | QString::number(info->size() ), | 662 | QString::number(info->size() ), |
609 | info->dirPath(true) ); | 663 | dir, locked ); |
610 | } | 664 | } |
611 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 665 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
@@ -615,14 +669,32 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | |||
615 | //if( showDirs ) | 669 | //if( showDirs ) |
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; | ||
617 | if( symlink){ | 676 | if( symlink){ |
618 | QPixmap map = (*m_pixmaps)["dirsymlink" ]; | 677 | pix = (*m_pixmaps)["symlinkedlocked"]; |
619 | qWarning("Symlink" ); | 678 | }else{ |
620 | new OFileSelectorItem(m_View, map, | 679 | pix = Resource::loadPixmap("lockedfolder" ); |
621 | info->fileName(), info->lastModified().toString() , | 680 | } |
622 | QString::number(info->size() ),info->dirPath(true), true ); | 681 | }else{ |
623 | }else | 682 | if( symlink ){ |
624 | new OFileSelectorItem(m_View, Resource::loadPixmap("folder" ), | 683 | pix = (*m_pixmaps)["dirsymlink" ]; |
625 | info->fileName(), info->lastModified().toString(), | 684 | }else{ |
626 | QString::number(info->size() ),info->dirPath(true), true ); | 685 | pix = Resource::loadPixmap("folder" ); |
686 | } | ||
687 | } | ||
688 | if( symlink){ | ||
689 | name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); | ||
690 | |||
691 | }else{ | ||
692 | //if(info->isReadable() ) | ||
693 | name = info->fileName(); | ||
694 | } | ||
695 | |||
696 | new OFileSelectorItem(m_View, pix, | ||
697 | name, info->lastModified().toString(), | ||
698 | QString::number(info->size() ),info->dirPath(true), locked, true ); | ||
627 | 699 | ||
628 | } | 700 | } |
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index 73674e2..6936773 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -69,5 +69,5 @@ class OFileSelectorItem : public QListViewItem { | |||
69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
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 ); |
73 | setText(1, path ); | 73 | setText(1, path ); |
@@ -77,4 +77,8 @@ class OFileSelectorItem : public QListViewItem { | |||
77 | m_dir = mDir; | 77 | m_dir = mDir; |
78 | dir = isDir; | 78 | dir = isDir; |
79 | mLocked = isLocked; | ||
80 | } | ||
81 | bool locked() const{ | ||
82 | return mLocked; | ||
79 | } | 83 | } |
80 | QString directory()const{ | 84 | QString directory()const{ |
@@ -105,4 +109,5 @@ class OFileSelectorItem : public QListViewItem { | |||
105 | }; | 109 | }; |
106 | private: | 110 | private: |
111 | bool mLocked:1; | ||
107 | bool dir:1; | 112 | bool dir:1; |
108 | QString m_dir; | 113 | QString m_dir; |
@@ -137,5 +142,5 @@ class OFileSelector : public QWidget { | |||
137 | void setShowDirs(bool ); | 142 | void setShowDirs(bool ); |
138 | 143 | ||
139 | const QListView* listview() { return m_View; }; | 144 | const QListView* listView() { return m_View; }; |
140 | 145 | ||
141 | bool isCaseSensetive()const { return m_case; } | 146 | bool isCaseSensetive()const { return m_case; } |
@@ -170,5 +175,5 @@ class OFileSelector : public QWidget { | |||
170 | DocLnk selectedDocument()const; | 175 | DocLnk selectedDocument()const; |
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 | ||
174 | signals: | 179 | signals: |