author | mickeyl <mickeyl> | 2005-07-03 21:12:58 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-07-03 21:12:58 (UTC) |
commit | 47011752d4457a1055894479e5bf855e100fddac (patch) (unidiff) | |
tree | d986b103f0023b990c02c208fc527d90f7c79ce3 | |
parent | 27bee477e2689d9b37d2d4cabce05c8d55295ebd (diff) | |
download | opie-47011752d4457a1055894479e5bf855e100fddac.zip opie-47011752d4457a1055894479e5bf855e100fddac.tar.gz opie-47011752d4457a1055894479e5bf855e100fddac.tar.bz2 |
remove hard coded scaling of 'UnknownDocument' icon (and restore header, btw.)
-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,202 +1,202 @@ | |||
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 | } |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * This opens up a filedialog in Open mode | 141 | * This opens up a filedialog in Open mode |
142 | * | 142 | * |
143 | * @param selector the Selector Mode | 143 | * @param selector the Selector Mode |
144 | * @param startDir Where to start from | 144 | * @param startDir Where to start from |
145 | * @param file A proposed filename | 145 | * @param file A proposed filename |
146 | * @param mimes A list of MimeTypes | 146 | * @param mimes A list of MimeTypes |
147 | * @param wid the parent | 147 | * @param wid the parent |
148 | * @param caption of the dialog if QString::null tr("Open") will be used | 148 | * @param caption of the dialog if QString::null tr("Open") will be used |
149 | * @return the fileName or QString::null | 149 | * @return the fileName or QString::null |
150 | */ | 150 | */ |
151 | QString OFileDialog::getOpenFileName(int selector, | 151 | QString OFileDialog::getOpenFileName(int selector, |
152 | const QString &_startDir, | 152 | const QString &_startDir, |
153 | const QString &file, | 153 | const QString &file, |
154 | const MimeTypes &mimes, | 154 | const MimeTypes &mimes, |
155 | QWidget *wid, | 155 | QWidget *wid, |
156 | const QString &caption ) | 156 | const QString &caption ) |
157 | { | 157 | { |
158 | QString ret; | 158 | QString ret; |
159 | QString startDir = _startDir; | 159 | QString startDir = _startDir; |
160 | if (startDir.isEmpty() ) | 160 | if (startDir.isEmpty() ) |
161 | startDir = lastUsedDir( "FileDialog-OPEN" ); | 161 | startDir = lastUsedDir( "FileDialog-OPEN" ); |
162 | 162 | ||
163 | 163 | ||
164 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, | 164 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, |
165 | wid, OFileSelector::Open, selector, startDir, file, mimes); | 165 | wid, OFileSelector::Open, selector, startDir, file, mimes); |
166 | if( QPEApplication::execDialog(&dlg ) ) | 166 | if( QPEApplication::execDialog(&dlg ) ) |
167 | { | 167 | { |
168 | ret = dlg.fileName(); | 168 | ret = dlg.fileName(); |
169 | saveLastDir( "FileDialog-OPEN", ret ); | 169 | saveLastDir( "FileDialog-OPEN", ret ); |
170 | } | 170 | } |
171 | 171 | ||
172 | return ret; | 172 | return ret; |
173 | } | 173 | } |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * This opens up a file dialog in save mode | 176 | * This opens up a file dialog in save mode |
177 | * @see getOpenFileName | 177 | * @see getOpenFileName |
178 | */ | 178 | */ |
179 | QString OFileDialog::getSaveFileName(int selector, | 179 | QString OFileDialog::getSaveFileName(int selector, |
180 | const QString &_startDir, | 180 | const QString &_startDir, |
181 | const QString &file, | 181 | const QString &file, |
182 | const MimeTypes &mimes, | 182 | const MimeTypes &mimes, |
183 | QWidget *wid, | 183 | QWidget *wid, |
184 | const QString &caption ) | 184 | const QString &caption ) |
185 | { | 185 | { |
186 | QString ret; | 186 | QString ret; |
187 | QString startDir = _startDir; | 187 | QString startDir = _startDir; |
188 | if (startDir.isEmpty() ) | 188 | if (startDir.isEmpty() ) |
189 | startDir = lastUsedDir( "FileDialog-SAVE" ); | 189 | startDir = lastUsedDir( "FileDialog-SAVE" ); |
190 | 190 | ||
191 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, | 191 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, |
192 | wid, OFileSelector::Save, selector, startDir, file, mimes); | 192 | wid, OFileSelector::Save, selector, startDir, file, mimes); |
193 | 193 | ||
194 | /* | 194 | /* |
195 | * For the save mode we do not want a file to be written | 195 | * For the save mode we do not want a file to be written |
196 | * if the user just clicked on it | 196 | * if the user just clicked on it |
197 | * #1522 | 197 | * #1522 |
198 | */ | 198 | */ |
199 | dlg.file->disconnect( &dlg ); | 199 | dlg.file->disconnect( &dlg ); |
200 | 200 | ||
201 | if( QPEApplication::execDialog(&dlg) ) | 201 | if( QPEApplication::execDialog(&dlg) ) |
202 | { | 202 | { |
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,220 +1,218 @@ | |||
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 | { |
157 | selector()->m_lneEdit->setText( str ); | 155 | selector()->m_lneEdit->setText( str ); |
158 | } | 156 | } |
159 | 157 | ||
160 | QString OFileViewInterface::currentFileName()const | 158 | QString OFileViewInterface::currentFileName()const |
161 | { | 159 | { |
162 | return selector()->m_lneEdit->text(); | 160 | return selector()->m_lneEdit->text(); |
163 | } | 161 | } |
164 | 162 | ||
165 | QString OFileViewInterface::startDirectory()const | 163 | QString OFileViewInterface::startDirectory()const |
166 | { | 164 | { |
167 | return selector()->m_startDir; | 165 | return selector()->m_startDir; |
168 | } | 166 | } |
169 | 167 | ||
170 | bool OFileViewInterface::allItem( const QString& item )const | 168 | bool OFileViewInterface::allItem( const QString& item )const |
171 | { | 169 | { |
172 | return selector()->m_allList.contains( item ); | 170 | return selector()->m_allList.contains( item ); |
173 | } | 171 | } |
174 | 172 | ||
175 | 173 | ||
176 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 174 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
177 | :OFileViewInterface( selector ) | 175 | :OFileViewInterface( selector ) |
178 | { | 176 | { |
179 | m_selector = 0; | 177 | m_selector = 0; |
180 | setName( QObject::tr("Documents") ); | 178 | setName( QObject::tr("Documents") ); |
181 | } | 179 | } |
182 | 180 | ||
183 | ODocumentFileView::~ODocumentFileView() | 181 | ODocumentFileView::~ODocumentFileView() |
184 | { | 182 | { |
185 | } | 183 | } |
186 | 184 | ||
187 | QString ODocumentFileView::selectedName()const | 185 | QString ODocumentFileView::selectedName()const |
188 | { | 186 | { |
189 | if (!m_selector) | 187 | if (!m_selector) |
190 | return QString::null; | 188 | return QString::null; |
191 | 189 | ||
192 | return m_selector->selectedDocument().file(); | 190 | return m_selector->selectedDocument().file(); |
193 | } | 191 | } |
194 | 192 | ||
195 | QString ODocumentFileView::selectedPath()const | 193 | QString ODocumentFileView::selectedPath()const |
196 | { | 194 | { |
197 | return QPEApplication::documentDir(); | 195 | return QPEApplication::documentDir(); |
198 | } | 196 | } |
199 | 197 | ||
200 | QString ODocumentFileView::directory()const | 198 | QString ODocumentFileView::directory()const |
201 | { | 199 | { |
202 | return selectedPath(); | 200 | return selectedPath(); |
203 | } | 201 | } |
204 | 202 | ||
205 | void ODocumentFileView::reread() | 203 | void ODocumentFileView::reread() |
206 | { | 204 | { |
207 | if (!m_selector) | 205 | if (!m_selector) |
208 | return; | 206 | return; |
209 | 207 | ||
210 | m_selector->setNewVisible( showNew() ); | 208 | m_selector->setNewVisible( showNew() ); |
211 | m_selector->setCloseVisible( showClose() ); | 209 | m_selector->setCloseVisible( showClose() ); |
212 | m_selector->filter = currentMimeType().join(";"); | 210 | m_selector->filter = currentMimeType().join(";"); |
213 | m_selector->reread(); | 211 | m_selector->reread(); |
214 | } | 212 | } |
215 | 213 | ||
216 | int ODocumentFileView::fileCount()const | 214 | int ODocumentFileView::fileCount()const |
217 | { | 215 | { |
218 | if (!m_selector) | 216 | if (!m_selector) |
219 | return -1; | 217 | return -1; |
220 | 218 | ||
@@ -442,403 +440,397 @@ void OFileViewFileListView::reread( bool all ) | |||
442 | { | 440 | { |
443 | m_view->clear(); | 441 | m_view->clear(); |
444 | 442 | ||
445 | if (selector()->showClose() ) | 443 | if (selector()->showClose() ) |
446 | m_btnClose->show(); | 444 | m_btnClose->show(); |
447 | else | 445 | else |
448 | m_btnClose->hide(); | 446 | m_btnClose->hide(); |
449 | 447 | ||
450 | if (selector()->showNew() ) | 448 | if (selector()->showNew() ) |
451 | m_btnNew->show(); | 449 | m_btnNew->show(); |
452 | else | 450 | else |
453 | m_btnNew->hide(); | 451 | m_btnNew->hide(); |
454 | 452 | ||
455 | m_mimes = selector()->currentMimeType(); | 453 | m_mimes = selector()->currentMimeType(); |
456 | m_all = all; | 454 | m_all = all; |
457 | 455 | ||
458 | QDir dir( m_currentDir ); | 456 | QDir dir( m_currentDir ); |
459 | if (!dir.exists() ) | 457 | if (!dir.exists() ) |
460 | return; | 458 | return; |
461 | 459 | ||
462 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 460 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
463 | int filter; | 461 | int filter; |
464 | filter = QDir::Dirs; | 462 | filter = QDir::Dirs; |
465 | if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) | 463 | if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) |
466 | filter = filter | QDir::Files | QDir::All; | 464 | filter = filter | QDir::Files | QDir::All; |
467 | 465 | ||
468 | if ( m_all ) | 466 | if ( m_all ) |
469 | filter = filter | QDir::Hidden; | 467 | filter = filter | QDir::Hidden; |
470 | 468 | ||
471 | dir.setFilter( filter ); | 469 | dir.setFilter( filter ); |
472 | 470 | ||
473 | // now go through all files | 471 | // now go through all files |
474 | const QFileInfoList *list = dir.entryInfoList(); | 472 | const QFileInfoList *list = dir.entryInfoList(); |
475 | if (!list) | 473 | if (!list) |
476 | { | 474 | { |
477 | cdUP(); | 475 | cdUP(); |
478 | return; | 476 | return; |
479 | } | 477 | } |
480 | 478 | ||
481 | QFileInfoListIterator it( *list ); | 479 | QFileInfoListIterator it( *list ); |
482 | QFileInfo *fi; | 480 | QFileInfo *fi; |
483 | while( (fi=it.current() ) ) | 481 | while( (fi=it.current() ) ) |
484 | { | 482 | { |
485 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) | 483 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) |
486 | { | 484 | { |
487 | ++it; | 485 | ++it; |
488 | continue; | 486 | continue; |
489 | } | 487 | } |
490 | 488 | ||
491 | /* | 489 | /* |
492 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 490 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
493 | * | 491 | * |
494 | */ | 492 | */ |
495 | if( fi->isSymLink() ) | 493 | if( fi->isSymLink() ) |
496 | { | 494 | { |
497 | QString file = createNewPath(fi->dirPath( true ),fi->readLink()); | 495 | QString file = createNewPath(fi->dirPath( true ),fi->readLink()); |
498 | for( int i = 0; i<=4; i++) | 496 | for( int i = 0; i<=4; i++) |
499 | { // 5 tries to prevent dos | 497 | { // 5 tries to prevent dos |
500 | QFileInfo info( file ); | 498 | QFileInfo info( file ); |
501 | if( !info.exists() ) | 499 | if( !info.exists() ) |
502 | { | 500 | { |
503 | addSymlink( fi, TRUE ); | 501 | addSymlink( fi, TRUE ); |
504 | break; | 502 | break; |
505 | } | 503 | } |
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(); |
781 | int fileCount()const; | 773 | int fileCount()const; |
782 | 774 | ||
783 | QWidget* widget( QWidget* parent ); | 775 | QWidget* widget( QWidget* parent ); |
784 | void activate( const QString& ); | 776 | void activate( const QString& ); |
785 | private: | 777 | private: |
786 | OFileViewFileListView* m_view; | 778 | OFileViewFileListView* m_view; |
787 | bool m_all : 1; | 779 | bool m_all : 1; |
788 | }; | 780 | }; |
789 | 781 | ||
790 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 782 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
791 | : OFileViewInterface( sel ) | 783 | : OFileViewInterface( sel ) |
792 | { | 784 | { |
793 | m_view = 0; | 785 | m_view = 0; |
794 | m_all = false; | 786 | m_all = false; |
795 | } | 787 | } |
796 | 788 | ||
797 | OFileViewFileSystem::~OFileViewFileSystem() | 789 | OFileViewFileSystem::~OFileViewFileSystem() |
798 | { | 790 | { |
799 | } | 791 | } |
800 | 792 | ||
801 | QString OFileViewFileSystem::selectedName()const | 793 | QString OFileViewFileSystem::selectedName()const |
802 | { | 794 | { |
803 | if (!m_view ) | 795 | if (!m_view ) |
804 | return QString::null; | 796 | return QString::null; |
805 | 797 | ||
806 | QString cFN=currentFileName(); | 798 | QString cFN=currentFileName(); |
807 | if (cFN.startsWith("/")) return cFN; | 799 | if (cFN.startsWith("/")) return cFN; |
808 | return createNewPath(m_view->currentDir(),cFN); | 800 | return createNewPath(m_view->currentDir(),cFN); |
809 | } | 801 | } |
810 | 802 | ||
811 | QString OFileViewFileSystem::selectedPath()const | 803 | QString OFileViewFileSystem::selectedPath()const |
812 | { | 804 | { |
813 | return QString::null; | 805 | return QString::null; |
814 | } | 806 | } |
815 | 807 | ||
816 | QString OFileViewFileSystem::directory()const | 808 | QString OFileViewFileSystem::directory()const |
817 | { | 809 | { |
818 | if (!m_view) | 810 | if (!m_view) |
819 | return QString::null; | 811 | return QString::null; |
820 | 812 | ||
821 | OFileSelectorItem* item = m_view->currentItem(); | 813 | OFileSelectorItem* item = m_view->currentItem(); |
822 | if (!item ) | 814 | if (!item ) |
823 | return QString::null; | 815 | return QString::null; |
824 | 816 | ||
825 | return QDir(item->directory() ).absPath(); | 817 | return QDir(item->directory() ).absPath(); |
826 | } | 818 | } |
827 | 819 | ||
828 | void OFileViewFileSystem::reread() | 820 | void OFileViewFileSystem::reread() |
829 | { | 821 | { |
830 | if (!m_view) | 822 | if (!m_view) |
831 | return; | 823 | return; |
832 | 824 | ||
833 | m_view->reread( m_all ); | 825 | m_view->reread( m_all ); |
834 | } | 826 | } |
835 | 827 | ||
836 | int OFileViewFileSystem::fileCount()const | 828 | int OFileViewFileSystem::fileCount()const |
837 | { | 829 | { |
838 | if (!m_view ) | 830 | if (!m_view ) |
839 | return -1; | 831 | return -1; |
840 | return m_view->fileCount(); | 832 | return m_view->fileCount(); |
841 | } | 833 | } |
842 | 834 | ||
843 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) | 835 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) |
844 | { | 836 | { |