author | alwin <alwin> | 2004-03-02 12:14:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:14:15 (UTC) |
commit | 0d59c780513da78033f4d9040475dee9db0256d4 (patch) (unidiff) | |
tree | 503d320b4aa3daae9982082e7b34e3e2c48bdfb7 /libopie2/opieui | |
parent | a0981652d61776d70f25980f035748b21339e946 (diff) | |
download | opie-0d59c780513da78033f4d9040475dee9db0256d4.zip opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.gz opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.bz2 |
run the optimize_connect script
the whole cvs is tagged with "before_optimize_connect" if there are problems you
can check the diff (but it had compiled and run here)
-rw-r--r-- | libopie2/opieui/fileselector/ofiledialog.cpp | 4 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 14 | ||||
-rw-r--r-- | libopie2/opieui/ofontselector.cpp | 8 | ||||
-rw-r--r-- | libopie2/opieui/otabwidget.cpp | 4 | ||||
-rw-r--r-- | libopie2/opieui/otimepicker.cpp | 12 | ||||
-rw-r--r-- | libopie2/opieui/oversatileview.cpp | 40 |
6 files changed, 41 insertions, 41 deletions
diff --git a/libopie2/opieui/fileselector/ofiledialog.cpp b/libopie2/opieui/fileselector/ofiledialog.cpp index 2a89c5d..e7daead 100644 --- a/libopie2/opieui/fileselector/ofiledialog.cpp +++ b/libopie2/opieui/fileselector/ofiledialog.cpp | |||
@@ -1,222 +1,222 @@ | |||
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 <zecke@handhelds.org> | 3 | .=l. Copyright (C) Holger Freyther <zecke@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; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
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 | using namespace Opie; | 42 | using namespace Opie; |
43 | 43 | ||
44 | namespace | 44 | namespace |
45 | { | 45 | { |
46 | /* | 46 | /* |
47 | * helper functions to load the start dir | 47 | * helper functions to load the start dir |
48 | * and to save it | 48 | * and to save it |
49 | * helper to extract the dir out of a file name | 49 | * helper to extract the dir out of a file name |
50 | */ | 50 | */ |
51 | /** | 51 | /** |
52 | * This method will use Config( argv[0] ); | 52 | * This method will use Config( argv[0] ); |
53 | * @param key The group key used | 53 | * @param key The group key used |
54 | */ | 54 | */ |
55 | QString lastUsedDir( const QString& key ) | 55 | QString lastUsedDir( const QString& key ) |
56 | { | 56 | { |
57 | if ( qApp->argc() < 1 ) | 57 | if ( qApp->argc() < 1 ) |
58 | return QString::null; | 58 | return QString::null; |
59 | 59 | ||
60 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname | 60 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname |
61 | cfg.setGroup( key ); | 61 | cfg.setGroup( key ); |
62 | return cfg.readEntry("LastDir", QPEApplication::documentDir() ); | 62 | return cfg.readEntry("LastDir", QPEApplication::documentDir() ); |
63 | } | 63 | } |
64 | 64 | ||
65 | void saveLastDir( const QString& key, const QString& file ) | 65 | void saveLastDir( const QString& key, const QString& file ) |
66 | { | 66 | { |
67 | if ( qApp->argc() < 1 ) | 67 | if ( qApp->argc() < 1 ) |
68 | return; | 68 | return; |
69 | 69 | ||
70 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); | 70 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); |
71 | cfg.setGroup( key ); | 71 | cfg.setGroup( key ); |
72 | QFileInfo inf( file ); | 72 | QFileInfo inf( file ); |
73 | cfg.writeEntry("LastDir", inf.dirPath( true ) ); | 73 | cfg.writeEntry("LastDir", inf.dirPath( true ) ); |
74 | } | 74 | } |
75 | }; | 75 | }; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * This constructs a modal dialog | 78 | * This constructs a modal dialog |
79 | * | 79 | * |
80 | * @param caption The caption of the dialog | 80 | * @param caption The caption of the dialog |
81 | * @param wid The parent widget | 81 | * @param wid The parent widget |
82 | * @param mode The mode of the OFileSelector @see OFileSelector | 82 | * @param mode The mode of the OFileSelector @see OFileSelector |
83 | * @param selector The selector of the OFileSelector | 83 | * @param selector The selector of the OFileSelector |
84 | * @param dirName the dir or resource to start from | 84 | * @param dirName the dir or resource to start from |
85 | * @param fileName a proposed or existing filename | 85 | * @param fileName a proposed or existing filename |
86 | * @param mimetypes The mimeTypes | 86 | * @param mimetypes The mimeTypes |
87 | */ | 87 | */ |
88 | OFileDialog::OFileDialog(const QString &caption, | 88 | OFileDialog::OFileDialog(const QString &caption, |
89 | QWidget *wid, int mode, int selector, | 89 | QWidget *wid, int mode, int selector, |
90 | const QString &dirName, | 90 | const QString &dirName, |
91 | const QString &fileName, | 91 | const QString &fileName, |
92 | const QMap<QString,QStringList>& mimetypes ) | 92 | const QMap<QString,QStringList>& mimetypes ) |
93 | : QDialog( wid, "OFileDialog", true ) | 93 | : QDialog( wid, "OFileDialog", true ) |
94 | { | 94 | { |
95 | // QVBoxLayout *lay = new QVBoxLayout(this); | 95 | // QVBoxLayout *lay = new QVBoxLayout(this); |
96 | //showMaximized(); | 96 | //showMaximized(); |
97 | QVBoxLayout *lay = new QVBoxLayout(this ); | 97 | QVBoxLayout *lay = new QVBoxLayout(this ); |
98 | file = new OFileSelector(this , mode, selector, | 98 | file = new OFileSelector(this , mode, selector, |
99 | dirName, fileName, | 99 | dirName, fileName, |
100 | mimetypes ); | 100 | mimetypes ); |
101 | lay->addWidget( file ); | 101 | lay->addWidget( file ); |
102 | 102 | ||
103 | //lay->addWidget( file ); | 103 | //lay->addWidget( file ); |
104 | //showFullScreen(); | 104 | //showFullScreen(); |
105 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); | 105 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); |
106 | connect(file, SIGNAL(fileSelected(const QString&) ), | 106 | connect(file, SIGNAL(fileSelected(const QString&) ), |
107 | this, SLOT(slotFileSelected(const QString&) ) ); | 107 | this, SLOT(slotFileSelected(const QString&) ) ); |
108 | connect(file, SIGNAL(ok() ), | 108 | connect(file, SIGNAL(ok() ), |
109 | this, SLOT(slotSelectorOk()) ) ; | 109 | this, SLOT(slotSelectorOk()) ) ; |
110 | 110 | ||
111 | connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); | 111 | connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); |
112 | 112 | ||
113 | #if 0 | 113 | #if 0 |
114 | connect(file, SIGNAL(dirSelected(const QString &) ), | 114 | connect(file, SIGNAL(dirSelected(const QString&) ), |
115 | this, SLOT(slotDirSelected(const QString &) ) ); | 115 | this, SLOT(slotDirSelected(const QString&) ) ); |
116 | #endif | 116 | #endif |
117 | } | 117 | } |
118 | /** | 118 | /** |
119 | * @returns the mimetype of the selected | 119 | * @returns the mimetype of the selected |
120 | * currently it return QString::null | 120 | * currently it return QString::null |
121 | */ | 121 | */ |
122 | QString OFileDialog::mimetype()const | 122 | QString OFileDialog::mimetype()const |
123 | { | 123 | { |
124 | return QString::null; | 124 | return QString::null; |
125 | } | 125 | } |
126 | 126 | ||
127 | /** | 127 | /** |
128 | * @return the fileName | 128 | * @return the fileName |
129 | */ | 129 | */ |
130 | QString OFileDialog::fileName()const | 130 | QString OFileDialog::fileName()const |
131 | { | 131 | { |
132 | return file->selectedName(); | 132 | return file->selectedName(); |
133 | } | 133 | } |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * return a DocLnk to the current file | 136 | * return a DocLnk to the current file |
137 | */ | 137 | */ |
138 | DocLnk OFileDialog::selectedDocument()const | 138 | DocLnk OFileDialog::selectedDocument()const |
139 | { | 139 | { |
140 | return file->selectedDocument(); | 140 | return file->selectedDocument(); |
141 | } | 141 | } |
142 | 142 | ||
143 | /** | 143 | /** |
144 | * This opens up a filedialog in Open mode | 144 | * This opens up a filedialog in Open mode |
145 | * | 145 | * |
146 | * @param selector the Selector Mode | 146 | * @param selector the Selector Mode |
147 | * @param startDir Where to start from | 147 | * @param startDir Where to start from |
148 | * @param file A proposed filename | 148 | * @param file A proposed filename |
149 | * @param mimes A list of MimeTypes | 149 | * @param mimes A list of MimeTypes |
150 | * @param wid the parent | 150 | * @param wid the parent |
151 | * @param caption of the dialog if QString::null tr("Open") will be used | 151 | * @param caption of the dialog if QString::null tr("Open") will be used |
152 | * @return the fileName or QString::null | 152 | * @return the fileName or QString::null |
153 | */ | 153 | */ |
154 | QString OFileDialog::getOpenFileName(int selector, | 154 | QString OFileDialog::getOpenFileName(int selector, |
155 | const QString &_startDir, | 155 | const QString &_startDir, |
156 | const QString &file, | 156 | const QString &file, |
157 | const MimeTypes &mimes, | 157 | const MimeTypes &mimes, |
158 | QWidget *wid, | 158 | QWidget *wid, |
159 | const QString &caption ) | 159 | const QString &caption ) |
160 | { | 160 | { |
161 | QString ret; | 161 | QString ret; |
162 | QString startDir = _startDir; | 162 | QString startDir = _startDir; |
163 | if (startDir.isEmpty() ) | 163 | if (startDir.isEmpty() ) |
164 | startDir = lastUsedDir( "FileDialog-OPEN" ); | 164 | startDir = lastUsedDir( "FileDialog-OPEN" ); |
165 | 165 | ||
166 | 166 | ||
167 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, | 167 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, |
168 | wid, OFileSelector::Open, selector, startDir, file, mimes); | 168 | wid, OFileSelector::Open, selector, startDir, file, mimes); |
169 | dlg.showMaximized(); | 169 | dlg.showMaximized(); |
170 | if( dlg.exec() ) | 170 | if( dlg.exec() ) |
171 | { | 171 | { |
172 | ret = dlg.fileName(); | 172 | ret = dlg.fileName(); |
173 | saveLastDir( "FileDialog-OPEN", ret ); | 173 | saveLastDir( "FileDialog-OPEN", ret ); |
174 | } | 174 | } |
175 | 175 | ||
176 | return ret; | 176 | return ret; |
177 | } | 177 | } |
178 | 178 | ||
179 | /** | 179 | /** |
180 | * This opens up a file dialog in save mode | 180 | * This opens up a file dialog in save mode |
181 | * @see getOpenFileName | 181 | * @see getOpenFileName |
182 | */ | 182 | */ |
183 | QString OFileDialog::getSaveFileName(int selector, | 183 | QString OFileDialog::getSaveFileName(int selector, |
184 | const QString &_startDir, | 184 | const QString &_startDir, |
185 | const QString &file, | 185 | const QString &file, |
186 | const MimeTypes &mimes, | 186 | const MimeTypes &mimes, |
187 | QWidget *wid, | 187 | QWidget *wid, |
188 | const QString &caption ) | 188 | const QString &caption ) |
189 | { | 189 | { |
190 | QString ret; | 190 | QString ret; |
191 | QString startDir = _startDir; | 191 | QString startDir = _startDir; |
192 | if (startDir.isEmpty() ) | 192 | if (startDir.isEmpty() ) |
193 | startDir = lastUsedDir( "FileDialog-SAVE" ); | 193 | startDir = lastUsedDir( "FileDialog-SAVE" ); |
194 | 194 | ||
195 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, | 195 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, |
196 | wid, OFileSelector::Save, selector, startDir, file, mimes); | 196 | wid, OFileSelector::Save, selector, startDir, file, mimes); |
197 | dlg.showMaximized(); | 197 | dlg.showMaximized(); |
198 | if( dlg.exec() ) | 198 | if( dlg.exec() ) |
199 | { | 199 | { |
200 | ret = dlg.fileName(); | 200 | ret = dlg.fileName(); |
201 | saveLastDir( "FileDialog-SAVE", ret ); | 201 | saveLastDir( "FileDialog-SAVE", ret ); |
202 | } | 202 | } |
203 | 203 | ||
204 | return ret; | 204 | return ret; |
205 | } | 205 | } |
206 | 206 | ||
207 | void OFileDialog::slotFileSelected(const QString & ) | 207 | void OFileDialog::slotFileSelected(const QString & ) |
208 | { | 208 | { |
209 | accept(); | 209 | accept(); |
210 | } | 210 | } |
211 | 211 | ||
212 | void OFileDialog::slotSelectorOk( ) | 212 | void OFileDialog::slotSelectorOk( ) |
213 | { | 213 | { |
214 | accept(); | 214 | accept(); |
215 | } | 215 | } |
216 | 216 | ||
217 | void OFileDialog::slotDirSelected(const QString &dir ) | 217 | void OFileDialog::slotDirSelected(const QString &dir ) |
218 | { | 218 | { |
219 | setCaption( dir ); | 219 | setCaption( dir ); |
220 | // if mode | 220 | // if mode |
221 | //accept(); | 221 | //accept(); |
222 | } | 222 | } |
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 600daff..15cadd4 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp | |||
@@ -1,1166 +1,1166 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> | 3 | .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@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; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
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 | /* hacky but we need to get FileSelector::filter */ | 29 | /* hacky but we need to get FileSelector::filter */ |
30 | #define private public | 30 | #define private public |
31 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
32 | #undef private | 32 | #undef private |
33 | 33 | ||
34 | #include "ofileselector_p.h" | 34 | #include "ofileselector_p.h" |
35 | 35 | ||
36 | /* OPIE */ | 36 | /* OPIE */ |
37 | #include <opie2/ofileselector.h> | 37 | #include <opie2/ofileselector.h> |
38 | 38 | ||
39 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
40 | #include <qpe/mimetype.h> | 40 | #include <qpe/mimetype.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/storage.h> | 42 | #include <qpe/storage.h> |
43 | 43 | ||
44 | /* QT */ | 44 | /* QT */ |
45 | #include <qcombobox.h> | 45 | #include <qcombobox.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qhbox.h> | 47 | #include <qhbox.h> |
48 | #include <qheader.h> | 48 | #include <qheader.h> |
49 | #include <qlabel.h> | 49 | #include <qlabel.h> |
50 | #include <qlayout.h> | 50 | #include <qlayout.h> |
51 | #include <qlineedit.h> | 51 | #include <qlineedit.h> |
52 | #include <qlistview.h> | 52 | #include <qlistview.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <qwidgetstack.h> | 54 | #include <qwidgetstack.h> |
55 | #include <qregexp.h> | 55 | #include <qregexp.h> |
56 | #include <qobjectlist.h> | 56 | #include <qobjectlist.h> |
57 | 57 | ||
58 | using namespace Opie; | 58 | using namespace Opie; |
59 | 59 | ||
60 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) | 60 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) |
61 | : m_selector( selector ) | 61 | : m_selector( selector ) |
62 | {} | 62 | {} |
63 | 63 | ||
64 | OFileViewInterface::~OFileViewInterface() | 64 | OFileViewInterface::~OFileViewInterface() |
65 | {} | 65 | {} |
66 | 66 | ||
67 | QString OFileViewInterface::name()const | 67 | QString OFileViewInterface::name()const |
68 | { | 68 | { |
69 | return m_name; | 69 | return m_name; |
70 | } | 70 | } |
71 | 71 | ||
72 | void OFileViewInterface::setName( const QString& name ) | 72 | void OFileViewInterface::setName( const QString& name ) |
73 | { | 73 | { |
74 | m_name = name; | 74 | m_name = name; |
75 | } | 75 | } |
76 | 76 | ||
77 | OFileSelector* OFileViewInterface::selector()const | 77 | OFileSelector* OFileViewInterface::selector()const |
78 | { | 78 | { |
79 | return m_selector; | 79 | return m_selector; |
80 | } | 80 | } |
81 | 81 | ||
82 | DocLnk OFileViewInterface::selectedDocument()const | 82 | DocLnk OFileViewInterface::selectedDocument()const |
83 | { | 83 | { |
84 | return DocLnk( selectedName() ); | 84 | return DocLnk( selectedName() ); |
85 | } | 85 | } |
86 | 86 | ||
87 | bool OFileViewInterface::showNew()const | 87 | bool OFileViewInterface::showNew()const |
88 | { | 88 | { |
89 | return selector()->showNew(); | 89 | return selector()->showNew(); |
90 | } | 90 | } |
91 | 91 | ||
92 | bool OFileViewInterface::showClose()const | 92 | bool OFileViewInterface::showClose()const |
93 | { | 93 | { |
94 | return selector()->showClose(); | 94 | return selector()->showClose(); |
95 | } | 95 | } |
96 | 96 | ||
97 | MimeTypes OFileViewInterface::mimeTypes()const | 97 | MimeTypes OFileViewInterface::mimeTypes()const |
98 | { | 98 | { |
99 | return selector()->mimeTypes(); | 99 | return selector()->mimeTypes(); |
100 | } | 100 | } |
101 | 101 | ||
102 | QStringList OFileViewInterface::currentMimeType()const | 102 | QStringList OFileViewInterface::currentMimeType()const |
103 | { | 103 | { |
104 | return selector()->currentMimeType(); | 104 | return selector()->currentMimeType(); |
105 | } | 105 | } |
106 | 106 | ||
107 | void OFileViewInterface::activate( const QString& ) | 107 | void OFileViewInterface::activate( const QString& ) |
108 | { | 108 | { |
109 | // not implemented here | 109 | // not implemented here |
110 | } | 110 | } |
111 | 111 | ||
112 | void OFileViewInterface::ok() | 112 | void OFileViewInterface::ok() |
113 | { | 113 | { |
114 | emit selector()->ok(); | 114 | emit selector()->ok(); |
115 | } | 115 | } |
116 | 116 | ||
117 | void OFileViewInterface::cancel() | 117 | void OFileViewInterface::cancel() |
118 | { | 118 | { |
119 | emit selector()->cancel(); | 119 | emit selector()->cancel(); |
120 | } | 120 | } |
121 | 121 | ||
122 | void OFileViewInterface::closeMe() | 122 | void OFileViewInterface::closeMe() |
123 | { | 123 | { |
124 | emit selector()->closeMe(); | 124 | emit selector()->closeMe(); |
125 | } | 125 | } |
126 | 126 | ||
127 | void OFileViewInterface::fileSelected( const QString& str) | 127 | void OFileViewInterface::fileSelected( const QString& str) |
128 | { | 128 | { |
129 | emit selector()->fileSelected( str); | 129 | emit selector()->fileSelected( str); |
130 | } | 130 | } |
131 | 131 | ||
132 | void OFileViewInterface::fileSelected( const DocLnk& lnk) | 132 | void OFileViewInterface::fileSelected( const DocLnk& lnk) |
133 | { | 133 | { |
134 | emit selector()->fileSelected( lnk ); | 134 | emit selector()->fileSelected( lnk ); |
135 | } | 135 | } |
136 | 136 | ||
137 | void OFileViewInterface::setCurrentFileName( const QString& str ) | 137 | void OFileViewInterface::setCurrentFileName( const QString& str ) |
138 | { | 138 | { |
139 | selector()->m_lneEdit->setText( str ); | 139 | selector()->m_lneEdit->setText( str ); |
140 | } | 140 | } |
141 | 141 | ||
142 | QString OFileViewInterface::currentFileName()const | 142 | QString OFileViewInterface::currentFileName()const |
143 | { | 143 | { |
144 | return selector()->m_lneEdit->text(); | 144 | return selector()->m_lneEdit->text(); |
145 | } | 145 | } |
146 | 146 | ||
147 | QString OFileViewInterface::startDirectory()const | 147 | QString OFileViewInterface::startDirectory()const |
148 | { | 148 | { |
149 | return selector()->m_startDir; | 149 | return selector()->m_startDir; |
150 | } | 150 | } |
151 | 151 | ||
152 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 152 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
153 | :OFileViewInterface( selector ) | 153 | :OFileViewInterface( selector ) |
154 | { | 154 | { |
155 | m_selector = 0; | 155 | m_selector = 0; |
156 | setName( QObject::tr("Documents") ); | 156 | setName( QObject::tr("Documents") ); |
157 | } | 157 | } |
158 | 158 | ||
159 | ODocumentFileView::~ODocumentFileView() | 159 | ODocumentFileView::~ODocumentFileView() |
160 | { | 160 | { |
161 | } | 161 | } |
162 | 162 | ||
163 | QString ODocumentFileView::selectedName()const | 163 | QString ODocumentFileView::selectedName()const |
164 | { | 164 | { |
165 | if (!m_selector) | 165 | if (!m_selector) |
166 | return QString::null; | 166 | return QString::null; |
167 | 167 | ||
168 | return m_selector->selectedDocument().file(); | 168 | return m_selector->selectedDocument().file(); |
169 | } | 169 | } |
170 | 170 | ||
171 | QString ODocumentFileView::selectedPath()const | 171 | QString ODocumentFileView::selectedPath()const |
172 | { | 172 | { |
173 | return QPEApplication::documentDir(); | 173 | return QPEApplication::documentDir(); |
174 | } | 174 | } |
175 | 175 | ||
176 | QString ODocumentFileView::directory()const | 176 | QString ODocumentFileView::directory()const |
177 | { | 177 | { |
178 | return selectedPath(); | 178 | return selectedPath(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void ODocumentFileView::reread() | 181 | void ODocumentFileView::reread() |
182 | { | 182 | { |
183 | if (!m_selector) | 183 | if (!m_selector) |
184 | return; | 184 | return; |
185 | 185 | ||
186 | m_selector->setNewVisible( showNew() ); | 186 | m_selector->setNewVisible( showNew() ); |
187 | m_selector->setCloseVisible( showClose() ); | 187 | m_selector->setCloseVisible( showClose() ); |
188 | m_selector->filter = currentMimeType().join(";"); | 188 | m_selector->filter = currentMimeType().join(";"); |
189 | m_selector->reread(); | 189 | m_selector->reread(); |
190 | } | 190 | } |
191 | 191 | ||
192 | int ODocumentFileView::fileCount()const | 192 | int ODocumentFileView::fileCount()const |
193 | { | 193 | { |
194 | if (!m_selector) | 194 | if (!m_selector) |
195 | return -1; | 195 | return -1; |
196 | 196 | ||
197 | return m_selector->fileCount(); | 197 | return m_selector->fileCount(); |
198 | } | 198 | } |
199 | 199 | ||
200 | DocLnk ODocumentFileView::selectedDocument()const | 200 | DocLnk ODocumentFileView::selectedDocument()const |
201 | { | 201 | { |
202 | if (!m_selector) | 202 | if (!m_selector) |
203 | return DocLnk(); | 203 | return DocLnk(); |
204 | 204 | ||
205 | return m_selector->selectedDocument(); | 205 | return m_selector->selectedDocument(); |
206 | } | 206 | } |
207 | 207 | ||
208 | QWidget* ODocumentFileView::widget( QWidget* parent ) | 208 | QWidget* ODocumentFileView::widget( QWidget* parent ) |
209 | { | 209 | { |
210 | if (!m_selector ) | 210 | if (!m_selector ) |
211 | { | 211 | { |
212 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | 212 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); |
213 | QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), | 213 | QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), |
214 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | 214 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); |
215 | QObject::connect(m_selector, SIGNAL(closeMe() ), | 215 | QObject::connect(m_selector, SIGNAL(closeMe() ), |
216 | selector(), SIGNAL(closeMe() ) ); | 216 | selector(), SIGNAL(closeMe() ) ); |
217 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), | 217 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), |
218 | selector(), SIGNAL(newSelected(const DocLnk& ) ) ); | 218 | selector(), SIGNAL(newSelected(const DocLnk&) ) ); |
219 | } | 219 | } |
220 | 220 | ||
221 | return m_selector; | 221 | return m_selector; |
222 | } | 222 | } |
223 | 223 | ||
224 | /* | 224 | /* |
225 | * This is the file system view used | 225 | * This is the file system view used |
226 | * we use a QListView + QListViewItems for it | 226 | * we use a QListView + QListViewItems for it |
227 | */ | 227 | */ |
228 | 228 | ||
229 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 229 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
230 | const QString& path, const QString& date, | 230 | const QString& path, const QString& date, |
231 | const QString& size, const QString& dir, | 231 | const QString& size, const QString& dir, |
232 | bool isLocked, bool isDir ) | 232 | bool isLocked, bool isDir ) |
233 | : QListViewItem( view ) | 233 | : QListViewItem( view ) |
234 | { | 234 | { |
235 | setPixmap(0, pixmap ); | 235 | setPixmap(0, pixmap ); |
236 | setText(1, path ); | 236 | setText(1, path ); |
237 | setText(2, size ); | 237 | setText(2, size ); |
238 | setText(3, date ); | 238 | setText(3, date ); |
239 | m_isDir = isDir; | 239 | m_isDir = isDir; |
240 | m_dir = dir; | 240 | m_dir = dir; |
241 | m_locked = isLocked; | 241 | m_locked = isLocked; |
242 | } | 242 | } |
243 | 243 | ||
244 | OFileSelectorItem::~OFileSelectorItem() | 244 | OFileSelectorItem::~OFileSelectorItem() |
245 | { | 245 | { |
246 | } | 246 | } |
247 | 247 | ||
248 | bool OFileSelectorItem::isLocked()const | 248 | bool OFileSelectorItem::isLocked()const |
249 | { | 249 | { |
250 | return m_locked; | 250 | return m_locked; |
251 | } | 251 | } |
252 | 252 | ||
253 | QString OFileSelectorItem::directory()const | 253 | QString OFileSelectorItem::directory()const |
254 | { | 254 | { |
255 | return m_dir; | 255 | return m_dir; |
256 | } | 256 | } |
257 | 257 | ||
258 | bool OFileSelectorItem::isDir()const | 258 | bool OFileSelectorItem::isDir()const |
259 | { | 259 | { |
260 | return m_isDir; | 260 | return m_isDir; |
261 | } | 261 | } |
262 | 262 | ||
263 | QString OFileSelectorItem::path()const | 263 | QString OFileSelectorItem::path()const |
264 | { | 264 | { |
265 | return text( 1 ); | 265 | return text( 1 ); |
266 | } | 266 | } |
267 | 267 | ||
268 | QString OFileSelectorItem::key( int id, bool )const | 268 | QString OFileSelectorItem::key( int id, bool )const |
269 | { | 269 | { |
270 | QString ke; | 270 | QString ke; |
271 | if( id == 0 || id == 1 ) | 271 | if( id == 0 || id == 1 ) |
272 | { // name | 272 | { // name |
273 | if( m_isDir ) | 273 | if( m_isDir ) |
274 | { | 274 | { |
275 | ke.append("0" ); | 275 | ke.append("0" ); |
276 | ke.append( text(1) ); | 276 | ke.append( text(1) ); |
277 | } | 277 | } |
278 | else | 278 | else |
279 | { | 279 | { |
280 | ke.append("1" ); | 280 | ke.append("1" ); |
281 | ke.append( text(1) ); | 281 | ke.append( text(1) ); |
282 | } | 282 | } |
283 | return ke; | 283 | return ke; |
284 | } | 284 | } |
285 | else | 285 | else |
286 | return text( id ); | 286 | return text( id ); |
287 | 287 | ||
288 | } | 288 | } |
289 | 289 | ||
290 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) | 290 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) |
291 | :QWidget( parent ), m_sel( sel ) | 291 | :QWidget( parent ), m_sel( sel ) |
292 | { | 292 | { |
293 | m_all = false; | 293 | m_all = false; |
294 | QVBoxLayout* lay = new QVBoxLayout( this ); | 294 | QVBoxLayout* lay = new QVBoxLayout( this ); |
295 | m_currentDir = startDir; | 295 | m_currentDir = startDir; |
296 | 296 | ||
297 | /* | 297 | /* |
298 | * now we add a special bar | 298 | * now we add a special bar |
299 | * One Button For Up | 299 | * One Button For Up |
300 | * Home | 300 | * Home |
301 | * Doc | 301 | * Doc |
302 | * And a dropdown menu with FileSystems | 302 | * And a dropdown menu with FileSystems |
303 | * FUTURE: one to change dir with lineedit | 303 | * FUTURE: one to change dir with lineedit |
304 | * Bookmarks | 304 | * Bookmarks |
305 | * Create Dir | 305 | * Create Dir |
306 | */ | 306 | */ |
307 | QHBox* box = new QHBox(this ); | 307 | QHBox* box = new QHBox(this ); |
308 | box->setBackgroundMode( PaletteButton ); | 308 | box->setBackgroundMode( PaletteButton ); |
309 | box->setSpacing( 0 ); | 309 | box->setSpacing( 0 ); |
310 | 310 | ||
311 | QToolButton *btn = new QToolButton( box ); | 311 | QToolButton *btn = new QToolButton( box ); |
312 | btn->setIconSet( Resource::loadIconSet("up") ); | 312 | btn->setIconSet( Resource::loadIconSet("up") ); |
313 | connect(btn, SIGNAL(clicked() ), | 313 | connect(btn, SIGNAL(clicked() ), |
314 | this, SLOT( cdUP() ) ); | 314 | this, SLOT( cdUP() ) ); |
315 | 315 | ||
316 | btn = new QToolButton( box ); | 316 | btn = new QToolButton( box ); |
317 | btn->setIconSet( Resource::loadIconSet("home") ); | 317 | btn->setIconSet( Resource::loadIconSet("home") ); |
318 | connect(btn, SIGNAL(clicked() ), | 318 | connect(btn, SIGNAL(clicked() ), |
319 | this, SLOT( cdHome() ) ); | 319 | this, SLOT( cdHome() ) ); |
320 | 320 | ||
321 | btn = new QToolButton( box ); | 321 | btn = new QToolButton( box ); |
322 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); | 322 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); |
323 | connect(btn, SIGNAL(clicked() ), | 323 | connect(btn, SIGNAL(clicked() ), |
324 | this, SLOT(cdDoc() ) ); | 324 | this, SLOT(cdDoc() ) ); |
325 | 325 | ||
326 | m_btnNew = new QToolButton( box ); | 326 | m_btnNew = new QToolButton( box ); |
327 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); | 327 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); |
328 | connect(m_btnNew, SIGNAL(clicked() ), | 328 | connect(m_btnNew, SIGNAL(clicked() ), |
329 | this, SLOT(slotNew() ) ); | 329 | this, SLOT(slotNew() ) ); |
330 | 330 | ||
331 | 331 | ||
332 | m_btnClose = new QToolButton( box ); | 332 | m_btnClose = new QToolButton( box ); |
333 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); | 333 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); |
334 | connect(m_btnClose, SIGNAL(clicked() ), | 334 | connect(m_btnClose, SIGNAL(clicked() ), |
335 | selector(), SIGNAL(closeMe() ) ); | 335 | selector(), SIGNAL(closeMe() ) ); |
336 | 336 | ||
337 | btn = new QToolButton( box ); | 337 | btn = new QToolButton( box ); |
338 | btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); | 338 | btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); |
339 | 339 | ||
340 | /* let's fill device parts */ | 340 | /* let's fill device parts */ |
341 | QPopupMenu* pop = new QPopupMenu(this); | 341 | QPopupMenu* pop = new QPopupMenu(this); |
342 | connect(pop, SIGNAL( activated(int) ), | 342 | connect(pop, SIGNAL( activated(int) ), |
343 | this, SLOT(slotFSActivated(int) ) ); | 343 | this, SLOT(slotFSActivated(int) ) ); |
344 | 344 | ||
345 | StorageInfo storage; | 345 | StorageInfo storage; |
346 | const QList<FileSystem> &fs = storage.fileSystems(); | 346 | const QList<FileSystem> &fs = storage.fileSystems(); |
347 | QListIterator<FileSystem> it(fs); | 347 | QListIterator<FileSystem> it(fs); |
348 | for ( ; it.current(); ++it ) | 348 | for ( ; it.current(); ++it ) |
349 | { | 349 | { |
350 | const QString disk = (*it)->name(); | 350 | const QString disk = (*it)->name(); |
351 | const QString path = (*it)->path(); | 351 | const QString path = (*it)->path(); |
352 | m_dev.insert( disk, path ); | 352 | m_dev.insert( disk, path ); |
353 | pop->insertItem( disk ); | 353 | pop->insertItem( disk ); |
354 | } | 354 | } |
355 | m_fsPop = pop; | 355 | m_fsPop = pop; |
356 | 356 | ||
357 | 357 | ||
358 | btn->setPopup( pop ); | 358 | btn->setPopup( pop ); |
359 | 359 | ||
360 | lay->addWidget( box ); | 360 | lay->addWidget( box ); |
361 | 361 | ||
362 | m_view = new QListView( this ); | 362 | m_view = new QListView( this ); |
363 | 363 | ||
364 | m_view->installEventFilter(this); | 364 | m_view->installEventFilter(this); |
365 | 365 | ||
366 | QPEApplication::setStylusOperation( m_view->viewport(), | 366 | QPEApplication::setStylusOperation( m_view->viewport(), |
367 | QPEApplication::RightOnHold); | 367 | QPEApplication::RightOnHold); |
368 | m_view->addColumn(" " ); | 368 | m_view->addColumn(" " ); |
369 | m_view->addColumn(tr("Name"), 135 ); | 369 | m_view->addColumn(tr("Name"), 135 ); |
370 | m_view->addColumn(tr("Size"), -1 ); | 370 | m_view->addColumn(tr("Size"), -1 ); |
371 | m_view->addColumn(tr("Date"), 60 ); | 371 | m_view->addColumn(tr("Date"), 60 ); |
372 | m_view->addColumn(tr("Mime Type"), -1 ); | 372 | m_view->addColumn(tr("Mime Type"), -1 ); |
373 | 373 | ||
374 | 374 | ||
375 | m_view->setSorting( 1 ); | 375 | m_view->setSorting( 1 ); |
376 | m_view->setAllColumnsShowFocus( TRUE ); | 376 | m_view->setAllColumnsShowFocus( TRUE ); |
377 | 377 | ||
378 | lay->addWidget( m_view, 1000 ); | 378 | lay->addWidget( m_view, 1000 ); |
379 | connectSlots(); | 379 | connectSlots(); |
380 | } | 380 | } |
381 | 381 | ||
382 | OFileViewFileListView::~OFileViewFileListView() | 382 | OFileViewFileListView::~OFileViewFileListView() |
383 | { | 383 | { |
384 | } | 384 | } |
385 | 385 | ||
386 | void OFileViewFileListView::slotNew() | 386 | void OFileViewFileListView::slotNew() |
387 | { | 387 | { |
388 | DocLnk lnk; | 388 | DocLnk lnk; |
389 | emit selector()->newSelected( lnk ); | 389 | emit selector()->newSelected( lnk ); |
390 | } | 390 | } |
391 | 391 | ||
392 | OFileSelectorItem* OFileViewFileListView::currentItem()const | 392 | OFileSelectorItem* OFileViewFileListView::currentItem()const |
393 | { | 393 | { |
394 | QListViewItem* item = m_view->currentItem(); | 394 | QListViewItem* item = m_view->currentItem(); |
395 | if (!item ) | 395 | if (!item ) |
396 | return 0l; | 396 | return 0l; |
397 | 397 | ||
398 | return static_cast<OFileSelectorItem*>(item); | 398 | return static_cast<OFileSelectorItem*>(item); |
399 | } | 399 | } |
400 | 400 | ||
401 | void OFileViewFileListView::reread( bool all ) | 401 | void OFileViewFileListView::reread( bool all ) |
402 | { | 402 | { |
403 | m_view->clear(); | 403 | m_view->clear(); |
404 | 404 | ||
405 | if (selector()->showClose() ) | 405 | if (selector()->showClose() ) |
406 | m_btnClose->show(); | 406 | m_btnClose->show(); |
407 | else | 407 | else |
408 | m_btnClose->hide(); | 408 | m_btnClose->hide(); |
409 | 409 | ||
410 | if (selector()->showNew() ) | 410 | if (selector()->showNew() ) |
411 | m_btnNew->show(); | 411 | m_btnNew->show(); |
412 | else | 412 | else |
413 | m_btnNew->hide(); | 413 | m_btnNew->hide(); |
414 | 414 | ||
415 | m_mimes = selector()->currentMimeType(); | 415 | m_mimes = selector()->currentMimeType(); |
416 | m_all = all; | 416 | m_all = all; |
417 | 417 | ||
418 | QDir dir( m_currentDir ); | 418 | QDir dir( m_currentDir ); |
419 | if (!dir.exists() ) | 419 | if (!dir.exists() ) |
420 | return; | 420 | return; |
421 | 421 | ||
422 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 422 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
423 | int filter; | 423 | int filter; |
424 | if (m_all ) | 424 | if (m_all ) |
425 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 425 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
426 | else | 426 | else |
427 | filter = QDir::Files | QDir::Dirs | QDir::All; | 427 | filter = QDir::Files | QDir::Dirs | QDir::All; |
428 | dir.setFilter( filter ); | 428 | dir.setFilter( filter ); |
429 | 429 | ||
430 | // now go through all files | 430 | // now go through all files |
431 | const QFileInfoList *list = dir.entryInfoList(); | 431 | const QFileInfoList *list = dir.entryInfoList(); |
432 | if (!list) | 432 | if (!list) |
433 | { | 433 | { |
434 | cdUP(); | 434 | cdUP(); |
435 | return; | 435 | return; |
436 | } | 436 | } |
437 | 437 | ||
438 | QFileInfoListIterator it( *list ); | 438 | QFileInfoListIterator it( *list ); |
439 | QFileInfo *fi; | 439 | QFileInfo *fi; |
440 | while( (fi=it.current() ) ) | 440 | while( (fi=it.current() ) ) |
441 | { | 441 | { |
442 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) | 442 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) |
443 | { | 443 | { |
444 | ++it; | 444 | ++it; |
445 | continue; | 445 | continue; |
446 | } | 446 | } |
447 | 447 | ||
448 | /* | 448 | /* |
449 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 449 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
450 | * | 450 | * |
451 | */ | 451 | */ |
452 | if( fi->isSymLink() ) | 452 | if( fi->isSymLink() ) |
453 | { | 453 | { |
454 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 454 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
455 | for( int i = 0; i<=4; i++) | 455 | for( int i = 0; i<=4; i++) |
456 | { // 5 tries to prevent dos | 456 | { // 5 tries to prevent dos |
457 | QFileInfo info( file ); | 457 | QFileInfo info( file ); |
458 | if( !info.exists() ) | 458 | if( !info.exists() ) |
459 | { | 459 | { |
460 | addSymlink( fi, TRUE ); | 460 | addSymlink( fi, TRUE ); |
461 | break; | 461 | break; |
462 | } | 462 | } |
463 | else if( info.isDir() ) | 463 | else if( info.isDir() ) |
464 | { | 464 | { |
465 | addDir( fi, TRUE ); | 465 | addDir( fi, TRUE ); |
466 | break; | 466 | break; |
467 | } | 467 | } |
468 | else if( info.isFile() ) | 468 | else if( info.isFile() ) |
469 | { | 469 | { |
470 | addFile( fi, TRUE ); | 470 | addFile( fi, TRUE ); |
471 | break; | 471 | break; |
472 | } | 472 | } |
473 | else if( info.isSymLink() ) | 473 | else if( info.isSymLink() ) |
474 | { | 474 | { |
475 | file = info.dirPath(true ) + "/" + info.readLink() ; | 475 | file = info.dirPath(true ) + "/" + info.readLink() ; |
476 | break; | 476 | break; |
477 | } | 477 | } |
478 | else if( i == 4) | 478 | else if( i == 4) |
479 | { // couldn't resolve symlink add it as symlink | 479 | { // couldn't resolve symlink add it as symlink |
480 | addSymlink( fi ); | 480 | addSymlink( fi ); |
481 | } | 481 | } |
482 | } // off for loop for symlink resolving | 482 | } // off for loop for symlink resolving |
483 | } | 483 | } |
484 | else if( fi->isDir() ) | 484 | else if( fi->isDir() ) |
485 | addDir( fi ); | 485 | addDir( fi ); |
486 | else if( fi->isFile() ) | 486 | else if( fi->isFile() ) |
487 | addFile( fi ); | 487 | addFile( fi ); |
488 | 488 | ||
489 | ++it; | 489 | ++it; |
490 | } // of while loop | 490 | } // of while loop |
491 | m_view->sort(); | 491 | m_view->sort(); |
492 | 492 | ||
493 | } | 493 | } |
494 | int OFileViewFileListView::fileCount()const | 494 | int OFileViewFileListView::fileCount()const |
495 | { | 495 | { |
496 | return m_view->childCount(); | 496 | return m_view->childCount(); |
497 | } | 497 | } |
498 | 498 | ||
499 | QString OFileViewFileListView::currentDir()const | 499 | QString OFileViewFileListView::currentDir()const |
500 | { | 500 | { |
501 | return m_currentDir; | 501 | return m_currentDir; |
502 | } | 502 | } |
503 | 503 | ||
504 | OFileSelector* OFileViewFileListView::selector() | 504 | OFileSelector* OFileViewFileListView::selector() |
505 | { | 505 | { |
506 | return m_sel; | 506 | return m_sel; |
507 | } | 507 | } |
508 | 508 | ||
509 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) | 509 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) |
510 | { | 510 | { |
511 | if ( e->type() == QEvent::KeyPress ) | 511 | if ( e->type() == QEvent::KeyPress ) |
512 | { | 512 | { |
513 | QKeyEvent *k = (QKeyEvent *)e; | 513 | QKeyEvent *k = (QKeyEvent *)e; |
514 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 514 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
515 | { | 515 | { |
516 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 516 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
517 | return true; | 517 | return true; |
518 | } | 518 | } |
519 | } | 519 | } |
520 | return false; | 520 | return false; |
521 | } | 521 | } |
522 | 522 | ||
523 | void OFileViewFileListView::connectSlots() | 523 | void OFileViewFileListView::connectSlots() |
524 | { | 524 | { |
525 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 525 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
526 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 526 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
527 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), | 527 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
528 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); | 528 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); |
529 | } | 529 | } |
530 | 530 | ||
531 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) | 531 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) |
532 | { | 532 | { |
533 | if (!item) | 533 | if (!item) |
534 | return; | 534 | return; |
535 | #if 0 | 535 | #if 0 |
536 | 536 | ||
537 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 537 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
538 | 538 | ||
539 | if (!sel->isDir() ) | 539 | if (!sel->isDir() ) |
540 | { | 540 | { |
541 | selector()->m_lneEdit->setText( sel->text(1) ); | 541 | selector()->m_lneEdit->setText( sel->text(1) ); |
542 | // if in fileselector mode we will emit selected | 542 | // if in fileselector mode we will emit selected |
543 | if ( selector()->mode() == OFileSelector::FileSelector ) | 543 | if ( selector()->mode() == OFileSelector::FileSelector ) |
544 | { | 544 | { |
545 | qWarning("slot Current Changed"); | 545 | qWarning("slot Current Changed"); |
546 | QStringList str = QStringList::split("->", sel->text(1) ); | 546 | QStringList str = QStringList::split("->", sel->text(1) ); |
547 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 547 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
548 | emit selector()->fileSelected( path ); | 548 | emit selector()->fileSelected( path ); |
549 | DocLnk lnk( path ); | 549 | DocLnk lnk( path ); |
550 | emit selector()->fileSelected( lnk ); | 550 | emit selector()->fileSelected( lnk ); |
551 | } | 551 | } |
552 | } | 552 | } |
553 | #endif | 553 | #endif |
554 | } | 554 | } |
555 | 555 | ||
556 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) | 556 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) |
557 | { | 557 | { |
558 | if (!item || ( button != Qt::LeftButton) ) | 558 | if (!item || ( button != Qt::LeftButton) ) |
559 | return; | 559 | return; |
560 | 560 | ||
561 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 561 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
562 | if (!sel->isLocked() ) | 562 | if (!sel->isLocked() ) |
563 | { | 563 | { |
564 | QStringList str = QStringList::split("->", sel->text(1) ); | 564 | QStringList str = QStringList::split("->", sel->text(1) ); |
565 | if (sel->isDir() ) | 565 | if (sel->isDir() ) |
566 | { | 566 | { |
567 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 567 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); |
568 | emit selector()->dirSelected( m_currentDir ); | 568 | emit selector()->dirSelected( m_currentDir ); |
569 | reread( m_all ); | 569 | reread( m_all ); |
570 | } | 570 | } |
571 | else | 571 | else |
572 | { // file | 572 | { // file |
573 | qWarning("slot Clicked"); | 573 | qWarning("slot Clicked"); |
574 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 574 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
575 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 575 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
576 | emit selector()->fileSelected( path ); | 576 | emit selector()->fileSelected( path ); |
577 | DocLnk lnk( path ); | 577 | DocLnk lnk( path ); |
578 | emit selector()->fileSelected( lnk ); | 578 | emit selector()->fileSelected( lnk ); |
579 | } | 579 | } |
580 | } // not locked | 580 | } // not locked |
581 | } | 581 | } |
582 | 582 | ||
583 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) | 583 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) |
584 | { | 584 | { |
585 | MimeType type( info->absFilePath() ); | 585 | MimeType type( info->absFilePath() ); |
586 | if (!compliesMime( type.id() ) ) | 586 | if (!compliesMime( type.id() ) ) |
587 | return; | 587 | return; |
588 | 588 | ||
589 | QPixmap pix = type.pixmap(); | 589 | QPixmap pix = type.pixmap(); |
590 | QString dir, name; bool locked; | 590 | QString dir, name; bool locked; |
591 | if ( pix.isNull() ) | 591 | if ( pix.isNull() ) |
592 | { | 592 | { |
593 | QWMatrix matrix; | 593 | QWMatrix matrix; |
594 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | 594 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); |
595 | matrix.scale( .4, .4 ); | 595 | matrix.scale( .4, .4 ); |
596 | pix = pixer.xForm( matrix ); | 596 | pix = pixer.xForm( matrix ); |
597 | } | 597 | } |
598 | dir = info->dirPath( true ); | 598 | dir = info->dirPath( true ); |
599 | locked = false; | 599 | locked = false; |
600 | if ( symlink ) | 600 | if ( symlink ) |
601 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | 601 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); |
602 | else | 602 | else |
603 | { | 603 | { |
604 | name = info->fileName(); | 604 | name = info->fileName(); |
605 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 605 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
606 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) | 606 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) |
607 | { | 607 | { |
608 | locked = true; pix = Resource::loadPixmap("locked"); | 608 | locked = true; pix = Resource::loadPixmap("locked"); |
609 | } | 609 | } |
610 | } | 610 | } |
611 | (void)new OFileSelectorItem( m_view, pix, name, | 611 | (void)new OFileSelectorItem( m_view, pix, name, |
612 | info->lastModified().toString(), QString::number( info->size() ), | 612 | info->lastModified().toString(), QString::number( info->size() ), |
613 | dir, locked ); | 613 | dir, locked ); |
614 | } | 614 | } |
615 | 615 | ||
616 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) | 616 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) |
617 | { | 617 | { |
618 | bool locked = false; QString name; QPixmap pix; | 618 | bool locked = false; QString name; QPixmap pix; |
619 | 619 | ||
620 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 620 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
621 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) | 621 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) |
622 | { | 622 | { |
623 | locked = true; | 623 | locked = true; |
624 | if ( symlink ) | 624 | if ( symlink ) |
625 | pix = Resource::loadPixmap( "opie/symlink" ); | 625 | pix = Resource::loadPixmap( "opie/symlink" ); |
626 | else | 626 | else |
627 | pix = Resource::loadPixmap( "lockedfolder" ); | 627 | pix = Resource::loadPixmap( "lockedfolder" ); |
628 | } | 628 | } |
629 | else | 629 | else |
630 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); | 630 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); |
631 | 631 | ||
632 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : | 632 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : |
633 | info->fileName(); | 633 | info->fileName(); |
634 | 634 | ||
635 | (void)new OFileSelectorItem( m_view, pix, name, | 635 | (void)new OFileSelectorItem( m_view, pix, name, |
636 | info->lastModified().toString(), | 636 | info->lastModified().toString(), |
637 | QString::number( info->size() ), | 637 | QString::number( info->size() ), |
638 | info->dirPath( true ), locked, true ); | 638 | info->dirPath( true ), locked, true ); |
639 | 639 | ||
640 | 640 | ||
641 | } | 641 | } |
642 | 642 | ||
643 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) | 643 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) |
644 | { | 644 | { |
645 | } | 645 | } |
646 | 646 | ||
647 | void OFileViewFileListView::cdUP() | 647 | void OFileViewFileListView::cdUP() |
648 | { | 648 | { |
649 | QDir dir( m_currentDir ); | 649 | QDir dir( m_currentDir ); |
650 | dir.cdUp(); | 650 | dir.cdUp(); |
651 | 651 | ||
652 | if (!dir.exists() ) | 652 | if (!dir.exists() ) |
653 | m_currentDir = "/"; | 653 | m_currentDir = "/"; |
654 | else | 654 | else |
655 | m_currentDir = dir.absPath(); | 655 | m_currentDir = dir.absPath(); |
656 | 656 | ||
657 | emit selector()->dirSelected( m_currentDir ); | 657 | emit selector()->dirSelected( m_currentDir ); |
658 | reread( m_all ); | 658 | reread( m_all ); |
659 | } | 659 | } |
660 | 660 | ||
661 | void OFileViewFileListView::cdHome() | 661 | void OFileViewFileListView::cdHome() |
662 | { | 662 | { |
663 | m_currentDir = QDir::homeDirPath(); | 663 | m_currentDir = QDir::homeDirPath(); |
664 | emit selector()->dirSelected( m_currentDir ); | 664 | emit selector()->dirSelected( m_currentDir ); |
665 | reread( m_all ); | 665 | reread( m_all ); |
666 | } | 666 | } |
667 | 667 | ||
668 | void OFileViewFileListView::cdDoc() | 668 | void OFileViewFileListView::cdDoc() |
669 | { | 669 | { |
670 | m_currentDir = QPEApplication::documentDir(); | 670 | m_currentDir = QPEApplication::documentDir(); |
671 | emit selector()->dirSelected( m_currentDir ); | 671 | emit selector()->dirSelected( m_currentDir ); |
672 | reread( m_all ); | 672 | reread( m_all ); |
673 | } | 673 | } |
674 | 674 | ||
675 | void OFileViewFileListView::changeDir( const QString& dir ) | 675 | void OFileViewFileListView::changeDir( const QString& dir ) |
676 | { | 676 | { |
677 | m_currentDir = dir; | 677 | m_currentDir = dir; |
678 | emit selector()->dirSelected( m_currentDir ); | 678 | emit selector()->dirSelected( m_currentDir ); |
679 | reread( m_all ); | 679 | reread( m_all ); |
680 | } | 680 | } |
681 | 681 | ||
682 | void OFileViewFileListView::slotFSActivated( int id ) | 682 | void OFileViewFileListView::slotFSActivated( int id ) |
683 | { | 683 | { |
684 | changeDir ( m_dev[m_fsPop->text(id)] ); | 684 | changeDir ( m_dev[m_fsPop->text(id)] ); |
685 | } | 685 | } |
686 | 686 | ||
687 | /* check if the mimetype in mime | 687 | /* check if the mimetype in mime |
688 | * complies with the one which is current | 688 | * complies with the one which is current |
689 | */ | 689 | */ |
690 | /* | 690 | /* |
691 | * We've the mimetype of the file | 691 | * We've the mimetype of the file |
692 | * We need to get the stringlist of the current mimetype | 692 | * We need to get the stringlist of the current mimetype |
693 | * | 693 | * |
694 | * mime = image@slashjpeg | 694 | * mime = image@slashjpeg |
695 | * QStringList = 'image@slash*' | 695 | * QStringList = 'image@slash*' |
696 | * or QStringList = image/jpeg;image/png;application/x-ogg | 696 | * or QStringList = image/jpeg;image/png;application/x-ogg |
697 | * or QStringList = application/x-ogg;image@slash*; | 697 | * or QStringList = application/x-ogg;image@slash*; |
698 | * with all these mime filters it should get acceptes | 698 | * with all these mime filters it should get acceptes |
699 | * to do so we need to look if mime is contained inside | 699 | * to do so we need to look if mime is contained inside |
700 | * the stringlist | 700 | * the stringlist |
701 | * if it's contained return true | 701 | * if it's contained return true |
702 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 702 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
703 | * is contained in the mimefilter and then we will | 703 | * is contained in the mimefilter and then we will |
704 | * look if both are equal until the '/' | 704 | * look if both are equal until the '/' |
705 | */ | 705 | */ |
706 | 706 | ||
707 | bool OFileViewFileListView::compliesMime( const QString& str) | 707 | bool OFileViewFileListView::compliesMime( const QString& str) |
708 | { | 708 | { |
709 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 709 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
710 | return true; | 710 | return true; |
711 | 711 | ||
712 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) | 712 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) |
713 | { | 713 | { |
714 | QRegExp reg( (*it) ); | 714 | QRegExp reg( (*it) ); |
715 | reg.setWildcard( true ); | 715 | reg.setWildcard( true ); |
716 | if ( str.find( reg ) != -1 ) | 716 | if ( str.find( reg ) != -1 ) |
717 | return true; | 717 | return true; |
718 | 718 | ||
719 | } | 719 | } |
720 | return false; | 720 | return false; |
721 | } | 721 | } |
722 | /* | 722 | /* |
723 | * The listView giving access to the file system! | 723 | * The listView giving access to the file system! |
724 | */ | 724 | */ |
725 | 725 | ||
726 | class OFileViewFileSystem : public OFileViewInterface | 726 | class OFileViewFileSystem : public OFileViewInterface |
727 | { | 727 | { |
728 | public: | 728 | public: |
729 | OFileViewFileSystem( OFileSelector* ); | 729 | OFileViewFileSystem( OFileSelector* ); |
730 | ~OFileViewFileSystem(); | 730 | ~OFileViewFileSystem(); |
731 | 731 | ||
732 | QString selectedName() const; | 732 | QString selectedName() const; |
733 | QString selectedPath() const; | 733 | QString selectedPath() const; |
734 | 734 | ||
735 | QString directory()const; | 735 | QString directory()const; |
736 | void reread(); | 736 | void reread(); |
737 | int fileCount()const; | 737 | int fileCount()const; |
738 | 738 | ||
739 | QWidget* widget( QWidget* parent ); | 739 | QWidget* widget( QWidget* parent ); |
740 | void activate( const QString& ); | 740 | void activate( const QString& ); |
741 | private: | 741 | private: |
742 | OFileViewFileListView* m_view; | 742 | OFileViewFileListView* m_view; |
743 | bool m_all : 1; | 743 | bool m_all : 1; |
744 | }; | 744 | }; |
745 | 745 | ||
746 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 746 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
747 | : OFileViewInterface( sel ) | 747 | : OFileViewInterface( sel ) |
748 | { | 748 | { |
749 | m_view = 0; | 749 | m_view = 0; |
750 | m_all = false; | 750 | m_all = false; |
751 | } | 751 | } |
752 | 752 | ||
753 | OFileViewFileSystem::~OFileViewFileSystem() | 753 | OFileViewFileSystem::~OFileViewFileSystem() |
754 | { | 754 | { |
755 | } | 755 | } |
756 | 756 | ||
757 | QString OFileViewFileSystem::selectedName()const | 757 | QString OFileViewFileSystem::selectedName()const |
758 | { | 758 | { |
759 | if (!m_view ) | 759 | if (!m_view ) |
760 | return QString::null; | 760 | return QString::null; |
761 | 761 | ||
762 | QString cFN=currentFileName(); | 762 | QString cFN=currentFileName(); |
763 | if (cFN.startsWith("/")) return cFN; | 763 | if (cFN.startsWith("/")) return cFN; |
764 | return m_view->currentDir() + "/" + cFN; | 764 | return m_view->currentDir() + "/" + cFN; |
765 | } | 765 | } |
766 | 766 | ||
767 | QString OFileViewFileSystem::selectedPath()const | 767 | QString OFileViewFileSystem::selectedPath()const |
768 | { | 768 | { |
769 | return QString::null; | 769 | return QString::null; |
770 | } | 770 | } |
771 | 771 | ||
772 | QString OFileViewFileSystem::directory()const | 772 | QString OFileViewFileSystem::directory()const |
773 | { | 773 | { |
774 | if (!m_view) | 774 | if (!m_view) |
775 | return QString::null; | 775 | return QString::null; |
776 | 776 | ||
777 | OFileSelectorItem* item = m_view->currentItem(); | 777 | OFileSelectorItem* item = m_view->currentItem(); |
778 | if (!item ) | 778 | if (!item ) |
779 | return QString::null; | 779 | return QString::null; |
780 | 780 | ||
781 | return QDir(item->directory() ).absPath(); | 781 | return QDir(item->directory() ).absPath(); |
782 | } | 782 | } |
783 | 783 | ||
784 | void OFileViewFileSystem::reread() | 784 | void OFileViewFileSystem::reread() |
785 | { | 785 | { |
786 | if (!m_view) | 786 | if (!m_view) |
787 | return; | 787 | return; |
788 | 788 | ||
789 | m_view->reread( m_all ); | 789 | m_view->reread( m_all ); |
790 | } | 790 | } |
791 | 791 | ||
792 | int OFileViewFileSystem::fileCount()const | 792 | int OFileViewFileSystem::fileCount()const |
793 | { | 793 | { |
794 | if (!m_view ) | 794 | if (!m_view ) |
795 | return -1; | 795 | return -1; |
796 | return m_view->fileCount(); | 796 | return m_view->fileCount(); |
797 | } | 797 | } |
798 | 798 | ||
799 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) | 799 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) |
800 | { | 800 | { |
801 | if (!m_view ) | 801 | if (!m_view ) |
802 | { | 802 | { |
803 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 803 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
804 | } | 804 | } |
805 | return m_view; | 805 | return m_view; |
806 | } | 806 | } |
807 | 807 | ||
808 | void OFileViewFileSystem::activate( const QString& str) | 808 | void OFileViewFileSystem::activate( const QString& str) |
809 | { | 809 | { |
810 | m_all = (str != QObject::tr("Files") ); | 810 | m_all = (str != QObject::tr("Files") ); |
811 | } | 811 | } |
812 | 812 | ||
813 | /* Selector */ | 813 | /* Selector */ |
814 | /** | 814 | /** |
815 | * @short new and complete c'tor | 815 | * @short new and complete c'tor |
816 | * | 816 | * |
817 | * Create a OFileSelector to let the user select a file. It can | 817 | * Create a OFileSelector to let the user select a file. It can |
818 | * either be used to open a file, select a save name in a dir or | 818 | * either be used to open a file, select a save name in a dir or |
819 | * as a dropin for the FileSelector. | 819 | * as a dropin for the FileSelector. |
820 | * | 820 | * |
821 | * <pre> | 821 | * <pre> |
822 | * QMap<QString, QStringList> mimeTypes; | 822 | * QMap<QString, QStringList> mimeTypes; |
823 | * QStringList types; | 823 | * QStringList types; |
824 | * types << "text@slash* "; | 824 | * types << "text@slash* "; |
825 | * types << "audio@slash*"; | 825 | * types << "audio@slash*"; |
826 | * mimeTypes.insert( tr("Audio and Text"), types ); | 826 | * mimeTypes.insert( tr("Audio and Text"), types ); |
827 | * mimeTypes.insert( tr("All"), "*@slash*); | 827 | * mimeTypes.insert( tr("All"), "*@slash*); |
828 | * | 828 | * |
829 | * now you could create your fileselector | 829 | * now you could create your fileselector |
830 | * </pre> | 830 | * </pre> |
831 | * | 831 | * |
832 | * | 832 | * |
833 | * @param parent the parent of this widget | 833 | * @param parent the parent of this widget |
834 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) | 834 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) |
835 | * @param sel The selector to be used | 835 | * @param sel The selector to be used |
836 | * @param dirName The name of the dir to start int | 836 | * @param dirName The name of the dir to start int |
837 | * @param fileName The fileName placed in the fileselector lineedit | 837 | * @param fileName The fileName placed in the fileselector lineedit |
838 | * @param mimetypes The MimeType map of used mimetypes | 838 | * @param mimetypes The MimeType map of used mimetypes |
839 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. | 839 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. |
840 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. | 840 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. |
841 | * | 841 | * |
842 | */ | 842 | */ |
843 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 843 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
844 | const QString& dirName, const QString& fileName, | 844 | const QString& dirName, const QString& fileName, |
845 | const MimeTypes& mimetypes, | 845 | const MimeTypes& mimetypes, |
846 | bool showNew, bool showClose) | 846 | bool showNew, bool showClose) |
847 | :QWidget( parent, "OFileSelector" ) | 847 | :QWidget( parent, "OFileSelector" ) |
848 | { | 848 | { |
849 | m_current = 0; | 849 | m_current = 0; |
850 | m_shNew = showNew; | 850 | m_shNew = showNew; |
851 | m_shClose = showClose; | 851 | m_shClose = showClose; |
852 | m_mimeType = mimetypes; | 852 | m_mimeType = mimetypes; |
853 | m_startDir = dirName; | 853 | m_startDir = dirName; |
854 | 854 | ||
855 | m_mode = mode; | 855 | m_mode = mode; |
856 | m_selector = sel; | 856 | m_selector = sel; |
857 | 857 | ||
858 | initUI(); | 858 | initUI(); |
859 | m_lneEdit->setText( fileName ); | 859 | m_lneEdit->setText( fileName ); |
860 | initMime(); | 860 | initMime(); |
861 | initViews(); | 861 | initViews(); |
862 | 862 | ||
863 | QString str; | 863 | QString str; |
864 | switch ( m_selector ) | 864 | switch ( m_selector ) |
865 | { | 865 | { |
866 | default: | 866 | default: |
867 | case Normal: | 867 | case Normal: |
868 | str = QObject::tr("Documents"); | 868 | str = QObject::tr("Documents"); |
869 | m_cmbView->setCurrentItem( 0 ); | 869 | m_cmbView->setCurrentItem( 0 ); |
870 | break; | 870 | break; |
871 | case Extended: | 871 | case Extended: |
872 | str = QObject::tr("Files"); | 872 | str = QObject::tr("Files"); |
873 | m_cmbView->setCurrentItem( 1 ); | 873 | m_cmbView->setCurrentItem( 1 ); |
874 | break; | 874 | break; |
875 | case ExtendedAll: | 875 | case ExtendedAll: |
876 | str = QObject::tr("All Files"); | 876 | str = QObject::tr("All Files"); |
877 | m_cmbView->setCurrentItem( 2 ); | 877 | m_cmbView->setCurrentItem( 2 ); |
878 | break; | 878 | break; |
879 | } | 879 | } |
880 | slotViewChange( str ); | 880 | slotViewChange( str ); |
881 | 881 | ||
882 | } | 882 | } |
883 | 883 | ||
884 | 884 | ||
885 | /** | 885 | /** |
886 | * This a convience c'tor to just substitute the use of FileSelector | 886 | * This a convience c'tor to just substitute the use of FileSelector |
887 | */ | 887 | */ |
888 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 888 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
889 | bool showNew, bool showClose ) | 889 | bool showNew, bool showClose ) |
890 | : QWidget( parent, name ) | 890 | : QWidget( parent, name ) |
891 | { | 891 | { |
892 | m_current = 0; | 892 | m_current = 0; |
893 | m_shNew = showNew; | 893 | m_shNew = showNew; |
894 | m_shClose = showClose; | 894 | m_shClose = showClose; |
895 | m_startDir = QPEApplication::documentDir(); | 895 | m_startDir = QPEApplication::documentDir(); |
896 | 896 | ||
897 | if (!mimeFilter.isEmpty() ) | 897 | if (!mimeFilter.isEmpty() ) |
898 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | 898 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); |
899 | 899 | ||
900 | m_mode = OFileSelector::FileSelector; | 900 | m_mode = OFileSelector::FileSelector; |
901 | m_selector = OFileSelector::Normal; | 901 | m_selector = OFileSelector::Normal; |
902 | 902 | ||
903 | initUI(); | 903 | initUI(); |
904 | initMime(); | 904 | initMime(); |
905 | initViews(); | 905 | initViews(); |
906 | m_cmbView->setCurrentItem( 0 ); | 906 | m_cmbView->setCurrentItem( 0 ); |
907 | slotViewChange( QObject::tr("Documents") ); | 907 | slotViewChange( QObject::tr("Documents") ); |
908 | } | 908 | } |
909 | 909 | ||
910 | /* | 910 | /* |
911 | * INIT UI will set up the basic GUI | 911 | * INIT UI will set up the basic GUI |
912 | * Layout: Simple VBoxLayout | 912 | * Layout: Simple VBoxLayout |
913 | * On top a WidgetStack containing the Views... | 913 | * On top a WidgetStack containing the Views... |
914 | * - List View | 914 | * - List View |
915 | * - Document View | 915 | * - Document View |
916 | * Below we will have a Label + LineEdit | 916 | * Below we will have a Label + LineEdit |
917 | * Below we will have two ComoBoxes one for choosing the view one for | 917 | * Below we will have two ComoBoxes one for choosing the view one for |
918 | * choosing the mimetype | 918 | * choosing the mimetype |
919 | */ | 919 | */ |
920 | void OFileSelector::initUI() | 920 | void OFileSelector::initUI() |
921 | { | 921 | { |
922 | QVBoxLayout* lay = new QVBoxLayout( this ); | 922 | QVBoxLayout* lay = new QVBoxLayout( this ); |
923 | 923 | ||
924 | m_stack = new QWidgetStack( this ); | 924 | m_stack = new QWidgetStack( this ); |
925 | lay->addWidget( m_stack, 1000 ); | 925 | lay->addWidget( m_stack, 1000 ); |
926 | 926 | ||
927 | m_nameBox = new QHBox( this ); | 927 | m_nameBox = new QHBox( this ); |
928 | (void)new QLabel( tr("Name:"), m_nameBox ); | 928 | (void)new QLabel( tr("Name:"), m_nameBox ); |
929 | m_lneEdit = new QLineEdit( m_nameBox ); | 929 | m_lneEdit = new QLineEdit( m_nameBox ); |
930 | m_lneEdit ->installEventFilter(this); | 930 | m_lneEdit ->installEventFilter(this); |
931 | lay->addWidget( m_nameBox ); | 931 | lay->addWidget( m_nameBox ); |
932 | 932 | ||
933 | m_cmbBox = new QHBox( this ); | 933 | m_cmbBox = new QHBox( this ); |
934 | m_cmbView = new QComboBox( m_cmbBox ); | 934 | m_cmbView = new QComboBox( m_cmbBox ); |
935 | m_cmbMime = new QComboBox( m_cmbBox ); | 935 | m_cmbMime = new QComboBox( m_cmbBox ); |
936 | lay->addWidget( m_cmbBox ); | 936 | lay->addWidget( m_cmbBox ); |
937 | } | 937 | } |
938 | 938 | ||
939 | /* | 939 | /* |
940 | * This will make sure that the return key in the name edit causes dialogs to close | 940 | * This will make sure that the return key in the name edit causes dialogs to close |
941 | */ | 941 | */ |
942 | 942 | ||
943 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) | 943 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) |
944 | { | 944 | { |
945 | if ( e->type() == QEvent::KeyPress ) | 945 | if ( e->type() == QEvent::KeyPress ) |
946 | { | 946 | { |
947 | QKeyEvent *k = (QKeyEvent *)e; | 947 | QKeyEvent *k = (QKeyEvent *)e; |
948 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 948 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
949 | { | 949 | { |
950 | emit ok(); | 950 | emit ok(); |
951 | return true; | 951 | return true; |
952 | } | 952 | } |
953 | } | 953 | } |
954 | return false; | 954 | return false; |
955 | } | 955 | } |
956 | 956 | ||
957 | /* | 957 | /* |
958 | * This will insert the MimeTypes into the Combo Box | 958 | * This will insert the MimeTypes into the Combo Box |
959 | * And also connect the changed signal | 959 | * And also connect the changed signal |
960 | * | 960 | * |
961 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes | 961 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes |
962 | */ | 962 | */ |
963 | void OFileSelector::initMime() | 963 | void OFileSelector::initMime() |
964 | { | 964 | { |
965 | MimeTypes::Iterator it; | 965 | MimeTypes::Iterator it; |
966 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) | 966 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) |
967 | { | 967 | { |
968 | m_cmbMime->insertItem( it.key() ); | 968 | m_cmbMime->insertItem( it.key() ); |
969 | } | 969 | } |
970 | m_cmbMime->setCurrentItem( 0 ); | 970 | m_cmbMime->setCurrentItem( 0 ); |
971 | 971 | ||
972 | connect( m_cmbMime, SIGNAL(activated(int) ), | 972 | connect( m_cmbMime, SIGNAL(activated(int) ), |
973 | this, SLOT(slotMimeTypeChanged() ) ); | 973 | this, SLOT(slotMimeTypeChanged() ) ); |
974 | 974 | ||
975 | } | 975 | } |
976 | 976 | ||
977 | void OFileSelector::initViews() | 977 | void OFileSelector::initViews() |
978 | { | 978 | { |
979 | m_cmbView->insertItem( QObject::tr("Documents") ); | 979 | m_cmbView->insertItem( QObject::tr("Documents") ); |
980 | m_cmbView->insertItem( QObject::tr("Files") ); | 980 | m_cmbView->insertItem( QObject::tr("Files") ); |
981 | m_cmbView->insertItem( QObject::tr("All Files") ); | 981 | m_cmbView->insertItem( QObject::tr("All Files") ); |
982 | connect(m_cmbView, SIGNAL(activated( const QString& ) ), | 982 | connect(m_cmbView, SIGNAL(activated(const QString&) ), |
983 | this, SLOT(slotViewChange( const QString& ) ) ); | 983 | this, SLOT(slotViewChange(const QString&) ) ); |
984 | 984 | ||
985 | 985 | ||
986 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); | 986 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); |
987 | 987 | ||
988 | /* see above why add both */ | 988 | /* see above why add both */ |
989 | OFileViewInterface* in = new OFileViewFileSystem( this ); | 989 | OFileViewInterface* in = new OFileViewFileSystem( this ); |
990 | m_views.insert( QObject::tr("Files"), in ); | 990 | m_views.insert( QObject::tr("Files"), in ); |
991 | m_views.insert( QObject::tr("All Files"), in ); | 991 | m_views.insert( QObject::tr("All Files"), in ); |
992 | } | 992 | } |
993 | 993 | ||
994 | /** | 994 | /** |
995 | * d'tor | 995 | * d'tor |
996 | */ | 996 | */ |
997 | OFileSelector::~OFileSelector() | 997 | OFileSelector::~OFileSelector() |
998 | { | 998 | { |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | 1001 | ||
1002 | 1002 | ||
1003 | /** | 1003 | /** |
1004 | * Convience function for the fileselector | 1004 | * Convience function for the fileselector |
1005 | * make sure to delete the DocLnk | 1005 | * make sure to delete the DocLnk |
1006 | * | 1006 | * |
1007 | * @see DocLnk | 1007 | * @see DocLnk |
1008 | * @todo remove in ODP | 1008 | * @todo remove in ODP |
1009 | */ | 1009 | */ |
1010 | const DocLnk* OFileSelector::selected() | 1010 | const DocLnk* OFileSelector::selected() |
1011 | { | 1011 | { |
1012 | DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); | 1012 | DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); |
1013 | return lnk; | 1013 | return lnk; |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | /** | 1016 | /** |
1017 | * | 1017 | * |
1018 | * @return the name of the selected file | 1018 | * @return the name of the selected file |
1019 | */ | 1019 | */ |
1020 | QString OFileSelector::selectedName()const | 1020 | QString OFileSelector::selectedName()const |
1021 | { | 1021 | { |
1022 | return currentView()->selectedName(); | 1022 | return currentView()->selectedName(); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | 1025 | ||
1026 | /** | 1026 | /** |
1027 | * @return the selected path | 1027 | * @return the selected path |
1028 | */ | 1028 | */ |
1029 | QString OFileSelector::selectedPath()const | 1029 | QString OFileSelector::selectedPath()const |
1030 | { | 1030 | { |
1031 | return currentView()->selectedPath(); | 1031 | return currentView()->selectedPath(); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | /** | 1034 | /** |
1035 | * @return the directory name | 1035 | * @return the directory name |
1036 | */ | 1036 | */ |
1037 | QString OFileSelector::directory()const | 1037 | QString OFileSelector::directory()const |
1038 | { | 1038 | { |
1039 | return currentView()->directory(); | 1039 | return currentView()->directory(); |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | /** | 1042 | /** |
1043 | * @return a DocLnk for the selected document | 1043 | * @return a DocLnk for the selected document |
1044 | */ | 1044 | */ |
1045 | DocLnk OFileSelector::selectedDocument()const | 1045 | DocLnk OFileSelector::selectedDocument()const |
1046 | { | 1046 | { |
1047 | return currentView()->selectedDocument(); | 1047 | return currentView()->selectedDocument(); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | /** | 1050 | /** |
1051 | * @return the number of items for the current view | 1051 | * @return the number of items for the current view |
1052 | */ | 1052 | */ |
1053 | int OFileSelector::fileCount()const | 1053 | int OFileSelector::fileCount()const |
1054 | { | 1054 | { |
1055 | return currentView()->fileCount(); | 1055 | return currentView()->fileCount(); |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | /** | 1058 | /** |
1059 | * @return reparse the file content | 1059 | * @return reparse the file content |
1060 | */ | 1060 | */ |
1061 | void OFileSelector::reread() | 1061 | void OFileSelector::reread() |
1062 | { | 1062 | { |
1063 | return currentView()->reread(); | 1063 | return currentView()->reread(); |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | OFileViewInterface* OFileSelector::currentView()const | 1066 | OFileViewInterface* OFileSelector::currentView()const |
1067 | { | 1067 | { |
1068 | return m_current; | 1068 | return m_current; |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | bool OFileSelector::showNew()const | 1071 | bool OFileSelector::showNew()const |
1072 | { | 1072 | { |
1073 | return m_shNew; | 1073 | return m_shNew; |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | bool OFileSelector::showClose()const | 1076 | bool OFileSelector::showClose()const |
1077 | { | 1077 | { |
1078 | return m_shClose; | 1078 | return m_shClose; |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | MimeTypes OFileSelector::mimeTypes()const | 1081 | MimeTypes OFileSelector::mimeTypes()const |
1082 | { | 1082 | { |
1083 | return m_mimeType; | 1083 | return m_mimeType; |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | /** | 1086 | /** |
1087 | * @return the Mode of the OFileSelector | 1087 | * @return the Mode of the OFileSelector |
1088 | */ | 1088 | */ |
1089 | int OFileSelector::mode()const | 1089 | int OFileSelector::mode()const |
1090 | { | 1090 | { |
1091 | return m_mode; | 1091 | return m_mode; |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | 1094 | ||
1095 | /** | 1095 | /** |
1096 | * @return the Selector of the OFileSelector | 1096 | * @return the Selector of the OFileSelector |
1097 | */ | 1097 | */ |
1098 | int OFileSelector::selector()const | 1098 | int OFileSelector::selector()const |
1099 | { | 1099 | { |
1100 | return m_selector; | 1100 | return m_selector; |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | QStringList OFileSelector::currentMimeType()const | 1103 | QStringList OFileSelector::currentMimeType()const |
1104 | { | 1104 | { |
1105 | return m_mimeType[m_cmbMime->currentText()]; | 1105 | return m_mimeType[m_cmbMime->currentText()]; |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | void OFileSelector::slotMimeTypeChanged() | 1108 | void OFileSelector::slotMimeTypeChanged() |
1109 | { | 1109 | { |
1110 | reread(); | 1110 | reread(); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) | 1113 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) |
1114 | { | 1114 | { |
1115 | m_lneEdit->setText( lnk.name() ); | 1115 | m_lneEdit->setText( lnk.name() ); |
1116 | emit fileSelected( lnk ); | 1116 | emit fileSelected( lnk ); |
1117 | emit fileSelected( lnk.name() ); | 1117 | emit fileSelected( lnk.name() ); |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | void OFileSelector::slotFileBridge( const QString& str) | 1120 | void OFileSelector::slotFileBridge( const QString& str) |
1121 | { | 1121 | { |
1122 | DocLnk lnk( str ); | 1122 | DocLnk lnk( str ); |
1123 | emit fileSelected( lnk ); | 1123 | emit fileSelected( lnk ); |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | void OFileSelector::slotViewChange( const QString& view ) | 1126 | void OFileSelector::slotViewChange( const QString& view ) |
1127 | { | 1127 | { |
1128 | OFileViewInterface* interface = m_views[view]; | 1128 | OFileViewInterface* interface = m_views[view]; |
1129 | if (!interface) | 1129 | if (!interface) |
1130 | return; | 1130 | return; |
1131 | 1131 | ||
1132 | interface->activate( view ); | 1132 | interface->activate( view ); |
1133 | if (m_current) | 1133 | if (m_current) |
1134 | m_stack->removeWidget( m_current->widget( m_stack ) ); | 1134 | m_stack->removeWidget( m_current->widget( m_stack ) ); |
1135 | 1135 | ||
1136 | static int id = 1; | 1136 | static int id = 1; |
1137 | 1137 | ||
1138 | m_stack->addWidget( interface->widget(m_stack), id ); | 1138 | m_stack->addWidget( interface->widget(m_stack), id ); |
1139 | m_stack->raiseWidget( id ); | 1139 | m_stack->raiseWidget( id ); |
1140 | 1140 | ||
1141 | interface->reread(); | 1141 | interface->reread(); |
1142 | m_current = interface; | 1142 | m_current = interface; |
1143 | 1143 | ||
1144 | id++; | 1144 | id++; |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | void OFileSelector::setNewVisible( bool b ) | 1147 | void OFileSelector::setNewVisible( bool b ) |
1148 | { | 1148 | { |
1149 | m_shNew = b; | 1149 | m_shNew = b; |
1150 | currentView()->reread(); | 1150 | currentView()->reread(); |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | void OFileSelector::setCloseVisible( bool b ) | 1153 | void OFileSelector::setCloseVisible( bool b ) |
1154 | { | 1154 | { |
1155 | m_shClose = b; | 1155 | m_shClose = b; |
1156 | currentView()->reread(); | 1156 | currentView()->reread(); |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | void OFileSelector::setNameVisible( bool b ) | 1159 | void OFileSelector::setNameVisible( bool b ) |
1160 | { | 1160 | { |
1161 | if ( b ) | 1161 | if ( b ) |
1162 | m_nameBox->show(); | 1162 | m_nameBox->show(); |
1163 | else | 1163 | else |
1164 | m_nameBox->hide(); | 1164 | m_nameBox->hide(); |
1165 | } | 1165 | } |
1166 | 1166 | ||
diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp index 49ddeb6..f93781f 100644 --- a/libopie2/opieui/ofontselector.cpp +++ b/libopie2/opieui/ofontselector.cpp | |||
@@ -1,428 +1,428 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Robert Griebl <sandman@handhelds.org> | 3 | Copyright (C) Robert Griebl <sandman@handhelds.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* OPIE */ | 30 | /* OPIE */ |
31 | #include <opie2/ofontselector.h> | 31 | #include <opie2/ofontselector.h> |
32 | #include <qpe/fontdatabase.h> | 32 | #include <qpe/fontdatabase.h> |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qlistbox.h> | 36 | #include <qlistbox.h> |
37 | #include <qcombobox.h> | 37 | #include <qcombobox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qmultilineedit.h> | 39 | #include <qmultilineedit.h> |
40 | 40 | ||
41 | using namespace Opie; | 41 | using namespace Opie; |
42 | 42 | ||
43 | namespace Opie | 43 | namespace Opie |
44 | { | 44 | { |
45 | 45 | ||
46 | class OFontSelectorPrivate | 46 | class OFontSelectorPrivate |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | QListBox * m_font_family_list; | 49 | QListBox * m_font_family_list; |
50 | QComboBox * m_font_style_list; | 50 | QComboBox * m_font_style_list; |
51 | QComboBox * m_font_size_list; | 51 | QComboBox * m_font_size_list; |
52 | QMultiLineEdit *m_preview; | 52 | QMultiLineEdit *m_preview; |
53 | 53 | ||
54 | bool m_pointbug : 1; | 54 | bool m_pointbug : 1; |
55 | 55 | ||
56 | FontDatabase m_fdb; | 56 | FontDatabase m_fdb; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | }; | 59 | }; |
60 | 60 | ||
61 | namespace | 61 | namespace |
62 | { | 62 | { |
63 | 63 | ||
64 | class FontListItem : public QListBoxText | 64 | class FontListItem : public QListBoxText |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() | 67 | FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() |
68 | { | 68 | { |
69 | m_name = t; | 69 | m_name = t; |
70 | m_styles = styles; | 70 | m_styles = styles; |
71 | m_sizes = sizes; | 71 | m_sizes = sizes; |
72 | 72 | ||
73 | QString str = t; | 73 | QString str = t; |
74 | str [0] = str [0]. upper(); | 74 | str [0] = str [0]. upper(); |
75 | setText ( str ); | 75 | setText ( str ); |
76 | } | 76 | } |
77 | 77 | ||
78 | QString family() const | 78 | QString family() const |
79 | { | 79 | { |
80 | return m_name; | 80 | return m_name; |
81 | } | 81 | } |
82 | 82 | ||
83 | const QStringList &styles() const | 83 | const QStringList &styles() const |
84 | { | 84 | { |
85 | return m_styles; | 85 | return m_styles; |
86 | } | 86 | } |
87 | 87 | ||
88 | const QValueList<int> &sizes() const | 88 | const QValueList<int> &sizes() const |
89 | { | 89 | { |
90 | return m_sizes; | 90 | return m_sizes; |
91 | } | 91 | } |
92 | 92 | ||
93 | private: | 93 | private: |
94 | QStringList m_styles; | 94 | QStringList m_styles; |
95 | QValueList<int> m_sizes; | 95 | QValueList<int> m_sizes; |
96 | QString m_name; | 96 | QString m_name; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | static int findItemCB( QComboBox *box, const QString &str ) | 100 | static int findItemCB( QComboBox *box, const QString &str ) |
101 | { | 101 | { |
102 | for ( int i = 0; i < box->count(); i++ ) | 102 | for ( int i = 0; i < box->count(); i++ ) |
103 | { | 103 | { |
104 | if ( box->text ( i ) == str ) | 104 | if ( box->text ( i ) == str ) |
105 | return i; | 105 | return i; |
106 | } | 106 | } |
107 | return -1; | 107 | return -1; |
108 | } | 108 | } |
109 | 109 | ||
110 | } | 110 | } |
111 | /* static same as anon. namespace */ | 111 | /* static same as anon. namespace */ |
112 | static int qt_version() | 112 | static int qt_version() |
113 | { | 113 | { |
114 | const char *qver = qVersion(); | 114 | const char *qver = qVersion(); |
115 | 115 | ||
116 | return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); | 116 | return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); |
117 | } | 117 | } |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * Constructs the Selector object | 120 | * Constructs the Selector object |
121 | * @param withpreview If a font preview should be given | 121 | * @param withpreview If a font preview should be given |
122 | * @param parent The parent of the Font Selector | 122 | * @param parent The parent of the Font Selector |
123 | * @param name The name of the object | 123 | * @param name The name of the object |
124 | * @param fl WidgetFlags | 124 | * @param fl WidgetFlags |
125 | */ | 125 | */ |
126 | OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) | 126 | OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) |
127 | { | 127 | { |
128 | d = new OFontSelectorPrivate(); | 128 | d = new OFontSelectorPrivate(); |
129 | 129 | ||
130 | QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); | 130 | QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); |
131 | gridLayout->setRowStretch( 4, 10 ); | 131 | gridLayout->setRowStretch( 4, 10 ); |
132 | 132 | ||
133 | d->m_font_family_list = new QListBox( this, "FontListBox" ); | 133 | d->m_font_family_list = new QListBox( this, "FontListBox" ); |
134 | gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); | 134 | gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); |
135 | connect( d->m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); | 135 | connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) ); |
136 | 136 | ||
137 | QLabel *label = new QLabel( tr( "Style" ), this ); | 137 | QLabel *label = new QLabel( tr( "Style" ), this ); |
138 | gridLayout->addWidget( label, 0, 1 ); | 138 | gridLayout->addWidget( label, 0, 1 ); |
139 | 139 | ||
140 | d->m_font_style_list = new QComboBox( this, "StyleListBox" ); | 140 | d->m_font_style_list = new QComboBox( this, "StyleListBox" ); |
141 | connect( d->m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); | 141 | connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) ); |
142 | gridLayout->addWidget( d->m_font_style_list, 1, 1 ); | 142 | gridLayout->addWidget( d->m_font_style_list, 1, 1 ); |
143 | 143 | ||
144 | label = new QLabel( tr( "Size" ), this ); | 144 | label = new QLabel( tr( "Size" ), this ); |
145 | gridLayout->addWidget( label, 2, 1 ); | 145 | gridLayout->addWidget( label, 2, 1 ); |
146 | 146 | ||
147 | d->m_font_size_list = new QComboBox( this, "SizeListBox" ); | 147 | d->m_font_size_list = new QComboBox( this, "SizeListBox" ); |
148 | connect( d->m_font_size_list, SIGNAL( activated( int ) ), | 148 | connect( d->m_font_size_list, SIGNAL( activated(int) ), |
149 | this, SLOT( fontSizeClicked( int ) ) ); | 149 | this, SLOT( fontSizeClicked(int) ) ); |
150 | gridLayout->addWidget( d->m_font_size_list, 3, 1 ); | 150 | gridLayout->addWidget( d->m_font_size_list, 3, 1 ); |
151 | 151 | ||
152 | d->m_pointbug = ( qt_version() <= 233 ); | 152 | d->m_pointbug = ( qt_version() <= 233 ); |
153 | 153 | ||
154 | if ( withpreview ) | 154 | if ( withpreview ) |
155 | { | 155 | { |
156 | d->m_preview = new QMultiLineEdit ( this, "Preview" ); | 156 | d->m_preview = new QMultiLineEdit ( this, "Preview" ); |
157 | d->m_preview->setAlignment ( AlignCenter ); | 157 | d->m_preview->setAlignment ( AlignCenter ); |
158 | d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); | 158 | d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); |
159 | d->m_preview->setMargin ( 3 ); | 159 | d->m_preview->setMargin ( 3 ); |
160 | d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); | 160 | d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); |
161 | gridLayout->addRowSpacing ( 5, 4 ); | 161 | gridLayout->addRowSpacing ( 5, 4 ); |
162 | gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); | 162 | gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); |
163 | gridLayout->setRowStretch ( 6, 5 ); | 163 | gridLayout->setRowStretch ( 6, 5 ); |
164 | } | 164 | } |
165 | else | 165 | else |
166 | d->m_preview = 0; | 166 | d->m_preview = 0; |
167 | 167 | ||
168 | loadFonts ( d->m_font_family_list ); | 168 | loadFonts ( d->m_font_family_list ); |
169 | } | 169 | } |
170 | 170 | ||
171 | OFontSelector::~OFontSelector() | 171 | OFontSelector::~OFontSelector() |
172 | { | 172 | { |
173 | delete d; | 173 | delete d; |
174 | } | 174 | } |
175 | 175 | ||
176 | /** | 176 | /** |
177 | * This methods tries to set the font | 177 | * This methods tries to set the font |
178 | * @param f The wishes font | 178 | * @param f The wishes font |
179 | * @return success or failure | 179 | * @return success or failure |
180 | */ | 180 | */ |
181 | bool OFontSelector::setSelectedFont ( const QFont &f ) | 181 | bool OFontSelector::setSelectedFont ( const QFont &f ) |
182 | { | 182 | { |
183 | return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); | 183 | return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | /** | 187 | /** |
188 | * This is an overloaded method @see setSelectedFont | 188 | * This is an overloaded method @see setSelectedFont |
189 | * @param familyStr The family of the font | 189 | * @param familyStr The family of the font |
190 | * @param styleStr The style of the font | 190 | * @param styleStr The style of the font |
191 | * @param sizeVal The size of font | 191 | * @param sizeVal The size of font |
192 | * @param charset The charset to be used. Will be deprecated by QT3 | 192 | * @param charset The charset to be used. Will be deprecated by QT3 |
193 | */ | 193 | */ |
194 | bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) | 194 | bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) |
195 | { | 195 | { |
196 | QString sizeStr = QString::number ( sizeVal ); | 196 | QString sizeStr = QString::number ( sizeVal ); |
197 | 197 | ||
198 | QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); | 198 | QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); |
199 | if ( !family ) | 199 | if ( !family ) |
200 | family = d->m_font_family_list->findItem ( "Helvetica" ); | 200 | family = d->m_font_family_list->findItem ( "Helvetica" ); |
201 | if ( !family ) | 201 | if ( !family ) |
202 | family = d->m_font_family_list->firstItem(); | 202 | family = d->m_font_family_list->firstItem(); |
203 | d->m_font_family_list->setCurrentItem ( family ); | 203 | d->m_font_family_list->setCurrentItem ( family ); |
204 | fontFamilyClicked ( d->m_font_family_list->index ( family )); | 204 | fontFamilyClicked ( d->m_font_family_list->index ( family )); |
205 | 205 | ||
206 | int style = findItemCB ( d->m_font_style_list, styleStr ); | 206 | int style = findItemCB ( d->m_font_style_list, styleStr ); |
207 | if ( style < 0 ) | 207 | if ( style < 0 ) |
208 | style = findItemCB ( d->m_font_style_list, "Regular" ); | 208 | style = findItemCB ( d->m_font_style_list, "Regular" ); |
209 | if ( style < 0 && d->m_font_style_list->count() > 0 ) | 209 | if ( style < 0 && d->m_font_style_list->count() > 0 ) |
210 | style = 0; | 210 | style = 0; |
211 | d->m_font_style_list->setCurrentItem ( style ); | 211 | d->m_font_style_list->setCurrentItem ( style ); |
212 | fontStyleClicked ( style ); | 212 | fontStyleClicked ( style ); |
213 | 213 | ||
214 | int size = findItemCB ( d->m_font_size_list, sizeStr ); | 214 | int size = findItemCB ( d->m_font_size_list, sizeStr ); |
215 | if ( size < 0 ) | 215 | if ( size < 0 ) |
216 | size = findItemCB ( d->m_font_size_list, "10" ); | 216 | size = findItemCB ( d->m_font_size_list, "10" ); |
217 | if ( size < 0 && d->m_font_size_list->count() > 0 ) | 217 | if ( size < 0 && d->m_font_size_list->count() > 0 ) |
218 | size = 0; | 218 | size = 0; |
219 | d->m_font_size_list->setCurrentItem ( size ); | 219 | d->m_font_size_list->setCurrentItem ( size ); |
220 | fontSizeClicked ( size ); | 220 | fontSizeClicked ( size ); |
221 | 221 | ||
222 | return (( family ) && ( style >= 0 ) && ( size >= 0 )); | 222 | return (( family ) && ( style >= 0 ) && ( size >= 0 )); |
223 | } | 223 | } |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * This method returns the name, style and size of the currently selected | 226 | * This method returns the name, style and size of the currently selected |
227 | * font or false if no font is selected | 227 | * font or false if no font is selected |
228 | * @param family The font family will be written there | 228 | * @param family The font family will be written there |
229 | * @param style The style will be written there | 229 | * @param style The style will be written there |
230 | * @param size The size will be written there | 230 | * @param size The size will be written there |
231 | * @return success or failure | 231 | * @return success or failure |
232 | */ | 232 | */ |
233 | bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) | 233 | bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) |
234 | { | 234 | { |
235 | QString dummy; | 235 | QString dummy; |
236 | return selectedFont ( family, style, size, dummy ); | 236 | return selectedFont ( family, style, size, dummy ); |
237 | } | 237 | } |
238 | 238 | ||
239 | 239 | ||
240 | /** | 240 | /** |
241 | * This method does return the font family or QString::null if there is | 241 | * This method does return the font family or QString::null if there is |
242 | * no font item selected | 242 | * no font item selected |
243 | * @return the font family | 243 | * @return the font family |
244 | */ | 244 | */ |
245 | QString OFontSelector::fontFamily() const | 245 | QString OFontSelector::fontFamily() const |
246 | { | 246 | { |
247 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); | 247 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); |
248 | 248 | ||
249 | return fli ? fli->family() : QString::null; | 249 | return fli ? fli->family() : QString::null; |
250 | } | 250 | } |
251 | 251 | ||
252 | /** | 252 | /** |
253 | * This method will return the style of the font or QString::null | 253 | * This method will return the style of the font or QString::null |
254 | * @return the style of the font | 254 | * @return the style of the font |
255 | */ | 255 | */ |
256 | QString OFontSelector::fontStyle() const | 256 | QString OFontSelector::fontStyle() const |
257 | { | 257 | { |
258 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); | 258 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); |
259 | int fst = d->m_font_style_list->currentItem(); | 259 | int fst = d->m_font_style_list->currentItem(); |
260 | 260 | ||
261 | return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null; | 261 | return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null; |
262 | } | 262 | } |
263 | 263 | ||
264 | /** | 264 | /** |
265 | * This method will return the font size or 10 if no font size is available | 265 | * This method will return the font size or 10 if no font size is available |
266 | */ | 266 | */ |
267 | int OFontSelector::fontSize() const | 267 | int OFontSelector::fontSize() const |
268 | { | 268 | { |
269 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); | 269 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); |
270 | int fsi = d->m_font_size_list->currentItem(); | 270 | int fsi = d->m_font_size_list->currentItem(); |
271 | 271 | ||
272 | return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10; | 272 | return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10; |
273 | } | 273 | } |
274 | 274 | ||
275 | /** | 275 | /** |
276 | * returns the charset of the font or QString::null | 276 | * returns the charset of the font or QString::null |
277 | */ | 277 | */ |
278 | QString OFontSelector::fontCharSet() const | 278 | QString OFontSelector::fontCharSet() const |
279 | { | 279 | { |
280 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); | 280 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); |
281 | 281 | ||
282 | return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null; | 282 | return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null; |
283 | } | 283 | } |
284 | 284 | ||
285 | /** | 285 | /** |
286 | * Overloaded member function see above | 286 | * Overloaded member function see above |
287 | * @see selectedFont | 287 | * @see selectedFont |
288 | */ | 288 | */ |
289 | bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) | 289 | bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) |
290 | { | 290 | { |
291 | int ffa = d->m_font_family_list->currentItem(); | 291 | int ffa = d->m_font_family_list->currentItem(); |
292 | int fst = d->m_font_style_list->currentItem(); | 292 | int fst = d->m_font_style_list->currentItem(); |
293 | int fsi = d->m_font_size_list->currentItem(); | 293 | int fsi = d->m_font_size_list->currentItem(); |
294 | 294 | ||
295 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa ); | 295 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa ); |
296 | 296 | ||
297 | if ( fli ) | 297 | if ( fli ) |
298 | { | 298 | { |
299 | family = fli->family(); | 299 | family = fli->family(); |
300 | style = fst >= 0 ? fli->styles() [fst] : QString::null; | 300 | style = fst >= 0 ? fli->styles() [fst] : QString::null; |
301 | size = fsi >= 0 ? fli->sizes() [fsi] : 10; | 301 | size = fsi >= 0 ? fli->sizes() [fsi] : 10; |
302 | charset = d->m_fdb. charSets ( fli->family()) [0]; | 302 | charset = d->m_fdb. charSets ( fli->family()) [0]; |
303 | 303 | ||
304 | return true; | 304 | return true; |
305 | } | 305 | } |
306 | else | 306 | else |
307 | return false; | 307 | return false; |
308 | } | 308 | } |
309 | 309 | ||
310 | void OFontSelector::loadFonts ( QListBox *list ) | 310 | void OFontSelector::loadFonts ( QListBox *list ) |
311 | { | 311 | { |
312 | QStringList f = d->m_fdb. families(); | 312 | QStringList f = d->m_fdb. families(); |
313 | 313 | ||
314 | for ( QStringList::ConstIterator it = f. begin(); it != f. end(); ++it ) | 314 | for ( QStringList::ConstIterator it = f. begin(); it != f. end(); ++it ) |
315 | { | 315 | { |
316 | QValueList <int> ps = d->m_fdb. pointSizes ( *it ); | 316 | QValueList <int> ps = d->m_fdb. pointSizes ( *it ); |
317 | 317 | ||
318 | if ( d->m_pointbug ) | 318 | if ( d->m_pointbug ) |
319 | { | 319 | { |
320 | for ( QValueList <int>::Iterator it = ps. begin(); it != ps. end(); it++ ) | 320 | for ( QValueList <int>::Iterator it = ps. begin(); it != ps. end(); it++ ) |
321 | *it /= 10; | 321 | *it /= 10; |
322 | } | 322 | } |
323 | 323 | ||
324 | list->insertItem ( new FontListItem ( *it, d->m_fdb. styles ( *it ), ps )); | 324 | list->insertItem ( new FontListItem ( *it, d->m_fdb. styles ( *it ), ps )); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | void OFontSelector::fontFamilyClicked ( int index ) | 328 | void OFontSelector::fontFamilyClicked ( int index ) |
329 | { | 329 | { |
330 | QString oldstyle = d->m_font_style_list->currentText(); | 330 | QString oldstyle = d->m_font_style_list->currentText(); |
331 | QString oldsize = d->m_font_size_list->currentText(); | 331 | QString oldsize = d->m_font_size_list->currentText(); |
332 | 332 | ||
333 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( index ); | 333 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( index ); |
334 | 334 | ||
335 | d->m_font_style_list->clear(); | 335 | d->m_font_style_list->clear(); |
336 | d->m_font_style_list->insertStringList ( fli->styles()); | 336 | d->m_font_style_list->insertStringList ( fli->styles()); |
337 | d->m_font_style_list->setEnabled ( !fli->styles(). isEmpty()); | 337 | d->m_font_style_list->setEnabled ( !fli->styles(). isEmpty()); |
338 | 338 | ||
339 | int i; | 339 | int i; |
340 | 340 | ||
341 | i = findItemCB ( d->m_font_style_list, oldstyle ); | 341 | i = findItemCB ( d->m_font_style_list, oldstyle ); |
342 | if ( i < 0 ) | 342 | if ( i < 0 ) |
343 | i = findItemCB ( d->m_font_style_list, "Regular" ); | 343 | i = findItemCB ( d->m_font_style_list, "Regular" ); |
344 | if (( i < 0 ) && ( d->m_font_style_list->count() > 0 )) | 344 | if (( i < 0 ) && ( d->m_font_style_list->count() > 0 )) |
345 | i = 0; | 345 | i = 0; |
346 | 346 | ||
347 | if ( i >= 0 ) | 347 | if ( i >= 0 ) |
348 | { | 348 | { |
349 | d->m_font_style_list->setCurrentItem ( i ); | 349 | d->m_font_style_list->setCurrentItem ( i ); |
350 | fontStyleClicked ( i ); | 350 | fontStyleClicked ( i ); |
351 | } | 351 | } |
352 | 352 | ||
353 | d->m_font_size_list->clear(); | 353 | d->m_font_size_list->clear(); |
354 | QValueList<int> sl = fli->sizes(); | 354 | QValueList<int> sl = fli->sizes(); |
355 | 355 | ||
356 | for ( QValueList<int>::Iterator it = sl. begin(); it != sl. end(); ++it ) | 356 | for ( QValueList<int>::Iterator it = sl. begin(); it != sl. end(); ++it ) |
357 | d->m_font_size_list->insertItem ( QString::number ( *it )); | 357 | d->m_font_size_list->insertItem ( QString::number ( *it )); |
358 | 358 | ||
359 | i = findItemCB ( d->m_font_size_list, oldsize ); | 359 | i = findItemCB ( d->m_font_size_list, oldsize ); |
360 | if ( i < 0 ) | 360 | if ( i < 0 ) |
361 | i = findItemCB ( d->m_font_size_list, "10" ); | 361 | i = findItemCB ( d->m_font_size_list, "10" ); |
362 | if (( i < 0 ) && ( d->m_font_size_list->count() > 0 )) | 362 | if (( i < 0 ) && ( d->m_font_size_list->count() > 0 )) |
363 | i = 0; | 363 | i = 0; |
364 | 364 | ||
365 | if ( i >= 0 ) | 365 | if ( i >= 0 ) |
366 | { | 366 | { |
367 | d->m_font_size_list->setCurrentItem ( i ); | 367 | d->m_font_size_list->setCurrentItem ( i ); |
368 | fontSizeClicked ( i ); | 368 | fontSizeClicked ( i ); |
369 | } | 369 | } |
370 | changeFont(); | 370 | changeFont(); |
371 | } | 371 | } |
372 | 372 | ||
373 | void OFontSelector::fontStyleClicked ( int /*index*/ ) | 373 | void OFontSelector::fontStyleClicked ( int /*index*/ ) |
374 | { | 374 | { |
375 | changeFont(); | 375 | changeFont(); |
376 | } | 376 | } |
377 | 377 | ||
378 | void OFontSelector::fontSizeClicked ( int /*index*/ ) | 378 | void OFontSelector::fontSizeClicked ( int /*index*/ ) |
379 | { | 379 | { |
380 | changeFont(); | 380 | changeFont(); |
381 | } | 381 | } |
382 | 382 | ||
383 | void OFontSelector::changeFont() | 383 | void OFontSelector::changeFont() |
384 | { | 384 | { |
385 | QFont f = selectedFont(); | 385 | QFont f = selectedFont(); |
386 | 386 | ||
387 | if ( d->m_preview ) | 387 | if ( d->m_preview ) |
388 | d->m_preview->setFont ( f ); | 388 | d->m_preview->setFont ( f ); |
389 | 389 | ||
390 | emit fontSelected ( f ); | 390 | emit fontSelected ( f ); |
391 | } | 391 | } |
392 | 392 | ||
393 | /** | 393 | /** |
394 | * Return the selected font | 394 | * Return the selected font |
395 | */ | 395 | */ |
396 | QFont OFontSelector::selectedFont() | 396 | QFont OFontSelector::selectedFont() |
397 | { | 397 | { |
398 | int ffa = d->m_font_family_list->currentItem(); | 398 | int ffa = d->m_font_family_list->currentItem(); |
399 | int fst = d->m_font_style_list->currentItem(); | 399 | int fst = d->m_font_style_list->currentItem(); |
400 | int fsi = d->m_font_size_list->currentItem(); | 400 | int fsi = d->m_font_size_list->currentItem(); |
401 | 401 | ||
402 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa ); | 402 | FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa ); |
403 | 403 | ||
404 | if ( fli ) | 404 | if ( fli ) |
405 | { | 405 | { |
406 | return d->m_fdb. font ( fli->family(), \ | 406 | return d->m_fdb. font ( fli->family(), \ |
407 | fst >= 0 ? fli->styles() [fst] : QString::null, \ | 407 | fst >= 0 ? fli->styles() [fst] : QString::null, \ |
408 | fsi >= 0 ? fli->sizes() [fsi] : 10, \ | 408 | fsi >= 0 ? fli->sizes() [fsi] : 10, \ |
409 | d->m_fdb. charSets ( fli->family()) [0] ); | 409 | d->m_fdb. charSets ( fli->family()) [0] ); |
410 | } | 410 | } |
411 | else | 411 | else |
412 | return QFont(); | 412 | return QFont(); |
413 | } | 413 | } |
414 | 414 | ||
415 | void OFontSelector::resizeEvent ( QResizeEvent *re ) | 415 | void OFontSelector::resizeEvent ( QResizeEvent *re ) |
416 | { | 416 | { |
417 | if ( d->m_preview ) | 417 | if ( d->m_preview ) |
418 | { | 418 | { |
419 | d->m_preview->setMinimumHeight ( 1 ); | 419 | d->m_preview->setMinimumHeight ( 1 ); |
420 | d->m_preview->setMaximumHeight ( 32767 ); | 420 | d->m_preview->setMaximumHeight ( 32767 ); |
421 | } | 421 | } |
422 | 422 | ||
423 | QWidget::resizeEvent ( re ); | 423 | QWidget::resizeEvent ( re ); |
424 | 424 | ||
425 | if ( d->m_preview ) | 425 | if ( d->m_preview ) |
426 | d->m_preview->setFixedHeight ( d->m_preview->height()); | 426 | d->m_preview->setFixedHeight ( d->m_preview->height()); |
427 | 427 | ||
428 | } | 428 | } |
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp index ec6af9d..f47c90b 100644 --- a/libopie2/opieui/otabwidget.cpp +++ b/libopie2/opieui/otabwidget.cpp | |||
@@ -1,423 +1,423 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | 4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <opie2/otabwidget.h> | 32 | #include <opie2/otabwidget.h> |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | #include <opie2/otabbar.h> | 38 | #include <opie2/otabbar.h> |
39 | 39 | ||
40 | /* QT */ | 40 | /* QT */ |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qwidgetstack.h> | 42 | #include <qwidgetstack.h> |
43 | 43 | ||
44 | using namespace Opie; | 44 | using namespace Opie; |
45 | 45 | ||
46 | OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) | 46 | OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) |
47 | : QWidget( parent, name ) | 47 | : QWidget( parent, name ) |
48 | { | 48 | { |
49 | if ( s == Global ) | 49 | if ( s == Global ) |
50 | { | 50 | { |
51 | Config config( "qpe" ); | 51 | Config config( "qpe" ); |
52 | config.setGroup( "Appearance" ); | 52 | config.setGroup( "Appearance" ); |
53 | s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); | 53 | s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); |
54 | if ( s <= Global || s > IconList) | 54 | if ( s <= Global || s > IconList) |
55 | { | 55 | { |
56 | s = IconTab; | 56 | s = IconTab; |
57 | } | 57 | } |
58 | QString pos = config.readEntry( "TabPosition", "Top"); | 58 | QString pos = config.readEntry( "TabPosition", "Top"); |
59 | if ( pos == "Bottom" ) | 59 | if ( pos == "Bottom" ) |
60 | { | 60 | { |
61 | p = Bottom; | 61 | p = Bottom; |
62 | } | 62 | } |
63 | else | 63 | else |
64 | { | 64 | { |
65 | p = Top; | 65 | p = Top; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | widgetStack = new QWidgetStack( this, "widgetstack" ); | 69 | widgetStack = new QWidgetStack( this, "widgetstack" ); |
70 | widgetStack->setFrameStyle( QFrame::NoFrame ); | 70 | widgetStack->setFrameStyle( QFrame::NoFrame ); |
71 | widgetStack->setLineWidth( style().defaultFrameWidth() ); | 71 | widgetStack->setLineWidth( style().defaultFrameWidth() ); |
72 | 72 | ||
73 | tabBarStack = new QWidgetStack( this, "tabbarstack" ); | 73 | tabBarStack = new QWidgetStack( this, "tabbarstack" ); |
74 | 74 | ||
75 | tabBar = new OTabBar( tabBarStack, "tabbar" ); | 75 | tabBar = new OTabBar( tabBarStack, "tabbar" ); |
76 | tabBarStack->addWidget( tabBar, 0 ); | 76 | tabBarStack->addWidget( tabBar, 0 ); |
77 | connect( tabBar, SIGNAL( selected( int ) ), this, SLOT( slotTabBarSelected( int ) ) ); | 77 | connect( tabBar, SIGNAL( selected(int) ), this, SLOT( slotTabBarSelected(int) ) ); |
78 | 78 | ||
79 | tabList = new QComboBox( false, tabBarStack, "tablist" ); | 79 | tabList = new QComboBox( false, tabBarStack, "tablist" ); |
80 | tabBarStack->addWidget( tabList, 1 ); | 80 | tabBarStack->addWidget( tabList, 1 ); |
81 | connect( tabList, SIGNAL( activated( int ) ), this, SLOT( slotTabListSelected( int ) ) ); | 81 | connect( tabList, SIGNAL( activated(int) ), this, SLOT( slotTabListSelected(int) ) ); |
82 | 82 | ||
83 | tabBarPosition = p; | 83 | tabBarPosition = p; |
84 | setTabStyle( s ); | 84 | setTabStyle( s ); |
85 | setTabPosition( p ); | 85 | setTabPosition( p ); |
86 | 86 | ||
87 | currTab= 0x0; | 87 | currTab= 0x0; |
88 | } | 88 | } |
89 | 89 | ||
90 | OTabWidget::~OTabWidget() | 90 | OTabWidget::~OTabWidget() |
91 | {} | 91 | {} |
92 | 92 | ||
93 | void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) | 93 | void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) |
94 | { | 94 | { |
95 | QPixmap iconset = loadSmooth( icon ); | 95 | QPixmap iconset = loadSmooth( icon ); |
96 | 96 | ||
97 | QTab *tab = new QTab(); | 97 | QTab *tab = new QTab(); |
98 | if ( tabBarStyle == IconTab ) | 98 | if ( tabBarStyle == IconTab ) |
99 | { | 99 | { |
100 | tab->label = QString::null; | 100 | tab->label = QString::null; |
101 | } | 101 | } |
102 | else | 102 | else |
103 | { | 103 | { |
104 | tab->label = label; | 104 | tab->label = label; |
105 | } | 105 | } |
106 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) | 106 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) |
107 | { | 107 | { |
108 | tab->iconset = new QIconSet( iconset ); | 108 | tab->iconset = new QIconSet( iconset ); |
109 | } | 109 | } |
110 | int tabid = tabBar->addTab( tab ); | 110 | int tabid = tabBar->addTab( tab ); |
111 | 111 | ||
112 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) | 112 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) |
113 | { | 113 | { |
114 | tabList->insertItem( iconset, label, -1 ); | 114 | tabList->insertItem( iconset, label, -1 ); |
115 | } | 115 | } |
116 | else | 116 | else |
117 | { | 117 | { |
118 | tabList->insertItem( label ); | 118 | tabList->insertItem( label ); |
119 | } | 119 | } |
120 | 120 | ||
121 | widgetStack->addWidget( child, tabid ); | 121 | widgetStack->addWidget( child, tabid ); |
122 | widgetStack->raiseWidget( child ); | 122 | widgetStack->raiseWidget( child ); |
123 | widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); | 123 | widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); |
124 | 124 | ||
125 | OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); | 125 | OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); |
126 | tabs.append( tabinfo ); | 126 | tabs.append( tabinfo ); |
127 | selectTab( tabinfo ); | 127 | selectTab( tabinfo ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void OTabWidget::removePage( QWidget *childwidget ) | 130 | void OTabWidget::removePage( QWidget *childwidget ) |
131 | { | 131 | { |
132 | if ( childwidget ) | 132 | if ( childwidget ) |
133 | { | 133 | { |
134 | OTabInfo *tab = tabs.first(); | 134 | OTabInfo *tab = tabs.first(); |
135 | while ( tab && tab->control() != childwidget ) | 135 | while ( tab && tab->control() != childwidget ) |
136 | { | 136 | { |
137 | tab = tabs.next(); | 137 | tab = tabs.next(); |
138 | } | 138 | } |
139 | if ( tab && tab->control() == childwidget ) | 139 | if ( tab && tab->control() == childwidget ) |
140 | { | 140 | { |
141 | tabBar->setTabEnabled( tab->id(), FALSE ); | 141 | tabBar->setTabEnabled( tab->id(), FALSE ); |
142 | tabBar->removeTab( tabBar->tab( tab->id() ) ); | 142 | tabBar->removeTab( tabBar->tab( tab->id() ) ); |
143 | int i = 0; | 143 | int i = 0; |
144 | while ( i < tabList->count() && tabList->text( i ) != tab->label() ) | 144 | while ( i < tabList->count() && tabList->text( i ) != tab->label() ) |
145 | { | 145 | { |
146 | i++; | 146 | i++; |
147 | } | 147 | } |
148 | if ( tabList->text( i ) == tab->label() ) | 148 | if ( tabList->text( i ) == tab->label() ) |
149 | { | 149 | { |
150 | tabList->removeItem( i ); | 150 | tabList->removeItem( i ); |
151 | } | 151 | } |
152 | widgetStack->removeWidget( childwidget ); | 152 | widgetStack->removeWidget( childwidget ); |
153 | tabs.remove( tab ); | 153 | tabs.remove( tab ); |
154 | delete tab; | 154 | delete tab; |
155 | currTab = tabs.current(); | 155 | currTab = tabs.current(); |
156 | if ( !currTab ) | 156 | if ( !currTab ) |
157 | { | 157 | { |
158 | widgetStack->setFrameStyle( QFrame::NoFrame ); | 158 | widgetStack->setFrameStyle( QFrame::NoFrame ); |
159 | } | 159 | } |
160 | 160 | ||
161 | setUpLayout(); | 161 | setUpLayout(); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) | 166 | void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) |
167 | { | 167 | { |
168 | OTabInfo *currtab = tabs.first(); | 168 | OTabInfo *currtab = tabs.first(); |
169 | while ( currtab && currtab->control() != widget ) | 169 | while ( currtab && currtab->control() != widget ) |
170 | { | 170 | { |
171 | currtab = tabs.next(); | 171 | currtab = tabs.next(); |
172 | } | 172 | } |
173 | if ( currtab && currtab->control() == widget ) | 173 | if ( currtab && currtab->control() == widget ) |
174 | { | 174 | { |
175 | QTab *tab = tabBar->tab( currtab->id() ); | 175 | QTab *tab = tabBar->tab( currtab->id() ); |
176 | QPixmap icon( loadSmooth( iconset ) ); | 176 | QPixmap icon( loadSmooth( iconset ) ); |
177 | tab->setText( label ); | 177 | tab->setText( label ); |
178 | if ( tabBarStyle == IconTab ) | 178 | if ( tabBarStyle == IconTab ) |
179 | tab->setIconSet( icon ); | 179 | tab->setIconSet( icon ); |
180 | int i = 0; | 180 | int i = 0; |
181 | while ( i < tabList->count() && tabList->text( i ) != currtab->label() ) | 181 | while ( i < tabList->count() && tabList->text( i ) != currtab->label() ) |
182 | { | 182 | { |
183 | i++; | 183 | i++; |
184 | } | 184 | } |
185 | if ( i < tabList->count() && tabList->text( i ) == currtab->label() ) | 185 | if ( i < tabList->count() && tabList->text( i ) == currtab->label() ) |
186 | { | 186 | { |
187 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) | 187 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) |
188 | { | 188 | { |
189 | tabList->changeItem( icon, label, i ); | 189 | tabList->changeItem( icon, label, i ); |
190 | } | 190 | } |
191 | else | 191 | else |
192 | { | 192 | { |
193 | tabList->changeItem( label, i ); | 193 | tabList->changeItem( label, i ); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | currtab->setLabel( label ); | 196 | currtab->setLabel( label ); |
197 | currtab->setIcon( iconset ); | 197 | currtab->setIcon( iconset ); |
198 | } | 198 | } |
199 | setUpLayout(); | 199 | setUpLayout(); |
200 | } | 200 | } |
201 | 201 | ||
202 | void OTabWidget::setCurrentTab( QWidget *childwidget ) | 202 | void OTabWidget::setCurrentTab( QWidget *childwidget ) |
203 | { | 203 | { |
204 | OTabInfo *currtab = tabs.first(); | 204 | OTabInfo *currtab = tabs.first(); |
205 | while ( currtab && currtab->control() != childwidget ) | 205 | while ( currtab && currtab->control() != childwidget ) |
206 | { | 206 | { |
207 | currtab = tabs.next(); | 207 | currtab = tabs.next(); |
208 | } | 208 | } |
209 | if ( currtab && currtab->control() == childwidget ) | 209 | if ( currtab && currtab->control() == childwidget ) |
210 | { | 210 | { |
211 | selectTab( currtab ); | 211 | selectTab( currtab ); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | void OTabWidget::setCurrentTab( const QString &tabname ) | 215 | void OTabWidget::setCurrentTab( const QString &tabname ) |
216 | { | 216 | { |
217 | OTabInfo *newtab = tabs.first(); | 217 | OTabInfo *newtab = tabs.first(); |
218 | while ( newtab && newtab->label() != tabname ) | 218 | while ( newtab && newtab->label() != tabname ) |
219 | { | 219 | { |
220 | newtab = tabs.next(); | 220 | newtab = tabs.next(); |
221 | } | 221 | } |
222 | if ( newtab && newtab->label() == tabname ) | 222 | if ( newtab && newtab->label() == tabname ) |
223 | { | 223 | { |
224 | selectTab( newtab ); | 224 | selectTab( newtab ); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | void OTabWidget::setCurrentTab(int tabindex) | 228 | void OTabWidget::setCurrentTab(int tabindex) |
229 | { | 229 | { |
230 | OTabInfo *newtab = tabs.first(); | 230 | OTabInfo *newtab = tabs.first(); |
231 | while ( newtab && newtab->id() != tabindex ) | 231 | while ( newtab && newtab->id() != tabindex ) |
232 | { | 232 | { |
233 | newtab = tabs.next(); | 233 | newtab = tabs.next(); |
234 | } | 234 | } |
235 | if ( newtab && newtab->id() == tabindex ) | 235 | if ( newtab && newtab->id() == tabindex ) |
236 | { | 236 | { |
237 | selectTab( newtab ); | 237 | selectTab( newtab ); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | OTabWidget::TabStyle OTabWidget::tabStyle() const | 242 | OTabWidget::TabStyle OTabWidget::tabStyle() const |
243 | { | 243 | { |
244 | return tabBarStyle; | 244 | return tabBarStyle; |
245 | } | 245 | } |
246 | 246 | ||
247 | void OTabWidget::setTabStyle( TabStyle s ) | 247 | void OTabWidget::setTabStyle( TabStyle s ) |
248 | { | 248 | { |
249 | tabBarStyle = s; | 249 | tabBarStyle = s; |
250 | if ( tabBarStyle == TextTab || tabBarStyle == IconTab ) | 250 | if ( tabBarStyle == TextTab || tabBarStyle == IconTab ) |
251 | { | 251 | { |
252 | QTab *currtab; | 252 | QTab *currtab; |
253 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) | 253 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) |
254 | { | 254 | { |
255 | currtab = tabBar->tab( tabinfo->id() ); | 255 | currtab = tabBar->tab( tabinfo->id() ); |
256 | if ( tabBarStyle == IconTab ) | 256 | if ( tabBarStyle == IconTab ) |
257 | { | 257 | { |
258 | currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) ); | 258 | currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) ); |
259 | if ( tabinfo == currTab ) | 259 | if ( tabinfo == currTab ) |
260 | currtab->setText( tabinfo->label() ); | 260 | currtab->setText( tabinfo->label() ); |
261 | else | 261 | else |
262 | currtab->setText( QString::null ); | 262 | currtab->setText( QString::null ); |
263 | } | 263 | } |
264 | else | 264 | else |
265 | { | 265 | { |
266 | currtab->iconset = 0x0; | 266 | currtab->iconset = 0x0; |
267 | currtab->setText( tabinfo->label() ); | 267 | currtab->setText( tabinfo->label() ); |
268 | } | 268 | } |
269 | } | 269 | } |
270 | tabBarStack->raiseWidget( tabBar ); | 270 | tabBarStack->raiseWidget( tabBar ); |
271 | } | 271 | } |
272 | else if ( tabBarStyle == TextList || tabBarStyle == IconList ) | 272 | else if ( tabBarStyle == TextList || tabBarStyle == IconList ) |
273 | { | 273 | { |
274 | tabList->clear(); | 274 | tabList->clear(); |
275 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) | 275 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) |
276 | { | 276 | { |
277 | if ( tabBarStyle == IconList ) | 277 | if ( tabBarStyle == IconList ) |
278 | { | 278 | { |
279 | tabList->insertItem( loadSmooth( tabinfo->icon() ), tabinfo->label() ); | 279 | tabList->insertItem( loadSmooth( tabinfo->icon() ), tabinfo->label() ); |
280 | } | 280 | } |
281 | else | 281 | else |
282 | { | 282 | { |
283 | tabList->insertItem( tabinfo->label() ); | 283 | tabList->insertItem( tabinfo->label() ); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | tabBarStack->raiseWidget( tabList ); | 286 | tabBarStack->raiseWidget( tabList ); |
287 | } | 287 | } |
288 | setUpLayout(); | 288 | setUpLayout(); |
289 | } | 289 | } |
290 | 290 | ||
291 | OTabWidget::TabPosition OTabWidget::tabPosition() const | 291 | OTabWidget::TabPosition OTabWidget::tabPosition() const |
292 | { | 292 | { |
293 | return tabBarPosition; | 293 | return tabBarPosition; |
294 | } | 294 | } |
295 | 295 | ||
296 | void OTabWidget::setTabPosition( TabPosition p ) | 296 | void OTabWidget::setTabPosition( TabPosition p ) |
297 | { | 297 | { |
298 | tabBarPosition = p; | 298 | tabBarPosition = p; |
299 | if ( tabBarPosition == Top ) | 299 | if ( tabBarPosition == Top ) |
300 | { | 300 | { |
301 | tabBar->setShape( QTabBar::RoundedAbove ); | 301 | tabBar->setShape( QTabBar::RoundedAbove ); |
302 | } | 302 | } |
303 | else | 303 | else |
304 | { | 304 | { |
305 | tabBar->setShape( QTabBar::RoundedBelow ); | 305 | tabBar->setShape( QTabBar::RoundedBelow ); |
306 | } | 306 | } |
307 | setUpLayout(); | 307 | setUpLayout(); |
308 | } | 308 | } |
309 | 309 | ||
310 | void OTabWidget::slotTabBarSelected( int id ) | 310 | void OTabWidget::slotTabBarSelected( int id ) |
311 | { | 311 | { |
312 | OTabInfo *newtab = tabs.first(); | 312 | OTabInfo *newtab = tabs.first(); |
313 | while ( newtab && newtab->id() != id ) | 313 | while ( newtab && newtab->id() != id ) |
314 | { | 314 | { |
315 | newtab = tabs.next(); | 315 | newtab = tabs.next(); |
316 | } | 316 | } |
317 | if ( newtab && newtab->id() == id ) | 317 | if ( newtab && newtab->id() == id ) |
318 | { | 318 | { |
319 | selectTab( newtab ); | 319 | selectTab( newtab ); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
323 | void OTabWidget::slotTabListSelected( int index ) | 323 | void OTabWidget::slotTabListSelected( int index ) |
324 | { | 324 | { |
325 | OTabInfo *newtab = tabs.at( index ); | 325 | OTabInfo *newtab = tabs.at( index ); |
326 | if ( newtab ) | 326 | if ( newtab ) |
327 | { | 327 | { |
328 | selectTab( newtab ); | 328 | selectTab( newtab ); |
329 | } | 329 | } |
330 | } | 330 | } |
331 | 331 | ||
332 | QPixmap OTabWidget::loadSmooth( const QString &name ) | 332 | QPixmap OTabWidget::loadSmooth( const QString &name ) |
333 | { | 333 | { |
334 | QPixmap p; | 334 | QPixmap p; |
335 | p.convertFromImage( Resource::loadImage( name ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 335 | p.convertFromImage( Resource::loadImage( name ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
336 | return p; | 336 | return p; |
337 | } | 337 | } |
338 | 338 | ||
339 | void OTabWidget::selectTab( OTabInfo *tab ) | 339 | void OTabWidget::selectTab( OTabInfo *tab ) |
340 | { | 340 | { |
341 | if ( tabBarStyle == IconTab ) | 341 | if ( tabBarStyle == IconTab ) |
342 | { | 342 | { |
343 | if ( currTab ) | 343 | if ( currTab ) |
344 | { | 344 | { |
345 | tabBar->tab( currTab->id() )->setText( QString::null ); | 345 | tabBar->tab( currTab->id() )->setText( QString::null ); |
346 | setUpLayout(); | 346 | setUpLayout(); |
347 | } | 347 | } |
348 | tabBar->tab( tab->id() )->setText( tab->label() ); | 348 | tabBar->tab( tab->id() )->setText( tab->label() ); |
349 | tabBar->setCurrentTab( tab->id() ); | 349 | tabBar->setCurrentTab( tab->id() ); |
350 | setUpLayout(); | 350 | setUpLayout(); |
351 | tabBar->update(); | 351 | tabBar->update(); |
352 | } | 352 | } |
353 | else | 353 | else |
354 | { | 354 | { |
355 | tabBar->setCurrentTab( tab->id() ); | 355 | tabBar->setCurrentTab( tab->id() ); |
356 | } | 356 | } |
357 | 357 | ||
358 | widgetStack->raiseWidget( tab->control() ); | 358 | widgetStack->raiseWidget( tab->control() ); |
359 | 359 | ||
360 | emit currentChanged( tab->control() ); | 360 | emit currentChanged( tab->control() ); |
361 | 361 | ||
362 | currTab = tab; | 362 | currTab = tab; |
363 | } | 363 | } |
364 | 364 | ||
365 | void OTabWidget::setUpLayout() | 365 | void OTabWidget::setUpLayout() |
366 | { | 366 | { |
367 | tabBar->layoutTabs(); | 367 | tabBar->layoutTabs(); |
368 | QSize t( tabBarStack->sizeHint() ); | 368 | QSize t( tabBarStack->sizeHint() ); |
369 | if ( tabBarStyle == IconTab ) | 369 | if ( tabBarStyle == IconTab ) |
370 | { | 370 | { |
371 | if ( t.width() > width() ) | 371 | if ( t.width() > width() ) |
372 | t.setWidth( width() ); | 372 | t.setWidth( width() ); |
373 | } | 373 | } |
374 | else | 374 | else |
375 | { | 375 | { |
376 | t.setWidth( width() ); | 376 | t.setWidth( width() ); |
377 | } | 377 | } |
378 | int lw = widgetStack->lineWidth(); | 378 | int lw = widgetStack->lineWidth(); |
379 | if ( tabBarPosition == Bottom ) | 379 | if ( tabBarPosition == Bottom ) |
380 | { | 380 | { |
381 | tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); | 381 | tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); |
382 | widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); | 382 | widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); |
383 | } | 383 | } |
384 | else | 384 | else |
385 | { | 385 | { |
386 | tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); | 386 | tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); |
387 | widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); | 387 | widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); |
388 | } | 388 | } |
389 | 389 | ||
390 | if ( autoMask() ) | 390 | if ( autoMask() ) |
391 | updateMask(); | 391 | updateMask(); |
392 | } | 392 | } |
393 | 393 | ||
394 | QSize OTabWidget::sizeHint() const | 394 | QSize OTabWidget::sizeHint() const |
395 | { | 395 | { |
396 | QSize s( widgetStack->sizeHint() ); | 396 | QSize s( widgetStack->sizeHint() ); |
397 | QSize t( tabBarStack->sizeHint() ); | 397 | QSize t( tabBarStack->sizeHint() ); |
398 | return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() ); | 398 | return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() ); |
399 | } | 399 | } |
400 | 400 | ||
401 | void OTabWidget::resizeEvent( QResizeEvent * ) | 401 | void OTabWidget::resizeEvent( QResizeEvent * ) |
402 | { | 402 | { |
403 | setUpLayout(); | 403 | setUpLayout(); |
404 | } | 404 | } |
405 | 405 | ||
406 | int OTabWidget::currentTab() | 406 | int OTabWidget::currentTab() |
407 | { | 407 | { |
408 | if ( currTab ) | 408 | if ( currTab ) |
409 | { | 409 | { |
410 | return currTab->id(); | 410 | return currTab->id(); |
411 | } | 411 | } |
412 | return -1; | 412 | return -1; |
413 | } | 413 | } |
414 | 414 | ||
415 | QWidget* OTabWidget::currentWidget()const | 415 | QWidget* OTabWidget::currentWidget()const |
416 | { | 416 | { |
417 | if ( currTab ) | 417 | if ( currTab ) |
418 | { | 418 | { |
419 | return currTab->control(); | 419 | return currTab->control(); |
420 | } | 420 | } |
421 | 421 | ||
422 | return 0; | 422 | return 0; |
423 | } | 423 | } |
diff --git a/libopie2/opieui/otimepicker.cpp b/libopie2/opieui/otimepicker.cpp index d4712a4..66f9ce0 100644 --- a/libopie2/opieui/otimepicker.cpp +++ b/libopie2/opieui/otimepicker.cpp | |||
@@ -1,292 +1,292 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | #include <opie2/otimepicker.h> | 35 | #include <opie2/otimepicker.h> |
36 | 36 | ||
37 | using namespace Opie; | 37 | using namespace Opie; |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Constructs the widget | 40 | * Constructs the widget |
41 | * @param parent The parent of the OTimePicker | 41 | * @param parent The parent of the OTimePicker |
42 | * @param name The name of the object | 42 | * @param name The name of the object |
43 | * @param fl Window Flags | 43 | * @param fl Window Flags |
44 | */ | 44 | */ |
45 | OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) | 45 | OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) |
46 | :QWidget(parent,name,fl) | 46 | :QWidget(parent,name,fl) |
47 | { | 47 | { |
48 | QVBoxLayout *vbox=new QVBoxLayout(this); | 48 | QVBoxLayout *vbox=new QVBoxLayout(this); |
49 | 49 | ||
50 | OClickableLabel *r; | 50 | OClickableLabel *r; |
51 | QString s; | 51 | QString s; |
52 | 52 | ||
53 | // Hour Row | 53 | // Hour Row |
54 | QWidget *row=new QWidget(this); | 54 | QWidget *row=new QWidget(this); |
55 | QHBoxLayout *l=new QHBoxLayout(row); | 55 | QHBoxLayout *l=new QHBoxLayout(row); |
56 | vbox->addWidget(row); | 56 | vbox->addWidget(row); |
57 | 57 | ||
58 | for (int i=0; i<24; i++) | 58 | for (int i=0; i<24; i++) |
59 | { | 59 | { |
60 | r=new OClickableLabel(row); | 60 | r=new OClickableLabel(row); |
61 | hourLst.append(r); | 61 | hourLst.append(r); |
62 | s.sprintf("%.2d",i); | 62 | s.sprintf("%.2d",i); |
63 | r->setText(s); | 63 | r->setText(s); |
64 | r->setToggleButton(true); | 64 | r->setToggleButton(true); |
65 | r->setAlignment(AlignHCenter | AlignVCenter); | 65 | r->setAlignment(AlignHCenter | AlignVCenter); |
66 | l->addWidget(r); | 66 | l->addWidget(r); |
67 | connect(r, SIGNAL(toggled(bool)), | 67 | connect(r, SIGNAL(toggled(bool)), |
68 | this, SLOT(slotHour(bool))); | 68 | this, SLOT(slotHour(bool))); |
69 | 69 | ||
70 | if (i==11) | 70 | if (i==11) |
71 | { // Second row | 71 | { // Second row |
72 | row=new QWidget(this); | 72 | row=new QWidget(this); |
73 | l=new QHBoxLayout(row); | 73 | l=new QHBoxLayout(row); |
74 | vbox->addWidget(row); | 74 | vbox->addWidget(row); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | // Minute Row | 78 | // Minute Row |
79 | row=new QWidget(this); | 79 | row=new QWidget(this); |
80 | l=new QHBoxLayout(row); | 80 | l=new QHBoxLayout(row); |
81 | vbox->addWidget(row); | 81 | vbox->addWidget(row); |
82 | 82 | ||
83 | for (int i=0; i<60; i+=5) | 83 | for (int i=0; i<60; i+=5) |
84 | { | 84 | { |
85 | r=new OClickableLabel(row); | 85 | r=new OClickableLabel(row); |
86 | minuteLst.append(r); | 86 | minuteLst.append(r); |
87 | s.sprintf("%.2d",i); | 87 | s.sprintf("%.2d",i); |
88 | r->setText(s); | 88 | r->setText(s); |
89 | r->setToggleButton(true); | 89 | r->setToggleButton(true); |
90 | r->setAlignment(AlignHCenter | AlignVCenter); | 90 | r->setAlignment(AlignHCenter | AlignVCenter); |
91 | l->addWidget(r); | 91 | l->addWidget(r); |
92 | connect(r, SIGNAL(toggled(bool)), | 92 | connect(r, SIGNAL(toggled(bool)), |
93 | this, SLOT(slotMinute(bool))); | 93 | this, SLOT(slotMinute(bool))); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * This method return the current time | 98 | * This method return the current time |
99 | * @return the time | 99 | * @return the time |
100 | */ | 100 | */ |
101 | QTime OTimePicker::time()const | 101 | QTime OTimePicker::time()const |
102 | { | 102 | { |
103 | return tm; | 103 | return tm; |
104 | } | 104 | } |
105 | 105 | ||
106 | void OTimePicker::slotHour(bool b) | 106 | void OTimePicker::slotHour(bool b) |
107 | { | 107 | { |
108 | 108 | ||
109 | OClickableLabel *r = (OClickableLabel *) sender(); | 109 | OClickableLabel *r = (OClickableLabel *) sender(); |
110 | 110 | ||
111 | if (b) | 111 | if (b) |
112 | { | 112 | { |
113 | QValueListIterator<OClickableLabel *> it; | 113 | QValueListIterator<OClickableLabel *> it; |
114 | for (it=hourLst.begin(); it!=hourLst.end(); it++) | 114 | for (it=hourLst.begin(); it!=hourLst.end(); it++) |
115 | { | 115 | { |
116 | if (*it != r) (*it)->setOn(false); | 116 | if (*it != r) (*it)->setOn(false); |
117 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); | 117 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); |
118 | } | 118 | } |
119 | emit timeChanged(tm); | 119 | emit timeChanged(tm); |
120 | } | 120 | } |
121 | else | 121 | else |
122 | { | 122 | { |
123 | r->setOn(true); | 123 | r->setOn(true); |
124 | } | 124 | } |
125 | 125 | ||
126 | } | 126 | } |
127 | 127 | ||
128 | void OTimePicker::slotMinute(bool b) | 128 | void OTimePicker::slotMinute(bool b) |
129 | { | 129 | { |
130 | 130 | ||
131 | OClickableLabel *r = (OClickableLabel *) sender(); | 131 | OClickableLabel *r = (OClickableLabel *) sender(); |
132 | 132 | ||
133 | if (b) | 133 | if (b) |
134 | { | 134 | { |
135 | QValueListIterator<OClickableLabel *> it; | 135 | QValueListIterator<OClickableLabel *> it; |
136 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) | 136 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) |
137 | { | 137 | { |
138 | if (*it != r) (*it)->setOn(false); | 138 | if (*it != r) (*it)->setOn(false); |
139 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); | 139 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); |
140 | } | 140 | } |
141 | emit timeChanged(tm); | 141 | emit timeChanged(tm); |
142 | } | 142 | } |
143 | else | 143 | else |
144 | { | 144 | { |
145 | r->setOn(true); | 145 | r->setOn(true); |
146 | } | 146 | } |
147 | 147 | ||
148 | } | 148 | } |
149 | 149 | ||
150 | /** | 150 | /** |
151 | * Method to set the time. No signal gets emitted during this method call | 151 | * Method to set the time. No signal gets emitted during this method call |
152 | * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) | 152 | * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) |
153 | * @param t The time to be set | 153 | * @param t The time to be set |
154 | */ | 154 | */ |
155 | void OTimePicker::setTime( const QTime& t) | 155 | void OTimePicker::setTime( const QTime& t) |
156 | { | 156 | { |
157 | setTime( t.hour(), t.minute() ); | 157 | setTime( t.hour(), t.minute() ); |
158 | } | 158 | } |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * Method to set the time. No signal gets emitted during this method call | 161 | * Method to set the time. No signal gets emitted during this method call |
162 | * @param h The hour | 162 | * @param h The hour |
163 | * @param m The minute. Minutes need to set by 5 minute steps | 163 | * @param m The minute. Minutes need to set by 5 minute steps |
164 | */ | 164 | */ |
165 | void OTimePicker::setTime( int h, int m ) | 165 | void OTimePicker::setTime( int h, int m ) |
166 | { | 166 | { |
167 | setHour(h); | 167 | setHour(h); |
168 | setMinute(m); | 168 | setMinute(m); |
169 | } | 169 | } |
170 | 170 | ||
171 | /* | 171 | /* |
172 | * FIXME round minutes to the 5 minute arrangement -zecke | 172 | * FIXME round minutes to the 5 minute arrangement -zecke |
173 | */ | 173 | */ |
174 | /** | 174 | /** |
175 | * Method to set the minutes | 175 | * Method to set the minutes |
176 | * @param m minutes | 176 | * @param m minutes |
177 | */ | 177 | */ |
178 | void OTimePicker::setMinute(int m) | 178 | void OTimePicker::setMinute(int m) |
179 | { | 179 | { |
180 | 180 | ||
181 | QString minute; | 181 | QString minute; |
182 | minute.sprintf("%.2d",m); | 182 | minute.sprintf("%.2d",m); |
183 | 183 | ||
184 | QValueListIterator<OClickableLabel *> it; | 184 | QValueListIterator<OClickableLabel *> it; |
185 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) | 185 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) |
186 | { | 186 | { |
187 | if ((*it)->text() == minute) (*it)->setOn(true); | 187 | if ((*it)->text() == minute) (*it)->setOn(true); |
188 | else (*it)->setOn(false); | 188 | else (*it)->setOn(false); |
189 | } | 189 | } |
190 | 190 | ||
191 | tm.setHMS(tm.hour(),m,0); | 191 | tm.setHMS(tm.hour(),m,0); |
192 | } | 192 | } |
193 | 193 | ||
194 | /** | 194 | /** |
195 | * Method to set the hour | 195 | * Method to set the hour |
196 | */ | 196 | */ |
197 | void OTimePicker::setHour(int h) | 197 | void OTimePicker::setHour(int h) |
198 | { | 198 | { |
199 | 199 | ||
200 | QString hour; | 200 | QString hour; |
201 | hour.sprintf("%.2d",h); | 201 | hour.sprintf("%.2d",h); |
202 | 202 | ||
203 | QValueListIterator<OClickableLabel *> it; | 203 | QValueListIterator<OClickableLabel *> it; |
204 | for (it=hourLst.begin(); it!=hourLst.end(); it++) | 204 | for (it=hourLst.begin(); it!=hourLst.end(); it++) |
205 | { | 205 | { |
206 | if ((*it)->text() == hour) (*it)->setOn(true); | 206 | if ((*it)->text() == hour) (*it)->setOn(true); |
207 | else (*it)->setOn(false); | 207 | else (*it)->setOn(false); |
208 | } | 208 | } |
209 | tm.setHMS(h,tm.minute(),0); | 209 | tm.setHMS(h,tm.minute(),0); |
210 | } | 210 | } |
211 | 211 | ||
212 | 212 | ||
213 | /** | 213 | /** |
214 | * This is a modal Dialog. | 214 | * This is a modal Dialog. |
215 | * | 215 | * |
216 | * @param parent The parent widget | 216 | * @param parent The parent widget |
217 | * @param name The name of the object | 217 | * @param name The name of the object |
218 | * @param fl Possible window flags | 218 | * @param fl Possible window flags |
219 | */ | 219 | */ |
220 | OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) | 220 | OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) |
221 | : OTimePickerDialogBase (parent , name, true , fl) | 221 | : OTimePickerDialogBase (parent , name, true , fl) |
222 | { | 222 | { |
223 | 223 | ||
224 | connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ), | 224 | connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ), |
225 | this, SLOT( setTime ( const QTime& ) ) ); | 225 | this, SLOT( setTime(const QTime&) ) ); |
226 | connect ( minuteField, SIGNAL( textChanged ( const QString& ) ), | 226 | connect ( minuteField, SIGNAL( textChanged(const QString&) ), |
227 | this, SLOT ( setMinute ( const QString& ) ) ); | 227 | this, SLOT ( setMinute(const QString&) ) ); |
228 | connect ( hourField, SIGNAL( textChanged ( const QString& ) ), | 228 | connect ( hourField, SIGNAL( textChanged(const QString&) ), |
229 | this, SLOT ( setHour ( const QString& ) ) ); | 229 | this, SLOT ( setHour(const QString&) ) ); |
230 | 230 | ||
231 | } | 231 | } |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * @return the time | 234 | * @return the time |
235 | */ | 235 | */ |
236 | QTime OTimePickerDialog::time()const | 236 | QTime OTimePickerDialog::time()const |
237 | { | 237 | { |
238 | return m_time; | 238 | return m_time; |
239 | } | 239 | } |
240 | 240 | ||
241 | /** | 241 | /** |
242 | * Set the time to time | 242 | * Set the time to time |
243 | * @param time The time to be set | 243 | * @param time The time to be set |
244 | */ | 244 | */ |
245 | void OTimePickerDialog::setTime( const QTime& time ) | 245 | void OTimePickerDialog::setTime( const QTime& time ) |
246 | { | 246 | { |
247 | m_time = time; | 247 | m_time = time; |
248 | 248 | ||
249 | m_timePicker->setHour ( time.hour() ); | 249 | m_timePicker->setHour ( time.hour() ); |
250 | m_timePicker->setMinute( time.minute() ); | 250 | m_timePicker->setMinute( time.minute() ); |
251 | 251 | ||
252 | // Set Textfields | 252 | // Set Textfields |
253 | if ( time.hour() < 10 ) | 253 | if ( time.hour() < 10 ) |
254 | hourField->setText( "0" + QString::number( time.hour() ) ); | 254 | hourField->setText( "0" + QString::number( time.hour() ) ); |
255 | else | 255 | else |
256 | hourField->setText( QString::number( time.hour() ) ); | 256 | hourField->setText( QString::number( time.hour() ) ); |
257 | 257 | ||
258 | if ( time.minute() < 10 ) | 258 | if ( time.minute() < 10 ) |
259 | minuteField->setText( "0" + QString::number( time.minute() ) ); | 259 | minuteField->setText( "0" + QString::number( time.minute() ) ); |
260 | else | 260 | else |
261 | minuteField->setText( QString::number( time.minute() ) ); | 261 | minuteField->setText( QString::number( time.minute() ) ); |
262 | 262 | ||
263 | } | 263 | } |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * This method takes the current minute and tries to set hour | 266 | * This method takes the current minute and tries to set hour |
267 | * to hour. This succeeds if the resulting date is valid | 267 | * to hour. This succeeds if the resulting date is valid |
268 | * @param hour The hour as a string | 268 | * @param hour The hour as a string |
269 | */ | 269 | */ |
270 | void OTimePickerDialog::setHour ( const QString& hour ) | 270 | void OTimePickerDialog::setHour ( const QString& hour ) |
271 | { | 271 | { |
272 | if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ) | 272 | if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ) |
273 | { | 273 | { |
274 | m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); | 274 | m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); |
275 | setTime ( m_time ); | 275 | setTime ( m_time ); |
276 | } | 276 | } |
277 | 277 | ||
278 | } | 278 | } |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * Method to set a new minute. It tries to convert the string to int and | 281 | * Method to set a new minute. It tries to convert the string to int and |
282 | * if the resulting date is valid a new date is set. | 282 | * if the resulting date is valid a new date is set. |
283 | * @see setHour | 283 | * @see setHour |
284 | */ | 284 | */ |
285 | void OTimePickerDialog::setMinute ( const QString& minute ) | 285 | void OTimePickerDialog::setMinute ( const QString& minute ) |
286 | { | 286 | { |
287 | if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ) | 287 | if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ) |
288 | { | 288 | { |
289 | m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); | 289 | m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); |
290 | setTime ( m_time ); | 290 | setTime ( m_time ); |
291 | } | 291 | } |
292 | } | 292 | } |
diff --git a/libopie2/opieui/oversatileview.cpp b/libopie2/opieui/oversatileview.cpp index 8839456..78154b7 100644 --- a/libopie2/opieui/oversatileview.cpp +++ b/libopie2/opieui/oversatileview.cpp | |||
@@ -1,1169 +1,1169 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | 32 | ||
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | #include <opie2/oversatileview.h> | 34 | #include <opie2/oversatileview.h> |
35 | #include <opie2/oversatileviewitem.h> | 35 | #include <opie2/oversatileviewitem.h> |
36 | #include <opie2/olistview.h> | 36 | #include <opie2/olistview.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | 39 | ||
40 | #include <qaction.h> | 40 | #include <qaction.h> |
41 | #include <qpopupmenu.h> | 41 | #include <qpopupmenu.h> |
42 | 42 | ||
43 | /* XPM */ | 43 | /* XPM */ |
44 | static const char * view_icon_xpm[] = { | 44 | static const char * view_icon_xpm[] = { |
45 | "16 16 16 1", | 45 | "16 16 16 1", |
46 | " c None", | 46 | " c None", |
47 | ".c #87BD88", | 47 | ".c #87BD88", |
48 | "+c #8BBE8B", | 48 | "+c #8BBE8B", |
49 | "@c #81BA81", | 49 | "@c #81BA81", |
50 | "#c #6DAF6D", | 50 | "#c #6DAF6D", |
51 | "$c #87BD87", | 51 | "$c #87BD87", |
52 | "%c #FCFDFC", | 52 | "%c #FCFDFC", |
53 | "&c #AED0AE", | 53 | "&c #AED0AE", |
54 | "*c #4E9C4C", | 54 | "*c #4E9C4C", |
55 | "=c #91BD91", | 55 | "=c #91BD91", |
56 | "-c #72B172", | 56 | "-c #72B172", |
57 | ";c #448643", | 57 | ";c #448643", |
58 | ">c #519F50", | 58 | ">c #519F50", |
59 | ",c #499247", | 59 | ",c #499247", |
60 | "'c #356A35", | 60 | "'c #356A35", |
61 | ")c #686868", | 61 | ")c #686868", |
62 | " ", | 62 | " ", |
63 | " .+@# .+@# ", | 63 | " .+@# .+@# ", |
64 | " $%&* $%&* ", | 64 | " $%&* $%&* ", |
65 | " @=-; @=-; ", | 65 | " @=-; @=-; ", |
66 | " #>,' #>,' ", | 66 | " #>,' #>,' ", |
67 | " ", | 67 | " ", |
68 | " )))))) )))))) ", | 68 | " )))))) )))))) ", |
69 | " ", | 69 | " ", |
70 | " ", | 70 | " ", |
71 | " .+@# .+@# ", | 71 | " .+@# .+@# ", |
72 | " $%&* $%&* ", | 72 | " $%&* $%&* ", |
73 | " @=-; @=-; ", | 73 | " @=-; @=-; ", |
74 | " #>,' #>,' ", | 74 | " #>,' #>,' ", |
75 | " ", | 75 | " ", |
76 | " )))))) )))))) ", | 76 | " )))))) )))))) ", |
77 | " "}; | 77 | " "}; |
78 | 78 | ||
79 | /* XPM */ | 79 | /* XPM */ |
80 | static const char * view_tree_xpm[] = { | 80 | static const char * view_tree_xpm[] = { |
81 | "16 16 17 1", | 81 | "16 16 17 1", |
82 | " c None", | 82 | " c None", |
83 | ".c #3A3A3A", | 83 | ".c #3A3A3A", |
84 | "+c #87BD88", | 84 | "+c #87BD88", |
85 | "@c #8BBE8B", | 85 | "@c #8BBE8B", |
86 | "#c #81BA81", | 86 | "#c #81BA81", |
87 | "$c #6DAF6D", | 87 | "$c #6DAF6D", |
88 | "%c #87BD87", | 88 | "%c #87BD87", |
89 | "&c #FCFDFC", | 89 | "&c #FCFDFC", |
90 | "*c #AED0AE", | 90 | "*c #AED0AE", |
91 | "=c #4E9C4C", | 91 | "=c #4E9C4C", |
92 | "-c #91BD91", | 92 | "-c #91BD91", |
93 | ";c #72B172", | 93 | ";c #72B172", |
94 | ">c #448643", | 94 | ">c #448643", |
95 | ",c #686868", | 95 | ",c #686868", |
96 | "'c #519F50", | 96 | "'c #519F50", |
97 | ")c #499247", | 97 | ")c #499247", |
98 | "!c #356A35", | 98 | "!c #356A35", |
99 | " . ", | 99 | " . ", |
100 | " . ", | 100 | " . ", |
101 | " . +@#$ ", | 101 | " . +@#$ ", |
102 | " . %&*= ", | 102 | " . %&*= ", |
103 | " .. #-;> ,, ,,,", | 103 | " .. #-;> ,, ,,,", |
104 | " . $')! ", | 104 | " . $')! ", |
105 | " . ", | 105 | " . ", |
106 | " . ", | 106 | " . ", |
107 | " . ", | 107 | " . ", |
108 | " . +@#$ ", | 108 | " . +@#$ ", |
109 | " . %&*= ", | 109 | " . %&*= ", |
110 | " .. #-;> ,, ,,,", | 110 | " .. #-;> ,, ,,,", |
111 | " $')! ", | 111 | " $')! ", |
112 | " ", | 112 | " ", |
113 | " ", | 113 | " ", |
114 | " "}; | 114 | " "}; |
115 | 115 | ||
116 | OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode ) | 116 | OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode ) |
117 | :QWidgetStack( parent, name ), | 117 | :QWidgetStack( parent, name ), |
118 | _viewmode( mode ), _warningpolicy( None ), | 118 | _viewmode( mode ), _warningpolicy( None ), |
119 | _treeleaf(), _treeopened(), _treeclosed(), | 119 | _treeleaf(), _treeopened(), _treeclosed(), |
120 | _iconleaf(), _iconopened(), _iconclosed() | 120 | _iconleaf(), _iconopened(), _iconclosed() |
121 | { | 121 | { |
122 | // | 122 | // |
123 | // Create child widgets and set some reasonable default styles | 123 | // Create child widgets and set some reasonable default styles |
124 | // | 124 | // |
125 | 125 | ||
126 | _listview = new OListView( this, "oversatileview embedded listview" ); | 126 | _listview = new OListView( this, "oversatileview embedded listview" ); |
127 | _iconview = new QIconView( this, "oversatileview embedded iconview" ); | 127 | _iconview = new QIconView( this, "oversatileview embedded iconview" ); |
128 | 128 | ||
129 | _listview->setAllColumnsShowFocus( true ); | 129 | _listview->setAllColumnsShowFocus( true ); |
130 | _listview->setRootIsDecorated( true ); | 130 | _listview->setRootIsDecorated( true ); |
131 | _listview->setShowSortIndicator( true ); | 131 | _listview->setShowSortIndicator( true ); |
132 | _iconview->setGridX( 90 ); | 132 | _iconview->setGridX( 90 ); |
133 | _iconview->setGridY( 42 ); | 133 | _iconview->setGridY( 42 ); |
134 | _iconview->setAutoArrange( true ); | 134 | _iconview->setAutoArrange( true ); |
135 | 135 | ||
136 | #ifdef QWS // TODO: Let this depend on current geometry (rotation) | 136 | #ifdef QWS // TODO: Let this depend on current geometry (rotation) |
137 | _iconview->setArrangement( QIconView::TopToBottom ); | 137 | _iconview->setArrangement( QIconView::TopToBottom ); |
138 | #else | 138 | #else |
139 | _iconview->setArrangement( QIconView::LeftToRight ); | 139 | _iconview->setArrangement( QIconView::LeftToRight ); |
140 | #endif | 140 | #endif |
141 | 141 | ||
142 | _iconview->setResizeMode( QIconView::Adjust ); | 142 | _iconview->setResizeMode( QIconView::Adjust ); |
143 | 143 | ||
144 | // qt-embedded: map stylus right on hold to right button press | 144 | // qt-embedded: map stylus right on hold to right button press |
145 | 145 | ||
146 | #ifdef QWS | 146 | #ifdef QWS |
147 | ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold ); | 147 | ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold ); |
148 | ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold ); | 148 | ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold ); |
149 | #endif | 149 | #endif |
150 | 150 | ||
151 | setViewMode( mode ); // TODO: Read last style from config | 151 | setViewMode( mode ); // TODO: Read last style from config |
152 | // setSynchronization( true ); // TODO: Implement this | 152 | // setSynchronization( true ); // TODO: Implement this |
153 | 153 | ||
154 | // create context menu allowing to switch between the views | 154 | // create context menu allowing to switch between the views |
155 | 155 | ||
156 | _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" ); | 156 | _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" ); |
157 | _contextmenu->setCaption( "Style" ); | 157 | _contextmenu->setCaption( "Style" ); |
158 | _contextmenu->setCheckable( true ); | 158 | _contextmenu->setCheckable( true ); |
159 | QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" ); | 159 | QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" ); |
160 | QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ), | 160 | QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ), |
161 | "View Icons", 0, ag, "viewicon action", true ); | 161 | "View Icons", 0, ag, "viewicon action", true ); |
162 | QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ), | 162 | QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ), |
163 | "View Tree", 0, ag, "viewtree action", true ); | 163 | "View Tree", 0, ag, "viewtree action", true ); |
164 | ag->addTo( _contextmenu ); | 164 | ag->addTo( _contextmenu ); |
165 | if ( mode == Icons ) | 165 | if ( mode == Icons ) |
166 | a1->setOn( true ); | 166 | a1->setOn( true ); |
167 | else if ( mode == Tree ) | 167 | else if ( mode == Tree ) |
168 | a2->setOn( true ); | 168 | a2->setOn( true ); |
169 | connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) ); | 169 | connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) ); |
170 | connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) ); | 170 | connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) ); |
171 | 171 | ||
172 | #if (QT_VERSION >= 0x030000) | 172 | #if (QT_VERSION >= 0x030000) |
173 | connect( _listview, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); | 173 | connect( _listview, SIGNAL( contextMenuRequested(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
174 | connect( _iconview, SIGNAL( contextMenuRequested( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); | 174 | connect( _iconview, SIGNAL( contextMenuRequested(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) ); |
175 | #else | 175 | #else |
176 | connect( _listview, SIGNAL( rightButtonPressed( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); | 176 | connect( _listview, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
177 | connect( _iconview, SIGNAL( rightButtonPressed( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); | 177 | connect( _iconview, SIGNAL( rightButtonPressed(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) ); |
178 | #endif | 178 | #endif |
179 | 179 | ||
180 | // | 180 | // |
181 | // signal forwarders | 181 | // signal forwarders |
182 | // | 182 | // |
183 | // unfortunately we can't short-circuit all the QListView and QIconView signals | 183 | // unfortunately we can't short-circuit all the QListView and QIconView signals |
184 | // to OVersatileView signals, because the signal/slot mechanism doesn't allow | 184 | // to OVersatileView signals, because the signal/slot mechanism doesn't allow |
185 | // type-conversion :-( | 185 | // type-conversion :-( |
186 | 186 | ||
187 | // common signals for listview | 187 | // common signals for listview |
188 | 188 | ||
189 | connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); | 189 | connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); |
190 | connect( _listview, SIGNAL( selectionChanged( QListViewItem * ) ), this, SLOT( selectionChanged( QListViewItem * ) ) ); | 190 | connect( _listview, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( selectionChanged(QListViewItem*) ) ); |
191 | connect( _listview, SIGNAL( currentChanged( QListViewItem * ) ), this, SLOT( currentChanged( QListViewItem * ) ) ); | 191 | connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) ); |
192 | connect( _listview, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( clicked( QListViewItem * ) ) ); | 192 | connect( _listview, SIGNAL( clicked(QListViewItem*) ), this, SLOT( clicked(QListViewItem*) ) ); |
193 | connect( _listview, SIGNAL( pressed( QListViewItem * ) ), this, SLOT( pressed( QListViewItem * ) ) ); | 193 | connect( _listview, SIGNAL( pressed(QListViewItem*) ), this, SLOT( pressed(QListViewItem*) ) ); |
194 | 194 | ||
195 | connect( _listview, SIGNAL( doubleClicked( QListViewItem * ) ), this, SLOT( doubleClicked( QListViewItem * ) ) ); | 195 | connect( _listview, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( doubleClicked(QListViewItem*) ) ); |
196 | connect( _listview, SIGNAL( returnPressed( QListViewItem * ) ), this, SLOT( returnPressed( QListViewItem * ) ) ); | 196 | connect( _listview, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( returnPressed(QListViewItem*) ) ); |
197 | 197 | ||
198 | connect( _listview, SIGNAL( onItem( QListViewItem * ) ), this, SLOT( onItem( QListViewItem * ) ) ); | 198 | connect( _listview, SIGNAL( onItem(QListViewItem*) ), this, SLOT( onItem(QListViewItem*) ) ); |
199 | connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); | 199 | connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); |
200 | 200 | ||
201 | // common signals for iconview | 201 | // common signals for iconview |
202 | 202 | ||
203 | connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); | 203 | connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); |
204 | connect( _iconview, SIGNAL( selectionChanged( QIconViewItem * ) ), this, SLOT( selectionChanged( QIconViewItem * ) ) ); | 204 | connect( _iconview, SIGNAL( selectionChanged(QIconViewItem*) ), this, SLOT( selectionChanged(QIconViewItem*) ) ); |
205 | connect( _iconview, SIGNAL( currentChanged( QIconViewItem * ) ), this, SLOT( currentChanged( QIconViewItem * ) ) ); | 205 | connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) ); |
206 | connect( _iconview, SIGNAL( clicked( QIconViewItem * ) ), this, SLOT( clicked( QIconViewItem * ) ) ); | 206 | connect( _iconview, SIGNAL( clicked(QIconViewItem*) ), this, SLOT( clicked(QIconViewItem*) ) ); |
207 | connect( _iconview, SIGNAL( pressed( QIconViewItem * ) ), this, SLOT( pressed( QIconViewItem * ) ) ); | 207 | connect( _iconview, SIGNAL( pressed(QIconViewItem*) ), this, SLOT( pressed(QIconViewItem*) ) ); |
208 | 208 | ||
209 | connect( _iconview, SIGNAL( doubleClicked( QIconViewItem * ) ), this, SLOT( doubleClicked( QIconViewItem * ) ) ); | 209 | connect( _iconview, SIGNAL( doubleClicked(QIconViewItem*) ), this, SLOT( doubleClicked(QIconViewItem*) ) ); |
210 | connect( _iconview, SIGNAL( returnPressed( QIconViewItem * ) ), this, SLOT( returnPressed( QIconViewItem * ) ) ); | 210 | connect( _iconview, SIGNAL( returnPressed(QIconViewItem*) ), this, SLOT( returnPressed(QIconViewItem*) ) ); |
211 | 211 | ||
212 | connect( _iconview, SIGNAL( onItem( QIconViewItem * ) ), this, SLOT( onItem( QIconViewItem * ) ) ); | 212 | connect( _iconview, SIGNAL( onItem(QIconViewItem*) ), this, SLOT( onItem(QIconViewItem*) ) ); |
213 | connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); | 213 | connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); |
214 | 214 | ||
215 | // listview only signals | 215 | // listview only signals |
216 | 216 | ||
217 | connect( _listview, SIGNAL( expanded( QListViewItem * ) ), this, SLOT( expanded( QListViewItem * ) ) ); | 217 | connect( _listview, SIGNAL( expanded(QListViewItem*) ), this, SLOT( expanded(QListViewItem*) ) ); |
218 | connect( _listview, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( collapsed( QListViewItem * ) ) ); | 218 | connect( _listview, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( collapsed(QListViewItem*) ) ); |
219 | 219 | ||
220 | // iconview only signals | 220 | // iconview only signals |
221 | 221 | ||
222 | connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) ); | 222 | connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) ); |
223 | } | 223 | } |
224 | 224 | ||
225 | OVersatileView::~OVersatileView() | 225 | OVersatileView::~OVersatileView() |
226 | { | 226 | { |
227 | } | 227 | } |
228 | 228 | ||
229 | QPopupMenu* OVersatileView::contextMenu() const | 229 | QPopupMenu* OVersatileView::contextMenu() const |
230 | { | 230 | { |
231 | return _contextmenu; | 231 | return _contextmenu; |
232 | } | 232 | } |
233 | 233 | ||
234 | void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col ) | 234 | void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col ) |
235 | { | 235 | { |
236 | // can't use QObject::inherits here, because ListViewItems, beit Q, O or K, | 236 | // can't use QObject::inherits here, because ListViewItems, beit Q, O or K, |
237 | // do not inherit from QObject - assuming here the programmer is | 237 | // do not inherit from QObject - assuming here the programmer is |
238 | // disciplined enough to only add OVersatileViewItems to an OVersatileView | 238 | // disciplined enough to only add OVersatileViewItems to an OVersatileView |
239 | popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col ); | 239 | popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col ); |
240 | } | 240 | } |
241 | 241 | ||
242 | void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos ) | 242 | void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos ) |
243 | { | 243 | { |
244 | // see above | 244 | // see above |
245 | popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 ); | 245 | popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 ); |
246 | } | 246 | } |
247 | 247 | ||
248 | void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col ) | 248 | void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col ) |
249 | { | 249 | { |
250 | if ( !item ) | 250 | if ( !item ) |
251 | _contextmenu->exec( pos ); | 251 | _contextmenu->exec( pos ); |
252 | else | 252 | else |
253 | emit( contextMenuRequested( item, pos, col ) ); | 253 | emit( contextMenuRequested( item, pos, col ) ); |
254 | } | 254 | } |
255 | 255 | ||
256 | void OVersatileView::setSynchronization( bool sync ) | 256 | void OVersatileView::setSynchronization( bool sync ) |
257 | { | 257 | { |
258 | _synchronization = sync; | 258 | _synchronization = sync; |
259 | } | 259 | } |
260 | 260 | ||
261 | bool OVersatileView::synchronization() | 261 | bool OVersatileView::synchronization() |
262 | { | 262 | { |
263 | return _synchronization; | 263 | return _synchronization; |
264 | } | 264 | } |
265 | 265 | ||
266 | void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ) | 266 | void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ) |
267 | { | 267 | { |
268 | if ( mode == Tree ) | 268 | if ( mode == Tree ) |
269 | { | 269 | { |
270 | _treeleaf = leaf; | 270 | _treeleaf = leaf; |
271 | _treeopened = opened; | 271 | _treeopened = opened; |
272 | _treeclosed = closed; | 272 | _treeclosed = closed; |
273 | } | 273 | } |
274 | else if ( mode == Icons ) | 274 | else if ( mode == Icons ) |
275 | { | 275 | { |
276 | _iconleaf = leaf; | 276 | _iconleaf = leaf; |
277 | _iconopened = opened; | 277 | _iconopened = opened; |
278 | _iconclosed = closed; | 278 | _iconclosed = closed; |
279 | } | 279 | } |
280 | else | 280 | else |
281 | { | 281 | { |
282 | odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl; | 282 | odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl; |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | QIconView* OVersatileView::iconView() const | 286 | QIconView* OVersatileView::iconView() const |
287 | { | 287 | { |
288 | return _iconview; | 288 | return _iconview; |
289 | } | 289 | } |
290 | 290 | ||
291 | OListView* OVersatileView::listView() const | 291 | OListView* OVersatileView::listView() const |
292 | { | 292 | { |
293 | return _listview; | 293 | return _listview; |
294 | } | 294 | } |
295 | 295 | ||
296 | void OVersatileView::setViewMode( int mode ) | 296 | void OVersatileView::setViewMode( int mode ) |
297 | { | 297 | { |
298 | if ( mode == Tree ) | 298 | if ( mode == Tree ) |
299 | { | 299 | { |
300 | _viewmode = mode; | 300 | _viewmode = mode; |
301 | raiseWidget( _listview ); | 301 | raiseWidget( _listview ); |
302 | } | 302 | } |
303 | else if ( mode == Icons ) | 303 | else if ( mode == Icons ) |
304 | { | 304 | { |
305 | _viewmode = mode; | 305 | _viewmode = mode; |
306 | raiseWidget( _iconview ); | 306 | raiseWidget( _iconview ); |
307 | } | 307 | } |
308 | else | 308 | else |
309 | { | 309 | { |
310 | odebug << "OVersatileView::setViewMode(): invalid mode" << oendl; | 310 | odebug << "OVersatileView::setViewMode(): invalid mode" << oendl; |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | void OVersatileView::setIconViewMode() | 314 | void OVersatileView::setIconViewMode() |
315 | { | 315 | { |
316 | setViewMode( Icons ); | 316 | setViewMode( Icons ); |
317 | } | 317 | } |
318 | 318 | ||
319 | void OVersatileView::setTreeViewMode() | 319 | void OVersatileView::setTreeViewMode() |
320 | { | 320 | { |
321 | setViewMode( Tree ); | 321 | setViewMode( Tree ); |
322 | } | 322 | } |
323 | 323 | ||
324 | bool OVersatileView::isValidViewMode( int mode ) const | 324 | bool OVersatileView::isValidViewMode( int mode ) const |
325 | { | 325 | { |
326 | switch ( _warningpolicy ) | 326 | switch ( _warningpolicy ) |
327 | { | 327 | { |
328 | case OVersatileView::None: | 328 | case OVersatileView::None: |
329 | { | 329 | { |
330 | return true; | 330 | return true; |
331 | } | 331 | } |
332 | case OVersatileView::Warn: | 332 | case OVersatileView::Warn: |
333 | { | 333 | { |
334 | if ( _viewmode != mode ) | 334 | if ( _viewmode != mode ) |
335 | { | 335 | { |
336 | odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; | 336 | odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; |
337 | return true; | 337 | return true; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | case OVersatileView::WarnReturn: | 340 | case OVersatileView::WarnReturn: |
341 | { | 341 | { |
342 | if ( _viewmode != mode ) | 342 | if ( _viewmode != mode ) |
343 | { | 343 | { |
344 | odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; | 344 | odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; |
345 | return false; | 345 | return false; |
346 | } | 346 | } |
347 | } | 347 | } |
348 | default: | 348 | default: |
349 | { | 349 | { |
350 | owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl; | 350 | owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl; |
351 | return true; | 351 | return true; |
352 | } | 352 | } |
353 | } | 353 | } |
354 | } | 354 | } |
355 | void OVersatileView::setWarningPolicy( int policy ) const | 355 | void OVersatileView::setWarningPolicy( int policy ) const |
356 | { | 356 | { |
357 | _warningpolicy = policy; | 357 | _warningpolicy = policy; |
358 | } | 358 | } |
359 | bool OVersatileView::warningPolicy() const | 359 | bool OVersatileView::warningPolicy() const |
360 | { | 360 | { |
361 | return _warningpolicy; | 361 | return _warningpolicy; |
362 | } | 362 | } |
363 | //==============================================================================================// | 363 | //==============================================================================================// |
364 | // Stupid Signal forwarders... | 364 | // Stupid Signal forwarders... |
365 | // Folks, this is why I like python with its dynamic typing: | 365 | // Folks, this is why I like python with its dynamic typing: |
366 | // I can code the following dozens of lines C++ in four Python lines... | 366 | // I can code the following dozens of lines C++ in four Python lines... |
367 | //==============================================================================================// | 367 | //==============================================================================================// |
368 | 368 | ||
369 | void OVersatileView::selectionChanged( QListViewItem * item ) | 369 | void OVersatileView::selectionChanged( QListViewItem * item ) |
370 | { | 370 | { |
371 | emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); | 371 | emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); |
372 | } | 372 | } |
373 | 373 | ||
374 | void OVersatileView::selectionChanged( QIconViewItem * item ) | 374 | void OVersatileView::selectionChanged( QIconViewItem * item ) |
375 | { | 375 | { |
376 | emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); | 376 | emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); |
377 | } | 377 | } |
378 | 378 | ||
379 | void OVersatileView::currentChanged( QListViewItem * item ) | 379 | void OVersatileView::currentChanged( QListViewItem * item ) |
380 | { | 380 | { |
381 | emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); | 381 | emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); |
382 | } | 382 | } |
383 | 383 | ||
384 | void OVersatileView::currentChanged( QIconViewItem * item ) | 384 | void OVersatileView::currentChanged( QIconViewItem * item ) |
385 | { | 385 | { |
386 | emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); | 386 | emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); |
387 | } | 387 | } |
388 | 388 | ||
389 | void OVersatileView::clicked( QListViewItem * item ) | 389 | void OVersatileView::clicked( QListViewItem * item ) |
390 | { | 390 | { |
391 | emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); | 391 | emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); |
392 | } | 392 | } |
393 | 393 | ||
394 | void OVersatileView::clicked( QIconViewItem * item ) | 394 | void OVersatileView::clicked( QIconViewItem * item ) |
395 | { | 395 | { |
396 | emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); | 396 | emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); |
397 | } | 397 | } |
398 | 398 | ||
399 | void OVersatileView::pressed( QListViewItem * item ) | 399 | void OVersatileView::pressed( QListViewItem * item ) |
400 | { | 400 | { |
401 | emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); | 401 | emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); |
402 | } | 402 | } |
403 | 403 | ||
404 | void OVersatileView::pressed( QIconViewItem * item ) | 404 | void OVersatileView::pressed( QIconViewItem * item ) |
405 | { | 405 | { |
406 | emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); | 406 | emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); |
407 | } | 407 | } |
408 | 408 | ||
409 | void OVersatileView::doubleClicked( QListViewItem * item ) | 409 | void OVersatileView::doubleClicked( QListViewItem * item ) |
410 | { | 410 | { |
411 | emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); | 411 | emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); |
412 | } | 412 | } |
413 | 413 | ||
414 | void OVersatileView::doubleClicked( QIconViewItem * item ) | 414 | void OVersatileView::doubleClicked( QIconViewItem * item ) |
415 | { | 415 | { |
416 | emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); | 416 | emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); |
417 | } | 417 | } |
418 | 418 | ||
419 | void OVersatileView::returnPressed( QListViewItem * item ) | 419 | void OVersatileView::returnPressed( QListViewItem * item ) |
420 | { | 420 | { |
421 | emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); | 421 | emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); |
422 | } | 422 | } |
423 | 423 | ||
424 | void OVersatileView::returnPressed( QIconViewItem * item ) | 424 | void OVersatileView::returnPressed( QIconViewItem * item ) |
425 | { | 425 | { |
426 | emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); | 426 | emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); |
427 | } | 427 | } |
428 | 428 | ||
429 | void OVersatileView::onItem( QListViewItem * item ) | 429 | void OVersatileView::onItem( QListViewItem * item ) |
430 | { | 430 | { |
431 | emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); | 431 | emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); |
432 | } | 432 | } |
433 | 433 | ||
434 | void OVersatileView::onItem( QIconViewItem * item ) | 434 | void OVersatileView::onItem( QIconViewItem * item ) |
435 | { | 435 | { |
436 | emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); | 436 | emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); |
437 | } | 437 | } |
438 | 438 | ||
439 | void OVersatileView::expanded( QListViewItem *item ) // QListView | 439 | void OVersatileView::expanded( QListViewItem *item ) // QListView |
440 | { | 440 | { |
441 | //odebug << "OVersatileView::expanded(): opening tree..." << oendl; | 441 | //odebug << "OVersatileView::expanded(): opening tree..." << oendl; |
442 | if ( !_treeopened.isNull() ) | 442 | if ( !_treeopened.isNull() ) |
443 | item->setPixmap( 0, _treeopened ); | 443 | item->setPixmap( 0, _treeopened ); |
444 | emit( expanded( static_cast<OVersatileViewItem*>( item ) ) ); | 444 | emit( expanded( static_cast<OVersatileViewItem*>( item ) ) ); |
445 | } | 445 | } |
446 | void OVersatileView::collapsed( QListViewItem *item ) // QListView | 446 | void OVersatileView::collapsed( QListViewItem *item ) // QListView |
447 | { | 447 | { |
448 | if ( !_treeclosed.isNull() ) | 448 | if ( !_treeclosed.isNull() ) |
449 | item->setPixmap( 0, _treeclosed ); | 449 | item->setPixmap( 0, _treeclosed ); |
450 | emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) ); | 450 | emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) ); |
451 | } | 451 | } |
452 | 452 | ||
453 | //=============================================================================================// | 453 | //=============================================================================================// |
454 | // OVersatileView Case I - API only existing in QListView or QIconView but not in both! | 454 | // OVersatileView Case I - API only existing in QListView or QIconView but not in both! |
455 | //==============================================================================================// | 455 | //==============================================================================================// |
456 | 456 | ||
457 | int OVersatileView::treeStepSize() const // QListView | 457 | int OVersatileView::treeStepSize() const // QListView |
458 | { | 458 | { |
459 | if ( !isValidViewMode( Tree ) ) | 459 | if ( !isValidViewMode( Tree ) ) |
460 | { | 460 | { |
461 | return -1; | 461 | return -1; |
462 | } | 462 | } |
463 | return _listview->treeStepSize(); | 463 | return _listview->treeStepSize(); |
464 | } | 464 | } |
465 | void OVersatileView::setTreeStepSize( int size ) // QListView | 465 | void OVersatileView::setTreeStepSize( int size ) // QListView |
466 | { | 466 | { |
467 | if ( !isValidViewMode( Tree ) ) | 467 | if ( !isValidViewMode( Tree ) ) |
468 | { | 468 | { |
469 | return; | 469 | return; |
470 | } | 470 | } |
471 | _listview->setTreeStepSize( size ); | 471 | _listview->setTreeStepSize( size ); |
472 | } | 472 | } |
473 | 473 | ||
474 | QHeader * OVersatileView::header() const // QListView | 474 | QHeader * OVersatileView::header() const // QListView |
475 | { | 475 | { |
476 | if ( !isValidViewMode( Tree ) ) | 476 | if ( !isValidViewMode( Tree ) ) |
477 | { | 477 | { |
478 | return 0; | 478 | return 0; |
479 | } | 479 | } |
480 | return _listview->header(); | 480 | return _listview->header(); |
481 | } | 481 | } |
482 | 482 | ||
483 | int OVersatileView::addColumn( const QString &label, int size ) // QListView | 483 | int OVersatileView::addColumn( const QString &label, int size ) // QListView |
484 | { | 484 | { |
485 | if ( !isValidViewMode( Tree ) ) | 485 | if ( !isValidViewMode( Tree ) ) |
486 | { | 486 | { |
487 | return -1; | 487 | return -1; |
488 | } | 488 | } |
489 | return _listview->addColumn( label, size ); | 489 | return _listview->addColumn( label, size ); |
490 | } | 490 | } |
491 | 491 | ||
492 | int OVersatileView::addColumn( const QIconSet& iconset, const QString &label, int size ) // QListView | 492 | int OVersatileView::addColumn( const QIconSet& iconset, const QString &label, int size ) // QListView |
493 | { | 493 | { |
494 | if ( !isValidViewMode( Tree ) ) | 494 | if ( !isValidViewMode( Tree ) ) |
495 | { | 495 | { |
496 | return -1; | 496 | return -1; |
497 | } | 497 | } |
498 | return _listview->addColumn( iconset, label, size ); | 498 | return _listview->addColumn( iconset, label, size ); |
499 | } | 499 | } |
500 | 500 | ||
501 | void OVersatileView::removeColumn( int index ) // QListView | 501 | void OVersatileView::removeColumn( int index ) // QListView |
502 | { | 502 | { |
503 | if ( !isValidViewMode( Tree ) ) | 503 | if ( !isValidViewMode( Tree ) ) |
504 | { | 504 | { |
505 | return; | 505 | return; |
506 | } | 506 | } |
507 | _listview->removeColumn( index ); | 507 | _listview->removeColumn( index ); |
508 | } | 508 | } |
509 | void OVersatileView::setColumnText( int column, const QString &label ) // QListView | 509 | void OVersatileView::setColumnText( int column, const QString &label ) // QListView |
510 | { | 510 | { |
511 | if ( !isValidViewMode( Tree ) ) | 511 | if ( !isValidViewMode( Tree ) ) |
512 | { | 512 | { |
513 | return; | 513 | return; |
514 | } | 514 | } |
515 | _listview->setColumnText( column, label ); | 515 | _listview->setColumnText( column, label ); |
516 | } | 516 | } |
517 | void OVersatileView::setColumnText( int column, const QIconSet& iconset, const QString &label ) // QListView | 517 | void OVersatileView::setColumnText( int column, const QIconSet& iconset, const QString &label ) // QListView |
518 | { | 518 | { |
519 | if ( !isValidViewMode( Tree ) ) | 519 | if ( !isValidViewMode( Tree ) ) |
520 | { | 520 | { |
521 | return; | 521 | return; |
522 | } | 522 | } |
523 | _listview->setColumnText( column, iconset, label ); | 523 | _listview->setColumnText( column, iconset, label ); |
524 | } | 524 | } |
525 | QString OVersatileView::columnText( int column ) const // QListView | 525 | QString OVersatileView::columnText( int column ) const // QListView |
526 | { | 526 | { |
527 | if ( !isValidViewMode( Tree ) ) | 527 | if ( !isValidViewMode( Tree ) ) |
528 | { | 528 | { |
529 | return QString::null; | 529 | return QString::null; |
530 | } | 530 | } |
531 | return _listview->columnText( column ); | 531 | return _listview->columnText( column ); |
532 | } | 532 | } |
533 | void OVersatileView::setColumnWidth( int column, int width ) // QListView | 533 | void OVersatileView::setColumnWidth( int column, int width ) // QListView |
534 | { | 534 | { |
535 | if ( !isValidViewMode( Tree ) ) | 535 | if ( !isValidViewMode( Tree ) ) |
536 | { | 536 | { |
537 | return; | 537 | return; |
538 | } | 538 | } |
539 | _listview->setColumnWidth( column, width ); | 539 | _listview->setColumnWidth( column, width ); |
540 | } | 540 | } |
541 | int OVersatileView::columnWidth( int column ) const // QListView | 541 | int OVersatileView::columnWidth( int column ) const // QListView |
542 | { | 542 | { |
543 | if ( !isValidViewMode( Tree ) ) | 543 | if ( !isValidViewMode( Tree ) ) |
544 | { | 544 | { |
545 | return -1; | 545 | return -1; |
546 | } | 546 | } |
547 | return _listview->columnWidth( column ); | 547 | return _listview->columnWidth( column ); |
548 | } | 548 | } |
549 | void OVersatileView::setColumnWidthMode( int column, WidthMode mode ) // QListView | 549 | void OVersatileView::setColumnWidthMode( int column, WidthMode mode ) // QListView |
550 | { | 550 | { |
551 | if ( !isValidViewMode( Tree ) ) | 551 | if ( !isValidViewMode( Tree ) ) |
552 | { | 552 | { |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | _listview->setColumnWidth( column, mode ); | 555 | _listview->setColumnWidth( column, mode ); |
556 | } | 556 | } |
557 | int OVersatileView::columns() const // QListView | 557 | int OVersatileView::columns() const // QListView |
558 | { | 558 | { |
559 | if ( !isValidViewMode( Tree ) ) | 559 | if ( !isValidViewMode( Tree ) ) |
560 | { | 560 | { |
561 | return -1; | 561 | return -1; |
562 | } | 562 | } |
563 | return _listview->columns(); | 563 | return _listview->columns(); |
564 | } | 564 | } |
565 | 565 | ||
566 | void OVersatileView::setColumnAlignment( int column, int align ) // QListView | 566 | void OVersatileView::setColumnAlignment( int column, int align ) // QListView |
567 | { | 567 | { |
568 | if ( !isValidViewMode( Tree ) ) | 568 | if ( !isValidViewMode( Tree ) ) |
569 | { | 569 | { |
570 | return; | 570 | return; |
571 | } | 571 | } |
572 | _listview->setColumnAlignment( column, align ); | 572 | _listview->setColumnAlignment( column, align ); |
573 | } | 573 | } |
574 | int OVersatileView::columnAlignment( int column ) const // QListView | 574 | int OVersatileView::columnAlignment( int column ) const // QListView |
575 | { | 575 | { |
576 | if ( !isValidViewMode( Tree ) ) | 576 | if ( !isValidViewMode( Tree ) ) |
577 | { | 577 | { |
578 | return -1; | 578 | return -1; |
579 | } | 579 | } |
580 | return _listview->columnAlignment( column ); | 580 | return _listview->columnAlignment( column ); |
581 | } | 581 | } |
582 | 582 | ||
583 | OVersatileViewItem * OVersatileView::itemAt( const QPoint & screenPos ) const // QListView | 583 | OVersatileViewItem * OVersatileView::itemAt( const QPoint & screenPos ) const // QListView |
584 | { | 584 | { |
585 | if ( !isValidViewMode( Tree ) ) | 585 | if ( !isValidViewMode( Tree ) ) |
586 | { | 586 | { |
587 | return 0; | 587 | return 0; |
588 | } | 588 | } |
589 | return static_cast<OVersatileViewItem*>( _listview->itemAt( screenPos ) ); | 589 | return static_cast<OVersatileViewItem*>( _listview->itemAt( screenPos ) ); |
590 | } | 590 | } |
591 | QRect OVersatileView::itemRect( const OVersatileViewItem * item ) const // QListView | 591 | QRect OVersatileView::itemRect( const OVersatileViewItem * item ) const // QListView |
592 | { | 592 | { |
593 | if ( !isValidViewMode( Tree ) ) | 593 | if ( !isValidViewMode( Tree ) ) |
594 | { | 594 | { |
595 | return QRect( -1, -1, -1, -1 ); | 595 | return QRect( -1, -1, -1, -1 ); |
596 | } | 596 | } |
597 | return _listview->itemRect( item ); | 597 | return _listview->itemRect( item ); |
598 | } | 598 | } |
599 | int OVersatileView::itemPos( const OVersatileViewItem * item ) // QListView | 599 | int OVersatileView::itemPos( const OVersatileViewItem * item ) // QListView |
600 | { | 600 | { |
601 | if ( !isValidViewMode( Tree ) ) | 601 | if ( !isValidViewMode( Tree ) ) |
602 | { | 602 | { |
603 | return -1; | 603 | return -1; |
604 | } | 604 | } |
605 | return _listview->itemPos( item ); | 605 | return _listview->itemPos( item ); |
606 | } | 606 | } |
607 | 607 | ||
608 | bool OVersatileView::isSelected( const OVersatileViewItem * item ) const // QListView // also in QIconViewItem but !in QIconView *shrug* | 608 | bool OVersatileView::isSelected( const OVersatileViewItem * item ) const // QListView // also in QIconViewItem but !in QIconView *shrug* |
609 | { | 609 | { |
610 | if ( !isValidViewMode( Tree ) ) | 610 | if ( !isValidViewMode( Tree ) ) |
611 | { | 611 | { |
612 | return false; | 612 | return false; |
613 | } | 613 | } |
614 | return _listview->isSelected( item ); | 614 | return _listview->isSelected( item ); |
615 | } | 615 | } |
616 | 616 | ||
617 | void OVersatileView::setMultiSelection( bool enable ) | 617 | void OVersatileView::setMultiSelection( bool enable ) |
618 | { | 618 | { |
619 | _listview->setMultiSelection( enable ); | 619 | _listview->setMultiSelection( enable ); |
620 | } | 620 | } |
621 | bool OVersatileView::isMultiSelection() const | 621 | bool OVersatileView::isMultiSelection() const |
622 | { | 622 | { |
623 | return _listview->isMultiSelection(); | 623 | return _listview->isMultiSelection(); |
624 | } | 624 | } |
625 | 625 | ||
626 | OVersatileViewItem * OVersatileView::selectedItem() const // QListView | 626 | OVersatileViewItem * OVersatileView::selectedItem() const // QListView |
627 | { | 627 | { |
628 | if ( !isValidViewMode( Tree ) ) | 628 | if ( !isValidViewMode( Tree ) ) |
629 | { | 629 | { |
630 | return 0; | 630 | return 0; |
631 | } | 631 | } |
632 | return static_cast<OVersatileViewItem*>( _listview->selectedItem() ); | 632 | return static_cast<OVersatileViewItem*>( _listview->selectedItem() ); |
633 | } | 633 | } |
634 | void OVersatileView::setOpen( OVersatileViewItem * item, bool open ) // QListView | 634 | void OVersatileView::setOpen( OVersatileViewItem * item, bool open ) // QListView |
635 | { | 635 | { |
636 | if ( !isValidViewMode( Tree ) ) | 636 | if ( !isValidViewMode( Tree ) ) |
637 | { | 637 | { |
638 | return; | 638 | return; |
639 | } | 639 | } |
640 | _listview->setOpen( item, open ); | 640 | _listview->setOpen( item, open ); |
641 | } | 641 | } |
642 | bool OVersatileView::isOpen( const OVersatileViewItem * item ) const // QListView | 642 | bool OVersatileView::isOpen( const OVersatileViewItem * item ) const // QListView |
643 | { | 643 | { |
644 | if ( !isValidViewMode( Tree ) ) | 644 | if ( !isValidViewMode( Tree ) ) |
645 | { | 645 | { |
646 | return false; | 646 | return false; |
647 | } | 647 | } |
648 | return _listview->isOpen( item ); | 648 | return _listview->isOpen( item ); |
649 | } | 649 | } |
650 | 650 | ||
651 | OVersatileViewItem * OVersatileView::firstChild() const // QListView | 651 | OVersatileViewItem * OVersatileView::firstChild() const // QListView |
652 | { | 652 | { |
653 | if ( !isValidViewMode( Tree ) ) | 653 | if ( !isValidViewMode( Tree ) ) |
654 | { | 654 | { |
655 | return 0; | 655 | return 0; |
656 | } | 656 | } |
657 | return static_cast<OVersatileViewItem*>( _listview->firstChild() ); | 657 | return static_cast<OVersatileViewItem*>( _listview->firstChild() ); |
658 | } | 658 | } |
659 | int OVersatileView::childCount() const // QListView | 659 | int OVersatileView::childCount() const // QListView |
660 | { | 660 | { |
661 | if ( !isValidViewMode( Tree ) ) | 661 | if ( !isValidViewMode( Tree ) ) |
662 | { | 662 | { |
663 | return -1; | 663 | return -1; |
664 | } | 664 | } |
665 | return _listview->childCount(); | 665 | return _listview->childCount(); |
666 | } | 666 | } |
667 | 667 | ||
668 | void OVersatileView::setAllColumnsShowFocus( bool focus ) // QListView | 668 | void OVersatileView::setAllColumnsShowFocus( bool focus ) // QListView |
669 | { | 669 | { |
670 | if ( !isValidViewMode( Tree ) ) | 670 | if ( !isValidViewMode( Tree ) ) |
671 | { | 671 | { |
672 | return; | 672 | return; |
673 | } | 673 | } |
674 | _listview->setAllColumnsShowFocus( focus ); | 674 | _listview->setAllColumnsShowFocus( focus ); |
675 | } | 675 | } |
676 | bool OVersatileView::allColumnsShowFocus() const // QListView | 676 | bool OVersatileView::allColumnsShowFocus() const // QListView |
677 | { | 677 | { |
678 | if ( !isValidViewMode( Tree ) ) | 678 | if ( !isValidViewMode( Tree ) ) |
679 | { | 679 | { |
680 | return false; | 680 | return false; |
681 | } | 681 | } |
682 | return _listview->allColumnsShowFocus(); | 682 | return _listview->allColumnsShowFocus(); |
683 | } | 683 | } |
684 | 684 | ||
685 | void OVersatileView::setItemMargin( int margin ) // QListView | 685 | void OVersatileView::setItemMargin( int margin ) // QListView |
686 | { | 686 | { |
687 | if ( !isValidViewMode( Tree ) ) | 687 | if ( !isValidViewMode( Tree ) ) |
688 | { | 688 | { |
689 | return; | 689 | return; |
690 | } | 690 | } |
691 | _listview->setItemMargin( margin ); | 691 | _listview->setItemMargin( margin ); |
692 | } | 692 | } |
693 | int OVersatileView::itemMargin() const // QListView | 693 | int OVersatileView::itemMargin() const // QListView |
694 | { | 694 | { |
695 | if ( !isValidViewMode( Tree ) ) | 695 | if ( !isValidViewMode( Tree ) ) |
696 | { | 696 | { |
697 | return -1; | 697 | return -1; |
698 | } | 698 | } |
699 | return _listview->itemMargin(); | 699 | return _listview->itemMargin(); |
700 | } | 700 | } |
701 | 701 | ||
702 | void OVersatileView::setRootIsDecorated( bool decorate ) // QListView | 702 | void OVersatileView::setRootIsDecorated( bool decorate ) // QListView |
703 | { | 703 | { |
704 | if ( !isValidViewMode( Tree ) ) | 704 | if ( !isValidViewMode( Tree ) ) |
705 | { | 705 | { |
706 | return; | 706 | return; |
707 | } | 707 | } |
708 | _listview->setRootIsDecorated( decorate ); | 708 | _listview->setRootIsDecorated( decorate ); |
709 | } | 709 | } |
710 | bool OVersatileView::rootIsDecorated() const // QListView | 710 | bool OVersatileView::rootIsDecorated() const // QListView |
711 | { | 711 | { |
712 | if ( !isValidViewMode( Tree ) ) | 712 | if ( !isValidViewMode( Tree ) ) |
713 | { | 713 | { |
714 | return false; | 714 | return false; |
715 | } | 715 | } |
716 | return _listview->rootIsDecorated(); | 716 | return _listview->rootIsDecorated(); |
717 | } | 717 | } |
718 | 718 | ||
719 | void OVersatileView::setShowSortIndicator( bool show ) // QListView | 719 | void OVersatileView::setShowSortIndicator( bool show ) // QListView |
720 | { | 720 | { |
721 | if ( !isValidViewMode( Tree ) ) | 721 | if ( !isValidViewMode( Tree ) ) |
722 | { | 722 | { |
723 | return; | 723 | return; |
724 | } | 724 | } |
725 | _listview->setShowSortIndicator( show ); | 725 | _listview->setShowSortIndicator( show ); |
726 | } | 726 | } |
727 | bool OVersatileView::showSortIndicator() const // QListView | 727 | bool OVersatileView::showSortIndicator() const // QListView |
728 | { | 728 | { |
729 | if ( !isValidViewMode( Tree ) ) | 729 | if ( !isValidViewMode( Tree ) ) |
730 | { | 730 | { |
731 | return false; | 731 | return false; |
732 | } | 732 | } |
733 | return _listview->showSortIndicator(); | 733 | return _listview->showSortIndicator(); |
734 | } | 734 | } |
735 | 735 | ||
736 | void OVersatileView::triggerUpdate() // QListView | 736 | void OVersatileView::triggerUpdate() // QListView |
737 | { | 737 | { |
738 | if ( !isValidViewMode( Tree ) ) | 738 | if ( !isValidViewMode( Tree ) ) |
739 | { | 739 | { |
740 | return; | 740 | return; |
741 | } | 741 | } |
742 | _listview->triggerUpdate(); | 742 | _listview->triggerUpdate(); |
743 | } | 743 | } |
744 | 744 | ||
745 | // | 745 | // |
746 | // only in QIconView | 746 | // only in QIconView |
747 | // | 747 | // |
748 | 748 | ||
749 | uint OVersatileView::count() const // QIconView | 749 | uint OVersatileView::count() const // QIconView |
750 | { | 750 | { |
751 | if ( !isValidViewMode( Icons ) ) | 751 | if ( !isValidViewMode( Icons ) ) |
752 | { | 752 | { |
753 | return 0; | 753 | return 0; |
754 | } | 754 | } |
755 | return _iconview->count(); | 755 | return _iconview->count(); |
756 | } | 756 | } |
757 | 757 | ||
758 | int OVersatileView::index( const OVersatileViewItem *item ) const // QIconView | 758 | int OVersatileView::index( const OVersatileViewItem *item ) const // QIconView |
759 | { | 759 | { |
760 | if ( !isValidViewMode( Icons ) ) | 760 | if ( !isValidViewMode( Icons ) ) |
761 | { | 761 | { |
762 | return -1; | 762 | return -1; |
763 | } | 763 | } |
764 | return _iconview->index( item ); | 764 | return _iconview->index( item ); |
765 | } | 765 | } |
766 | 766 | ||
767 | OVersatileViewItem* OVersatileView::firstItem() const // QIconView | 767 | OVersatileViewItem* OVersatileView::firstItem() const // QIconView |
768 | { | 768 | { |
769 | if ( !isValidViewMode( Icons ) ) | 769 | if ( !isValidViewMode( Icons ) ) |
770 | { | 770 | { |
771 | return 0; | 771 | return 0; |
772 | } | 772 | } |
773 | return static_cast<OVersatileViewItem*>( _iconview->firstItem() ); | 773 | return static_cast<OVersatileViewItem*>( _iconview->firstItem() ); |
774 | } | 774 | } |
775 | OVersatileViewItem* OVersatileView::lastItem() const // QIconView | 775 | OVersatileViewItem* OVersatileView::lastItem() const // QIconView |
776 | { | 776 | { |
777 | if ( !isValidViewMode( Icons ) ) | 777 | if ( !isValidViewMode( Icons ) ) |
778 | { | 778 | { |
779 | return 0; | 779 | return 0; |
780 | } | 780 | } |
781 | return static_cast<OVersatileViewItem*>( _iconview->lastItem() ); | 781 | return static_cast<OVersatileViewItem*>( _iconview->lastItem() ); |
782 | } | 782 | } |
783 | 783 | ||
784 | OVersatileViewItem* OVersatileView::findItem( const QPoint &pos ) const // QIconView | 784 | OVersatileViewItem* OVersatileView::findItem( const QPoint &pos ) const // QIconView |
785 | { | 785 | { |
786 | if ( !isValidViewMode( Icons ) ) | 786 | if ( !isValidViewMode( Icons ) ) |
787 | { | 787 | { |
788 | return 0; | 788 | return 0; |
789 | } | 789 | } |
790 | return static_cast<OVersatileViewItem*>( _iconview->findItem( pos ) ); | 790 | return static_cast<OVersatileViewItem*>( _iconview->findItem( pos ) ); |
791 | } | 791 | } |
792 | OVersatileViewItem* OVersatileView::findItem( const QString &text ) const // QIconView | 792 | OVersatileViewItem* OVersatileView::findItem( const QString &text ) const // QIconView |
793 | { | 793 | { |
794 | if ( !isValidViewMode( Icons ) ) | 794 | if ( !isValidViewMode( Icons ) ) |
795 | { | 795 | { |
796 | return 0; | 796 | return 0; |
797 | } | 797 | } |
798 | return static_cast<OVersatileViewItem*>( _iconview->findItem( text ) ); | 798 | return static_cast<OVersatileViewItem*>( _iconview->findItem( text ) ); |
799 | } | 799 | } |
800 | 800 | ||
801 | OVersatileViewItem* OVersatileView::findFirstVisibleItem( const QRect &r ) const // QIconView | 801 | OVersatileViewItem* OVersatileView::findFirstVisibleItem( const QRect &r ) const // QIconView |
802 | { | 802 | { |
803 | if ( !isValidViewMode( Icons ) ) | 803 | if ( !isValidViewMode( Icons ) ) |
804 | { | 804 | { |
805 | return 0; | 805 | return 0; |
806 | } | 806 | } |
807 | return static_cast<OVersatileViewItem*>( _iconview->findFirstVisibleItem( r ) ); | 807 | return static_cast<OVersatileViewItem*>( _iconview->findFirstVisibleItem( r ) ); |
808 | } | 808 | } |
809 | OVersatileViewItem* OVersatileView::findLastVisibleItem( const QRect &r ) const // QIconView | 809 | OVersatileViewItem* OVersatileView::findLastVisibleItem( const QRect &r ) const // QIconView |
810 | { | 810 | { |
811 | if ( !isValidViewMode( Icons ) ) | 811 | if ( !isValidViewMode( Icons ) ) |
812 | { | 812 | { |
813 | return 0; | 813 | return 0; |
814 | } | 814 | } |
815 | return static_cast<OVersatileViewItem*>( _iconview->findLastVisibleItem( r ) ); | 815 | return static_cast<OVersatileViewItem*>( _iconview->findLastVisibleItem( r ) ); |
816 | } | 816 | } |
817 | 817 | ||
818 | void OVersatileView::setGridX( int rx ) // QIconView | 818 | void OVersatileView::setGridX( int rx ) // QIconView |
819 | { | 819 | { |
820 | if ( !isValidViewMode( Icons ) ) | 820 | if ( !isValidViewMode( Icons ) ) |
821 | { | 821 | { |
822 | return; | 822 | return; |
823 | } | 823 | } |
824 | _iconview->setGridX( rx ); | 824 | _iconview->setGridX( rx ); |
825 | } | 825 | } |
826 | void OVersatileView::setGridY( int ry ) // QIconView | 826 | void OVersatileView::setGridY( int ry ) // QIconView |
827 | { | 827 | { |
828 | if ( !isValidViewMode( Icons ) ) | 828 | if ( !isValidViewMode( Icons ) ) |
829 | { | 829 | { |
830 | return; | 830 | return; |
831 | } | 831 | } |
832 | _iconview->setGridY( ry ); | 832 | _iconview->setGridY( ry ); |
833 | } | 833 | } |
834 | int OVersatileView::gridX() const // QIconView | 834 | int OVersatileView::gridX() const // QIconView |
835 | { | 835 | { |
836 | if ( !isValidViewMode( Icons ) ) | 836 | if ( !isValidViewMode( Icons ) ) |
837 | { | 837 | { |
838 | return -1; | 838 | return -1; |
839 | } | 839 | } |
840 | return _iconview->gridX(); | 840 | return _iconview->gridX(); |
841 | } | 841 | } |
842 | int OVersatileView::gridY() const // QIconView | 842 | int OVersatileView::gridY() const // QIconView |
843 | { | 843 | { |
844 | if ( !isValidViewMode( Icons ) ) | 844 | if ( !isValidViewMode( Icons ) ) |
845 | { | 845 | { |
846 | return -1; | 846 | return -1; |
847 | } | 847 | } |
848 | return _iconview->gridY(); | 848 | return _iconview->gridY(); |
849 | } | 849 | } |
850 | void OVersatileView::setSpacing( int sp ) // QIconView | 850 | void OVersatileView::setSpacing( int sp ) // QIconView |
851 | { | 851 | { |
852 | if ( !isValidViewMode( Icons ) ) | 852 | if ( !isValidViewMode( Icons ) ) |
853 | { | 853 | { |
854 | return; | 854 | return; |
855 | } | 855 | } |
856 | _iconview->setSpacing( sp ); | 856 | _iconview->setSpacing( sp ); |
857 | } | 857 | } |
858 | int OVersatileView::spacing() const // QIconView | 858 | int OVersatileView::spacing() const // QIconView |
859 | { | 859 | { |
860 | if ( !isValidViewMode( Icons ) ) | 860 | if ( !isValidViewMode( Icons ) ) |
861 | { | 861 | { |
862 | return -1; | 862 | return -1; |
863 | } | 863 | } |
864 | return _iconview->spacing(); | 864 | return _iconview->spacing(); |
865 | } | 865 | } |
866 | void OVersatileView::setItemTextPos( QIconView::ItemTextPos pos ) // QIconView | 866 | void OVersatileView::setItemTextPos( QIconView::ItemTextPos pos ) // QIconView |
867 | { | 867 | { |
868 | if ( !isValidViewMode( Icons ) ) | 868 | if ( !isValidViewMode( Icons ) ) |
869 | { | 869 | { |
870 | return; | 870 | return; |
871 | } | 871 | } |
872 | _iconview->setItemTextPos( pos ); | 872 | _iconview->setItemTextPos( pos ); |
873 | } | 873 | } |
874 | QIconView::ItemTextPos OVersatileView::itemTextPos() const // QIconView | 874 | QIconView::ItemTextPos OVersatileView::itemTextPos() const // QIconView |
875 | { | 875 | { |
876 | if ( !isValidViewMode( Icons ) ) | 876 | if ( !isValidViewMode( Icons ) ) |
877 | { | 877 | { |
878 | return (QIconView::ItemTextPos) -1; | 878 | return (QIconView::ItemTextPos) -1; |
879 | } | 879 | } |
880 | return _iconview->itemTextPos(); | 880 | return _iconview->itemTextPos(); |
881 | } | 881 | } |
882 | void OVersatileView::setItemTextBackground( const QBrush &b ) // QIconView | 882 | void OVersatileView::setItemTextBackground( const QBrush &b ) // QIconView |
883 | { | 883 | { |
884 | if ( !isValidViewMode( Icons ) ) | 884 | if ( !isValidViewMode( Icons ) ) |
885 | { | 885 | { |
886 | return; | 886 | return; |
887 | } | 887 | } |
888 | _iconview->setItemTextBackground( b ); | 888 | _iconview->setItemTextBackground( b ); |
889 | } | 889 | } |
890 | QBrush OVersatileView::itemTextBackground() const // QIconView | 890 | QBrush OVersatileView::itemTextBackground() const // QIconView |
891 | { | 891 | { |
892 | if ( !isValidViewMode( Icons ) ) | 892 | if ( !isValidViewMode( Icons ) ) |
893 | { | 893 | { |
894 | return QBrush(); | 894 | return QBrush(); |
895 | } | 895 | } |
896 | return _iconview->itemTextBackground(); | 896 | return _iconview->itemTextBackground(); |
897 | } | 897 | } |
898 | void OVersatileView::setArrangement( QIconView::Arrangement am ) // QIconView | 898 | void OVersatileView::setArrangement( QIconView::Arrangement am ) // QIconView |
899 | { | 899 | { |
900 | if ( !isValidViewMode( Icons ) ) | 900 | if ( !isValidViewMode( Icons ) ) |
901 | { | 901 | { |
902 | return; | 902 | return; |
903 | } | 903 | } |
904 | _iconview->setArrangement( am ); | 904 | _iconview->setArrangement( am ); |
905 | } | 905 | } |
906 | QIconView::Arrangement OVersatileView::arrangement() const // QIconView | 906 | QIconView::Arrangement OVersatileView::arrangement() const // QIconView |
907 | { | 907 | { |
908 | if ( !isValidViewMode( Icons ) ) | 908 | if ( !isValidViewMode( Icons ) ) |
909 | { | 909 | { |
910 | return (QIconView::Arrangement) -1; | 910 | return (QIconView::Arrangement) -1; |
911 | } | 911 | } |
912 | return _iconview->arrangement(); | 912 | return _iconview->arrangement(); |
913 | } | 913 | } |
914 | void OVersatileView::setResizeMode( QIconView::ResizeMode am ) // QIconView | 914 | void OVersatileView::setResizeMode( QIconView::ResizeMode am ) // QIconView |
915 | { | 915 | { |
916 | if ( !isValidViewMode( Icons ) ) | 916 | if ( !isValidViewMode( Icons ) ) |
917 | { | 917 | { |
918 | return; | 918 | return; |
919 | } | 919 | } |
920 | _iconview->setResizeMode( am ); | 920 | _iconview->setResizeMode( am ); |
921 | } | 921 | } |
922 | QIconView::ResizeMode OVersatileView::resizeMode() const // QIconView | 922 | QIconView::ResizeMode OVersatileView::resizeMode() const // QIconView |
923 | { | 923 | { |
924 | if ( !isValidViewMode( Icons ) ) | 924 | if ( !isValidViewMode( Icons ) ) |
925 | { | 925 | { |
926 | return (QIconView::ResizeMode) -1; | 926 | return (QIconView::ResizeMode) -1; |
927 | } | 927 | } |
928 | return _iconview->resizeMode(); | 928 | return _iconview->resizeMode(); |
929 | } | 929 | } |
930 | void OVersatileView::setMaxItemWidth( int w ) // QIconView | 930 | void OVersatileView::setMaxItemWidth( int w ) // QIconView |
931 | { | 931 | { |
932 | if ( !isValidViewMode( Icons ) ) | 932 | if ( !isValidViewMode( Icons ) ) |
933 | { | 933 | { |
934 | return; | 934 | return; |
935 | } | 935 | } |
936 | _iconview->setMaxItemWidth( w ); | 936 | _iconview->setMaxItemWidth( w ); |
937 | } | 937 | } |
938 | int OVersatileView::maxItemWidth() const // QIconView | 938 | int OVersatileView::maxItemWidth() const // QIconView |
939 | { | 939 | { |
940 | if ( !isValidViewMode( Icons ) ) | 940 | if ( !isValidViewMode( Icons ) ) |
941 | { | 941 | { |
942 | return -1; | 942 | return -1; |
943 | } | 943 | } |
944 | return _iconview->maxItemWidth(); | 944 | return _iconview->maxItemWidth(); |
945 | } | 945 | } |
946 | void OVersatileView::setMaxItemTextLength( int w ) // QIconView | 946 | void OVersatileView::setMaxItemTextLength( int w ) // QIconView |
947 | { | 947 | { |
948 | if ( !isValidViewMode( Icons ) ) | 948 | if ( !isValidViewMode( Icons ) ) |
949 | { | 949 | { |
950 | return; | 950 | return; |
951 | } | 951 | } |
952 | _iconview->setMaxItemTextLength( w ); | 952 | _iconview->setMaxItemTextLength( w ); |
953 | } | 953 | } |
954 | int OVersatileView::maxItemTextLength() const // QIconView | 954 | int OVersatileView::maxItemTextLength() const // QIconView |
955 | { | 955 | { |
956 | if ( !isValidViewMode( Icons ) ) | 956 | if ( !isValidViewMode( Icons ) ) |
957 | { | 957 | { |
958 | return -1; | 958 | return -1; |
959 | } | 959 | } |
960 | return _iconview->maxItemTextLength(); | 960 | return _iconview->maxItemTextLength(); |
961 | } | 961 | } |
962 | void OVersatileView::setAutoArrange( bool b ) // QIconView | 962 | void OVersatileView::setAutoArrange( bool b ) // QIconView |
963 | { | 963 | { |
964 | if ( !isValidViewMode( Icons ) ) | 964 | if ( !isValidViewMode( Icons ) ) |
965 | { | 965 | { |
966 | return; | 966 | return; |
967 | } | 967 | } |
968 | _iconview->setAutoArrange( b ); | 968 | _iconview->setAutoArrange( b ); |
969 | } | 969 | } |
970 | bool OVersatileView::autoArrange() const // QIconView | 970 | bool OVersatileView::autoArrange() const // QIconView |
971 | { | 971 | { |
972 | if ( !isValidViewMode( Icons ) ) | 972 | if ( !isValidViewMode( Icons ) ) |
973 | { | 973 | { |
974 | return false; | 974 | return false; |
975 | } | 975 | } |
976 | return _iconview->autoArrange(); | 976 | return _iconview->autoArrange(); |
977 | } | 977 | } |
978 | void OVersatileView::setShowToolTips( bool b ) // QIconView | 978 | void OVersatileView::setShowToolTips( bool b ) // QIconView |
979 | { | 979 | { |
980 | if ( !isValidViewMode( Icons ) ) | 980 | if ( !isValidViewMode( Icons ) ) |
981 | { | 981 | { |
982 | return; | 982 | return; |
983 | } | 983 | } |
984 | _iconview->setShowToolTips( b ); | 984 | _iconview->setShowToolTips( b ); |
985 | } | 985 | } |
986 | bool OVersatileView::showToolTips() const // QIconView | 986 | bool OVersatileView::showToolTips() const // QIconView |
987 | { | 987 | { |
988 | if ( !isValidViewMode( Icons ) ) | 988 | if ( !isValidViewMode( Icons ) ) |
989 | { | 989 | { |
990 | return false; | 990 | return false; |
991 | } | 991 | } |
992 | return _iconview->showToolTips(); | 992 | return _iconview->showToolTips(); |
993 | } | 993 | } |
994 | 994 | ||
995 | bool OVersatileView::sorting() const // QIconView | 995 | bool OVersatileView::sorting() const // QIconView |
996 | { | 996 | { |
997 | if ( !isValidViewMode( Icons ) ) | 997 | if ( !isValidViewMode( Icons ) ) |
998 | { | 998 | { |
999 | return false; | 999 | return false; |
1000 | } | 1000 | } |
1001 | return _iconview->sorting(); | 1001 | return _iconview->sorting(); |
1002 | } | 1002 | } |
1003 | bool OVersatileView::sortDirection() const // QIconView | 1003 | bool OVersatileView::sortDirection() const // QIconView |
1004 | { | 1004 | { |
1005 | if ( !isValidViewMode( Icons ) ) | 1005 | if ( !isValidViewMode( Icons ) ) |
1006 | { | 1006 | { |
1007 | return false; | 1007 | return false; |
1008 | } | 1008 | } |
1009 | return _iconview->sortDirection(); | 1009 | return _iconview->sortDirection(); |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | void OVersatileView::setItemsMovable( bool b ) // QIconView | 1012 | void OVersatileView::setItemsMovable( bool b ) // QIconView |
1013 | { | 1013 | { |
1014 | if ( !isValidViewMode( Icons ) ) | 1014 | if ( !isValidViewMode( Icons ) ) |
1015 | { | 1015 | { |
1016 | return; | 1016 | return; |
1017 | } | 1017 | } |
1018 | _iconview->setItemsMovable( b ); | 1018 | _iconview->setItemsMovable( b ); |
1019 | } | 1019 | } |
1020 | bool OVersatileView::itemsMovable() const // QIconView | 1020 | bool OVersatileView::itemsMovable() const // QIconView |
1021 | { | 1021 | { |
1022 | if ( !isValidViewMode( Icons ) ) | 1022 | if ( !isValidViewMode( Icons ) ) |
1023 | { | 1023 | { |
1024 | return false; | 1024 | return false; |
1025 | } | 1025 | } |
1026 | return _iconview->itemsMovable(); | 1026 | return _iconview->itemsMovable(); |
1027 | } | 1027 | } |
1028 | void OVersatileView::setWordWrapIconText( bool b ) // QIconView | 1028 | void OVersatileView::setWordWrapIconText( bool b ) // QIconView |
1029 | { | 1029 | { |
1030 | if ( !isValidViewMode( Icons ) ) | 1030 | if ( !isValidViewMode( Icons ) ) |
1031 | { | 1031 | { |
1032 | return; | 1032 | return; |
1033 | } | 1033 | } |
1034 | _iconview->setWordWrapIconText( b ); | 1034 | _iconview->setWordWrapIconText( b ); |
1035 | } | 1035 | } |
1036 | bool OVersatileView::wordWrapIconText() const // QIconView | 1036 | bool OVersatileView::wordWrapIconText() const // QIconView |
1037 | { | 1037 | { |
1038 | if ( !isValidViewMode( Icons ) ) | 1038 | if ( !isValidViewMode( Icons ) ) |
1039 | { | 1039 | { |
1040 | return false; | 1040 | return false; |
1041 | } | 1041 | } |
1042 | return _iconview->wordWrapIconText(); | 1042 | return _iconview->wordWrapIconText(); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | void OVersatileView::arrangeItemsInGrid( const QSize &grid, bool update ) // QIconView | 1045 | void OVersatileView::arrangeItemsInGrid( const QSize &grid, bool update ) // QIconView |
1046 | { | 1046 | { |
1047 | if ( !isValidViewMode( Icons ) ) | 1047 | if ( !isValidViewMode( Icons ) ) |
1048 | { | 1048 | { |
1049 | return; | 1049 | return; |
1050 | } | 1050 | } |
1051 | _iconview->arrangeItemsInGrid( grid, update ); | 1051 | _iconview->arrangeItemsInGrid( grid, update ); |
1052 | } | 1052 | } |
1053 | void OVersatileView::arrangeItemsInGrid( bool update ) // QIconView | 1053 | void OVersatileView::arrangeItemsInGrid( bool update ) // QIconView |
1054 | { | 1054 | { |
1055 | if ( !isValidViewMode( Icons ) ) | 1055 | if ( !isValidViewMode( Icons ) ) |
1056 | { | 1056 | { |
1057 | return; | 1057 | return; |
1058 | } | 1058 | } |
1059 | _iconview->arrangeItemsInGrid( update ); | 1059 | _iconview->arrangeItemsInGrid( update ); |
1060 | } | 1060 | } |
1061 | void OVersatileView::updateContents() // QIconView | 1061 | void OVersatileView::updateContents() // QIconView |
1062 | { | 1062 | { |
1063 | if ( !isValidViewMode( Icons ) ) | 1063 | if ( !isValidViewMode( Icons ) ) |
1064 | { | 1064 | { |
1065 | return; | 1065 | return; |
1066 | } | 1066 | } |
1067 | _iconview->updateContents(); | 1067 | _iconview->updateContents(); |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | //==============================================================================================// | 1070 | //==============================================================================================// |
1071 | // OVersatileView Case II - QListView / QIconView common API | 1071 | // OVersatileView Case II - QListView / QIconView common API |
1072 | //==============================================================================================// | 1072 | //==============================================================================================// |
1073 | 1073 | ||
1074 | void OVersatileView::clear() | 1074 | void OVersatileView::clear() |
1075 | { | 1075 | { |
1076 | _iconview->clear(); | 1076 | _iconview->clear(); |
1077 | _listview->clear(); | 1077 | _listview->clear(); |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | void OVersatileView::setFont( const QFont & font ) | 1080 | void OVersatileView::setFont( const QFont & font ) |
1081 | { | 1081 | { |
1082 | _iconview->setFont( font ); | 1082 | _iconview->setFont( font ); |
1083 | _listview->setFont( font ); | 1083 | _listview->setFont( font ); |
1084 | } | 1084 | } |
1085 | void OVersatileView::setPalette( const QPalette & palette ) | 1085 | void OVersatileView::setPalette( const QPalette & palette ) |
1086 | { | 1086 | { |
1087 | _iconview->setPalette( palette ); | 1087 | _iconview->setPalette( palette ); |
1088 | _listview->setPalette( palette ); | 1088 | _listview->setPalette( palette ); |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | void OVersatileView::takeItem( OVersatileViewItem * item ) | 1091 | void OVersatileView::takeItem( OVersatileViewItem * item ) |
1092 | { | 1092 | { |
1093 | _iconview->takeItem( item ); | 1093 | _iconview->takeItem( item ); |
1094 | _listview->takeItem( item ); | 1094 | _listview->takeItem( item ); |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | void OVersatileView::setSelectionMode( SelectionMode mode ) | 1097 | void OVersatileView::setSelectionMode( SelectionMode mode ) |
1098 | { | 1098 | { |
1099 | _iconview->setSelectionMode( (QIconView::SelectionMode) mode ); | 1099 | _iconview->setSelectionMode( (QIconView::SelectionMode) mode ); |
1100 | _listview->setSelectionMode( (QListView::SelectionMode) mode ); | 1100 | _listview->setSelectionMode( (QListView::SelectionMode) mode ); |
1101 | } | 1101 | } |
1102 | OVersatileView::SelectionMode OVersatileView::selectionMode() const | 1102 | OVersatileView::SelectionMode OVersatileView::selectionMode() const |
1103 | { | 1103 | { |
1104 | return (OVersatileView::SelectionMode) _iconview->selectionMode(); | 1104 | return (OVersatileView::SelectionMode) _iconview->selectionMode(); |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | void OVersatileView::selectAll( bool select ) | 1107 | void OVersatileView::selectAll( bool select ) |
1108 | { | 1108 | { |
1109 | _iconview->selectAll( select ); | 1109 | _iconview->selectAll( select ); |
1110 | } | 1110 | } |
1111 | void OVersatileView::clearSelection() | 1111 | void OVersatileView::clearSelection() |
1112 | { | 1112 | { |
1113 | _iconview->clearSelection(); | 1113 | _iconview->clearSelection(); |
1114 | _listview->clearSelection(); | 1114 | _listview->clearSelection(); |
1115 | } | 1115 | } |
1116 | void OVersatileView::invertSelection() | 1116 | void OVersatileView::invertSelection() |
1117 | { | 1117 | { |
1118 | _iconview->invertSelection(); | 1118 | _iconview->invertSelection(); |
1119 | _listview->invertSelection(); | 1119 | _listview->invertSelection(); |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | void OVersatileView::ensureItemVisible( const OVersatileViewItem * item ) | 1122 | void OVersatileView::ensureItemVisible( const OVersatileViewItem * item ) |
1123 | { | 1123 | { |
1124 | _iconview->ensureItemVisible( const_cast<OVersatileViewItem*>( item ) ); | 1124 | _iconview->ensureItemVisible( const_cast<OVersatileViewItem*>( item ) ); |
1125 | _listview->ensureItemVisible( item ); | 1125 | _listview->ensureItemVisible( item ); |
1126 | } | 1126 | } |
1127 | void OVersatileView::repaintItem( const OVersatileViewItem * item ) const | 1127 | void OVersatileView::repaintItem( const OVersatileViewItem * item ) const |
1128 | { | 1128 | { |
1129 | _iconview->repaintItem( const_cast<OVersatileViewItem*>( item ) ); | 1129 | _iconview->repaintItem( const_cast<OVersatileViewItem*>( item ) ); |
1130 | _listview->repaintItem( item ); | 1130 | _listview->repaintItem( item ); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | void OVersatileView::setCurrentItem( OVersatileViewItem * item ) | 1133 | void OVersatileView::setCurrentItem( OVersatileViewItem * item ) |
1134 | { | 1134 | { |
1135 | _iconview->setCurrentItem( item ); | 1135 | _iconview->setCurrentItem( item ); |
1136 | _listview->setCurrentItem( item ); | 1136 | _listview->setCurrentItem( item ); |
1137 | } | 1137 | } |
1138 | OVersatileViewItem * OVersatileView::currentItem() const | 1138 | OVersatileViewItem * OVersatileView::currentItem() const |
1139 | { | 1139 | { |
1140 | return static_cast<OVersatileViewItem*>( _listview->currentItem() ); | 1140 | return static_cast<OVersatileViewItem*>( _listview->currentItem() ); |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | // bool eventFilter( QObject * o, QEvent * ) // use QWidgetStack implementation | 1143 | // bool eventFilter( QObject * o, QEvent * ) // use QWidgetStack implementation |
1144 | 1144 | ||
1145 | // QSize minimumSizeHint() const // use QWidgetStack implementation | 1145 | // QSize minimumSizeHint() const // use QWidgetStack implementation |
1146 | // QSizePolicy sizePolicy() const // use QWidgetStack implementation | 1146 | // QSizePolicy sizePolicy() const // use QWidgetStack implementation |
1147 | // QSize sizeHint() const // use QWidgetStack implementation | 1147 | // QSize sizeHint() const // use QWidgetStack implementation |
1148 | 1148 | ||
1149 | //==============================================================================================// | 1149 | //==============================================================================================// |
1150 | // OVersatileView Case III - APIs which differ slightly | 1150 | // OVersatileView Case III - APIs which differ slightly |
1151 | //==============================================================================================// | 1151 | //==============================================================================================// |
1152 | 1152 | ||
1153 | /* | 1153 | /* |
1154 | 1154 | ||
1155 | void OVersatileView::insertItem( OVersatileViewItem * ) // QListView | 1155 | void OVersatileView::insertItem( OVersatileViewItem * ) // QListView |
1156 | void OVersatileView::insertItem( OVersatileViewItem *item, OVersatileViewItem *after = 0L ) // QIconView | 1156 | void OVersatileView::insertItem( OVersatileViewItem *item, OVersatileViewItem *after = 0L ) // QIconView |
1157 | 1157 | ||
1158 | void OVersatileView::setSelected( OVersatileViewItem *, bool ) // QListView | 1158 | void OVersatileView::setSelected( OVersatileViewItem *, bool ) // QListView |
1159 | void OVersatileView::setSelected( OVersatileViewItem *item, bool s, bool cb = FALSE ) // QIconView | 1159 | void OVersatileView::setSelected( OVersatileViewItem *item, bool s, bool cb = FALSE ) // QIconView |
1160 | 1160 | ||
1161 | void OVersatileView::setSorting( int column, bool increasing = TRUE ) // QListView | 1161 | void OVersatileView::setSorting( int column, bool increasing = TRUE ) // QListView |
1162 | void OVersatileView::setSorting( bool sort, bool ascending = TRUE ) // QIconView | 1162 | void OVersatileView::setSorting( bool sort, bool ascending = TRUE ) // QIconView |
1163 | 1163 | ||
1164 | void OVersatileView::sort() // #### make in next major release // QListView | 1164 | void OVersatileView::sort() // #### make in next major release // QListView |
1165 | void OVersatileView::sort( bool ascending = TRUE ) // QIconView | 1165 | void OVersatileView::sort( bool ascending = TRUE ) // QIconView |
1166 | 1166 | ||
1167 | */ | 1167 | */ |
1168 | 1168 | ||
1169 | 1169 | ||