author | llornkcor <llornkcor> | 2003-04-15 01:46:54 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-04-15 01:46:54 (UTC) |
commit | d2f7c238e852eb60fdcfe3e4024823480713e50e (patch) (unidiff) | |
tree | 0109f1fc75cd7477581cb2cfac1a349fcb44c6ef | |
parent | 79e83da7936995f247f7ad7ad0f768b6e2545cf1 (diff) | |
download | opie-d2f7c238e852eb60fdcfe3e4024823480713e50e.zip opie-d2f7c238e852eb60fdcfe3e4024823480713e50e.tar.gz opie-d2f7c238e852eb60fdcfe3e4024823480713e50e.tar.bz2 |
fixed for bug 855, changed currentChanged(...) to clicked(...). also changed UnknownDocument-14 to scaled UnknownDocument
-rw-r--r-- | libopie/ofileselector.cc | 217 |
1 files changed, 112 insertions, 105 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 7481360..6748bec 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,10 +1,11 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qwmatrix.h> | ||
3 | #include <qcheckbox.h> | 4 | #include <qcheckbox.h> |
4 | #include <qcombobox.h> | 5 | #include <qcombobox.h> |
5 | #include <qheader.h> | 6 | #include <qheader.h> |
6 | #include <qlabel.h> | 7 | #include <qlabel.h> |
7 | #include <qabstractlayout.h> | 8 | #include <qabstractlayout.h> |
8 | #include <qlayout.h> | 9 | #include <qlayout.h> |
9 | #include <qlineedit.h> | 10 | #include <qlineedit.h> |
10 | #include <qlistview.h> | 11 | #include <qlistview.h> |
@@ -35,27 +36,27 @@ | |||
35 | 36 | ||
36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 37 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
37 | 38 | ||
38 | namespace { | 39 | namespace { |
39 | int indexByString( const QComboBox *box, const QString &str ){ | 40 | int indexByString( const QComboBox *box, const QString &str ){ |
40 | int index= 0; | 41 | int index= 0; |
41 | for(int i= 0; i < box->count(); i++ ){ | 42 | for(int i= 0; i < box->count(); i++ ){ |
42 | if( str == box->text(i ) ){ | 43 | if( str == box->text(i ) ){ |
43 | index= i; | 44 | index= i; |
44 | break; | 45 | break; |
45 | } | 46 | } |
46 | } | 47 | } |
47 | return index; | 48 | return index; |
48 | } | 49 | } |
49 | class OFileSelectorItem : public QListViewItem { | 50 | class OFileSelectorItem : public QListViewItem { |
50 | public: | 51 | public: |
51 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 52 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
52 | const QString &date, const QString &size, const QString &mDir, | 53 | const QString &date, const QString &size, const QString &mDir, |
53 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 54 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
54 | setPixmap(0, pixmap ); | 55 | setPixmap(0, pixmap ); |
55 | setText(1, path ); | 56 | setText(1, path ); |
56 | setText(2, size ); | 57 | setText(2, size ); |
57 | setText(3, date ); | 58 | setText(3, date ); |
58 | //setText(4, mDir ); | 59 | //setText(4, mDir ); |
59 | m_dir = mDir; | 60 | m_dir = mDir; |
60 | dir = isDir; | 61 | dir = isDir; |
61 | mLocked = isLocked; | 62 | mLocked = isLocked; |
@@ -70,58 +71,58 @@ namespace { | |||
70 | return dir; | 71 | return dir; |
71 | } | 72 | } |
72 | QString path()const{ | 73 | QString path()const{ |
73 | return text(1 ); | 74 | return text(1 ); |
74 | } | 75 | } |
75 | QString key(int id, bool )const { | 76 | QString key(int id, bool )const { |
76 | QString ke; | 77 | QString ke; |
77 | if( id == 0 || id == 1 ){ // name | 78 | if( id == 0 || id == 1 ){ // name |
78 | if( dir ){ | 79 | if( dir ){ |
79 | ke.append("0" ); | 80 | ke.append("0" ); |
80 | ke.append( text(1) ); | 81 | ke.append( text(1) ); |
81 | }else{ | 82 | }else{ |
82 | ke.append("1" ); | 83 | ke.append("1" ); |
83 | ke.append( text(1) ); | 84 | ke.append( text(1) ); |
84 | } | 85 | } |
85 | }else if( id == 2 ){ // size | 86 | }else if( id == 2 ){ // size |
86 | return text(2); | 87 | return text(2); |
87 | }else if( id == 3 ){ // date | 88 | }else if( id == 3 ){ // date |
88 | return text(3); | 89 | return text(3); |
89 | } | 90 | } |
90 | return ke; | 91 | return ke; |
91 | }; | 92 | }; |
92 | private: | 93 | private: |
93 | bool mLocked:1; | 94 | bool mLocked:1; |
94 | bool dir:1; | 95 | bool dir:1; |
95 | QString m_dir; | 96 | QString m_dir; |
96 | }; | 97 | }; |
97 | }; | 98 | }; |
98 | 99 | ||
99 | 100 | ||
100 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | 101 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, |
101 | const QString &dirName, | 102 | const QString &dirName, |
102 | const QString &fileName, | 103 | const QString &fileName, |
103 | const QMap<QString,QStringList>& mimeTypes) | 104 | const QMap<QString,QStringList>& mimeTypes) |
104 | : QWidget( wid, "OFileSelector") | 105 | : QWidget( wid, "OFileSelector") |
105 | { | 106 | { |
106 | m_mimetypes = mimeTypes; | 107 | m_mimetypes = mimeTypes; |
107 | if (mode == SAVE ) | 108 | if (mode == SAVE ) |
108 | m_name = fileName; | 109 | m_name = fileName; |
109 | initVars(); | 110 | initVars(); |
110 | m_mode = mode; | 111 | m_mode = mode; |
111 | m_selector = selector; | 112 | m_selector = selector; |
112 | m_currentDir = dirName; | 113 | m_currentDir = dirName; |
113 | init(); | 114 | init(); |
114 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); | 115 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); |
115 | } | 116 | } |
116 | 117 | ||
117 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | 118 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, |
118 | const char *name, bool newVisible, | 119 | const char *name, bool newVisible, |
119 | bool closeVisible ) | 120 | bool closeVisible ) |
120 | : QWidget( parent, name ) | 121 | : QWidget( parent, name ) |
121 | { | 122 | { |
122 | if (!mimeFilter.isEmpty() ) { | 123 | if (!mimeFilter.isEmpty() ) { |
123 | QStringList list = QStringList::split(";", mimeFilter ); | 124 | QStringList list = QStringList::split(";", mimeFilter ); |
124 | m_mimetypes.insert(mimeFilter, list ); | 125 | m_mimetypes.insert(mimeFilter, list ); |
125 | } | 126 | } |
126 | initVars(); | 127 | initVars(); |
127 | m_currentDir = QPEApplication::documentDir(); | 128 | m_currentDir = QPEApplication::documentDir(); |
@@ -129,39 +130,38 @@ OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | |||
129 | m_selector = NORMAL; | 130 | m_selector = NORMAL; |
130 | m_shClose = closeVisible; | 131 | m_shClose = closeVisible; |
131 | m_shNew = newVisible; | 132 | m_shNew = newVisible; |
132 | m_shLne = false; | 133 | m_shLne = false; |
133 | m_shPerm = false; | 134 | m_shPerm = false; |
134 | m_shYesNo = false; | 135 | m_shYesNo = false; |
135 | init(); | 136 | init(); |
136 | 137 | ||
137 | |||
138 | } | 138 | } |
139 | 139 | ||
140 | OFileSelector::~OFileSelector() | 140 | OFileSelector::~OFileSelector() |
141 | { | 141 | { |
142 | 142 | ||
143 | 143 | ||
144 | } | 144 | } |
145 | 145 | ||
146 | void OFileSelector::setNewVisible( bool visible ) | 146 | void OFileSelector::setNewVisible( bool visible ) |
147 | { | 147 | { |
148 | m_shNew = visible; | 148 | m_shNew = visible; |
149 | if( m_selector == NORMAL ){ | 149 | if( m_selector == NORMAL ){ |
150 | delete m_select; | 150 | delete m_select; |
151 | // we need to initialize but keep the selected mimetype | 151 | // we need to initialize but keep the selected mimetype |
152 | QString mime = currentMimeType(); | 152 | QString mime = currentMimeType(); |
153 | m_select = new FileSelector( mime , | 153 | m_select = new FileSelector( mime , |
154 | m_stack, "fileselector", | 154 | m_stack, "fileselector", |
155 | m_shNew, m_shClose); | 155 | m_shNew, m_shClose); |
156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
158 | connect(m_select, SIGNAL(closeMe() ), | 158 | connect(m_select, SIGNAL(closeMe() ), |
159 | this, SIGNAL(closeMe() ) ); | 159 | this, SIGNAL(closeMe() ) ); |
160 | //connect to close me and other signals as well | 160 | //connect to close me and other signals as well |
161 | m_stack->addWidget( m_select, NORMAL ); | 161 | m_stack->addWidget( m_select, NORMAL ); |
162 | }else{ | 162 | }else{ |
163 | m_new->show(); | 163 | m_new->show(); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | void OFileSelector::setCloseVisible( bool visible ) | 166 | void OFileSelector::setCloseVisible( bool visible ) |
167 | { | 167 | { |
@@ -428,20 +428,20 @@ void OFileSelector::slotCancel() | |||
428 | void OFileSelector::slotViewCheck(const QString &sel) | 428 | void OFileSelector::slotViewCheck(const QString &sel) |
429 | { | 429 | { |
430 | if( sel == tr("Documents" ) ){ | 430 | if( sel == tr("Documents" ) ){ |
431 | if( m_select == 0 ){ | 431 | if( m_select == 0 ){ |
432 | // autMime? fix cause now we use All and not the current | 432 | // autMime? fix cause now we use All and not the current |
433 | // yes currentMime fixes that for us | 433 | // yes currentMime fixes that for us |
434 | QString mime = currentMimeType(); | 434 | QString mime = currentMimeType(); |
435 | m_select = new FileSelector(mime, | 435 | m_select = new FileSelector(mime, |
436 | m_stack, "fileselector", | 436 | m_stack, "fileselector", |
437 | m_shNew, m_shClose); | 437 | m_shNew, m_shClose); |
438 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 438 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
439 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 439 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
440 | connect(m_select, SIGNAL(closeMe() ), | 440 | connect(m_select, SIGNAL(closeMe() ), |
441 | this, SIGNAL(closeMe() ) ); | 441 | this, SIGNAL(closeMe() ) ); |
442 | //connect to close me and other signals as well | 442 | //connect to close me and other signals as well |
443 | 443 | ||
444 | m_stack->addWidget( m_select, NORMAL ); | 444 | m_stack->addWidget( m_select, NORMAL ); |
445 | } | 445 | } |
446 | m_stack->raiseWidget( NORMAL ); | 446 | m_stack->raiseWidget( NORMAL ); |
447 | m_selector = NORMAL; | 447 | m_selector = NORMAL; |
@@ -493,19 +493,19 @@ void OFileSelector::slotMimeCheck(const QString &mime) | |||
493 | } | 493 | } |
494 | } | 494 | } |
495 | delete m_select; | 495 | delete m_select; |
496 | m_select = new FileSelector( newMimeType, | 496 | m_select = new FileSelector( newMimeType, |
497 | m_stack, "fileselector", | 497 | m_stack, "fileselector", |
498 | m_shNew, m_shClose); | 498 | m_shNew, m_shClose); |
499 | 499 | ||
500 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 500 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
501 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 501 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
502 | connect(m_select, SIGNAL(closeMe() ), | 502 | connect(m_select, SIGNAL(closeMe() ), |
503 | this, SIGNAL(closeMe() ) ); | 503 | this, SIGNAL(closeMe() ) ); |
504 | //connect to close me and other signals as well | 504 | //connect to close me and other signals as well |
505 | m_stack->addWidget( m_select, NORMAL ); | 505 | m_stack->addWidget( m_select, NORMAL ); |
506 | m_stack->raiseWidget( NORMAL ); | 506 | m_stack->raiseWidget( NORMAL ); |
507 | updateMimes(); | 507 | updateMimes(); |
508 | updateMimeCheck(); | 508 | updateMimeCheck(); |
509 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 509 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
510 | //} | 510 | //} |
511 | }else{ // others | 511 | }else{ // others |
@@ -578,31 +578,31 @@ void OFileSelector::init() | |||
578 | if (!m_autoMime) { | 578 | if (!m_autoMime) { |
579 | if (!m_mimetypes.isEmpty() ) { | 579 | if (!m_mimetypes.isEmpty() ) { |
580 | QMap<QString, QStringList>::Iterator it; | 580 | QMap<QString, QStringList>::Iterator it; |
581 | it = m_mimetypes.begin(); // cause we're in the init | 581 | it = m_mimetypes.begin(); // cause we're in the init |
582 | mime = it.data().join(";"); | 582 | mime = it.data().join(";"); |
583 | } | 583 | } |
584 | } | 584 | } |
585 | m_select = new FileSelector(mime, | 585 | m_select = new FileSelector(mime, |
586 | m_stack, "fileselector", | 586 | m_stack, "fileselector", |
587 | m_shNew, m_shClose); | 587 | m_shNew, m_shClose); |
588 | 588 | ||
589 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 589 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
590 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 590 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
591 | connect(m_select, SIGNAL(closeMe() ), | 591 | connect(m_select, SIGNAL(closeMe() ), |
592 | this, SIGNAL( closeMe() ) ); | 592 | this, SIGNAL( closeMe() ) ); |
593 | //connect to close me and other signals as well | 593 | //connect to close me and other signals as well |
594 | 594 | ||
595 | m_stack->addWidget( m_select, NORMAL ); | 595 | m_stack->addWidget( m_select, NORMAL ); |
596 | m_stack->raiseWidget( NORMAL ); | 596 | m_stack->raiseWidget( NORMAL ); |
597 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL | 597 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL |
598 | // and initializeListview will take care of those | 598 | // and initializeListview will take care of those |
599 | // toolbar get's generade in initializeListView | 599 | // toolbar get's generade in initializeListView |
600 | initializeListView( ); // will raise the widget as well | 600 | initializeListView( ); // will raise the widget as well |
601 | m_stack->raiseWidget( EXTENDED ); | 601 | m_stack->raiseWidget( EXTENDED ); |
602 | } | 602 | } |
603 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch | 603 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch |
604 | 604 | ||
605 | if( m_shLne ) // the LineEdit with the current FileName | 605 | if( m_shLne ) // the LineEdit with the current FileName |
606 | initializeName(); | 606 | initializeName(); |
607 | 607 | ||
608 | if( m_shPerm ) // the Permission QCheckBox | 608 | if( m_shPerm ) // the Permission QCheckBox |
@@ -622,18 +622,18 @@ void OFileSelector::updateMimes() | |||
622 | if( m_autoMime ){ | 622 | if( m_autoMime ){ |
623 | m_mimetypes.clear(); | 623 | m_mimetypes.clear(); |
624 | m_mimetypes.insert( tr("All"), QString::null ); | 624 | m_mimetypes.insert( tr("All"), QString::null ); |
625 | if( m_selector == NORMAL ){ | 625 | if( m_selector == NORMAL ){ |
626 | DocLnkSet set; | 626 | DocLnkSet set; |
627 | Global::findDocuments(&set, QString::null ); | 627 | Global::findDocuments(&set, QString::null ); |
628 | QListIterator<DocLnk> dit( set.children() ); | 628 | QListIterator<DocLnk> dit( set.children() ); |
629 | for( ; dit.current(); ++dit ){ | 629 | for( ; dit.current(); ++dit ){ |
630 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 630 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
631 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 631 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
632 | } | 632 | } |
633 | }// else done in reparse | 633 | }// else done in reparse |
634 | } | 634 | } |
635 | } | 635 | } |
636 | void OFileSelector::initVars() | 636 | void OFileSelector::initVars() |
637 | { | 637 | { |
638 | if( m_mimetypes.isEmpty() ) | 638 | if( m_mimetypes.isEmpty() ) |
639 | m_autoMime = true; | 639 | m_autoMime = true; |
@@ -691,57 +691,63 @@ void OFileSelector::addFile(const QString &/*mime*/, QFileInfo *info, bool symli | |||
691 | MimeType type( info->absFilePath() ); | 691 | MimeType type( info->absFilePath() ); |
692 | if (!compliesMime( type.id() ) ) | 692 | if (!compliesMime( type.id() ) ) |
693 | return; | 693 | return; |
694 | 694 | ||
695 | QPixmap pix = type.pixmap(); | 695 | QPixmap pix = type.pixmap(); |
696 | QString dir; | 696 | QString dir; |
697 | QString name; | 697 | QString name; |
698 | bool locked; | 698 | bool locked; |
699 | if( pix.isNull() ) | 699 | if( pix.isNull() ) { |
700 | pix = Resource::loadPixmap( "UnknownDocument-14"); | 700 | //TODO make this scaled pixmap global, so we dont have to keep doing this |
701 | QWMatrix matrix; | ||
702 | QPixmap pixer(Resource::loadPixmap( "UnknownDocument" )); | ||
703 | matrix.scale( .4, .4); | ||
704 | pix = pixer.xForm(matrix); | ||
705 | // pix = Resource::loadPixmap( "UnknownDocument-14"); | ||
706 | } | ||
701 | dir = info->dirPath( true ); | 707 | dir = info->dirPath( true ); |
702 | if( symlink ) | 708 | if( symlink ) |
703 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); | 709 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); |
704 | else { | 710 | else { |
705 | name = info->fileName(); | 711 | name = info->fileName(); |
706 | if( ( m_mode == OPEN && !info->isReadable() )|| | 712 | if( ( m_mode == OPEN && !info->isReadable() )|| |
707 | ( m_mode == SAVE && !info->isWritable() ) ){ | 713 | ( m_mode == SAVE && !info->isWritable() ) ){ |
708 | 714 | ||
709 | locked = true; pix = Resource::loadPixmap("locked"); | 715 | locked = true; pix = Resource::loadPixmap("locked"); |
710 | } | 716 | } |
711 | } | 717 | } |
712 | new OFileSelectorItem( m_View, pix, name, | 718 | new OFileSelectorItem( m_View, pix, name, |
713 | info->lastModified().toString(), | 719 | info->lastModified().toString(), |
714 | QString::number( info->size() ), | 720 | QString::number( info->size() ), |
715 | dir, locked ); | 721 | dir, locked ); |
716 | } | 722 | } |
717 | void OFileSelector::addDir(const QString &/*mime*/, QFileInfo *info, bool symlink ) | 723 | void OFileSelector::addDir(const QString &/*mime*/, QFileInfo *info, bool symlink ) |
718 | { | 724 | { |
719 | if(!m_dir) | 725 | if(!m_dir) |
720 | return; | 726 | return; |
721 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ | 727 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ |
722 | bool locked = false; | 728 | bool locked = false; |
723 | QString name; | 729 | QString name; |
724 | QPixmap pix; | 730 | QPixmap pix; |
725 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | 731 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ |
726 | locked = true; | 732 | locked = true; |
727 | if( symlink ) | 733 | if( symlink ) |
728 | pix = (*m_pixmaps)["symlinkedlocked"]; | 734 | pix = (*m_pixmaps)["symlinkedlocked"]; |
729 | else | 735 | else |
730 | pix = Resource::loadPixmap("lockedfolder"); | 736 | pix = Resource::loadPixmap("lockedfolder"); |
731 | }else { // readable | 737 | }else { // readable |
732 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; | 738 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; |
733 | } | 739 | } |
734 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; | 740 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; |
735 | new OFileSelectorItem( m_View, pix, name, | 741 | new OFileSelectorItem( m_View, pix, name, |
736 | info->lastModified().toString(), | 742 | info->lastModified().toString(), |
737 | QString::number( info->size() ), | 743 | QString::number( info->size() ), |
738 | info->dirPath( true ), locked, | 744 | info->dirPath( true ), locked, |
739 | true ); | 745 | true ); |
740 | 746 | ||
741 | }// else CUSTOM View | 747 | }// else CUSTOM View |
742 | } | 748 | } |
743 | void OFileSelector::delItems() | 749 | void OFileSelector::delItems() |
744 | { | 750 | { |
745 | 751 | ||
746 | } | 752 | } |
747 | void OFileSelector::initializeName() | 753 | void OFileSelector::initializeName() |
@@ -781,19 +787,19 @@ void OFileSelector::initializeYes() | |||
781 | 787 | ||
782 | //m_boxOk->addWidget( m_ok ); | 788 | //m_boxOk->addWidget( m_ok ); |
783 | //m_boxOk->addWidget( m_cancel ); | 789 | //m_boxOk->addWidget( m_cancel ); |
784 | m_boxOk->setMargin( 5 ); | 790 | m_boxOk->setMargin( 5 ); |
785 | m_boxOk->setSpacing( 10 ); | 791 | m_boxOk->setSpacing( 10 ); |
786 | m_lay->addWidget( m_boxOk, 0 ); | 792 | m_lay->addWidget( m_boxOk, 0 ); |
787 | 793 | ||
788 | connect( m_ok, SIGNAL( clicked() ), | 794 | connect( m_ok, SIGNAL( clicked() ), |
789 | this, SLOT(slotOk() ) ); | 795 | this, SLOT(slotOk() ) ); |
790 | connect( m_cancel, SIGNAL( clicked() ), | 796 | connect( m_cancel, SIGNAL( clicked() ), |
791 | this, SLOT( slotCancel() ) ); | 797 | this, SLOT( slotCancel() ) ); |
792 | } | 798 | } |
793 | } | 799 | } |
794 | /* | 800 | /* |
795 | * OK m_mimeCheck is a QComboBox we now want to fill | 801 | * OK m_mimeCheck is a QComboBox we now want to fill |
796 | * out that combobox | 802 | * out that combobox |
797 | * if automime we need to update the mimetypes | 803 | * if automime we need to update the mimetypes |
798 | */ | 804 | */ |
799 | void OFileSelector::updateMimeCheck() { | 805 | void OFileSelector::updateMimeCheck() { |
@@ -819,19 +825,19 @@ void OFileSelector::initializeChooser() | |||
819 | m_lay->addWidget(m_boxView, 0 ); | 825 | m_lay->addWidget(m_boxView, 0 ); |
820 | 826 | ||
821 | m_viewCheck->insertItem( tr("Documents") ); | 827 | m_viewCheck->insertItem( tr("Documents") ); |
822 | m_viewCheck->insertItem( tr("Files") ); | 828 | m_viewCheck->insertItem( tr("Files") ); |
823 | m_viewCheck->insertItem( tr("All Files") ); | 829 | m_viewCheck->insertItem( tr("All Files") ); |
824 | updateMimeCheck(); | 830 | updateMimeCheck(); |
825 | 831 | ||
826 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 832 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
827 | this, SLOT( slotViewCheck(const QString & ) ) ); | 833 | this, SLOT( slotViewCheck(const QString & ) ) ); |
828 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | 834 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), |
829 | this, SLOT( slotMimeCheck( const QString & ) ) ); | 835 | this, SLOT( slotMimeCheck( const QString & ) ) ); |
830 | } | 836 | } |
831 | } | 837 | } |
832 | void OFileSelector::initializeListView() | 838 | void OFileSelector::initializeListView() |
833 | { | 839 | { |
834 | qWarning("initializeListView"); | 840 | qWarning("initializeListView"); |
835 | if( m_pseudo == 0 ){ | 841 | if( m_pseudo == 0 ){ |
836 | qWarning("init"); | 842 | qWarning("init"); |
837 | m_pseudo = new QWidget( m_stack, "Pseudo Widget"); | 843 | m_pseudo = new QWidget( m_stack, "Pseudo Widget"); |
@@ -842,99 +848,100 @@ void OFileSelector::initializeListView() | |||
842 | 848 | ||
843 | // toolbar members | 849 | // toolbar members |
844 | { | 850 | { |
845 | // location QComboBox | 851 | // location QComboBox |
846 | m_location = new QComboBox( m_boxToolbar ); | 852 | m_location = new QComboBox( m_boxToolbar ); |
847 | m_location->setEditable( TRUE ); | 853 | m_location->setEditable( TRUE ); |
848 | m_location->setDuplicatesEnabled( FALSE ); | 854 | m_location->setDuplicatesEnabled( FALSE ); |
849 | connect( m_location, SIGNAL(activated(const QString &) ), | 855 | connect( m_location, SIGNAL(activated(const QString &) ), |
850 | this, SLOT( slotLocationActivated(const QString &) ) ); | 856 | this, SLOT( slotLocationActivated(const QString &) ) ); |
851 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), | 857 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), |
852 | this, SLOT(locationComboChanged() ) ); | 858 | this, SLOT(locationComboChanged() ) ); |
853 | // UP Button | 859 | // UP Button |
854 | m_up = new QPushButton(Resource::loadIconSet("up"),"", | 860 | m_up = new QPushButton(Resource::loadIconSet("up"),"", |
855 | m_boxToolbar,"cdUpButton"); | 861 | m_boxToolbar,"cdUpButton"); |
856 | m_up->setFixedSize( QSize( 20, 20 ) ); | 862 | m_up->setFixedSize( QSize( 20, 20 ) ); |
857 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | 863 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); |
858 | m_up->setFlat(TRUE); | 864 | m_up->setFlat(TRUE); |
859 | 865 | ||
860 | // Home Button | 866 | // Home Button |
861 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , | 867 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , |
862 | "", m_boxToolbar); | 868 | "", m_boxToolbar); |
863 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); | 869 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); |
864 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | 870 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); |
865 | m_homeButton->setFlat(TRUE); | 871 | m_homeButton->setFlat(TRUE); |
866 | // Documents Button | 872 | // Documents Button |
867 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", | 873 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", |
868 | m_boxToolbar,"docsButton"); | 874 | m_boxToolbar,"docsButton"); |
869 | m_docButton->setFixedSize( QSize( 20, 20 ) ); | 875 | m_docButton->setFixedSize( QSize( 20, 20 ) ); |
870 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | 876 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); |
871 | m_docButton->setFlat(TRUE); | 877 | m_docButton->setFlat(TRUE); |
872 | 878 | ||
873 | // Close button | 879 | // Close button |
874 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | 880 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", |
875 | m_boxToolbar ); | 881 | m_boxToolbar ); |
876 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | 882 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); |
877 | m_close->setFixedSize( 20, 20 ); | 883 | m_close->setFixedSize( 20, 20 ); |
878 | 884 | ||
879 | m_boxToolbar->setFixedHeight( 20 ); | 885 | m_boxToolbar->setFixedHeight( 20 ); |
880 | m_pseudoLayout->addWidget(m_boxToolbar ); | 886 | m_pseudoLayout->addWidget(m_boxToolbar ); |
881 | 887 | ||
882 | // let;s fill the Location ComboBox | 888 | // let;s fill the Location ComboBox |
883 | StorageInfo storage; | 889 | StorageInfo storage; |
884 | const QList<FileSystem> &fs = storage.fileSystems(); | 890 | const QList<FileSystem> &fs = storage.fileSystems(); |
885 | QListIterator<FileSystem> it ( fs ); | 891 | QListIterator<FileSystem> it ( fs ); |
886 | for( ; it.current(); ++it ){ | 892 | for( ; it.current(); ++it ){ |
887 | const QString disk = (*it)->name(); | 893 | const QString disk = (*it)->name(); |
888 | const QString path = (*it)->path(); | 894 | const QString path = (*it)->path(); |
889 | m_location->insertItem(path+ "<-"+disk ); | 895 | m_location->insertItem(path+ "<-"+disk ); |
890 | } | 896 | } |
891 | int count = m_location->count(); | 897 | int count = m_location->count(); |
892 | m_location->insertItem( m_currentDir ); | 898 | m_location->insertItem( m_currentDir ); |
893 | m_location->setCurrentItem( count ); | 899 | m_location->setCurrentItem( count ); |
894 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it | 900 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it |
895 | if( !m_shTool ){ | 901 | if( !m_shTool ){ |
896 | m_location->hide( ); | 902 | m_location->hide( ); |
897 | m_up->hide( ); | 903 | m_up->hide( ); |
898 | m_homeButton->hide( ); | 904 | m_homeButton->hide( ); |
899 | m_docButton->hide( ); | 905 | m_docButton->hide( ); |
900 | } | 906 | } |
901 | if(!m_shClose ) | 907 | if(!m_shClose ) |
902 | m_close->hide(); | 908 | m_close->hide(); |
903 | //if(!m_shNew) | 909 | //if(!m_shNew) |
904 | //m_close->hide(); | 910 | //m_close->hide(); |
905 | 911 | ||
906 | } // off toolbar | 912 | } // off toolbar |
907 | // the Main ListView | 913 | // the Main ListView |
908 | // make a QWidgetStack first so Views can share the Toolbar | 914 | // make a QWidgetStack first so Views can share the Toolbar |
909 | m_View = new QListView( m_pseudo, "Extended view"); | 915 | m_View = new QListView( m_pseudo, "Extended view"); |
910 | QPEApplication::setStylusOperation( m_View->viewport(), | 916 | QPEApplication::setStylusOperation( m_View->viewport(), |
911 | QPEApplication::RightOnHold); | 917 | QPEApplication::RightOnHold); |
912 | m_View->addColumn(" " ); | 918 | m_View->addColumn(" " ); |
913 | m_View->addColumn(tr("Name"), 135 ); | 919 | m_View->addColumn(tr("Name"), 135 ); |
914 | m_View->addColumn(tr("Size"), -1 ); | 920 | m_View->addColumn(tr("Size"), -1 ); |
915 | m_View->addColumn(tr("Date"), 60 ); | 921 | m_View->addColumn(tr("Date"), 60 ); |
916 | m_View->addColumn(tr("Mime Type"), -1 ); | 922 | m_View->addColumn(tr("Mime Type"), -1 ); |
917 | QHeader *header = m_View->header(); | 923 | QHeader *header = m_View->header(); |
918 | header->hide(); | 924 | header->hide(); |
919 | m_View->setSorting( 1 ); | 925 | m_View->setSorting( 1 ); |
920 | m_View->setAllColumnsShowFocus( TRUE ); | 926 | m_View->setAllColumnsShowFocus( TRUE ); |
921 | 927 | ||
922 | connect(m_View, SIGNAL(selectionChanged() ), | 928 | connect(m_View, SIGNAL(selectionChanged() ), |
923 | this, SLOT(slotSelectionChanged() ) ); | 929 | this, SLOT(slotSelectionChanged() ) ); |
924 | 930 | ||
925 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), | 931 | connect(m_View, SIGNAL(clicked(QListViewItem *) ), |
926 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | 932 | // connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), |
933 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | ||
927 | 934 | ||
928 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | 935 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), |
929 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | 936 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); |
930 | 937 | ||
931 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | 938 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), |
932 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | 939 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); |
933 | 940 | ||
934 | m_pseudoLayout->addWidget( m_View, 288 ); | 941 | m_pseudoLayout->addWidget( m_View, 288 ); |
935 | m_stack->addWidget( m_pseudo, EXTENDED ); | 942 | m_stack->addWidget( m_pseudo, EXTENDED ); |
936 | } | 943 | } |
937 | } | 944 | } |
938 | void OFileSelector::initializePerm() | 945 | void OFileSelector::initializePerm() |
939 | { | 946 | { |
940 | if( m_checkPerm == 0 ){ | 947 | if( m_checkPerm == 0 ){ |
@@ -1045,17 +1052,17 @@ void OFileSelector::slotCurrentChanged(QListViewItem* item ) | |||
1045 | { | 1052 | { |
1046 | if( item == 0 ) | 1053 | if( item == 0 ) |
1047 | return; | 1054 | return; |
1048 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 1055 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
1049 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) | 1056 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) |
1050 | qWarning("current changed"); | 1057 | qWarning("current changed"); |
1051 | if(!sel->isDir() ){ | 1058 | if(!sel->isDir() ){ |
1052 | if( m_shLne ) | 1059 | if( m_shLne ) |
1053 | m_edit->setText( sel->text(1) ); | 1060 | m_edit->setText( sel->text(1) ); |
1054 | 1061 | ||
1055 | if (m_mode == FILESELECTOR ) { | 1062 | if (m_mode == FILESELECTOR ) { |
1056 | QStringList str = QStringList::split("->", sel->text(1) ); | 1063 | QStringList str = QStringList::split("->", sel->text(1) ); |
1057 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); | 1064 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); |
1058 | emit fileSelected(path ); | 1065 | emit fileSelected(path ); |
1059 | DocLnk lnk( path ); | 1066 | DocLnk lnk( path ); |
1060 | emit fileSelected(lnk ); | 1067 | emit fileSelected(lnk ); |
1061 | } | 1068 | } |
@@ -1074,26 +1081,26 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint & | |||
1074 | default: | 1081 | default: |
1075 | break; | 1082 | break; |
1076 | case EXTENDED: // fall through | 1083 | case EXTENDED: // fall through |
1077 | case EXTENDED_ALL:{ | 1084 | case EXTENDED_ALL:{ |
1078 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 1085 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
1079 | if(!sel->isLocked() ){ | 1086 | if(!sel->isLocked() ){ |
1080 | QStringList str = QStringList::split("->", sel->text(1) ); | 1087 | QStringList str = QStringList::split("->", sel->text(1) ); |
1081 | if( sel->isDir() ){ | 1088 | if( sel->isDir() ){ |
1082 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1089 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
1083 | // if MODE Dir m_shLne set the Text | 1090 | // if MODE Dir m_shLne set the Text |
1084 | }else{ | 1091 | }else{ |
1085 | if( m_shLne ) | 1092 | if( m_shLne ) |
1086 | m_edit->setText( str[0].stripWhiteSpace() ); | 1093 | m_edit->setText( str[0].stripWhiteSpace() ); |
1087 | qWarning("selected here in slot clicked"); | 1094 | qWarning("selected here in slot clicked"); |
1088 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1095 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
1089 | DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1096 | DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
1090 | qWarning("file selected"); | 1097 | qWarning("file selected"); |
1091 | emit fileSelected( lnk ); | 1098 | emit fileSelected( lnk ); |
1092 | } | 1099 | } |
1093 | } | 1100 | } |
1094 | break; | 1101 | break; |
1095 | } | 1102 | } |
1096 | } | 1103 | } |
1097 | } | 1104 | } |
1098 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | 1105 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) |
1099 | { | 1106 | { |
@@ -1204,27 +1211,27 @@ void OFileSelector::reparse() | |||
1204 | QDir dir( m_currentDir ); | 1211 | QDir dir( m_currentDir ); |
1205 | if( dir.exists() ){ | 1212 | if( dir.exists() ){ |
1206 | dir.setFilter( QDir::Files | QDir::Readable ); | 1213 | dir.setFilter( QDir::Files | QDir::Readable ); |
1207 | dir.setSorting( QDir::Size ); | 1214 | dir.setSorting( QDir::Size ); |
1208 | const QFileInfoList *list = dir.entryInfoList(); | 1215 | const QFileInfoList *list = dir.entryInfoList(); |
1209 | QFileInfoListIterator it( *list ); | 1216 | QFileInfoListIterator it( *list ); |
1210 | QFileInfo *fi; | 1217 | QFileInfo *fi; |
1211 | while( (fi=it.current() ) ) { | 1218 | while( (fi=it.current() ) ) { |
1212 | if( fi->extension() == QString::fromLatin1("desktop") ){ | 1219 | if( fi->extension() == QString::fromLatin1("desktop") ){ |
1213 | ++it; | 1220 | ++it; |
1214 | continue; | 1221 | continue; |
1215 | } | 1222 | } |
1216 | MimeType type( fi->absFilePath() ); | 1223 | MimeType type( fi->absFilePath() ); |
1217 | if( !m_mimetypes.contains( type.id() ) ){ | 1224 | if( !m_mimetypes.contains( type.id() ) ){ |
1218 | //qWarning("Type %s", type.id().latin1() ); | 1225 | //qWarning("Type %s", type.id().latin1() ); |
1219 | m_mimetypes.insert( type.id(), type.id() ); | 1226 | m_mimetypes.insert( type.id(), type.id() ); |
1220 | } | 1227 | } |
1221 | 1228 | ||
1222 | ++it; | 1229 | ++it; |
1223 | } | 1230 | } |
1224 | // add them to the chooser | 1231 | // add them to the chooser |
1225 | updateMimeCheck(); | 1232 | updateMimeCheck(); |
1226 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | 1233 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); |
1227 | currentMimeType = m_mimeCheck->currentText(); | 1234 | currentMimeType = m_mimeCheck->currentText(); |
1228 | } | 1235 | } |
1229 | } | 1236 | } |
1230 | }else { // no autoMime | 1237 | }else { // no autoMime |
@@ -1263,32 +1270,32 @@ void OFileSelector::reparse() | |||
1263 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 1270 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
1264 | //qWarning(".. or ." ); | 1271 | //qWarning(".. or ." ); |
1265 | ++it; | 1272 | ++it; |
1266 | continue; | 1273 | continue; |
1267 | } | 1274 | } |
1268 | if( fi->isSymLink() ){ | 1275 | if( fi->isSymLink() ){ |
1269 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 1276 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
1270 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | 1277 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos |
1271 | QFileInfo info( file ); | 1278 | QFileInfo info( file ); |
1272 | if( !info.exists() ){ | 1279 | if( !info.exists() ){ |
1273 | addSymlink( currentMimeType, fi, TRUE ); | 1280 | addSymlink( currentMimeType, fi, TRUE ); |
1274 | break; | 1281 | break; |
1275 | }else if( info.isDir() ){ | 1282 | }else if( info.isDir() ){ |
1276 | addDir( currentMimeType, fi, TRUE ); | 1283 | addDir( currentMimeType, fi, TRUE ); |
1277 | break; | 1284 | break; |
1278 | }else if( info.isFile() ){ | 1285 | }else if( info.isFile() ){ |
1279 | addFile( currentMimeType, fi, TRUE ); | 1286 | addFile( currentMimeType, fi, TRUE ); |
1280 | break; | 1287 | break; |
1281 | }else if( info.isSymLink() ){ | 1288 | }else if( info.isSymLink() ){ |
1282 | file = info.dirPath(true ) + "/" + info.readLink() ; | 1289 | file = info.dirPath(true ) + "/" + info.readLink() ; |
1283 | break; | 1290 | break; |
1284 | }else if( i == 4){ | 1291 | }else if( i == 4){ |
1285 | addSymlink( currentMimeType, fi ); | 1292 | addSymlink( currentMimeType, fi ); |
1286 | } | 1293 | } |
1287 | } // off for loop | 1294 | } // off for loop |
1288 | }else if( fi->isDir() ){ | 1295 | }else if( fi->isDir() ){ |
1289 | addDir( currentMimeType, fi ); | 1296 | addDir( currentMimeType, fi ); |
1290 | }else if( fi->isFile() ){ | 1297 | }else if( fi->isFile() ){ |
1291 | addFile( currentMimeType, fi ); | 1298 | addFile( currentMimeType, fi ); |
1292 | } | 1299 | } |
1293 | //qWarning( "%s", fi->fileName().latin1() ); | 1300 | //qWarning( "%s", fi->fileName().latin1() ); |
1294 | ++it; | 1301 | ++it; |