#include <QCoreApplication>
#include <QDateTime>
+#include <QSettings>
+#include <QFileInfo>
+#include <QDir>
QString htmlize(QString str)
{
m_timezone=olsonname;
}
+QString currentDir()
+{
+ return QSettings().value("lastUsedDirectory",".").toString();
+}
+
+void setCurrentDir(QString fn)
+{
+ if(fn.isEmpty())return;
+ QFileInfo fi(fn);
+ //it is already a directory
+ if(fi.isDir())QSettings().setValue("lastUsedDirectory",fn);
+ //it is probably a file
+ else {
+ //get parent directory name
+ fn=fi.dir().absolutePath();
+ if(QFileInfo(fn).isDir())
+ QSettings().setValue("lastUsedDirectory",fn);
+ //abort if not found by now, this was bogus
+ }
+}
// Description: miscellaneous helper functions
//
//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008-2011
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008-2012
//
// Copyright: See README/COPYING.GPL files that come with this distribution
//
/**return a (localized) regular expression that validates prices*/
QRegExp priceRegExp(bool localize=true);
+///returns the current directory (the one last used in a file dialog)
+QString currentDir();
+
+///sets a new current directory (transparently handles files and directories)
+void setCurrentDir(QString);
+
/**localized formatter class for timestamps, numbers and money;
per default it uses the local translation to format data, but can be overidden;