-rw-r--r-- | libopie2/opieui/fileselector/ofiledialog.cpp | 4 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 56 |
2 files changed, 26 insertions, 34 deletions
diff --git a/libopie2/opieui/fileselector/ofiledialog.cpp b/libopie2/opieui/fileselector/ofiledialog.cpp index 2d38961..11a9e33 100644 --- a/libopie2/opieui/fileselector/ofiledialog.cpp +++ b/libopie2/opieui/fileselector/ofiledialog.cpp | |||
@@ -1,138 +1,138 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (C) Holger Freyther <freyther@handhelds.org> | 3 | .=l. Copyright (C) Holger Freyther <freyther@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; version 2 of the License. |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | /* OPIE */ | 30 | /* OPIE */ |
31 | #include <opie2/ofiledialog.h> | 31 | #include <opie2/ofiledialog.h> |
32 | #include <qpe/applnk.h> | 32 | #include <qpe/applnk.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | 35 | ||
36 | /* QT */ | 36 | /* QT */ |
37 | #include <qfileinfo.h> | 37 | #include <qfileinfo.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | 41 | ||
42 | 42 | ||
43 | /* TRANSLATOR Opie::Ui::OFileDialog */ | 43 | /* TRANSLATOR Opie::Ui::OFileDialog */ |
44 | 44 | ||
45 | using namespace Opie::Ui; | 45 | using namespace Opie::Ui; |
46 | 46 | ||
47 | namespace | 47 | namespace |
48 | { | 48 | { |
49 | /* | 49 | /* |
50 | * helper functions to load the start dir | 50 | * helper functions to load the start dir |
51 | * and to save it | 51 | * and to save it |
52 | * helper to extract the dir out of a file name | 52 | * helper to extract the dir out of a file name |
53 | */ | 53 | */ |
54 | /** | 54 | /** |
55 | * This method will use Config( argv[0] ); | 55 | * This method will use Config( argv[0] ); |
56 | * @param key The group key used | 56 | * @param key The group key used |
57 | */ | 57 | */ |
58 | QString lastUsedDir( const QString& key ) | 58 | QString lastUsedDir( const QString& key ) |
59 | { | 59 | { |
60 | if ( qApp->argc() < 1 ) | 60 | if ( qApp->argc() < 1 ) |
61 | return QString::null; | 61 | return QString::null; |
62 | 62 | ||
63 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname | 63 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname |
64 | cfg.setGroup( key ); | 64 | cfg.setGroup( key ); |
65 | return cfg.readEntry("LastDir", QPEApplication::documentDir() ); | 65 | return cfg.readEntry("LastDir", QPEApplication::documentDir() ); |
66 | } | 66 | } |
67 | 67 | ||
68 | void saveLastDir( const QString& key, const QString& file ) | 68 | void saveLastDir( const QString& key, const QString& file ) |
69 | { | 69 | { |
70 | if ( qApp->argc() < 1 ) | 70 | if ( qApp->argc() < 1 ) |
71 | return; | 71 | return; |
72 | 72 | ||
73 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); | 73 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); |
74 | cfg.setGroup( key ); | 74 | cfg.setGroup( key ); |
75 | QFileInfo inf( file ); | 75 | QFileInfo inf( file ); |
76 | if ( inf.isFile() ) | 76 | if ( inf.isFile() ) |
77 | cfg.writeEntry("LastDir", inf.dirPath( true ) ); | 77 | cfg.writeEntry("LastDir", inf.dirPath( true ) ); |
78 | else | 78 | else |
79 | cfg.writeEntry("LastDir", file ); | 79 | cfg.writeEntry("LastDir", file ); |
80 | } | 80 | } |
81 | }; | 81 | }; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * This constructs a modal dialog | 84 | * This constructs a modal dialog |
85 | * | 85 | * |
86 | * @param caption The caption of the dialog | 86 | * @param caption The caption of the dialog |
87 | * @param wid The parent widget | 87 | * @param wid The parent widget |
88 | * @param mode The mode of the OFileSelector @see OFileSelector | 88 | * @param mode The mode of the OFileSelector @see OFileSelector |
89 | * @param selector The selector of the OFileSelector | 89 | * @param selector The selector of the OFileSelector |
90 | * @param dirName the dir or resource to start from | 90 | * @param dirName the dir or resource to start from |
91 | * @param fileName a proposed or existing filename | 91 | * @param fileName a proposed or existing filename |
92 | * @param mimetypes The mimeTypes | 92 | * @param mimetypes The mimeTypes |
93 | */ | 93 | */ |
94 | OFileDialog::OFileDialog(const QString &caption, | 94 | OFileDialog::OFileDialog(const QString &caption, |
95 | QWidget *wid, int mode, int selector, | 95 | QWidget *wid, int mode, int selector, |
96 | const QString &dirName, | 96 | const QString &dirName, |
97 | const QString &fileName, | 97 | const QString &fileName, |
98 | const QMap<QString,QStringList>& mimetypes ) | 98 | const QMap<QString,QStringList>& mimetypes ) |
99 | : QDialog( wid, "OFileDialog", true ) | 99 | : QDialog( wid, "OFileDialog", true ) |
100 | { | 100 | { |
101 | QVBoxLayout *lay = new QVBoxLayout(this ); | 101 | QVBoxLayout *lay = new QVBoxLayout(this ); |
102 | file = new OFileSelector(this , mode, selector, | 102 | file = new OFileSelector(this , mode, selector, |
103 | dirName, fileName, | 103 | dirName, fileName, |
104 | mimetypes ); | 104 | mimetypes ); |
105 | lay->addWidget( file ); | 105 | lay->addWidget( file ); |
106 | 106 | ||
107 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); | 107 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); |
108 | connect(file, SIGNAL(fileSelected(const QString&) ), | 108 | connect(file, SIGNAL(fileSelected(const QString&) ), |
109 | this, SLOT(slotFileSelected(const QString&) ) ); | 109 | this, SLOT(slotFileSelected(const QString&) ) ); |
110 | connect(file, SIGNAL(ok() ), | 110 | connect(file, SIGNAL(ok() ), |
111 | this, SLOT(slotSelectorOk()) ) ; | 111 | this, SLOT(slotSelectorOk()) ) ; |
112 | 112 | ||
113 | connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); | 113 | connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); |
114 | } | 114 | } |
115 | /** | 115 | /** |
116 | * @returns the mimetype of the selected | 116 | * @returns the mimetype of the selected |
117 | * currently it return QString::null | 117 | * currently it return QString::null |
118 | */ | 118 | */ |
119 | QString OFileDialog::mimetype()const | 119 | QString OFileDialog::mimetype()const |
120 | { | 120 | { |
121 | return QString::null; | 121 | return QString::null; |
122 | } | 122 | } |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * @return the fileName | 125 | * @return the fileName |
126 | */ | 126 | */ |
127 | QString OFileDialog::fileName()const | 127 | QString OFileDialog::fileName()const |
128 | { | 128 | { |
129 | return file->selectedName(); | 129 | return file->selectedName(); |
130 | } | 130 | } |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * return a DocLnk to the current file | 133 | * return a DocLnk to the current file |
134 | */ | 134 | */ |
135 | DocLnk OFileDialog::selectedDocument()const | 135 | DocLnk OFileDialog::selectedDocument()const |
136 | { | 136 | { |
137 | return file->selectedDocument(); | 137 | return file->selectedDocument(); |
138 | } | 138 | } |
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 02404e5..5b5dc2f 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp | |||
@@ -1,156 +1,154 @@ | |||
1 | /* | 1 | /* |
2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project | 2 | =. This file is part of the OPIE Project |
3 | 3 | .=l. Copyright (C) Holger Freyther <freyther@handhelds.org> | |
4 | Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> | 4 | .>+-= |
5 | =. | 5 | _;:, .> :=|. This library is free software; you can |
6 | .=l. | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | Â Â Â Â Â Â .>+-= | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under | 9 | - . .-<_> .<> Foundation; version 2 of the License. |
10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public | 10 | ._= =} : |
11 | .="- .-=="i, Â Â .._ License as published by the Free Software | 11 | .%`+i> _;_. |
12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | Â Â .%`+i> Â Â Â _;_. | 14 | : .. .:, . . . without even the implied warranty of |
15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | : .. Â Â .:, Â Â . . . without even the implied warranty of | 17 | ..}^=.= = ; Library General Public License for more |
18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | ++= -. .` .: details. |
19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU | 19 | : = ...= . :.=- |
20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | ++= Â -. Â Â .` Â Â .: details. | 21 | -_. . . )=. = Library General Public License along with |
22 | : Â Â = Â ...= . :.=- | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU | ||
24 | Â -_. . . Â )=. Â = Library General Public License along with | ||
25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | |||
29 | */ | 27 | */ |
30 | 28 | ||
31 | /* hacky but we need to get FileSelector::filter */ | 29 | /* hacky but we need to get FileSelector::filter */ |
32 | #define private public | 30 | #define private public |
33 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
34 | #undef private | 32 | #undef private |
35 | 33 | ||
36 | #include "ofileselector_p.h" | 34 | #include "ofileselector_p.h" |
37 | 35 | ||
38 | /* OPIE */ | 36 | /* OPIE */ |
39 | #include <opie2/odebug.h> | 37 | #include <opie2/odebug.h> |
40 | #include <opie2/ofileselector.h> | 38 | #include <opie2/ofileselector.h> |
41 | #include <opie2/oresource.h> | 39 | #include <opie2/oresource.h> |
42 | 40 | ||
43 | #include <qpe/qpeapplication.h> | 41 | #include <qpe/qpeapplication.h> |
44 | #include <qpe/mimetype.h> | 42 | #include <qpe/mimetype.h> |
45 | #include <qpe/storage.h> | 43 | #include <qpe/storage.h> |
46 | 44 | ||
47 | /* QT */ | 45 | /* QT */ |
48 | #include <qcombobox.h> | 46 | #include <qcombobox.h> |
49 | #include <qdir.h> | 47 | #include <qdir.h> |
50 | #include <qhbox.h> | 48 | #include <qhbox.h> |
51 | #include <qheader.h> | 49 | #include <qheader.h> |
52 | #include <qlabel.h> | 50 | #include <qlabel.h> |
53 | #include <qlayout.h> | 51 | #include <qlayout.h> |
54 | #include <qlineedit.h> | 52 | #include <qlineedit.h> |
55 | #include <qlistview.h> | 53 | #include <qlistview.h> |
56 | #include <qpopupmenu.h> | 54 | #include <qpopupmenu.h> |
57 | #include <qwidgetstack.h> | 55 | #include <qwidgetstack.h> |
58 | #include <qregexp.h> | 56 | #include <qregexp.h> |
59 | #include <qobjectlist.h> | 57 | #include <qobjectlist.h> |
60 | 58 | ||
61 | using namespace Opie::Ui::Internal; | 59 | using namespace Opie::Ui::Internal; |
62 | 60 | ||
63 | namespace Opie { | 61 | namespace Opie { |
64 | namespace Ui { | 62 | namespace Ui { |
65 | namespace Internal { | 63 | namespace Internal { |
66 | /* | 64 | /* |
67 | * Create a path by adding a '/'/QDir::seperator in between | 65 | * Create a path by adding a '/'/QDir::seperator in between |
68 | * base and ending, but only if base is not empty | 66 | * base and ending, but only if base is not empty |
69 | */ | 67 | */ |
70 | static inline QString createNewPath(const QString& base, const QString &ending) { | 68 | static inline QString createNewPath(const QString& base, const QString &ending) { |
71 | return base == QString::fromLatin1("/") ? | 69 | return base == QString::fromLatin1("/") ? |
72 | base + ending : base + "/" + ending; | 70 | base + ending : base + "/" + ending; |
73 | } | 71 | } |
74 | 72 | ||
75 | 73 | ||
76 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) | 74 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) |
77 | : m_selector( _selector ) | 75 | : m_selector( _selector ) |
78 | { | 76 | { |
79 | selector()->registerView( this ); | 77 | selector()->registerView( this ); |
80 | } | 78 | } |
81 | 79 | ||
82 | OFileViewInterface::~OFileViewInterface() | 80 | OFileViewInterface::~OFileViewInterface() |
83 | {} | 81 | {} |
84 | 82 | ||
85 | QString OFileViewInterface::name()const | 83 | QString OFileViewInterface::name()const |
86 | { | 84 | { |
87 | return m_name; | 85 | return m_name; |
88 | } | 86 | } |
89 | 87 | ||
90 | void OFileViewInterface::setName( const QString& name ) | 88 | void OFileViewInterface::setName( const QString& name ) |
91 | { | 89 | { |
92 | m_name = name; | 90 | m_name = name; |
93 | } | 91 | } |
94 | 92 | ||
95 | OFileSelector* OFileViewInterface::selector()const | 93 | OFileSelector* OFileViewInterface::selector()const |
96 | { | 94 | { |
97 | return m_selector; | 95 | return m_selector; |
98 | } | 96 | } |
99 | 97 | ||
100 | DocLnk OFileViewInterface::selectedDocument()const | 98 | DocLnk OFileViewInterface::selectedDocument()const |
101 | { | 99 | { |
102 | return DocLnk( selectedName() ); | 100 | return DocLnk( selectedName() ); |
103 | } | 101 | } |
104 | 102 | ||
105 | bool OFileViewInterface::showNew()const | 103 | bool OFileViewInterface::showNew()const |
106 | { | 104 | { |
107 | return selector()->showNew(); | 105 | return selector()->showNew(); |
108 | } | 106 | } |
109 | 107 | ||
110 | bool OFileViewInterface::showClose()const | 108 | bool OFileViewInterface::showClose()const |
111 | { | 109 | { |
112 | return selector()->showClose(); | 110 | return selector()->showClose(); |
113 | } | 111 | } |
114 | 112 | ||
115 | MimeTypes OFileViewInterface::mimeTypes()const | 113 | MimeTypes OFileViewInterface::mimeTypes()const |
116 | { | 114 | { |
117 | return selector()->mimeTypes(); | 115 | return selector()->mimeTypes(); |
118 | } | 116 | } |
119 | 117 | ||
120 | QStringList OFileViewInterface::currentMimeType()const | 118 | QStringList OFileViewInterface::currentMimeType()const |
121 | { | 119 | { |
122 | return selector()->currentMimeType(); | 120 | return selector()->currentMimeType(); |
123 | } | 121 | } |
124 | 122 | ||
125 | void OFileViewInterface::activate( const QString& ) | 123 | void OFileViewInterface::activate( const QString& ) |
126 | { | 124 | { |
127 | // not implemented here | 125 | // not implemented here |
128 | } | 126 | } |
129 | 127 | ||
130 | void OFileViewInterface::ok() | 128 | void OFileViewInterface::ok() |
131 | { | 129 | { |
132 | emit selector()->ok(); | 130 | emit selector()->ok(); |
133 | } | 131 | } |
134 | 132 | ||
135 | void OFileViewInterface::cancel() | 133 | void OFileViewInterface::cancel() |
136 | { | 134 | { |
137 | emit selector()->cancel(); | 135 | emit selector()->cancel(); |
138 | } | 136 | } |
139 | 137 | ||
140 | void OFileViewInterface::closeMe() | 138 | void OFileViewInterface::closeMe() |
141 | { | 139 | { |
142 | emit selector()->closeMe(); | 140 | emit selector()->closeMe(); |
143 | } | 141 | } |
144 | 142 | ||
145 | void OFileViewInterface::fileSelected( const QString& str) | 143 | void OFileViewInterface::fileSelected( const QString& str) |
146 | { | 144 | { |
147 | emit selector()->fileSelected( str); | 145 | emit selector()->fileSelected( str); |
148 | } | 146 | } |
149 | 147 | ||
150 | void OFileViewInterface::fileSelected( const DocLnk& lnk) | 148 | void OFileViewInterface::fileSelected( const DocLnk& lnk) |
151 | { | 149 | { |
152 | emit selector()->fileSelected( lnk ); | 150 | emit selector()->fileSelected( lnk ); |
153 | } | 151 | } |
154 | 152 | ||
155 | void OFileViewInterface::setCurrentFileName( const QString& str ) | 153 | void OFileViewInterface::setCurrentFileName( const QString& str ) |
156 | { | 154 | { |
@@ -506,275 +504,269 @@ void OFileViewFileListView::reread( bool all ) | |||
506 | else if( info.isDir() ) | 504 | else if( info.isDir() ) |
507 | { | 505 | { |
508 | addDir( fi, TRUE ); | 506 | addDir( fi, TRUE ); |
509 | break; | 507 | break; |
510 | } | 508 | } |
511 | else if( info.isFile() ) | 509 | else if( info.isFile() ) |
512 | { | 510 | { |
513 | addFile( fi, TRUE ); | 511 | addFile( fi, TRUE ); |
514 | break; | 512 | break; |
515 | } | 513 | } |
516 | else if( info.isSymLink() ) | 514 | else if( info.isSymLink() ) |
517 | { | 515 | { |
518 | file = createNewPath(info.dirPath(true ),info.readLink()); | 516 | file = createNewPath(info.dirPath(true ),info.readLink()); |
519 | break; | 517 | break; |
520 | } | 518 | } |
521 | else if( i == 4) | 519 | else if( i == 4) |
522 | { // couldn't resolve symlink add it as symlink | 520 | { // couldn't resolve symlink add it as symlink |
523 | addSymlink( fi ); | 521 | addSymlink( fi ); |
524 | } | 522 | } |
525 | } // off for loop for symlink resolving | 523 | } // off for loop for symlink resolving |
526 | } | 524 | } |
527 | else if( fi->isDir() ) | 525 | else if( fi->isDir() ) |
528 | addDir( fi ); | 526 | addDir( fi ); |
529 | else if( fi->isFile() ) | 527 | else if( fi->isFile() ) |
530 | addFile( fi ); | 528 | addFile( fi ); |
531 | 529 | ||
532 | ++it; | 530 | ++it; |
533 | } // of while loop | 531 | } // of while loop |
534 | m_view->sort(); | 532 | m_view->sort(); |
535 | 533 | ||
536 | } | 534 | } |
537 | int OFileViewFileListView::fileCount()const | 535 | int OFileViewFileListView::fileCount()const |
538 | { | 536 | { |
539 | return m_view->childCount(); | 537 | return m_view->childCount(); |
540 | } | 538 | } |
541 | 539 | ||
542 | QString OFileViewFileListView::currentDir()const | 540 | QString OFileViewFileListView::currentDir()const |
543 | { | 541 | { |
544 | return m_currentDir; | 542 | return m_currentDir; |
545 | } | 543 | } |
546 | 544 | ||
547 | OFileSelector* OFileViewFileListView::selector() | 545 | OFileSelector* OFileViewFileListView::selector() |
548 | { | 546 | { |
549 | return m_sel; | 547 | return m_sel; |
550 | } | 548 | } |
551 | 549 | ||
552 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) | 550 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) |
553 | { | 551 | { |
554 | if ( e->type() == QEvent::KeyPress ) | 552 | if ( e->type() == QEvent::KeyPress ) |
555 | { | 553 | { |
556 | QKeyEvent *k = (QKeyEvent *)e; | 554 | QKeyEvent *k = (QKeyEvent *)e; |
557 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 555 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
558 | { | 556 | { |
559 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 557 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
560 | return true; | 558 | return true; |
561 | } | 559 | } |
562 | } | 560 | } |
563 | return false; | 561 | return false; |
564 | } | 562 | } |
565 | 563 | ||
566 | void OFileViewFileListView::connectSlots() | 564 | void OFileViewFileListView::connectSlots() |
567 | { | 565 | { |
568 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 566 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
569 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 567 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
570 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), | 568 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
571 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); | 569 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); |
572 | } | 570 | } |
573 | 571 | ||
574 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) | 572 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) |
575 | { | 573 | { |
576 | if (!item) | 574 | if (!item) |
577 | return; | 575 | return; |
578 | #if 0 | 576 | #if 0 |
579 | 577 | ||
580 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 578 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
581 | 579 | ||
582 | if (!sel->isDir() ) | 580 | if (!sel->isDir() ) |
583 | { | 581 | { |
584 | selector()->m_lneEdit->setText( sel->text(1) ); | 582 | selector()->m_lneEdit->setText( sel->text(1) ); |
585 | // if in fileselector mode we will emit selected | 583 | // if in fileselector mode we will emit selected |
586 | if ( selector()->mode() == OFileSelector::FileSelector ) | 584 | if ( selector()->mode() == OFileSelector::FileSelector ) |
587 | { | 585 | { |
588 | odebug << "slot Current Changed" << oendl; | 586 | odebug << "slot Current Changed" << oendl; |
589 | QStringList str = QStringList::split("->", sel->text(1) ); | 587 | QStringList str = QStringList::split("->", sel->text(1) ); |
590 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); | 588 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
591 | emit selector()->fileSelected( path ); | 589 | emit selector()->fileSelected( path ); |
592 | DocLnk lnk( path ); | 590 | DocLnk lnk( path ); |
593 | emit selector()->fileSelected( lnk ); | 591 | emit selector()->fileSelected( lnk ); |
594 | } | 592 | } |
595 | } | 593 | } |
596 | #endif | 594 | #endif |
597 | } | 595 | } |
598 | 596 | ||
599 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) | 597 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) |
600 | { | 598 | { |
601 | if (!item || ( button != Qt::LeftButton) ) | 599 | if (!item || ( button != Qt::LeftButton) ) |
602 | return; | 600 | return; |
603 | 601 | ||
604 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 602 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
605 | if (!sel->isLocked() ) | 603 | if (!sel->isLocked() ) |
606 | { | 604 | { |
607 | QStringList str = QStringList::split("->", sel->text(1) ); | 605 | QStringList str = QStringList::split("->", sel->text(1) ); |
608 | if (sel->isDir() ) | 606 | if (sel->isDir() ) |
609 | { | 607 | { |
610 | m_currentDir = createNewPath(sel->directory(),str[0].stripWhiteSpace()); | 608 | m_currentDir = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
611 | emit selector()->dirSelected( m_currentDir ); | 609 | emit selector()->dirSelected( m_currentDir ); |
612 | reread( m_all ); | 610 | reread( m_all ); |
613 | } | 611 | } |
614 | else | 612 | else |
615 | { // file | 613 | { // file |
616 | odebug << "slot Clicked" << oendl; | 614 | odebug << "slot Clicked" << oendl; |
617 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 615 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
618 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); | 616 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
619 | emit selector()->fileSelected( path ); | 617 | emit selector()->fileSelected( path ); |
620 | DocLnk lnk( path ); | 618 | DocLnk lnk( path ); |
621 | emit selector()->fileSelected( lnk ); | 619 | emit selector()->fileSelected( lnk ); |
622 | } | 620 | } |
623 | } // not locked | 621 | } // not locked |
624 | } | 622 | } |
625 | 623 | ||
626 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) | 624 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) |
627 | { | 625 | { |
628 | MimeType type( info->absFilePath() ); | 626 | MimeType type( info->absFilePath() ); |
629 | if (!compliesMime( type.id() ) ) | 627 | if (!compliesMime( type.id() ) ) |
630 | return; | 628 | return; |
631 | 629 | ||
632 | QPixmap pix = type.pixmap(); | 630 | QPixmap pix = type.pixmap(); |
633 | QString dir, name; bool locked; | 631 | QString dir, name; bool locked; |
634 | if ( pix.isNull() ) | 632 | if ( pix.isNull() ) pix = Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ); |
635 | { | ||
636 | QWMatrix matrix; | ||
637 | QPixmap pixer( Opie::Core::OResource::loadPixmap( "UnknownDocument" ) ); | ||
638 | matrix.scale( .4, .4 ); | ||
639 | pix = pixer.xForm( matrix ); | ||
640 | } | ||
641 | dir = info->dirPath( true ); | 633 | dir = info->dirPath( true ); |
642 | locked = false; | 634 | locked = false; |
643 | if ( symlink ) | 635 | if ( symlink ) |
644 | name = info->fileName() + " -> " + createNewPath(info->dirPath(),info->readLink()); | 636 | name = info->fileName() + " -> " + createNewPath(info->dirPath(),info->readLink()); |
645 | else | 637 | else |
646 | { | 638 | { |
647 | name = info->fileName(); | 639 | name = info->fileName(); |
648 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 640 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
649 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) | 641 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) |
650 | { | 642 | { |
651 | locked = true; | 643 | locked = true; |
652 | pix = Opie::Core::OResource::loadPixmap( "locked" ); | 644 | pix = Opie::Core::OResource::loadPixmap( "locked", Opie::Core::OResource::SmallIcon ); |
653 | } | 645 | } |
654 | } | 646 | } |
655 | (void)new OFileSelectorItem( m_view, pix, name, | 647 | (void)new OFileSelectorItem( m_view, pix, name, |
656 | info->lastModified().toString(), QString::number( info->size() ), | 648 | info->lastModified().toString(), QString::number( info->size() ), |
657 | dir, locked ); | 649 | dir, locked ); |
658 | } | 650 | } |
659 | 651 | ||
660 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) | 652 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) |
661 | { | 653 | { |
662 | bool locked = false; QString name; QPixmap pix; | 654 | bool locked = false; QString name; QPixmap pix; |
663 | 655 | ||
664 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 656 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
665 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) | 657 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) |
666 | { | 658 | { |
667 | locked = true; | 659 | locked = true; |
668 | if ( symlink ) | 660 | if ( symlink ) |
669 | pix = Opie::Core::OResource::loadPixmap( "opie/symlink" ); | 661 | pix = Opie::Core::OResource::loadPixmap( "opie/symlink" ); |
670 | else | 662 | else |
671 | pix = Opie::Core::OResource::loadPixmap( "lockedfolder" ); | 663 | pix = Opie::Core::OResource::loadPixmap( "lockedfolder" ); |
672 | } | 664 | } |
673 | else | 665 | else |
674 | pix = symlink ? Opie::Core::OResource::loadPixmap( "opie/symlink" ) : Opie::Core::OResource::loadPixmap( "folder" ); | 666 | pix = symlink ? Opie::Core::OResource::loadPixmap( "opie/symlink" ) : Opie::Core::OResource::loadPixmap( "folder" ); |
675 | 667 | ||
676 | name = symlink ? info->fileName() + " -> " + createNewPath(info->dirPath(true),info->readLink()) : | 668 | name = symlink ? info->fileName() + " -> " + createNewPath(info->dirPath(true),info->readLink()) : |
677 | info->fileName(); | 669 | info->fileName(); |
678 | 670 | ||
679 | (void)new OFileSelectorItem( m_view, pix, name, | 671 | (void)new OFileSelectorItem( m_view, pix, name, |
680 | info->lastModified().toString(), | 672 | info->lastModified().toString(), |
681 | QString::number( info->size() ), | 673 | QString::number( info->size() ), |
682 | info->dirPath( true ), locked, true ); | 674 | info->dirPath( true ), locked, true ); |
683 | 675 | ||
684 | 676 | ||
685 | } | 677 | } |
686 | 678 | ||
687 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) | 679 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) |
688 | { | 680 | { |
689 | } | 681 | } |
690 | 682 | ||
691 | void OFileViewFileListView::cdUP() | 683 | void OFileViewFileListView::cdUP() |
692 | { | 684 | { |
693 | QDir dir( m_currentDir ); | 685 | QDir dir( m_currentDir ); |
694 | dir.cdUp(); | 686 | dir.cdUp(); |
695 | 687 | ||
696 | if (!dir.exists() ) | 688 | if (!dir.exists() ) |
697 | m_currentDir = "/"; | 689 | m_currentDir = "/"; |
698 | else | 690 | else |
699 | m_currentDir = dir.absPath(); | 691 | m_currentDir = dir.absPath(); |
700 | 692 | ||
701 | emit selector()->dirSelected( m_currentDir ); | 693 | emit selector()->dirSelected( m_currentDir ); |
702 | reread( m_all ); | 694 | reread( m_all ); |
703 | } | 695 | } |
704 | 696 | ||
705 | void OFileViewFileListView::cdHome() | 697 | void OFileViewFileListView::cdHome() |
706 | { | 698 | { |
707 | m_currentDir = QDir::homeDirPath(); | 699 | m_currentDir = QDir::homeDirPath(); |
708 | emit selector()->dirSelected( m_currentDir ); | 700 | emit selector()->dirSelected( m_currentDir ); |
709 | reread( m_all ); | 701 | reread( m_all ); |
710 | } | 702 | } |
711 | 703 | ||
712 | void OFileViewFileListView::cdDoc() | 704 | void OFileViewFileListView::cdDoc() |
713 | { | 705 | { |
714 | m_currentDir = QPEApplication::documentDir(); | 706 | m_currentDir = QPEApplication::documentDir(); |
715 | emit selector()->dirSelected( m_currentDir ); | 707 | emit selector()->dirSelected( m_currentDir ); |
716 | reread( m_all ); | 708 | reread( m_all ); |
717 | } | 709 | } |
718 | 710 | ||
719 | void OFileViewFileListView::changeDir( const QString& dir ) | 711 | void OFileViewFileListView::changeDir( const QString& dir ) |
720 | { | 712 | { |
721 | m_currentDir = dir; | 713 | m_currentDir = dir; |
722 | emit selector()->dirSelected( m_currentDir ); | 714 | emit selector()->dirSelected( m_currentDir ); |
723 | reread( m_all ); | 715 | reread( m_all ); |
724 | } | 716 | } |
725 | 717 | ||
726 | void OFileViewFileListView::slotFSActivated( int id ) | 718 | void OFileViewFileListView::slotFSActivated( int id ) |
727 | { | 719 | { |
728 | changeDir ( m_dev[m_fsPop->text(id)] ); | 720 | changeDir ( m_dev[m_fsPop->text(id)] ); |
729 | } | 721 | } |
730 | 722 | ||
731 | /* check if the mimetype in mime | 723 | /* check if the mimetype in mime |
732 | * complies with the one which is current | 724 | * complies with the one which is current |
733 | */ | 725 | */ |
734 | /* | 726 | /* |
735 | * We've the mimetype of the file | 727 | * We've the mimetype of the file |
736 | * We need to get the stringlist of the current mimetype | 728 | * We need to get the stringlist of the current mimetype |
737 | * | 729 | * |
738 | * mime = image@slashjpeg | 730 | * mime = image@slashjpeg |
739 | * QStringList = 'image@slash*' | 731 | * QStringList = 'image@slash*' |
740 | * or QStringList = image/jpeg;image/png;application/x-ogg | 732 | * or QStringList = image/jpeg;image/png;application/x-ogg |
741 | * or QStringList = application/x-ogg;image@slash*; | 733 | * or QStringList = application/x-ogg;image@slash*; |
742 | * with all these mime filters it should get acceptes | 734 | * with all these mime filters it should get acceptes |
743 | * to do so we need to look if mime is contained inside | 735 | * to do so we need to look if mime is contained inside |
744 | * the stringlist | 736 | * the stringlist |
745 | * if it's contained return true | 737 | * if it's contained return true |
746 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 738 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
747 | * is contained in the mimefilter and then we will | 739 | * is contained in the mimefilter and then we will |
748 | * look if both are equal until the '/' | 740 | * look if both are equal until the '/' |
749 | */ | 741 | */ |
750 | 742 | ||
751 | bool OFileViewFileListView::compliesMime( const QString& str) | 743 | bool OFileViewFileListView::compliesMime( const QString& str) |
752 | { | 744 | { |
753 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 745 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
754 | return true; | 746 | return true; |
755 | 747 | ||
756 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) | 748 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) |
757 | { | 749 | { |
758 | QRegExp reg( (*it) ); | 750 | QRegExp reg( (*it) ); |
759 | reg.setWildcard( true ); | 751 | reg.setWildcard( true ); |
760 | if ( str.find( reg ) != -1 ) | 752 | if ( str.find( reg ) != -1 ) |
761 | return true; | 753 | return true; |
762 | 754 | ||
763 | } | 755 | } |
764 | return false; | 756 | return false; |
765 | } | 757 | } |
766 | /* | 758 | /* |
767 | * The listView giving access to the file system! | 759 | * The listView giving access to the file system! |
768 | */ | 760 | */ |
769 | 761 | ||
770 | class OFileViewFileSystem : public OFileViewInterface | 762 | class OFileViewFileSystem : public OFileViewInterface |
771 | { | 763 | { |
772 | public: | 764 | public: |
773 | OFileViewFileSystem( OFileSelector* ); | 765 | OFileViewFileSystem( OFileSelector* ); |
774 | ~OFileViewFileSystem(); | 766 | ~OFileViewFileSystem(); |
775 | 767 | ||
776 | QString selectedName() const; | 768 | QString selectedName() const; |
777 | QString selectedPath() const; | 769 | QString selectedPath() const; |
778 | 770 | ||
779 | QString directory()const; | 771 | QString directory()const; |
780 | void reread(); | 772 | void reread(); |