-rw-r--r-- | library/backend/categories.h | 1 | ||||
-rw-r--r-- | library/global.cpp | 49 | ||||
-rw-r--r-- | library/global.h | 6 | ||||
-rw-r--r-- | library/library.pro | 2 | ||||
-rw-r--r-- | library/locationcombo.cpp | 295 | ||||
-rw-r--r-- | library/locationcombo.h | 88 | ||||
-rw-r--r-- | library/qlibrary_unix.cpp | 4 | ||||
-rw-r--r-- | library/timestring.cpp | 243 | ||||
-rw-r--r-- | library/timestring.h | 84 |
9 files changed, 672 insertions, 100 deletions
diff --git a/library/backend/categories.h b/library/backend/categories.h index 91c93e7..6be3bc0 100644 --- a/library/backend/categories.h +++ b/library/backend/categories.h | |||
@@ -32,4 +32,5 @@ | |||
32 | 32 | ||
33 | class CategoryGroup; | 33 | class CategoryGroup; |
34 | QString categoryFileName(); | ||
34 | 35 | ||
35 | #if defined(QPC_TEMPLATEDLL) | 36 | #if defined(QPC_TEMPLATEDLL) |
diff --git a/library/global.cpp b/library/global.cpp index ec87555..f7a0767 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -809,4 +809,53 @@ QStringList Global::helpPath() | |||
809 | } | 809 | } |
810 | 810 | ||
811 | /*! | ||
812 | \internal | ||
813 | Truncate file to size specified | ||
814 | \a f must be an open file | ||
815 | \a size must be a positive value | ||
816 | */ | ||
817 | bool Global::truncateFile(QFile &f, int size){ | ||
818 | if (!f.isOpen()) | ||
819 | return FALSE; | ||
820 | |||
821 | return ::ftruncate(f.handle(), size) != -1; | ||
822 | } | ||
823 | |||
824 | |||
825 | |||
826 | |||
827 | // #if defined(Q_OS_UNIX) && defined(Q_WS_QWS) | ||
828 | // extern int qws_display_id; | ||
829 | // #endif | ||
830 | |||
831 | /*! | ||
832 | /internal | ||
833 | Returns the default system path for storing temporary files. | ||
834 | Note: This does not it ensure that the provided directory exists | ||
835 | */ | ||
836 | QString Global::tempDir() | ||
837 | { | ||
838 | QString result; | ||
839 | #ifdef Q_OS_UNIX | ||
840 | #ifdef Q_WS_QWS | ||
841 | result = QString("/tmp/qtopia-%1/").arg(QString::number(qws_display_id)); | ||
842 | #else | ||
843 | result="/tmp/"; | ||
844 | #endif | ||
845 | #else | ||
846 | if (getenv("TEMP")) | ||
847 | result = getenv("TEMP"); | ||
848 | else | ||
849 | result = getenv("TMP"); | ||
850 | |||
851 | if (result[(int)result.length() - 1] != QDir::separator()) | ||
852 | result.append(QDir::separator()); | ||
853 | #endif | ||
854 | |||
855 | return result; | ||
856 | } | ||
857 | |||
858 | //#endif | ||
859 | |||
811 | 860 | ||
812 | #include "global.moc" | 861 | #include "global.moc" |
diff --git a/library/global.h b/library/global.h index 1136b12..f32c498 100644 --- a/library/global.h +++ b/library/global.h | |||
@@ -28,5 +28,5 @@ class QWidget; | |||
28 | class AppLnk; | 28 | class AppLnk; |
29 | class DocLnkSet; | 29 | class DocLnkSet; |
30 | 30 | class QFile; | |
31 | class Global | 31 | class Global |
32 | { | 32 | { |
@@ -81,4 +81,8 @@ public: | |||
81 | static QStringList helpPath(); | 81 | static QStringList helpPath(); |
82 | #endif | 82 | #endif |
83 | //#ifdef QTOPIA_INTERNAL_FILEOPERATIONS | ||
84 | static bool truncateFile(QFile &f, int size); | ||
85 | static QString tempDir( ); | ||
86 | //#endif | ||
83 | 87 | ||
84 | private: | 88 | private: |
diff --git a/library/library.pro b/library/library.pro index 7143454..4142529 100644 --- a/library/library.pro +++ b/library/library.pro | |||
@@ -60,4 +60,5 @@ HEADERS = calendar.h \ | |||
60 | textcodecinterface.h \ | 60 | textcodecinterface.h \ |
61 | imagecodecinterface.h \ | 61 | imagecodecinterface.h \ |
62 | locationcombo.h \ | ||
62 | qpeglobal.h | 63 | qpeglobal.h |
63 | 64 | ||
@@ -117,4 +118,5 @@ SOURCES = calendar.cpp \ | |||
117 | finddialog.cpp \ | 118 | finddialog.cpp \ |
118 | lnkproperties.cpp \ | 119 | lnkproperties.cpp \ |
120 | locationcombo.cpp \ | ||
119 | widget_showing.cpp | 121 | widget_showing.cpp |
120 | 122 | ||
diff --git a/library/locationcombo.cpp b/library/locationcombo.cpp new file mode 100644 index 0000000..31429f5 --- a/dev/null +++ b/library/locationcombo.cpp | |||
@@ -0,0 +1,295 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2006 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This program is free software; you can redistribute it and/or modify it | ||
7 | ** under the terms of the GNU General Public License as published by the | ||
8 | ** Free Software Foundation; either version 2 of the License, or (at your | ||
9 | ** option) any later version. | ||
10 | ** | ||
11 | ** A copy of the GNU GPL license version 2 is included in this package as | ||
12 | ** LICENSE.GPL. | ||
13 | ** | ||
14 | ** This program is distributed in the hope that it will be useful, but | ||
15 | ** WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | ** See the GNU General Public License for more details. | ||
18 | ** | ||
19 | ** In addition, as a special exception Trolltech gives permission to link | ||
20 | ** the code of this program with Qtopia applications copyrighted, developed | ||
21 | ** and distributed by Trolltech under the terms of the Qtopia Personal Use | ||
22 | ** License Agreement. You must comply with the GNU General Public License | ||
23 | ** in all respects for all of the code used other than the applications | ||
24 | ** licensed under the Qtopia Personal Use License Agreement. If you modify | ||
25 | ** this file, you may extend this exception to your version of the file, | ||
26 | ** but you are not obligated to do so. If you do not wish to do so, delete | ||
27 | ** this exception statement from your version. | ||
28 | ** | ||
29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
30 | ** | ||
31 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
32 | ** not clear to you. | ||
33 | ** | ||
34 | **********************************************************************/ | ||
35 | |||
36 | #include "locationcombo.h" | ||
37 | |||
38 | #include <qpe/ir.h> | ||
39 | #include <qpe/applnk.h> | ||
40 | #include <qpe/global.h> | ||
41 | #include <qpe/categorywidget.h> | ||
42 | #include <qpe/categoryselect.h> | ||
43 | #ifdef QWS | ||
44 | #include <qpe/qcopenvelope_qws.h> | ||
45 | #endif | ||
46 | #include <qpe/filemanager.h> | ||
47 | #include <qpe/config.h> | ||
48 | #include <qpe/storage.h> | ||
49 | #include <qpe/global.h> | ||
50 | #include <qtopia/qpemessagebox.h> | ||
51 | |||
52 | #include <qlineedit.h> | ||
53 | #include <qtoolbutton.h> | ||
54 | #include <qpushbutton.h> | ||
55 | #include <qgroupbox.h> | ||
56 | #include <qcheckbox.h> | ||
57 | #include <qlabel.h> | ||
58 | #include <qlayout.h> | ||
59 | #include <qfile.h> | ||
60 | #include <qdir.h> | ||
61 | #include <qfileinfo.h> | ||
62 | #include <qmessagebox.h> | ||
63 | #include <qsize.h> | ||
64 | #include <qcombobox.h> | ||
65 | #include <qregexp.h> | ||
66 | |||
67 | #include <qradiobutton.h> | ||
68 | #include <qlayout.h> | ||
69 | |||
70 | #include <stdlib.h> | ||
71 | |||
72 | /*! | ||
73 | \class LocationCombo locationcombo.h | ||
74 | \brief The LocationCombo class displays a list of available storage | ||
75 | locations. | ||
76 | |||
77 | First availability: Qtopia 1.6 | ||
78 | |||
79 | \ingroup qtopiaemb | ||
80 | \sa DocPropertiesDialog | ||
81 | */ | ||
82 | |||
83 | |||
84 | class LocationComboPrivate | ||
85 | { | ||
86 | public: | ||
87 | LocationComboPrivate() : homeLocation(-1), fileSize(0), listEmpty(TRUE) {} | ||
88 | QString originalPath; | ||
89 | int homeLocation; | ||
90 | int fileSize; | ||
91 | bool listEmpty; | ||
92 | }; | ||
93 | |||
94 | /*! | ||
95 | Constructs a LocationCombo with parent \a parent and name \a name. | ||
96 | */ | ||
97 | LocationCombo::LocationCombo( QWidget *parent, const char *name ) | ||
98 | : QComboBox( FALSE, parent, name ) | ||
99 | { | ||
100 | storage = new StorageInfo; | ||
101 | d = new LocationComboPrivate; | ||
102 | setLocation( 0 ); | ||
103 | connect( this, SIGNAL(activated(int)), this, SIGNAL(newPath()) ); | ||
104 | connect( storage, SIGNAL(disksChanged()), this, SLOT(updatePaths()) ); | ||
105 | } | ||
106 | |||
107 | /*! | ||
108 | Constructs a LocationCombo with parent \a parent and name \a name. | ||
109 | \a lnk is pointer to an existing AppLnk. | ||
110 | */ | ||
111 | LocationCombo::LocationCombo( const AppLnk * lnk, QWidget *parent, const char *name ) | ||
112 | : QComboBox( FALSE, parent, name ) | ||
113 | { | ||
114 | storage = new StorageInfo; | ||
115 | d = new LocationComboPrivate; | ||
116 | setLocation(lnk); | ||
117 | connect( this, SIGNAL(activated(int)), this, SIGNAL(newPath()) ); | ||
118 | connect( storage, SIGNAL(disksChanged()), this, SLOT(updatePaths()) ); | ||
119 | } | ||
120 | |||
121 | /*! | ||
122 | Destroys the widget. | ||
123 | */ | ||
124 | LocationCombo::~LocationCombo() | ||
125 | { | ||
126 | delete storage; | ||
127 | delete d; | ||
128 | } | ||
129 | |||
130 | /*! | ||
131 | Sets the display of the LocationCombo to the location associated with the | ||
132 | AppLnk \a lnk. | ||
133 | */ | ||
134 | void LocationCombo::setLocation( const AppLnk * lnk ) | ||
135 | { | ||
136 | // NB: setLocation(const QString) assumes only lnk->file() is used. | ||
137 | |||
138 | if ( lnk ) { | ||
139 | QFileInfo fi( lnk->file() ); | ||
140 | d->fileSize = fi.size(); | ||
141 | const FileSystem *fs = storage->fileSystemOf( lnk->file() ); | ||
142 | d->originalPath = fs ? fs->path() : QString::null; | ||
143 | } else { | ||
144 | d->fileSize = 0; | ||
145 | d->originalPath = QString::null; | ||
146 | } | ||
147 | |||
148 | setupCombo(); | ||
149 | |||
150 | int currentLocation = -1; | ||
151 | if ( lnk ) { | ||
152 | int n = locations.count(); | ||
153 | for ( int i = 0; i < n; i++ ) { | ||
154 | if ( lnk->file().contains( locations[i] ) ) | ||
155 | currentLocation = i; | ||
156 | } | ||
157 | } | ||
158 | if ( currentLocation == -1 ) | ||
159 | currentLocation = 0; //default to the first one | ||
160 | |||
161 | setCurrentItem( currentLocation ); | ||
162 | } | ||
163 | |||
164 | /*! | ||
165 | \internal | ||
166 | */ | ||
167 | void LocationCombo::setupCombo() | ||
168 | { | ||
169 | clear(); | ||
170 | locations.clear(); | ||
171 | |||
172 | const QList<FileSystem> &fs = storage->fileSystems(); | ||
173 | QListIterator<FileSystem> it ( fs ); | ||
174 | QString s; | ||
175 | QString homeDir = QDir::homeDirPath(); | ||
176 | QString homeFs; | ||
177 | QString homeFsPath; | ||
178 | int index = 0; | ||
179 | for ( ; it.current(); ++it ) { | ||
180 | // we add 10k to the file size so we are sure we can also save the desktop file | ||
181 | if ( !d->fileSize || (*it)->path() == d->originalPath || | ||
182 | (ulong)(*it)->availBlocks() * (ulong)(*it)->blockSize() | ||
183 | > (ulong)d->fileSize + 10000 ) | ||
184 | { | ||
185 | if ( (*it)->isRemovable() ) { | ||
186 | insertItem( (*it)->name(), index ); | ||
187 | locations.append( (*it)->path() ); | ||
188 | index++; | ||
189 | } else if ( homeDir.contains( (*it)->path() ) && | ||
190 | (*it)->path().length() > homeFsPath.length() ) { | ||
191 | homeFs = (*it)->name(); | ||
192 | homeFsPath = (*it)->path(); | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | |||
197 | // $HOME is *somewhere*, but not shown in Storage::fileSystems(), | ||
198 | // eg. because it's mounted in some unexpected way. | ||
199 | if ( homeFsPath.isEmpty() ) { | ||
200 | homeFs = StorageInfo::tr("Internal Storage"); | ||
201 | homeFsPath = homeDir; | ||
202 | } | ||
203 | |||
204 | if ( !homeFsPath.isEmpty() ) { | ||
205 | d->homeLocation = 0; | ||
206 | insertItem( homeFs, d->homeLocation ); | ||
207 | locations.prepend( homeDir ); | ||
208 | } else { | ||
209 | d->homeLocation = -1; | ||
210 | } | ||
211 | |||
212 | d->listEmpty = locations.count() == 0; | ||
213 | if ( d->listEmpty ) { | ||
214 | insertItem( tr("No FileSystems Available!"), 0 ); | ||
215 | locations.append( "" ); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | /*! | ||
220 | \internal | ||
221 | */ | ||
222 | void LocationCombo::updatePaths() | ||
223 | { | ||
224 | QString oldPath = locations[currentItem()]; | ||
225 | |||
226 | setupCombo(); | ||
227 | |||
228 | int currentLocation = 0; | ||
229 | int n = locations.count(); | ||
230 | for ( int i = 0; i < n; i++ ) { | ||
231 | if ( oldPath == locations[i] ) { | ||
232 | currentLocation = i; | ||
233 | } | ||
234 | } | ||
235 | setCurrentItem( currentLocation ); | ||
236 | if ( locations[currentItem()] != oldPath ) | ||
237 | emit newPath(); | ||
238 | } | ||
239 | |||
240 | /*! | ||
241 | Returns TRUE to indicate that the user has changed the location displayed | ||
242 | by the LocationCombo. Most useful when the LocationCombo is part of a | ||
243 | dialog; when the dialog is accept()ed, LocationCombo::isChanged() can be | ||
244 | examined to check for a change of location. | ||
245 | */ | ||
246 | bool LocationCombo::isChanged() const | ||
247 | { | ||
248 | if ( const FileSystem *fs = storage->fileSystemOf(locations[currentItem()]) ) | ||
249 | return fs->path() != d->originalPath; | ||
250 | |||
251 | return TRUE; | ||
252 | } | ||
253 | |||
254 | /*! | ||
255 | Returns the default (home) location for the file associated with this | ||
256 | LocationCombo. | ||
257 | */ | ||
258 | QString LocationCombo::installationPath() const | ||
259 | { | ||
260 | return currentItem() == d->homeLocation ? | ||
261 | QString("/") : locations[ currentItem() ]+"/"; | ||
262 | } | ||
263 | |||
264 | /*! | ||
265 | Returns the document path associated with this LocationCombo. This | ||
266 | will be "\<path\>/Documents". | ||
267 | */ | ||
268 | QString LocationCombo::documentPath() const | ||
269 | { | ||
270 | return locations[ currentItem() ]+"/Documents/"; | ||
271 | } | ||
272 | |||
273 | /*! | ||
274 | Returns a pointer to FileSystem object, associated with the current | ||
275 | selection of the LocationCombo. | ||
276 | */ | ||
277 | const FileSystem *LocationCombo::fileSystem() const | ||
278 | { | ||
279 | if ( d->listEmpty ) | ||
280 | return 0; | ||
281 | return storage->fileSystemOf( locations[ currentItem() ] ); | ||
282 | } | ||
283 | |||
284 | /*! | ||
285 | \fn LocationCombo::newPath() | ||
286 | Emitted when the LocationCombo changes to a new location. | ||
287 | */ | ||
288 | |||
289 | |||
290 | #if 0 | ||
291 | void LocationCombo::apply() | ||
292 | { | ||
293 | } | ||
294 | #endif | ||
295 | |||
diff --git a/library/locationcombo.h b/library/locationcombo.h new file mode 100644 index 0000000..fab3dfc --- a/dev/null +++ b/library/locationcombo.h | |||
@@ -0,0 +1,88 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2006 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This program is free software; you can redistribute it and/or modify it | ||
7 | ** under the terms of the GNU General Public License as published by the | ||
8 | ** Free Software Foundation; either version 2 of the License, or (at your | ||
9 | ** option) any later version. | ||
10 | ** | ||
11 | ** A copy of the GNU GPL license version 2 is included in this package as | ||
12 | ** LICENSE.GPL. | ||
13 | ** | ||
14 | ** This program is distributed in the hope that it will be useful, but | ||
15 | ** WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | ** See the GNU General Public License for more details. | ||
18 | ** | ||
19 | ** In addition, as a special exception Trolltech gives permission to link | ||
20 | ** the code of this program with Qtopia applications copyrighted, developed | ||
21 | ** and distributed by Trolltech under the terms of the Qtopia Personal Use | ||
22 | ** License Agreement. You must comply with the GNU General Public License | ||
23 | ** in all respects for all of the code used other than the applications | ||
24 | ** licensed under the Qtopia Personal Use License Agreement. If you modify | ||
25 | ** this file, you may extend this exception to your version of the file, | ||
26 | ** but you are not obligated to do so. If you do not wish to do so, delete | ||
27 | ** this exception statement from your version. | ||
28 | ** | ||
29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
30 | ** | ||
31 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
32 | ** not clear to you. | ||
33 | ** | ||
34 | **********************************************************************/ | ||
35 | |||
36 | #ifndef LOCATIONCOMBO_H | ||
37 | #define LOCATIONCOMBO_H | ||
38 | |||
39 | #include <qpe/qpeglobal.h> | ||
40 | |||
41 | #ifdef Q_WS_QWS | ||
42 | |||
43 | #include <qstringlist.h> | ||
44 | #include <qcombobox.h> | ||
45 | |||
46 | class AppLnk; | ||
47 | class QListViewItem; | ||
48 | class DocLnk; | ||
49 | class FileSystem; | ||
50 | class StorageInfo; | ||
51 | |||
52 | |||
53 | class LocationComboPrivate; | ||
54 | |||
55 | class LocationCombo : public QComboBox | ||
56 | { | ||
57 | Q_OBJECT | ||
58 | public: | ||
59 | LocationCombo( QWidget *parent, const char *name=0 ); | ||
60 | LocationCombo( const AppLnk * lnk, QWidget *parent, const char *name=0 ); | ||
61 | |||
62 | ~LocationCombo(); | ||
63 | |||
64 | void setLocation( const QString& path ); // qtopia 2 | ||
65 | void setLocation( const AppLnk * ); | ||
66 | |||
67 | QString installationPath() const; | ||
68 | QString documentPath() const; | ||
69 | const FileSystem *fileSystem() const; | ||
70 | |||
71 | bool isChanged() const; | ||
72 | |||
73 | signals: | ||
74 | void newPath(); | ||
75 | |||
76 | private slots: | ||
77 | void updatePaths(); | ||
78 | |||
79 | private: | ||
80 | void setupCombo(); | ||
81 | QStringList locations; | ||
82 | StorageInfo *storage; | ||
83 | LocationComboPrivate *d; | ||
84 | }; | ||
85 | |||
86 | |||
87 | #endif // QWS | ||
88 | #endif // LNKPROPERTIES_H | ||
diff --git a/library/qlibrary_unix.cpp b/library/qlibrary_unix.cpp index fee73c2..f4d60cb 100644 --- a/library/qlibrary_unix.cpp +++ b/library/qlibrary_unix.cpp | |||
@@ -199,5 +199,5 @@ bool QLibraryPrivate::loadLibrary() | |||
199 | QString filename = library->library(); | 199 | QString filename = library->library(); |
200 | 200 | ||
201 | pHnd = dlopen( filename.latin1() , RTLD_LAZY ); | 201 | pHnd = ::dlopen( filename.latin1() , RTLD_LAZY ); |
202 | // #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 202 | // #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
203 | if ( !pHnd ) | 203 | if ( !pHnd ) |
@@ -212,5 +212,5 @@ bool QLibraryPrivate::freeLibrary() | |||
212 | return TRUE; | 212 | return TRUE; |
213 | 213 | ||
214 | int ec = dlclose( pHnd ); | 214 | int ec = ::dlclose( pHnd ); |
215 | if ( !ec ) | 215 | if ( !ec ) |
216 | pHnd = 0; | 216 | pHnd = 0; |
diff --git a/library/timestring.cpp b/library/timestring.cpp index 91c29ae..afd162d 100644 --- a/library/timestring.cpp +++ b/library/timestring.cpp | |||
@@ -1,14 +1,29 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2006 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This program is free software; you can redistribute it and/or modify it |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** under the terms of the GNU General Public License as published by the |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Free Software Foundation; either version 2 of the License, or (at your |
9 | ** packaging of this file. | 9 | ** option) any later version. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** A copy of the GNU GPL license version 2 is included in this package as |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** LICENSE.GPL. |
13 | ** | ||
14 | ** This program is distributed in the hope that it will be useful, but | ||
15 | ** WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | ** See the GNU General Public License for more details. | ||
18 | ** | ||
19 | ** In addition, as a special exception Trolltech gives permission to link | ||
20 | ** the code of this program with Qtopia applications copyrighted, developed | ||
21 | ** and distributed by Trolltech under the terms of the Qtopia Personal Use | ||
22 | ** License Agreement. You must comply with the GNU General Public License | ||
23 | ** in all respects for all of the code used other than the applications | ||
24 | ** licensed under the Qtopia Personal Use License Agreement. If you modify | ||
25 | ** this file, you may extend this exception to your version of the file, | ||
26 | ** but you are not obligated to do so. If you do not wish to do so, delete | ||
27 | ** this exception statement from your version. | ||
13 | ** | 28 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
@@ -21,9 +36,12 @@ | |||
21 | #include "timestring.h" | 36 | #include "timestring.h" |
22 | #include <qobject.h> | 37 | #include <qobject.h> |
23 | #include <qpe/qpeapplication.h> //for qApp | 38 | #include <qdatetime.h> |
39 | #include <qapplication.h> | ||
24 | #include "config.h" | 40 | #include "config.h" |
25 | 41 | ||
42 | #include <time.h> | ||
43 | |||
26 | 44 | ||
27 | class TimeStringFormatKeeper : public QObject | 45 | class TimeStringFormat : public QObject |
28 | { | 46 | { |
29 | Q_OBJECT | 47 | Q_OBJECT |
@@ -32,5 +50,5 @@ public: | |||
32 | { | 50 | { |
33 | if ( !self ) | 51 | if ( !self ) |
34 | self = new TimeStringFormatKeeper; | 52 | self = new TimeStringFormat; |
35 | return self->format; | 53 | return self->format; |
36 | } | 54 | } |
@@ -41,15 +59,15 @@ private slots: | |||
41 | } | 59 | } |
42 | private: | 60 | private: |
43 | static TimeStringFormatKeeper *self; | 61 | static TimeStringFormat *self; |
44 | DateFormat format; | 62 | DateFormat format; |
45 | 63 | ||
46 | TimeStringFormatKeeper() | 64 | TimeStringFormat() |
47 | : QObject( qApp ) | 65 | : QObject( qApp ) |
48 | { | 66 | { |
49 | Config config("qpe"); | 67 | Config config("qpe"); |
50 | config.setGroup( "Date" ); | 68 | config.setGroup( "Date" ); |
51 | format = DateFormat(QChar(config.readEntry("Separator", "/")[0]), | 69 | format = ::DateFormat(QChar(config.readEntry("Separator", "/")[0]), |
52 | (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), | 70 | (::DateFormat::Order)config.readNumEntry("ShortOrder", ::DateFormat::DayMonthYear), |
53 | (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); | 71 | (::DateFormat::Order)config.readNumEntry("LongOrder", ::DateFormat::DayMonthYear)); |
54 | 72 | ||
55 | connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ), | 73 | connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ), |
@@ -58,5 +76,5 @@ private: | |||
58 | }; | 76 | }; |
59 | 77 | ||
60 | TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0; | 78 | TimeStringFormat *TimeStringFormat::self = 0; |
61 | 79 | ||
62 | QString DateFormat::toNumberString() const | 80 | QString DateFormat::toNumberString() const |
@@ -68,11 +86,11 @@ QString DateFormat::toNumberString() const | |||
68 | switch((_shortOrder >> (i * 3)) & 0x0007) { | 86 | switch((_shortOrder >> (i * 3)) & 0x0007) { |
69 | case 0x0001: | 87 | case 0x0001: |
70 | buf += QObject::tr( "D" , "Shortcut for Day"); | 88 | buf += TimeStringFormat::tr( "D", "first letter of the word 'Day'" ); |
71 | break; | 89 | break; |
72 | case 0x0002: | 90 | case 0x0002: |
73 | buf += QObject::tr( "M", "Shortcur for Month" ); | 91 | buf += TimeStringFormat::tr( "M" , "first letter of the word 'Month'" ); |
74 | break; | 92 | break; |
75 | case 0x0004: | 93 | case 0x0004: |
76 | buf += QObject::tr( "Y" ); | 94 | buf += TimeStringFormat::tr( "Y" , "first letter of the word 'Year'" ); |
77 | break; | 95 | break; |
78 | } | 96 | } |
@@ -91,5 +109,5 @@ QString DateFormat::toWordString() const | |||
91 | switch((_longOrder >> (i * 3)) & 0x0007) { | 109 | switch((_longOrder >> (i * 3)) & 0x0007) { |
92 | case 0x0001: | 110 | case 0x0001: |
93 | buf += QObject::tr( "day" ); | 111 | buf += TimeStringFormat::tr( "day", "in month" ); |
94 | if (i < 2) { | 112 | if (i < 2) { |
95 | if ((_shortOrder << ((i+1) * 3)) & 0x0007) | 113 | if ((_shortOrder << ((i+1) * 3)) & 0x0007) |
@@ -100,10 +118,10 @@ QString DateFormat::toWordString() const | |||
100 | break; | 118 | break; |
101 | case 0x0002: | 119 | case 0x0002: |
102 | buf += QObject::tr( "month" ); | 120 | buf += TimeStringFormat::tr( "month" ); |
103 | if (i < 2) | 121 | if (i < 2) |
104 | buf += " "; | 122 | buf += " "; |
105 | break; | 123 | break; |
106 | case 0x0004: | 124 | case 0x0004: |
107 | buf += QObject::tr( "year" ); | 125 | buf += TimeStringFormat::tr( "year" ); |
108 | if (i < 2) | 126 | if (i < 2) |
109 | buf += ", "; | 127 | buf += ", "; |
@@ -150,46 +168,109 @@ QString DateFormat::numberDate(const QDate &d, int v) const | |||
150 | } | 168 | } |
151 | 169 | ||
170 | static const char* unTranslatedFullMonthNames[] = { | ||
171 | QT_TRANSLATE_NOOP( "QDate", "January" ), | ||
172 | QT_TRANSLATE_NOOP( "QDate", "February" ), | ||
173 | QT_TRANSLATE_NOOP( "QDate", "March" ), | ||
174 | QT_TRANSLATE_NOOP( "QDate", "April" ), | ||
175 | QT_TRANSLATE_NOOP( "QDate", "May" ), | ||
176 | QT_TRANSLATE_NOOP( "QDate", "June" ), | ||
177 | QT_TRANSLATE_NOOP( "QDate", "July" ), | ||
178 | QT_TRANSLATE_NOOP( "QDate", "August" ), | ||
179 | QT_TRANSLATE_NOOP( "QDate", "September" ), | ||
180 | QT_TRANSLATE_NOOP( "QDate", "October" ), | ||
181 | QT_TRANSLATE_NOOP( "QDate", "November" ), | ||
182 | QT_TRANSLATE_NOOP( "QDate", "December" ) | ||
183 | }; | ||
184 | |||
185 | static const char* unTranslatedFullDayNames[] = { | ||
186 | QT_TRANSLATE_NOOP( "QDate", "Monday" ), | ||
187 | QT_TRANSLATE_NOOP( "QDate", "Tuesday" ), | ||
188 | QT_TRANSLATE_NOOP( "QDate", "Wednesday" ), | ||
189 | QT_TRANSLATE_NOOP( "QDate", "Thursday" ), | ||
190 | QT_TRANSLATE_NOOP( "QDate", "Friday" ), | ||
191 | QT_TRANSLATE_NOOP( "QDate", "Saturday" ), | ||
192 | QT_TRANSLATE_NOOP( "QDate", "Sunday" ) | ||
193 | }; | ||
194 | |||
195 | #ifdef QTOPIA_DESKTOP | ||
196 | //translations in qt.qm | ||
197 | static const char* unTranslatedMediumDayNames[] = { | ||
198 | "Mon" , "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" | ||
199 | }; | ||
200 | |||
201 | static const char* unTranslatedMediumMonthNames[] = { | ||
202 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", | ||
203 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" | ||
204 | }; | ||
205 | #endif | ||
206 | |||
207 | static QString dayname(const QDate& d, bool lng) | ||
208 | { | ||
209 | if (lng && qApp) | ||
210 | return qApp->translate("QDate", unTranslatedFullDayNames[d.dayOfWeek()-1]); | ||
211 | else { | ||
212 | #ifdef QTOPIA_DESKTOP | ||
213 | if (qApp) | ||
214 | return qApp->translate("QDate", unTranslatedMediumDayNames[ d.dayOfWeek()-1]); | ||
215 | #endif | ||
216 | return d.dayName(d.dayOfWeek()); | ||
217 | } | ||
218 | } | ||
219 | |||
152 | QString DateFormat::wordDate(const QDate &d, int v) const | 220 | QString DateFormat::wordDate(const QDate &d, int v) const |
153 | { | 221 | { |
154 | QString buf = ""; | ||
155 | // for each part of the order | 222 | // for each part of the order |
156 | if (v & showWeekDay) { | 223 | QString weekDay; |
157 | QString weekDay = d.dayName(d.dayOfWeek()); | 224 | if (v & showWeekDay) |
158 | if (!(v & longWord)) { | 225 | weekDay = ::dayname(d,(v & longWord)); |
159 | weekDay = weekDay.left(3); | ||
160 | } | ||
161 | buf += weekDay; | ||
162 | if ((_longOrder & 0x0007) == 0x0002) | ||
163 | buf += ' '; | ||
164 | else | ||
165 | buf += ", "; | ||
166 | } | ||
167 | 226 | ||
227 | QString date=""; | ||
228 | QString sep=""; | ||
168 | for (int i = 0; i < 3; i++) { | 229 | for (int i = 0; i < 3; i++) { |
169 | // switch on the relavent 3 bits. | 230 | // switch on the relavent 3 bits. |
170 | switch((_longOrder >> (i * 3)) & 0x0007) { | 231 | int field = (_longOrder >> (i * 3)) & 0x0007; |
171 | case 0x0001: | 232 | if ( field && !date.isEmpty() ) |
233 | date += sep; | ||
234 | switch (field) { | ||
235 | case 0x0001: // Day | ||
236 | { | ||
237 | QString daysuffix = TimeStringFormat::tr("@day", "day suffix - applies to some asian languages (e.g. Japanese and Trad. Chinese). If it doesn't apply to your language it has to be translated to an '@day' " ); | ||
172 | if (i==1) { | 238 | if (i==1) { |
173 | buf += QString().sprintf("%02d, ",d.day()); | 239 | date += QString().sprintf("%02d",d.day()); |
240 | if (daysuffix != "@day") | ||
241 | date+=daysuffix; | ||
242 | sep = TimeStringFormat::tr(",","day-date separator") + " "; | ||
174 | } else { | 243 | } else { |
175 | buf += QString().sprintf("%2d",d.day()); | 244 | date += QString().sprintf("%2d",d.day()); |
245 | if (daysuffix == "@day") { | ||
176 | if (separator()=='.') // 2002/1/11 | 246 | if (separator()=='.') // 2002/1/11 |
177 | buf += ". "; | 247 | sep = ". "; |
178 | else | 248 | else |
179 | buf += " "; | 249 | sep = " "; |
250 | } else { | ||
251 | date += daysuffix+" "; | ||
252 | sep = " "; | ||
253 | } | ||
254 | } | ||
180 | } | 255 | } |
181 | break; | 256 | break; |
182 | case 0x0002: | 257 | case 0x0002: // Month |
183 | { | 258 | { |
184 | QString monthName = d.monthName(d.month()); | 259 | QString monthName; |
185 | if (!(v & longWord)) { | 260 | |
186 | monthName = monthName.left(3); | 261 | if (v & longWord) |
262 | monthName = qApp->translate("QDate", unTranslatedFullMonthNames[d.month()-1] ); | ||
263 | else { | ||
264 | #ifdef QTOPIA_DESKTOP | ||
265 | monthName = qApp->translate("QDate", unTranslatedMediumMonthNames[d.month()-1] ); | ||
266 | #else | ||
267 | monthName = d.monthName( d.month() ); | ||
268 | #endif | ||
187 | } | 269 | } |
188 | buf += monthName; | 270 | date += monthName; |
189 | } | 271 | } |
190 | if (i < 2) | 272 | sep = " ";//TimeStringFormat::tr(" ","month-date separator"); |
191 | buf += " "; | ||
192 | break; | 273 | break; |
193 | case 0x0004: | 274 | case 0x0004: // Year |
194 | { | 275 | { |
195 | int year = d.year(); | 276 | int year = d.year(); |
@@ -198,14 +279,27 @@ QString DateFormat::wordDate(const QDate &d, int v) const | |||
198 | 279 | ||
199 | if (year < 10) | 280 | if (year < 10) |
200 | buf += "0"; | 281 | date += "0"; |
282 | |||
283 | date += QString::number(year); | ||
284 | QString yearsuffix = TimeStringFormat::tr("@year", "year suffix - applies to some asian languages (e.g. Japanese and Trad. Chinese). If it doesn't apply to your language it has to be translated to an '@year' " ); | ||
285 | if (yearsuffix != "@year") | ||
286 | date += yearsuffix; | ||
201 | 287 | ||
202 | buf += QString::number(year); | ||
203 | } | 288 | } |
204 | if (i < 2) | 289 | sep = TimeStringFormat::tr(",","year-date seperator") + " "; |
205 | buf += ", "; | ||
206 | break; | 290 | break; |
207 | } | 291 | } |
208 | } | 292 | } |
209 | return buf; | 293 | |
294 | QString r = ""; | ||
295 | if ( weekDay.isEmpty() ) | ||
296 | r = date; | ||
297 | else if ((_longOrder & 0x0007) == 0x0002) | ||
298 | r = TimeStringFormat::tr("%1 %2","1=Monday 2=January 12").arg(weekDay).arg(date); | ||
299 | else if ( _longOrder ) | ||
300 | r = TimeStringFormat::tr("%1, %2","1=Monday 2=12 January").arg(weekDay).arg(date); | ||
301 | else | ||
302 | r = weekDay; | ||
303 | return r; | ||
210 | } | 304 | } |
211 | 305 | ||
@@ -252,5 +346,5 @@ QString TimeString::shortDate( const QDate &d, DateFormat dtf ) | |||
252 | QString TimeString::dateString( const QDate &d, DateFormat dtf ) | 346 | QString TimeString::dateString( const QDate &d, DateFormat dtf ) |
253 | { | 347 | { |
254 | return QObject::tr( dtf.wordDate(d, DateFormat::longNumber | DateFormat::longWord) ); | 348 | return dtf.wordDate(d, DateFormat::longNumber); |
255 | } | 349 | } |
256 | 350 | ||
@@ -258,11 +352,11 @@ QString TimeString::dateString( const QDate &d, DateFormat dtf ) | |||
258 | QString TimeString::longDateString( const QDate &d, DateFormat dtf ) | 352 | QString TimeString::longDateString( const QDate &d, DateFormat dtf ) |
259 | { | 353 | { |
260 | return QObject::tr( dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber | 354 | return dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber |
261 | | DateFormat::longWord) ); | 355 | | DateFormat::longWord); |
262 | } | 356 | } |
263 | 357 | ||
264 | DateFormat TimeString::currentDateFormat() | 358 | DateFormat TimeString::currentDateFormat() |
265 | { | 359 | { |
266 | return TimeStringFormatKeeper::currentFormat(); | 360 | return TimeStringFormat::currentFormat(); |
267 | } | 361 | } |
268 | 362 | ||
@@ -314,7 +408,7 @@ QString TimeString::timeString( const QTime &t, bool ampm, bool seconds ) | |||
314 | argString = argString.arg( strSec ); | 408 | argString = argString.arg( strSec ); |
315 | if ( hour >= 12 ) | 409 | if ( hour >= 12 ) |
316 | argString = argString.arg( QObject::tr("PM") ); | 410 | argString = argString.arg( TimeStringFormat::tr("PM") ); |
317 | else | 411 | else |
318 | argString = argString.arg( QObject::tr("AM") ); | 412 | argString = argString.arg( TimeStringFormat::tr("AM") ); |
319 | return argString; | 413 | return argString; |
320 | } | 414 | } |
@@ -322,18 +416,9 @@ QString TimeString::timeString( const QTime &t, bool ampm, bool seconds ) | |||
322 | QString TimeString::shortTime( bool ampm, bool seconds ) | 416 | QString TimeString::shortTime( bool ampm, bool seconds ) |
323 | { | 417 | { |
324 | static const char* const day[] = { | ||
325 | QT_TRANSLATE_NOOP( "QObject", "Mon" ), | ||
326 | QT_TRANSLATE_NOOP( "QObject", "Tue" ), | ||
327 | QT_TRANSLATE_NOOP( "QObject", "Wed" ), | ||
328 | QT_TRANSLATE_NOOP( "QObject", "Thu" ), | ||
329 | QT_TRANSLATE_NOOP( "QObject", "Fri" ), | ||
330 | QT_TRANSLATE_NOOP( "QObject", "Sat" ), | ||
331 | QT_TRANSLATE_NOOP( "QObject", "Sun" ) | ||
332 | }; | ||
333 | // just create a shorter time String | 418 | // just create a shorter time String |
334 | QDateTime dtTmp = QDateTime::currentDateTime(); | 419 | QDateTime dtTmp = QDateTime::currentDateTime(); |
335 | QString strTime; | 420 | QString strTime = TimeStringFormat::tr( "%1 %2", "1=Monday 2=12:45" ) |
336 | strTime = QObject::tr( day[dtTmp.date().dayOfWeek()-1] ) + " " + | 421 | .arg(::dayname(dtTmp.date(),FALSE)) |
337 | timeString( dtTmp.time(), ampm, seconds ); | 422 | .arg(timeString( dtTmp.time(), ampm, seconds )); |
338 | return strTime; | 423 | return strTime; |
339 | } | 424 | } |
@@ -362,4 +447,20 @@ QString TimeString::longNumberDateString( const QDate &d, DateFormat dtf ) | |||
362 | return dtf.numberDate(d,DateFormat::longNumber); | 447 | return dtf.numberDate(d,DateFormat::longNumber); |
363 | } | 448 | } |
449 | /*! | ||
450 | Returns date/time \a dt as a string, | ||
451 | showing year, month, date, hours, minutes, and seconds. | ||
452 | \a len determines the length of the resulting string. | ||
453 | |||
454 | The format, including order depends on the user's settings. | ||
455 | |||
456 | First availability: Qtopia 1.6 | ||
457 | */ | ||
458 | //QString TimeString::localYMDHMS( const QDateTime &dt, Length len ) | ||
459 | //{ | ||
460 | // const QDate& d = dt.date(); | ||
461 | // const QTime& t = dt.time(); | ||
462 | // return LocalTimeFormat::tr("%1 %2","date,time").arg(localYMD(d,len)).arg(localHMS(t)); | ||
463 | //} | ||
464 | |||
364 | 465 | ||
365 | #include "timestring.moc" | 466 | #include "timestring.moc" |
diff --git a/library/timestring.h b/library/timestring.h index 875c8bf..b8d1aea 100644 --- a/library/timestring.h +++ b/library/timestring.h | |||
@@ -1,14 +1,29 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2006 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This program is free software; you can redistribute it and/or modify it |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** under the terms of the GNU General Public License as published by the |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Free Software Foundation; either version 2 of the License, or (at your |
9 | ** packaging of this file. | 9 | ** option) any later version. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** A copy of the GNU GPL license version 2 is included in this package as |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** LICENSE.GPL. |
13 | ** | ||
14 | ** This program is distributed in the hope that it will be useful, but | ||
15 | ** WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | ** See the GNU General Public License for more details. | ||
18 | ** | ||
19 | ** In addition, as a special exception Trolltech gives permission to link | ||
20 | ** the code of this program with Qtopia applications copyrighted, developed | ||
21 | ** and distributed by Trolltech under the terms of the Qtopia Personal Use | ||
22 | ** License Agreement. You must comply with the GNU General Public License | ||
23 | ** in all respects for all of the code used other than the applications | ||
24 | ** licensed under the Qtopia Personal Use License Agreement. If you modify | ||
25 | ** this file, you may extend this exception to your version of the file, | ||
26 | ** but you are not obligated to do so. If you do not wish to do so, delete | ||
27 | ** this exception statement from your version. | ||
13 | ** | 28 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
@@ -23,4 +38,5 @@ | |||
23 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
24 | #include <qstring.h> | 39 | #include <qstring.h> |
40 | #include <qarray.h> | ||
25 | 41 | ||
26 | #if (QT_VERSION-0 >= 0x030000) | 42 | #if (QT_VERSION-0 >= 0x030000) |
@@ -28,4 +44,8 @@ | |||
28 | #endif | 44 | #endif |
29 | 45 | ||
46 | #include <qtopia/qpeglobal.h> | ||
47 | |||
48 | class QObject; | ||
49 | |||
30 | // return a string with the time based on whether or not you want | 50 | // return a string with the time based on whether or not you want |
31 | // you want it in 12 hour form. if ampm is true, then return | 51 | // you want it in 12 hour form. if ampm is true, then return |
@@ -35,9 +55,9 @@ class DateFormat | |||
35 | { | 55 | { |
36 | public: | 56 | public: |
37 | // date format type 001,010,100 = day month year | 57 | // date format type 1,2,4 = day,month,year |
38 | enum Order { | 58 | enum Order { |
39 | DayMonthYear = 0x0111, // 0x001 + 0x010(0x2 << 3) + 0x100(0x4 << 3) | 59 | DayMonthYear = 0421, // right-to-left |
40 | MonthDayYear = 0x010A, | 60 | MonthDayYear = 0412, |
41 | YearMonthDay = 0x0054 | 61 | YearMonthDay = 0124 |
42 | }; | 62 | }; |
43 | 63 | ||
@@ -103,8 +123,6 @@ public: | |||
103 | //YearMonthDay = ISO8601 }; | 123 | //YearMonthDay = ISO8601 }; |
104 | 124 | ||
105 | /** | 125 | |
106 | * @name Convience functions which use currentDateFormat | 126 | //private: |
107 | */ | ||
108 | //@{ | ||
109 | static QString shortDate( const QDate &d ) | 127 | static QString shortDate( const QDate &d ) |
110 | { return shortDate( d, currentDateFormat() ); } | 128 | { return shortDate( d, currentDateFormat() ); } |
@@ -113,19 +131,35 @@ public: | |||
113 | static QString longDateString( const QDate &d ) | 131 | static QString longDateString( const QDate &d ) |
114 | { return longDateString( d, currentDateFormat() ); } | 132 | { return longDateString( d, currentDateFormat() ); } |
115 | //@} | ||
116 | static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) | 133 | static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) |
117 | { return dateString( dt, ampm, seconds, currentDateFormat() ); } | 134 | { return dateString( dt, ampm, seconds, currentDateFormat() ); } |
118 | 135 | ||
136 | public: | ||
137 | enum Length { Short, Medium, Long }; | ||
138 | static QString localH( int hour ); | ||
139 | static QString localHM( const QTime & ); | ||
140 | static QString localHM( const QTime &, Length ); // qtopia 2.1.0 | ||
141 | static QString localHMS( const QTime & ); | ||
142 | static QString localHMDayOfWeek( const QDateTime &t ); | ||
143 | static QString localHMSDayOfWeek( const QDateTime &t ); | ||
144 | static QString localMD( const QDate &, Length=Medium ); | ||
145 | static QString localYMD( const QDate &, Length=Medium ); | ||
146 | static QString localYMDHMS( const QDateTime &, Length=Medium ); | ||
147 | static QString localDayOfWeek( const QDate&, Length=Medium ); | ||
148 | static QString localDayOfWeek( int day1to7, Length=Medium ); | ||
149 | |||
150 | static QString hourString( int hour, bool ampm ); | ||
151 | static bool currentAMPM(); | ||
152 | static DateFormat currentDateFormat(); | ||
153 | static QArray<DateFormat> formatOptions(); // qtopia 1.6.0 | ||
154 | |||
155 | static void connectChange(QObject*,const char* member); | ||
156 | static void disconnectChange(QObject*,const char* member); | ||
119 | 157 | ||
120 | /** @name Do not use as they don't honor system settings for AMPM | 158 | // Not recommended to call these (they don't honor system ampm) |
121 | * | 159 | static QString dateString( const QDateTime &t, bool ampm ); |
122 | */ | ||
123 | //@{ | ||
124 | static QString dateString( const QDateTime &t, bool ampm = false ); | ||
125 | static QString timeString( const QTime &t, bool ampm, bool seconds ); | 160 | static QString timeString( const QTime &t, bool ampm, bool seconds ); |
126 | static QString timeString( const QTime &t, bool ampm = false ); | 161 | static QString timeString( const QTime &t, bool ampm ); |
127 | static QString shortTime( bool ampm, bool seconds ); | 162 | static QString shortTime( bool ampm, bool seconds ); |
128 | static QString shortTime( bool ampm = false ); | 163 | static QString shortTime( bool ampm ); |
129 | //@} | ||
130 | 164 | ||
131 | static QString numberDateString( const QDate &d, DateFormat ); | 165 | static QString numberDateString( const QDate &d, DateFormat ); |
@@ -140,6 +174,4 @@ public: | |||
140 | static QString longDateString( const QDate &, DateFormat ); | 174 | static QString longDateString( const QDate &, DateFormat ); |
141 | 175 | ||
142 | static DateFormat currentDateFormat(); | ||
143 | |||
144 | private: | 176 | private: |
145 | static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); | 177 | static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); |