-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 30 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.h | 3 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector_p.h | 2 |
3 files changed, 12 insertions, 23 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index e8d502f..01a51a2 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp | |||
@@ -111,96 +111,102 @@ QStringList OFileViewInterface::currentMimeType()const | |||
111 | return selector()->currentMimeType(); | 111 | return selector()->currentMimeType(); |
112 | } | 112 | } |
113 | 113 | ||
114 | void OFileViewInterface::activate( const QString& ) | 114 | void OFileViewInterface::activate( const QString& ) |
115 | { | 115 | { |
116 | // not implemented here | 116 | // not implemented here |
117 | } | 117 | } |
118 | 118 | ||
119 | void OFileViewInterface::ok() | 119 | void OFileViewInterface::ok() |
120 | { | 120 | { |
121 | emit selector()->ok(); | 121 | emit selector()->ok(); |
122 | } | 122 | } |
123 | 123 | ||
124 | void OFileViewInterface::cancel() | 124 | void OFileViewInterface::cancel() |
125 | { | 125 | { |
126 | emit selector()->cancel(); | 126 | emit selector()->cancel(); |
127 | } | 127 | } |
128 | 128 | ||
129 | void OFileViewInterface::closeMe() | 129 | void OFileViewInterface::closeMe() |
130 | { | 130 | { |
131 | emit selector()->closeMe(); | 131 | emit selector()->closeMe(); |
132 | } | 132 | } |
133 | 133 | ||
134 | void OFileViewInterface::fileSelected( const QString& str) | 134 | void OFileViewInterface::fileSelected( const QString& str) |
135 | { | 135 | { |
136 | emit selector()->fileSelected( str); | 136 | emit selector()->fileSelected( str); |
137 | } | 137 | } |
138 | 138 | ||
139 | void OFileViewInterface::fileSelected( const DocLnk& lnk) | 139 | void OFileViewInterface::fileSelected( const DocLnk& lnk) |
140 | { | 140 | { |
141 | emit selector()->fileSelected( lnk ); | 141 | emit selector()->fileSelected( lnk ); |
142 | } | 142 | } |
143 | 143 | ||
144 | void OFileViewInterface::setCurrentFileName( const QString& str ) | 144 | void OFileViewInterface::setCurrentFileName( const QString& str ) |
145 | { | 145 | { |
146 | selector()->m_lneEdit->setText( str ); | 146 | selector()->m_lneEdit->setText( str ); |
147 | } | 147 | } |
148 | 148 | ||
149 | QString OFileViewInterface::currentFileName()const | 149 | QString OFileViewInterface::currentFileName()const |
150 | { | 150 | { |
151 | return selector()->m_lneEdit->text(); | 151 | return selector()->m_lneEdit->text(); |
152 | } | 152 | } |
153 | 153 | ||
154 | QString OFileViewInterface::startDirectory()const | 154 | QString OFileViewInterface::startDirectory()const |
155 | { | 155 | { |
156 | return selector()->m_startDir; | 156 | return selector()->m_startDir; |
157 | } | 157 | } |
158 | 158 | ||
159 | bool OFileViewInterface::allItem( const QString& item )const | ||
160 | { | ||
161 | return selector()->m_allList.contains( item ); | ||
162 | } | ||
163 | |||
164 | |||
159 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 165 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
160 | :OFileViewInterface( selector ) | 166 | :OFileViewInterface( selector ) |
161 | { | 167 | { |
162 | m_selector = 0; | 168 | m_selector = 0; |
163 | setName( QObject::tr("Documents") ); | 169 | setName( QObject::tr("Documents") ); |
164 | } | 170 | } |
165 | 171 | ||
166 | ODocumentFileView::~ODocumentFileView() | 172 | ODocumentFileView::~ODocumentFileView() |
167 | { | 173 | { |
168 | } | 174 | } |
169 | 175 | ||
170 | QString ODocumentFileView::selectedName()const | 176 | QString ODocumentFileView::selectedName()const |
171 | { | 177 | { |
172 | if (!m_selector) | 178 | if (!m_selector) |
173 | return QString::null; | 179 | return QString::null; |
174 | 180 | ||
175 | return m_selector->selectedDocument().file(); | 181 | return m_selector->selectedDocument().file(); |
176 | } | 182 | } |
177 | 183 | ||
178 | QString ODocumentFileView::selectedPath()const | 184 | QString ODocumentFileView::selectedPath()const |
179 | { | 185 | { |
180 | return QPEApplication::documentDir(); | 186 | return QPEApplication::documentDir(); |
181 | } | 187 | } |
182 | 188 | ||
183 | QString ODocumentFileView::directory()const | 189 | QString ODocumentFileView::directory()const |
184 | { | 190 | { |
185 | return selectedPath(); | 191 | return selectedPath(); |
186 | } | 192 | } |
187 | 193 | ||
188 | void ODocumentFileView::reread() | 194 | void ODocumentFileView::reread() |
189 | { | 195 | { |
190 | if (!m_selector) | 196 | if (!m_selector) |
191 | return; | 197 | return; |
192 | 198 | ||
193 | m_selector->setNewVisible( showNew() ); | 199 | m_selector->setNewVisible( showNew() ); |
194 | m_selector->setCloseVisible( showClose() ); | 200 | m_selector->setCloseVisible( showClose() ); |
195 | m_selector->filter = currentMimeType().join(";"); | 201 | m_selector->filter = currentMimeType().join(";"); |
196 | m_selector->reread(); | 202 | m_selector->reread(); |
197 | } | 203 | } |
198 | 204 | ||
199 | int ODocumentFileView::fileCount()const | 205 | int ODocumentFileView::fileCount()const |
200 | { | 206 | { |
201 | if (!m_selector) | 207 | if (!m_selector) |
202 | return -1; | 208 | return -1; |
203 | 209 | ||
204 | return m_selector->fileCount(); | 210 | return m_selector->fileCount(); |
205 | } | 211 | } |
206 | 212 | ||
@@ -485,104 +491,96 @@ void OFileViewFileListView::reread( bool all ) | |||
485 | file = info.dirPath(true ) + "/" + info.readLink() ; | 491 | file = info.dirPath(true ) + "/" + info.readLink() ; |
486 | break; | 492 | break; |
487 | } | 493 | } |
488 | else if( i == 4) | 494 | else if( i == 4) |
489 | { // couldn't resolve symlink add it as symlink | 495 | { // couldn't resolve symlink add it as symlink |
490 | addSymlink( fi ); | 496 | addSymlink( fi ); |
491 | } | 497 | } |
492 | } // off for loop for symlink resolving | 498 | } // off for loop for symlink resolving |
493 | } | 499 | } |
494 | else if( fi->isDir() ) | 500 | else if( fi->isDir() ) |
495 | addDir( fi ); | 501 | addDir( fi ); |
496 | else if( fi->isFile() ) | 502 | else if( fi->isFile() ) |
497 | addFile( fi ); | 503 | addFile( fi ); |
498 | 504 | ||
499 | ++it; | 505 | ++it; |
500 | } // of while loop | 506 | } // of while loop |
501 | m_view->sort(); | 507 | m_view->sort(); |
502 | 508 | ||
503 | } | 509 | } |
504 | int OFileViewFileListView::fileCount()const | 510 | int OFileViewFileListView::fileCount()const |
505 | { | 511 | { |
506 | return m_view->childCount(); | 512 | return m_view->childCount(); |
507 | } | 513 | } |
508 | 514 | ||
509 | QString OFileViewFileListView::currentDir()const | 515 | QString OFileViewFileListView::currentDir()const |
510 | { | 516 | { |
511 | return m_currentDir; | 517 | return m_currentDir; |
512 | } | 518 | } |
513 | 519 | ||
514 | OFileSelector* OFileViewFileListView::selector() | 520 | OFileSelector* OFileViewFileListView::selector() |
515 | { | 521 | { |
516 | return m_sel; | 522 | return m_sel; |
517 | } | 523 | } |
518 | 524 | ||
519 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) | 525 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) |
520 | { | 526 | { |
521 | if ( e->type() == QEvent::KeyPress ) | 527 | if ( e->type() == QEvent::KeyPress ) |
522 | { | 528 | { |
523 | QKeyEvent *k = (QKeyEvent *)e; | 529 | QKeyEvent *k = (QKeyEvent *)e; |
524 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 530 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
525 | { | 531 | { |
526 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 532 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
527 | return true; | 533 | return true; |
528 | } | 534 | } |
529 | } | 535 | } |
530 | return false; | 536 | return false; |
531 | } | 537 | } |
532 | 538 | ||
533 | /** | ||
534 | * @return true if the item show all files or directories | ||
535 | */ | ||
536 | bool OFileViewFileListView::allItem( const QString& item )const | ||
537 | { | ||
538 | return m_sel->allItem( item ); | ||
539 | } | ||
540 | |||
541 | void OFileViewFileListView::connectSlots() | 539 | void OFileViewFileListView::connectSlots() |
542 | { | 540 | { |
543 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 541 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
544 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 542 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
545 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), | 543 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
546 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); | 544 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); |
547 | } | 545 | } |
548 | 546 | ||
549 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) | 547 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) |
550 | { | 548 | { |
551 | if (!item) | 549 | if (!item) |
552 | return; | 550 | return; |
553 | #if 0 | 551 | #if 0 |
554 | 552 | ||
555 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 553 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
556 | 554 | ||
557 | if (!sel->isDir() ) | 555 | if (!sel->isDir() ) |
558 | { | 556 | { |
559 | selector()->m_lneEdit->setText( sel->text(1) ); | 557 | selector()->m_lneEdit->setText( sel->text(1) ); |
560 | // if in fileselector mode we will emit selected | 558 | // if in fileselector mode we will emit selected |
561 | if ( selector()->mode() == OFileSelector::FileSelector ) | 559 | if ( selector()->mode() == OFileSelector::FileSelector ) |
562 | { | 560 | { |
563 | odebug << "slot Current Changed" << oendl; | 561 | odebug << "slot Current Changed" << oendl; |
564 | QStringList str = QStringList::split("->", sel->text(1) ); | 562 | QStringList str = QStringList::split("->", sel->text(1) ); |
565 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 563 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
566 | emit selector()->fileSelected( path ); | 564 | emit selector()->fileSelected( path ); |
567 | DocLnk lnk( path ); | 565 | DocLnk lnk( path ); |
568 | emit selector()->fileSelected( lnk ); | 566 | emit selector()->fileSelected( lnk ); |
569 | } | 567 | } |
570 | } | 568 | } |
571 | #endif | 569 | #endif |
572 | } | 570 | } |
573 | 571 | ||
574 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) | 572 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) |
575 | { | 573 | { |
576 | if (!item || ( button != Qt::LeftButton) ) | 574 | if (!item || ( button != Qt::LeftButton) ) |
577 | return; | 575 | return; |
578 | 576 | ||
579 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 577 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
580 | if (!sel->isLocked() ) | 578 | if (!sel->isLocked() ) |
581 | { | 579 | { |
582 | QStringList str = QStringList::split("->", sel->text(1) ); | 580 | QStringList str = QStringList::split("->", sel->text(1) ); |
583 | if (sel->isDir() ) | 581 | if (sel->isDir() ) |
584 | { | 582 | { |
585 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 583 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); |
586 | emit selector()->dirSelected( m_currentDir ); | 584 | emit selector()->dirSelected( m_currentDir ); |
587 | reread( m_all ); | 585 | reread( m_all ); |
588 | } | 586 | } |
@@ -780,147 +778,147 @@ QString OFileViewFileSystem::selectedName()const | |||
780 | QString cFN=currentFileName(); | 778 | QString cFN=currentFileName(); |
781 | if (cFN.startsWith("/")) return cFN; | 779 | if (cFN.startsWith("/")) return cFN; |
782 | return m_view->currentDir() + "/" + cFN; | 780 | return m_view->currentDir() + "/" + cFN; |
783 | } | 781 | } |
784 | 782 | ||
785 | QString OFileViewFileSystem::selectedPath()const | 783 | QString OFileViewFileSystem::selectedPath()const |
786 | { | 784 | { |
787 | return QString::null; | 785 | return QString::null; |
788 | } | 786 | } |
789 | 787 | ||
790 | QString OFileViewFileSystem::directory()const | 788 | QString OFileViewFileSystem::directory()const |
791 | { | 789 | { |
792 | if (!m_view) | 790 | if (!m_view) |
793 | return QString::null; | 791 | return QString::null; |
794 | 792 | ||
795 | OFileSelectorItem* item = m_view->currentItem(); | 793 | OFileSelectorItem* item = m_view->currentItem(); |
796 | if (!item ) | 794 | if (!item ) |
797 | return QString::null; | 795 | return QString::null; |
798 | 796 | ||
799 | return QDir(item->directory() ).absPath(); | 797 | return QDir(item->directory() ).absPath(); |
800 | } | 798 | } |
801 | 799 | ||
802 | void OFileViewFileSystem::reread() | 800 | void OFileViewFileSystem::reread() |
803 | { | 801 | { |
804 | if (!m_view) | 802 | if (!m_view) |
805 | return; | 803 | return; |
806 | 804 | ||
807 | m_view->reread( m_all ); | 805 | m_view->reread( m_all ); |
808 | } | 806 | } |
809 | 807 | ||
810 | int OFileViewFileSystem::fileCount()const | 808 | int OFileViewFileSystem::fileCount()const |
811 | { | 809 | { |
812 | if (!m_view ) | 810 | if (!m_view ) |
813 | return -1; | 811 | return -1; |
814 | return m_view->fileCount(); | 812 | return m_view->fileCount(); |
815 | } | 813 | } |
816 | 814 | ||
817 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) | 815 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) |
818 | { | 816 | { |
819 | if (!m_view ) | 817 | if (!m_view ) |
820 | { | 818 | { |
821 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 819 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
822 | } | 820 | } |
823 | return m_view; | 821 | return m_view; |
824 | } | 822 | } |
825 | 823 | ||
826 | void OFileViewFileSystem::activate( const QString& str ) | 824 | void OFileViewFileSystem::activate( const QString& str ) |
827 | { | 825 | { |
828 | m_all = m_view->allItem( str ); | 826 | m_all = allItem( str ); |
829 | } | 827 | } |
830 | 828 | ||
831 | 829 | ||
832 | } | 830 | } |
833 | /* Selector */ | 831 | /* Selector */ |
834 | /** | 832 | /** |
835 | * @short new and complete c'tor | 833 | * @short new and complete c'tor |
836 | * | 834 | * |
837 | * Create a OFileSelector to let the user select a file. It can | 835 | * Create a OFileSelector to let the user select a file. It can |
838 | * either be used to open a file, select a save name in a dir or | 836 | * either be used to open a file, select a save name in a dir or |
839 | * as a dropin for the FileSelector. | 837 | * as a dropin for the FileSelector. |
840 | * | 838 | * |
841 | * <pre> | 839 | * <pre> |
842 | * QMap<QString, QStringList> mimeTypes; | 840 | * QMap<QString, QStringList> mimeTypes; |
843 | * QStringList types; | 841 | * QStringList types; |
844 | * types << "text@slash* "; | 842 | * types << "text@slash* "; |
845 | * types << "audio@slash*"; | 843 | * types << "audio@slash*"; |
846 | * mimeTypes.insert( tr("Audio and Text"), types ); | 844 | * mimeTypes.insert( tr("Audio and Text"), types ); |
847 | * mimeTypes.insert( tr("All"), "*@slash*); | 845 | * mimeTypes.insert( tr("All"), "*@slash*); |
848 | * | 846 | * |
849 | * now you could create your fileselector | 847 | * now you could create your fileselector |
850 | * </pre> | 848 | * </pre> |
851 | * | 849 | * |
852 | * | 850 | * |
853 | * @param parent the parent of this widget | 851 | * @param parent the parent of this widget |
854 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) | 852 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) |
855 | * @param sel The selector to be used | 853 | * @param sel The selector to be used |
856 | * @param dirName The name of the dir to start int | 854 | * @param dirName The name of the dir to start int |
857 | * @param fileName The fileName placed in the fileselector lineedit | 855 | * @param fileName The fileName placed in the fileselector lineedit |
858 | * @param mimetypes The MimeType map of used mimetypes | 856 | * @param mimetypes The MimeType map of used mimetypes |
859 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. | 857 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. |
860 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. | 858 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. |
861 | * | 859 | * |
862 | */ | 860 | */ |
863 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 861 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
864 | const QString& dirName, const QString& fileName, | 862 | const QString& dirName, const QString& fileName, |
865 | const MimeTypes& mimetypes, | 863 | const MimeTypes& mimetypes, |
866 | bool showNew, bool showClose) | 864 | bool showNew, bool showClose) |
867 | :QWidget( parent, "OFileSelector" ) | 865 | :QWidget( parent, "OFileSelector" ) |
868 | { | 866 | { |
869 | m_current = 0; | 867 | m_current = 0; |
870 | m_shNew = showNew; | 868 | m_shNew = showNew; |
871 | m_shClose = showClose; | 869 | m_shClose = showClose; |
872 | m_mimeType = mimetypes; | 870 | m_mimeType = mimetypes; |
873 | m_startDir = dirName; | 871 | m_startDir = dirName; |
874 | 872 | ||
875 | m_mode = mode; | 873 | m_mode = mode; |
876 | m_selector = sel; | 874 | m_selector = sel; |
877 | 875 | ||
878 | m_allList = new QStringList(); | 876 | m_allList = QStringList(); |
879 | 877 | ||
880 | initUI(); | 878 | initUI(); |
881 | m_lneEdit->setText( fileName ); | 879 | m_lneEdit->setText( fileName ); |
882 | initMime(); | 880 | initMime(); |
883 | initViews(); | 881 | initViews(); |
884 | 882 | ||
885 | QString str; | 883 | QString str; |
886 | switch ( m_selector ) | 884 | switch ( m_selector ) |
887 | { | 885 | { |
888 | default: | 886 | default: |
889 | case Normal: | 887 | case Normal: |
890 | if ( m_mode == DIRECTORYSELECTOR ) | 888 | if ( m_mode == DIRECTORYSELECTOR ) |
891 | str = QObject::tr("Directories"); | 889 | str = QObject::tr("Directories"); |
892 | else | 890 | else |
893 | str = QObject::tr("Documents"); | 891 | str = QObject::tr("Documents"); |
894 | m_cmbView->setCurrentItem( 0 ); | 892 | m_cmbView->setCurrentItem( 0 ); |
895 | break; | 893 | break; |
896 | case Extended: | 894 | case Extended: |
897 | if ( m_mode == DIRECTORYSELECTOR ) | 895 | if ( m_mode == DIRECTORYSELECTOR ) |
898 | { | 896 | { |
899 | str = QObject::tr("Directories"); | 897 | str = QObject::tr("Directories"); |
900 | m_cmbView->setCurrentItem( 0 ); | 898 | m_cmbView->setCurrentItem( 0 ); |
901 | } else { | 899 | } else { |
902 | str = QObject::tr("Files"); | 900 | str = QObject::tr("Files"); |
903 | m_cmbView->setCurrentItem( 1 ); | 901 | m_cmbView->setCurrentItem( 1 ); |
904 | } | 902 | } |
905 | break; | 903 | break; |
906 | case ExtendedAll: | 904 | case ExtendedAll: |
907 | if ( m_mode == DIRECTORYSELECTOR ) | 905 | if ( m_mode == DIRECTORYSELECTOR ) |
908 | { | 906 | { |
909 | str = QObject::tr("All Directories"); | 907 | str = QObject::tr("All Directories"); |
910 | m_cmbView->setCurrentItem( 1 ); | 908 | m_cmbView->setCurrentItem( 1 ); |
911 | } else { | 909 | } else { |
912 | str = QObject::tr("All Files"); | 910 | str = QObject::tr("All Files"); |
913 | m_cmbView->setCurrentItem( 2 ); | 911 | m_cmbView->setCurrentItem( 2 ); |
914 | } | 912 | } |
915 | break; | 913 | break; |
916 | } | 914 | } |
917 | slotViewChange( str ); | 915 | slotViewChange( str ); |
918 | 916 | ||
919 | } | 917 | } |
920 | 918 | ||
921 | 919 | ||
922 | /** | 920 | /** |
923 | * This a convience c'tor to just substitute the use of FileSelector | 921 | * This a convience c'tor to just substitute the use of FileSelector |
924 | */ | 922 | */ |
925 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 923 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
926 | bool showNew, bool showClose ) | 924 | bool showNew, bool showClose ) |
@@ -988,102 +986,102 @@ bool OFileSelector::eventFilter (QObject *, QEvent *e) | |||
988 | return true; | 986 | return true; |
989 | } | 987 | } |
990 | } | 988 | } |
991 | return false; | 989 | return false; |
992 | } | 990 | } |
993 | 991 | ||
994 | /* | 992 | /* |
995 | * This will insert the MimeTypes into the Combo Box | 993 | * This will insert the MimeTypes into the Combo Box |
996 | * And also connect the changed signal | 994 | * And also connect the changed signal |
997 | * | 995 | * |
998 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes | 996 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes |
999 | */ | 997 | */ |
1000 | void OFileSelector::initMime() | 998 | void OFileSelector::initMime() |
1001 | { | 999 | { |
1002 | MimeTypes::Iterator it; | 1000 | MimeTypes::Iterator it; |
1003 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) | 1001 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) |
1004 | { | 1002 | { |
1005 | m_cmbMime->insertItem( it.key() ); | 1003 | m_cmbMime->insertItem( it.key() ); |
1006 | } | 1004 | } |
1007 | m_cmbMime->setCurrentItem( 0 ); | 1005 | m_cmbMime->setCurrentItem( 0 ); |
1008 | 1006 | ||
1009 | connect( m_cmbMime, SIGNAL(activated(int) ), | 1007 | connect( m_cmbMime, SIGNAL(activated(int) ), |
1010 | this, SLOT(slotMimeTypeChanged() ) ); | 1008 | this, SLOT(slotMimeTypeChanged() ) ); |
1011 | 1009 | ||
1012 | } | 1010 | } |
1013 | 1011 | ||
1014 | void OFileSelector::initViews() | 1012 | void OFileSelector::initViews() |
1015 | { | 1013 | { |
1016 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) | 1014 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) |
1017 | { | 1015 | { |
1018 | m_cmbView->insertItem( QObject::tr("Directories") ); | 1016 | m_cmbView->insertItem( QObject::tr("Directories") ); |
1019 | m_cmbView->insertItem( QObject::tr("All Directories") ); | 1017 | m_cmbView->insertItem( QObject::tr("All Directories") ); |
1020 | } else { | 1018 | } else { |
1021 | m_cmbView->insertItem( QObject::tr("Documents") ); | 1019 | m_cmbView->insertItem( QObject::tr("Documents") ); |
1022 | m_cmbView->insertItem( QObject::tr("Files") ); | 1020 | m_cmbView->insertItem( QObject::tr("Files") ); |
1023 | m_cmbView->insertItem( QObject::tr("All Files") ); | 1021 | m_cmbView->insertItem( QObject::tr("All Files") ); |
1024 | } | 1022 | } |
1025 | 1023 | ||
1026 | connect(m_cmbView, SIGNAL(activated(const QString&) ), | 1024 | connect(m_cmbView, SIGNAL(activated(const QString&) ), |
1027 | this, SLOT(slotViewChange(const QString&) ) ); | 1025 | this, SLOT(slotViewChange(const QString&) ) ); |
1028 | 1026 | ||
1029 | /* see above why add both */ | 1027 | /* see above why add both */ |
1030 | OFileViewInterface* in = new OFileViewFileSystem( this ); | 1028 | OFileViewInterface* in = new OFileViewFileSystem( this ); |
1031 | 1029 | ||
1032 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) | 1030 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) |
1033 | { | 1031 | { |
1034 | m_views.insert( QObject::tr("Directories"), in ); | 1032 | m_views.insert( QObject::tr("Directories"), in ); |
1035 | m_views.insert( QObject::tr("All Directories"), in ); | 1033 | m_views.insert( QObject::tr("All Directories"), in ); |
1036 | m_allList->append( QObject::tr("All Directories") ); | 1034 | m_allList.append( QObject::tr("All Directories") ); |
1037 | } else { | 1035 | } else { |
1038 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); | 1036 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); |
1039 | m_views.insert( QObject::tr("Files"), in ); | 1037 | m_views.insert( QObject::tr("Files"), in ); |
1040 | m_views.insert( QObject::tr("All Files"), in ); | 1038 | m_views.insert( QObject::tr("All Files"), in ); |
1041 | m_allList->append( QObject::tr("All Files") ); | 1039 | m_allList.append( QObject::tr("All Files") ); |
1042 | } | 1040 | } |
1043 | } | 1041 | } |
1044 | 1042 | ||
1045 | void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { | 1043 | void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { |
1046 | m_viewsPtr.append( iface ); | 1044 | m_viewsPtr.append( iface ); |
1047 | } | 1045 | } |
1048 | 1046 | ||
1049 | 1047 | ||
1050 | /** | 1048 | /** |
1051 | * d'tor | 1049 | * d'tor |
1052 | */ | 1050 | */ |
1053 | OFileSelector::~OFileSelector() | 1051 | OFileSelector::~OFileSelector() |
1054 | { | 1052 | { |
1055 | m_viewsPtr.setAutoDelete( true ); | 1053 | m_viewsPtr.setAutoDelete( true ); |
1056 | m_viewsPtr.clear(); | 1054 | m_viewsPtr.clear(); |
1057 | } | 1055 | } |
1058 | 1056 | ||
1059 | 1057 | ||
1060 | 1058 | ||
1061 | /** | 1059 | /** |
1062 | * Convience function for the fileselector | 1060 | * Convience function for the fileselector |
1063 | * make sure to delete the DocLnk | 1061 | * make sure to delete the DocLnk |
1064 | * | 1062 | * |
1065 | * @see DocLnk | 1063 | * @see DocLnk |
1066 | * @todo remove in ODP | 1064 | * @todo remove in ODP |
1067 | */ | 1065 | */ |
1068 | const DocLnk* OFileSelector::selected() | 1066 | const DocLnk* OFileSelector::selected() |
1069 | { | 1067 | { |
1070 | DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); | 1068 | DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); |
1071 | return lnk; | 1069 | return lnk; |
1072 | } | 1070 | } |
1073 | 1071 | ||
1074 | /** | 1072 | /** |
1075 | * | 1073 | * |
1076 | * @return the name of the selected file | 1074 | * @return the name of the selected file |
1077 | */ | 1075 | */ |
1078 | QString OFileSelector::selectedName()const | 1076 | QString OFileSelector::selectedName()const |
1079 | { | 1077 | { |
1080 | return currentView()->selectedName(); | 1078 | return currentView()->selectedName(); |
1081 | } | 1079 | } |
1082 | 1080 | ||
1083 | 1081 | ||
1084 | /** | 1082 | /** |
1085 | * @return the selected path | 1083 | * @return the selected path |
1086 | */ | 1084 | */ |
1087 | QString OFileSelector::selectedPath()const | 1085 | QString OFileSelector::selectedPath()const |
1088 | { | 1086 | { |
1089 | return currentView()->selectedPath(); | 1087 | return currentView()->selectedPath(); |
@@ -1113,104 +1111,96 @@ int OFileSelector::fileCount()const | |||
1113 | return currentView()->fileCount(); | 1111 | return currentView()->fileCount(); |
1114 | } | 1112 | } |
1115 | 1113 | ||
1116 | /** | 1114 | /** |
1117 | * @return reparse the file content | 1115 | * @return reparse the file content |
1118 | */ | 1116 | */ |
1119 | void OFileSelector::reread() | 1117 | void OFileSelector::reread() |
1120 | { | 1118 | { |
1121 | return currentView()->reread(); | 1119 | return currentView()->reread(); |
1122 | } | 1120 | } |
1123 | 1121 | ||
1124 | OFileViewInterface* OFileSelector::currentView()const | 1122 | OFileViewInterface* OFileSelector::currentView()const |
1125 | { | 1123 | { |
1126 | return m_current; | 1124 | return m_current; |
1127 | } | 1125 | } |
1128 | 1126 | ||
1129 | bool OFileSelector::showNew()const | 1127 | bool OFileSelector::showNew()const |
1130 | { | 1128 | { |
1131 | return m_shNew; | 1129 | return m_shNew; |
1132 | } | 1130 | } |
1133 | 1131 | ||
1134 | bool OFileSelector::showClose()const | 1132 | bool OFileSelector::showClose()const |
1135 | { | 1133 | { |
1136 | return m_shClose; | 1134 | return m_shClose; |
1137 | } | 1135 | } |
1138 | 1136 | ||
1139 | MimeTypes OFileSelector::mimeTypes()const | 1137 | MimeTypes OFileSelector::mimeTypes()const |
1140 | { | 1138 | { |
1141 | return m_mimeType; | 1139 | return m_mimeType; |
1142 | } | 1140 | } |
1143 | 1141 | ||
1144 | /** | 1142 | /** |
1145 | * @return the Mode of the OFileSelector | 1143 | * @return the Mode of the OFileSelector |
1146 | */ | 1144 | */ |
1147 | int OFileSelector::mode()const | 1145 | int OFileSelector::mode()const |
1148 | { | 1146 | { |
1149 | return m_mode; | 1147 | return m_mode; |
1150 | } | 1148 | } |
1151 | 1149 | ||
1152 | 1150 | ||
1153 | /** | 1151 | /** |
1154 | * @return the Selector of the OFileSelector | 1152 | * @return the Selector of the OFileSelector |
1155 | */ | 1153 | */ |
1156 | int OFileSelector::selector()const | 1154 | int OFileSelector::selector()const |
1157 | { | 1155 | { |
1158 | return m_selector; | 1156 | return m_selector; |
1159 | } | 1157 | } |
1160 | 1158 | ||
1161 | /** | ||
1162 | * @return true if the item show all files or directories | ||
1163 | */ | ||
1164 | bool OFileSelector::allItem( const QString& item )const | ||
1165 | { | ||
1166 | return ( m_allList->findIndex( item ) != -1 ); | ||
1167 | } | ||
1168 | |||
1169 | QStringList OFileSelector::currentMimeType()const | 1159 | QStringList OFileSelector::currentMimeType()const |
1170 | { | 1160 | { |
1171 | return m_mimeType[m_cmbMime->currentText()]; | 1161 | return m_mimeType[m_cmbMime->currentText()]; |
1172 | } | 1162 | } |
1173 | 1163 | ||
1174 | void OFileSelector::slotMimeTypeChanged() | 1164 | void OFileSelector::slotMimeTypeChanged() |
1175 | { | 1165 | { |
1176 | reread(); | 1166 | reread(); |
1177 | } | 1167 | } |
1178 | 1168 | ||
1179 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) | 1169 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) |
1180 | { | 1170 | { |
1181 | m_lneEdit->setText( lnk.name() ); | 1171 | m_lneEdit->setText( lnk.name() ); |
1182 | emit fileSelected( lnk ); | 1172 | emit fileSelected( lnk ); |
1183 | emit fileSelected( lnk.name() ); | 1173 | emit fileSelected( lnk.name() ); |
1184 | } | 1174 | } |
1185 | 1175 | ||
1186 | void OFileSelector::slotFileBridge( const QString& str) | 1176 | void OFileSelector::slotFileBridge( const QString& str) |
1187 | { | 1177 | { |
1188 | DocLnk lnk( str ); | 1178 | DocLnk lnk( str ); |
1189 | emit fileSelected( lnk ); | 1179 | emit fileSelected( lnk ); |
1190 | } | 1180 | } |
1191 | 1181 | ||
1192 | void OFileSelector::slotViewChange( const QString& view ) | 1182 | void OFileSelector::slotViewChange( const QString& view ) |
1193 | { | 1183 | { |
1194 | OFileViewInterface* interface = m_views[view]; | 1184 | OFileViewInterface* interface = m_views[view]; |
1195 | if (!interface) | 1185 | if (!interface) |
1196 | return; | 1186 | return; |
1197 | 1187 | ||
1198 | if (m_current) | 1188 | if (m_current) |
1199 | m_stack->removeWidget( m_current->widget( m_stack ) ); | 1189 | m_stack->removeWidget( m_current->widget( m_stack ) ); |
1200 | 1190 | ||
1201 | static int id = 1; | 1191 | static int id = 1; |
1202 | 1192 | ||
1203 | m_stack->addWidget( interface->widget(m_stack), id ); | 1193 | m_stack->addWidget( interface->widget(m_stack), id ); |
1204 | m_stack->raiseWidget( id ); | 1194 | m_stack->raiseWidget( id ); |
1205 | 1195 | ||
1206 | interface->activate( view ); | 1196 | interface->activate( view ); |
1207 | interface->reread(); | 1197 | interface->reread(); |
1208 | m_current = interface; | 1198 | m_current = interface; |
1209 | 1199 | ||
1210 | id++; | 1200 | id++; |
1211 | } | 1201 | } |
1212 | 1202 | ||
1213 | void OFileSelector::setNewVisible( bool b ) | 1203 | void OFileSelector::setNewVisible( bool b ) |
1214 | { | 1204 | { |
1215 | m_shNew = b; | 1205 | m_shNew = b; |
1216 | currentView()->reread(); | 1206 | currentView()->reread(); |
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h index d96712a..d166afd 100644 --- a/libopie2/opieui/fileselector/ofileselector.h +++ b/libopie2/opieui/fileselector/ofileselector.h | |||
@@ -76,161 +76,160 @@ class OFileViewFileListView; | |||
76 | class OFileSelector : public QWidget | 76 | class OFileSelector : public QWidget |
77 | { | 77 | { |
78 | Q_OBJECT | 78 | Q_OBJECT |
79 | friend class Internal::OFileViewInterface; | 79 | friend class Internal::OFileViewInterface; |
80 | friend class Internal::OFileViewFileListView; | 80 | friend class Internal::OFileViewFileListView; |
81 | 81 | ||
82 | public: | 82 | public: |
83 | /** | 83 | /** |
84 | * The Mode of the Fileselector | 84 | * The Mode of the Fileselector |
85 | * Open = Open A File | 85 | * Open = Open A File |
86 | * Save = Save a File | 86 | * Save = Save a File |
87 | * FILESELECTOR = As A GUI in a screen to select a file | 87 | * FILESELECTOR = As A GUI in a screen to select a file |
88 | * SelectDir = Select a Directory | 88 | * SelectDir = Select a Directory |
89 | */ | 89 | */ |
90 | enum Mode { Open = 1, Save = 2, DirectorySelector = 3, FileSelector = 4, OPEN = 1, SAVE = 2, DIRECTORYSELECTOR = 3, FILESELECTOR = 4 }; | 90 | enum Mode { Open = 1, Save = 2, DirectorySelector = 3, FileSelector = 4, OPEN = 1, SAVE = 2, DIRECTORYSELECTOR = 3, FILESELECTOR = 4 }; |
91 | // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; | 91 | // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; |
92 | /** | 92 | /** |
93 | * Normal = The old FileSelector | 93 | * Normal = The old FileSelector |
94 | * Extended = Dir View | 94 | * Extended = Dir View |
95 | * ExtendedAll = Dir View with all hidden files | 95 | * ExtendedAll = Dir View with all hidden files |
96 | * Default = What the vendor considers best | 96 | * Default = What the vendor considers best |
97 | */ | 97 | */ |
98 | enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; | 98 | enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; |
99 | // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; | 99 | // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; |
100 | 100 | ||
101 | OFileSelector(QWidget* parent, int mode, int selector, | 101 | OFileSelector(QWidget* parent, int mode, int selector, |
102 | const QString& dirName, | 102 | const QString& dirName, |
103 | const QString& fileName, | 103 | const QString& fileName, |
104 | const MimeTypes& mimetypes = MimeTypes(), | 104 | const MimeTypes& mimetypes = MimeTypes(), |
105 | bool newVisible = FALSE, bool closeVisible = FALSE ); | 105 | bool newVisible = FALSE, bool closeVisible = FALSE ); |
106 | 106 | ||
107 | OFileSelector(const QString& mimeFilter, QWidget* parent, | 107 | OFileSelector(const QString& mimeFilter, QWidget* parent, |
108 | const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); | 108 | const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); |
109 | ~OFileSelector(); | 109 | ~OFileSelector(); |
110 | 110 | ||
111 | const DocLnk* selected(); | 111 | const DocLnk* selected(); |
112 | 112 | ||
113 | QString selectedName()const; | 113 | QString selectedName()const; |
114 | QString selectedPath()const; | 114 | QString selectedPath()const; |
115 | QString directory()const; | 115 | QString directory()const; |
116 | 116 | ||
117 | DocLnk selectedDocument()const; | 117 | DocLnk selectedDocument()const; |
118 | 118 | ||
119 | int fileCount()const; | 119 | int fileCount()const; |
120 | void reread(); | 120 | void reread(); |
121 | 121 | ||
122 | int mode()const; | 122 | int mode()const; |
123 | int selector()const; | 123 | int selector()const; |
124 | bool allItem( const QString& )const; | ||
125 | 124 | ||
126 | /** | 125 | /** |
127 | * Set the Icon visible | 126 | * Set the Icon visible |
128 | * @param b Show or Hide the New Button | 127 | * @param b Show or Hide the New Button |
129 | */ | 128 | */ |
130 | void setNewVisible( bool b ); | 129 | void setNewVisible( bool b ); |
131 | 130 | ||
132 | /** | 131 | /** |
133 | * Set the Icon visible | 132 | * Set the Icon visible |
134 | */ | 133 | */ |
135 | void setCloseVisible( bool b ); | 134 | void setCloseVisible( bool b ); |
136 | 135 | ||
137 | /** | 136 | /** |
138 | * Set the Name Line visible | 137 | * Set the Name Line visible |
139 | */ | 138 | */ |
140 | void setNameVisible( bool b ); | 139 | void setNameVisible( bool b ); |
141 | 140 | ||
142 | signals: | 141 | signals: |
143 | /** | 142 | /** |
144 | * dirSelected is emitted whenever changed into a different dir | 143 | * dirSelected is emitted whenever changed into a different dir |
145 | */ | 144 | */ |
146 | void dirSelected( const QString& ); | 145 | void dirSelected( const QString& ); |
147 | 146 | ||
148 | /** | 147 | /** |
149 | * fileSelected is emitted when a file is selected | 148 | * fileSelected is emitted when a file is selected |
150 | * it uses a DocLnk as parameter | 149 | * it uses a DocLnk as parameter |
151 | */ | 150 | */ |
152 | void fileSelected( const DocLnk& ); | 151 | void fileSelected( const DocLnk& ); |
153 | 152 | ||
154 | /** | 153 | /** |
155 | * fileSelected is emitted when a file is selected | 154 | * fileSelected is emitted when a file is selected |
156 | * the complete path is a parameter | 155 | * the complete path is a parameter |
157 | */ | 156 | */ |
158 | void fileSelected( const QString& ); | 157 | void fileSelected( const QString& ); |
159 | 158 | ||
160 | /** | 159 | /** |
161 | * Create a new File with a DocLnk | 160 | * Create a new File with a DocLnk |
162 | */ | 161 | */ |
163 | void newSelected( const DocLnk& ); | 162 | void newSelected( const DocLnk& ); |
164 | 163 | ||
165 | void closeMe(); | 164 | void closeMe(); |
166 | 165 | ||
167 | /** | 166 | /** |
168 | * Ok is emitted on a Qt::Key_Return or Q::Key_Enter | 167 | * Ok is emitted on a Qt::Key_Return or Q::Key_Enter |
169 | * in the line edit | 168 | * in the line edit |
170 | */ | 169 | */ |
171 | void ok(); | 170 | void ok(); |
172 | void cancel(); | 171 | void cancel(); |
173 | 172 | ||
174 | /* used by the ViewInterface */ | 173 | /* used by the ViewInterface */ |
175 | private: | 174 | private: |
176 | bool showNew()const; | 175 | bool showNew()const; |
177 | bool showClose()const; | 176 | bool showClose()const; |
178 | MimeTypes mimeTypes()const; | 177 | MimeTypes mimeTypes()const; |
179 | QStringList currentMimeType()const; | 178 | QStringList currentMimeType()const; |
180 | 179 | ||
181 | private: | 180 | private: |
182 | /* inits the Widgets */ | 181 | /* inits the Widgets */ |
183 | void initUI(); | 182 | void initUI(); |
184 | /* inits the MimeType ComboBox content + connects signals and slots */ | 183 | /* inits the MimeType ComboBox content + connects signals and slots */ |
185 | void initMime(); | 184 | void initMime(); |
186 | /* init the Views :) */ | 185 | /* init the Views :) */ |
187 | void initViews(); | 186 | void initViews(); |
188 | 187 | ||
189 | 188 | ||
190 | /* | 189 | /* |
191 | * register a view for deletion. | 190 | * register a view for deletion. |
192 | * This happens on creation of a OFileViewInterface | 191 | * This happens on creation of a OFileViewInterface |
193 | */ | 192 | */ |
194 | void registerView( const Internal::OFileViewInterface* ); | 193 | void registerView( const Internal::OFileViewInterface* ); |
195 | 194 | ||
196 | private: | 195 | private: |
197 | QLineEdit* m_lneEdit; // the LineEdit for the Name | 196 | QLineEdit* m_lneEdit; // the LineEdit for the Name |
198 | QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType | 197 | QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType |
199 | QWidgetStack* m_stack; // our widget stack which will contain the views | 198 | QWidgetStack* m_stack; // our widget stack which will contain the views |
200 | Internal::OFileViewInterface* currentView() const; // returns the currentView | 199 | Internal::OFileViewInterface* currentView() const; // returns the currentView |
201 | Internal::OFileViewInterface* m_current; // here is the view saved | 200 | Internal::OFileViewInterface* m_current; // here is the view saved |
202 | bool m_shNew : 1; // should we show New? | 201 | bool m_shNew : 1; // should we show New? |
203 | bool m_shClose : 1; // should we show Close? | 202 | bool m_shClose : 1; // should we show Close? |
204 | MimeTypes m_mimeType; // list of mimetypes | 203 | MimeTypes m_mimeType; // list of mimetypes |
205 | 204 | ||
206 | QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr | 205 | QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr |
207 | /* views register themselves automatically */ | 206 | /* views register themselves automatically */ |
208 | QList<Internal::OFileViewInterface> m_viewsPtr; | 207 | QList<Internal::OFileViewInterface> m_viewsPtr; |
209 | QHBox* m_nameBox; // the LineEdit + Label is hold here | 208 | QHBox* m_nameBox; // the LineEdit + Label is hold here |
210 | QHBox* m_cmbBox; // this holds the two combo boxes | 209 | QHBox* m_cmbBox; // this holds the two combo boxes |
211 | 210 | ||
212 | QString m_startDir; | 211 | QString m_startDir; |
213 | int m_mode; | 212 | int m_mode; |
214 | int m_selector; | 213 | int m_selector; |
215 | 214 | ||
216 | QStringList* m_allList; | 215 | QStringList m_allList; |
217 | 216 | ||
218 | struct Data; // used for future versions | 217 | struct Data; // used for future versions |
219 | Data *d; | 218 | Data *d; |
220 | 219 | ||
221 | private slots: | 220 | private slots: |
222 | void slotMimeTypeChanged(); | 221 | void slotMimeTypeChanged(); |
223 | 222 | ||
224 | /* will set the text of the lineedit and emit a fileChanged signal */ | 223 | /* will set the text of the lineedit and emit a fileChanged signal */ |
225 | void slotDocLnkBridge( const DocLnk& ); | 224 | void slotDocLnkBridge( const DocLnk& ); |
226 | void slotFileBridge( const QString& ); | 225 | void slotFileBridge( const QString& ); |
227 | void slotViewChange( const QString& ); | 226 | void slotViewChange( const QString& ); |
228 | 227 | ||
229 | bool eventFilter (QObject *o, QEvent *e); | 228 | bool eventFilter (QObject *o, QEvent *e); |
230 | 229 | ||
231 | }; | 230 | }; |
232 | 231 | ||
233 | } | 232 | } |
234 | } | 233 | } |
235 | 234 | ||
236 | #endif | 235 | #endif |
diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h index 252a7f5..790d2bd 100644 --- a/libopie2/opieui/fileselector/ofileselector_p.h +++ b/libopie2/opieui/fileselector/ofileselector_p.h | |||
@@ -30,165 +30,165 @@ | |||
30 | #define OFILESELECTOR_PRIVATE_H | 30 | #define OFILESELECTOR_PRIVATE_H |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <qpe/applnk.h> | 33 | #include <qpe/applnk.h> |
34 | #include <qpe/fileselector.h> | 34 | #include <qpe/fileselector.h> |
35 | 35 | ||
36 | /* QT */ | 36 | /* QT */ |
37 | #include <qmap.h> | 37 | #include <qmap.h> |
38 | #include <qstringlist.h> | 38 | #include <qstringlist.h> |
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qlistview.h> | 40 | #include <qlistview.h> |
41 | 41 | ||
42 | /* | 42 | /* |
43 | * How to avoid having really two different objects | 43 | * How to avoid having really two different objects |
44 | * for Extended and ExtendedAll | 44 | * for Extended and ExtendedAll |
45 | * The only difference is the Lister... | 45 | * The only difference is the Lister... |
46 | * a) static object? | 46 | * a) static object? |
47 | * b) leave some object inside the OFileSelector which can be used? | 47 | * b) leave some object inside the OFileSelector which can be used? |
48 | * c) when switching views tell which view we want o have.. internally we can switch then | 48 | * c) when switching views tell which view we want o have.. internally we can switch then |
49 | * | 49 | * |
50 | * I'll take c) -zecke | 50 | * I'll take c) -zecke |
51 | */ | 51 | */ |
52 | 52 | ||
53 | typedef QMap<QString, QStringList> MimeTypes; | 53 | typedef QMap<QString, QStringList> MimeTypes; |
54 | 54 | ||
55 | /* the View Interface */ | 55 | /* the View Interface */ |
56 | class QFileInfo; | 56 | class QFileInfo; |
57 | class QToolButton; | 57 | class QToolButton; |
58 | 58 | ||
59 | namespace Opie{ | 59 | namespace Opie{ |
60 | namespace Ui{ | 60 | namespace Ui{ |
61 | class OFileSelector; | 61 | class OFileSelector; |
62 | namespace Internal { | 62 | namespace Internal { |
63 | 63 | ||
64 | class OFileViewInterface | 64 | class OFileViewInterface |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | OFileViewInterface( OFileSelector* selector ); | 67 | OFileViewInterface( OFileSelector* selector ); |
68 | virtual ~OFileViewInterface(); | 68 | virtual ~OFileViewInterface(); |
69 | virtual QString selectedName()const = 0; | 69 | virtual QString selectedName()const = 0; |
70 | virtual QString selectedPath()const = 0; | 70 | virtual QString selectedPath()const = 0; |
71 | virtual QString directory()const = 0; | 71 | virtual QString directory()const = 0; |
72 | virtual void reread() = 0; | 72 | virtual void reread() = 0; |
73 | virtual int fileCount()const = 0; | 73 | virtual int fileCount()const = 0; |
74 | virtual DocLnk selectedDocument()const; | 74 | virtual DocLnk selectedDocument()const; |
75 | virtual QWidget* widget( QWidget* parent) = 0; | 75 | virtual QWidget* widget( QWidget* parent) = 0; |
76 | virtual void activate( const QString& ); | 76 | virtual void activate( const QString& ); |
77 | QString name()const; | 77 | QString name()const; |
78 | bool allItem( const QString& )const; | ||
78 | protected: | 79 | protected: |
79 | OFileSelector* selector()const; | 80 | OFileSelector* selector()const; |
80 | void setName( const QString& ); | 81 | void setName( const QString& ); |
81 | bool showNew()const; | 82 | bool showNew()const; |
82 | bool showClose()const; | 83 | bool showClose()const; |
83 | MimeTypes mimeTypes()const; | 84 | MimeTypes mimeTypes()const; |
84 | QStringList currentMimeType()const; | 85 | QStringList currentMimeType()const; |
85 | QString startDirectory()const; | 86 | QString startDirectory()const; |
86 | protected: | 87 | protected: |
87 | void ok(); | 88 | void ok(); |
88 | void cancel(); | 89 | void cancel(); |
89 | void closeMe(); | 90 | void closeMe(); |
90 | void fileSelected( const QString& ); | 91 | void fileSelected( const QString& ); |
91 | void fileSelected( const DocLnk& ); | 92 | void fileSelected( const DocLnk& ); |
92 | void setCurrentFileName( const QString& ); | 93 | void setCurrentFileName( const QString& ); |
93 | QString currentFileName()const; | 94 | QString currentFileName()const; |
94 | 95 | ||
95 | private: | 96 | private: |
96 | QString m_name; | 97 | QString m_name; |
97 | OFileSelector* m_selector; | 98 | OFileSelector* m_selector; |
98 | }; | 99 | }; |
99 | 100 | ||
100 | 101 | ||
101 | /* THE Document View hosting a FileSelector*/ | 102 | /* THE Document View hosting a FileSelector*/ |
102 | class ODocumentFileView : public OFileViewInterface | 103 | class ODocumentFileView : public OFileViewInterface |
103 | { | 104 | { |
104 | public: | 105 | public: |
105 | ODocumentFileView( OFileSelector* selector ); | 106 | ODocumentFileView( OFileSelector* selector ); |
106 | ~ODocumentFileView(); | 107 | ~ODocumentFileView(); |
107 | 108 | ||
108 | QString selectedName() const; | 109 | QString selectedName() const; |
109 | QString selectedPath() const; | 110 | QString selectedPath() const; |
110 | 111 | ||
111 | QString directory() const; | 112 | QString directory() const; |
112 | void reread(); | 113 | void reread(); |
113 | int fileCount()const; | 114 | int fileCount()const; |
114 | DocLnk selectedDocument()const; | 115 | DocLnk selectedDocument()const; |
115 | 116 | ||
116 | QWidget* widget( QWidget* parent ); | 117 | QWidget* widget( QWidget* parent ); |
117 | 118 | ||
118 | private: | 119 | private: |
119 | mutable FileSelector* m_selector; | 120 | mutable FileSelector* m_selector; |
120 | 121 | ||
121 | }; | 122 | }; |
122 | 123 | ||
123 | 124 | ||
124 | class OFileSelectorItem : public QListViewItem | 125 | class OFileSelectorItem : public QListViewItem |
125 | { | 126 | { |
126 | public: | 127 | public: |
127 | OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 128 | OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
128 | const QString& path, const QString& date, | 129 | const QString& path, const QString& date, |
129 | const QString& size, const QString& mDir, | 130 | const QString& size, const QString& mDir, |
130 | bool isLocked = false, bool isDir = false ); | 131 | bool isLocked = false, bool isDir = false ); |
131 | ~OFileSelectorItem(); | 132 | ~OFileSelectorItem(); |
132 | bool isLocked()const; | 133 | bool isLocked()const; |
133 | bool isDir()const; | 134 | bool isDir()const; |
134 | QString directory()const; | 135 | QString directory()const; |
135 | QString path()const; | 136 | QString path()const; |
136 | QString key(int id, bool )const; | 137 | QString key(int id, bool )const; |
137 | 138 | ||
138 | private: | 139 | private: |
139 | bool m_locked : 1; | 140 | bool m_locked : 1; |
140 | bool m_isDir : 1; | 141 | bool m_isDir : 1; |
141 | QString m_dir; | 142 | QString m_dir; |
142 | }; | 143 | }; |
143 | 144 | ||
144 | class OFileViewFileListView : public QWidget | 145 | class OFileViewFileListView : public QWidget |
145 | { | 146 | { |
146 | Q_OBJECT | 147 | Q_OBJECT |
147 | public: | 148 | public: |
148 | OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); | 149 | OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); |
149 | ~OFileViewFileListView(); | 150 | ~OFileViewFileListView(); |
150 | 151 | ||
151 | OFileSelectorItem* currentItem()const; | 152 | OFileSelectorItem* currentItem()const; |
152 | void reread( bool all = false ); | 153 | void reread( bool all = false ); |
153 | int fileCount()const; | 154 | int fileCount()const; |
154 | QString currentDir()const; | 155 | QString currentDir()const; |
155 | bool allItem( const QString& )const; | ||
156 | protected: | 156 | protected: |
157 | bool eventFilter (QObject *o, QEvent *e); | 157 | bool eventFilter (QObject *o, QEvent *e); |
158 | private slots: | 158 | private slots: |
159 | void slotNew(); // will emit newSelected | 159 | void slotNew(); // will emit newSelected |
160 | void cdUP(); | 160 | void cdUP(); |
161 | void cdHome(); | 161 | void cdHome(); |
162 | void cdDoc(); | 162 | void cdDoc(); |
163 | void changeDir( const QString& ); | 163 | void changeDir( const QString& ); |
164 | void slotCurrentChanged( QListViewItem* ); | 164 | void slotCurrentChanged( QListViewItem* ); |
165 | void slotClicked(int, QListViewItem*, const QPoint&, int ); | 165 | void slotClicked(int, QListViewItem*, const QPoint&, int ); |
166 | void slotFSActivated(int); | 166 | void slotFSActivated(int); |
167 | 167 | ||
168 | protected: | 168 | protected: |
169 | OFileSelector* selector(); | 169 | OFileSelector* selector(); |
170 | 170 | ||
171 | private: | 171 | private: |
172 | QMap<QString, QString> m_dev; | 172 | QMap<QString, QString> m_dev; |
173 | bool m_all : 1; | 173 | bool m_all : 1; |
174 | OFileSelector* m_sel; | 174 | OFileSelector* m_sel; |
175 | QPopupMenu* m_fsPop; | 175 | QPopupMenu* m_fsPop; |
176 | bool compliesMime( const QString& ); | 176 | bool compliesMime( const QString& ); |
177 | QStringList m_mimes; // used in compy mime | 177 | QStringList m_mimes; // used in compy mime |
178 | QString m_currentDir; | 178 | QString m_currentDir; |
179 | QToolButton *m_btnNew, *m_btnClose; | 179 | QToolButton *m_btnNew, *m_btnClose; |
180 | void connectSlots(); | 180 | void connectSlots(); |
181 | void addFile( QFileInfo* info, bool symlink = FALSE ); | 181 | void addFile( QFileInfo* info, bool symlink = FALSE ); |
182 | void addDir ( QFileInfo* info, bool symlink = FALSE ); | 182 | void addDir ( QFileInfo* info, bool symlink = FALSE ); |
183 | void addSymlink( QFileInfo* info, bool = FALSE ); | 183 | void addSymlink( QFileInfo* info, bool = FALSE ); |
184 | 184 | ||
185 | 185 | ||
186 | private: | 186 | private: |
187 | QListView* m_view; | 187 | QListView* m_view; |
188 | }; | 188 | }; |
189 | 189 | ||
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | #endif | 194 | #endif |