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) (side-by-side diff)
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) (ignore 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 @@
+#ifndef __UTIL_H
+#define __UTIL_H
+
+#include <qstring.h>
+#include <qdir.h>
+#include <stdlib.h>
+
+QString filesize(unsigned long l);
+QString percent(unsigned long pos, unsigned long len);
+QString fmt(unsigned long pos, unsigned long len);
+
+/**
+ * class with utility inline function(s)
+ * (in contrast to global functions they become available by just
+ * including util.h)
+ */
+class QTReaderUtil
+{
+ public:
+
+ /**
+ * searches for a specific direcory inside OpieReader installation
+ *
+ * @param subdir name of sub directory inside installation directory which is needed
+ * @return full path name including that sub directory
+ *
+ * search order is (on all platforms):
+ * - OPIEDIR
+ * - QTDIR
+ * - READERDIR
+ */
+ static QString getPluginPath( const char *subdir = "codecs/" )
+ {
+ QString dirname;
+ dirname = getenv("OPIEDIR");
+ dirname += "/plugins/reader/";
+ dirname += subdir;
+ if (QDir(dirname).exists())
+ return dirname;
+
+ dirname = getenv("QTDIR");
+ dirname += "/plugins/reader/";
+ dirname += subdir;
+ if (QDir(dirname).exists())
+ return dirname;
+
+ dirname = getenv("READERDIR");
+ dirname += "/";
+ dirname += subdir;
+ if (QDir(dirname).exists())
+ return dirname;
+
+ return "";
+ }
+};
+
+#endif