summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/util.h
authorpohly <pohly>2004-08-24 20:52:45 (UTC)
committer pohly <pohly>2004-08-24 20:52:45 (UTC)
commit73253e93327cf4ef0932de1b4afb56af22a0f37e (patch) (unidiff)
tree1c9a7a6dd3341e036a894d348a3372525d29acec /noncore/apps/opie-reader/util.h
parente90847c784c48bd21bf8768cb38edb853b832697 (diff)
downloadopie-73253e93327cf4ef0932de1b4afb56af22a0f37e.zip
opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.gz
opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.bz2
updated source to opie-reader 0.7g
Diffstat (limited to 'noncore/apps/opie-reader/util.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/util.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/util.h b/noncore/apps/opie-reader/util.h
new file mode 100644
index 0000000..f831ead
--- a/dev/null
+++ b/noncore/apps/opie-reader/util.h
@@ -0,0 +1,57 @@
1#ifndef __UTIL_H
2#define __UTIL_H
3
4#include <qstring.h>
5#include <qdir.h>
6#include <stdlib.h>
7
8QString filesize(unsigned long l);
9QString percent(unsigned long pos, unsigned long len);
10QString fmt(unsigned long pos, unsigned long len);
11
12/**
13 * class with utility inline function(s)
14 * (in contrast to global functions they become available by just
15 * including util.h)
16 */
17class QTReaderUtil
18{
19 public:
20
21 /**
22 * searches for a specific direcory inside OpieReader installation
23 *
24 * @param subdir name of sub directory inside installation directory which is needed
25 * @return full path name including that sub directory
26 *
27 * search order is (on all platforms):
28 * - OPIEDIR
29 * - QTDIR
30 * - READERDIR
31 */
32 static QString getPluginPath( const char *subdir = "codecs/" )
33 {
34 QString dirname;
35 dirname = getenv("OPIEDIR");
36 dirname += "/plugins/reader/";
37 dirname += subdir;
38 if (QDir(dirname).exists())
39 return dirname;
40
41 dirname = getenv("QTDIR");
42 dirname += "/plugins/reader/";
43 dirname += subdir;
44 if (QDir(dirname).exists())
45 return dirname;
46
47 dirname = getenv("READERDIR");
48 dirname += "/";
49 dirname += subdir;
50 if (QDir(dirname).exists())
51 return dirname;
52
53 return "";
54 }
55};
56
57#endif