-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsupportfunctions.h
More file actions
74 lines (56 loc) · 2.45 KB
/
supportfunctions.h
File metadata and controls
74 lines (56 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef SUPPORTFUNCTIONS_H
#define SUPPORTFUNCTIONS_H
#include <QString>
#include <QDateTime>
#include <QWidget>
#include <QLineEdit>
#include <QDebug>
QString& dateTimeStringToZulu(QString str) ;
// Parse a free-text string into a data/time
//QDateTime &dateStringToDateTime(QString str) ;
//QString& datetimeToDateString(QDateTime dt) ;
// Convert DateTime to/from ISO DateTime Strings
QString& dateTimeToIsoString(QDateTime &t) ;
QDateTime& isoStringToDateTime(QString str) ;
QString& nowToIsoString() ;
// Parse DD/MM/YYYY (date) to and from YYYY-MM-DD (xs)
QString& xsDateToDate(QString xsDate) ;
QString& dateToXsDate(QString date) ;
QDateTime& xsDateToDateTime(QString xsDate) ;
QString& dateTimeToXsDate(QDateTime datetime) ;
// Parse a free-text duration into minutes
int durationstringToInt(QString str) ;
QString& durationintToString(int mins) ;
// Remove accents
QString& deAccent(QString& str) ;
// File Read and Write
bool writeToFile(QString filename, QString data, bool append=false) ;
bool readFromFile(QString filename, QString &buffer, QString codec=QString("UTF-8"), QString altcodec=QString("System")) ;
// File and Directory Processing
bool copyFile(QString from, QString to) ;
bool fileExists(QString filename) ;
bool directoryExists(QString directory) ;
bool parseDirectory(QString& directory, QStringList& into, QString extension, bool reversesort=false, bool clear=true) ;
bool deleteDirectoryAndFiles(QString directory, QString fileextension) ;
// Save a copy of the file in the deleted subdirectory of path
bool backupFile(QString& path, QString& filename) ;
// Present a warning form and OK button, or YES/NO buttons
bool warningYesNoDialog(QWidget *parent, QString title, QString message, QString yestext = QString("Yes"), QChar yeskey = QChar('y'), QString notext = QString("No"), QChar nokey = QChar('n')) ;
bool warningOkDialog(QWidget *parent, QString title, QString message, bool iserror=false, bool beep=true) ;
bool errorOkDialog(QWidget *parent, QString title, QString message) ;
QString inputDialog(QWidget *parent, QString title, QString prompt, QLineEdit::EchoMode echo, QString defaulttext, bool *ok) ;
// Manage logging
QString& getLog() ;
void addLog(QString entry) ;
// Zip
bool zip(QString contactmanagerbase, QString destinationfile) ;
// sleep
void qSleep(int ms) ;
// debug to console
void setupdebug() ;
#ifndef QT_NO_DEBUG_OUTPUT
#define dbg(s) qDebug() << s ; fflush(stderr) ;
#else
#define dbg(s)
#endif
#endif // SUPPORTFUNCTIONS_H