-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileselect.cpp
129 lines (107 loc) · 2.93 KB
/
fileselect.cpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "fileselect.h"
#include "ui_fileselect.h"
#include <QFileInfo>
#include <QDateTime>
#include <QDialog>
FileSelect::FileSelect(QWidget *parent) :
QDialog(parent),
ui(new Ui::FileSelect)
{
ui->setupUi(this);
}
FileSelect::~FileSelect()
{
delete ui;
}
FileSelect::InputType FileSelect::execDialog()
{
ui->fileSelect->setFocus() ;
ui->fileSelect->setFilename() ;
if (QDialog::exec()==0) return FileSelect::Cancel ;
if (ui->fileSelect->isRenameFolder()) return FileSelect::RenameFolder ;
if (ui->fileSelect->isDeleteFolder()) return FileSelect::DeleteFolder ;
if (ui->fileSelect->isCreateFolder()) return FileSelect::CreateFolder ;
if (ui->fileSelect->isCreateEncryptedFolder()) return FileSelect::CreateEncryptedFolder ;
if (ui->fileSelect->isCreateFile()) {
if (ui->fileSelect->isFolderEncrypted()) return FileSelect::CreateEncryptedFile ;
else return FileSelect::CreateAFile ;
}
return FileSelect::LoadFile ;
}
void FileSelect::setPath(QString path)
{
ui->fileSelect->setPath(path) ;
}
QString& FileSelect::getPath()
{
return ui->fileSelect->getPath() ;
}
void FileSelect::setFilename(QString folder, QString file)
{
ui->fileSelect->setFilename(folder, file) ;
ui->fileSelect->update() ;
}
void FileSelect::setFilenameFromPath(QString path)
{
// remove .autosave tail
path = path.replace(".autosave","") ;
ui->fileSelect->setFilenameFromPath(path) ;
ui->fileSelect->update() ;
}
void FileSelect::clearFilename()
{
ui->fileSelect->clearFilename() ;
}
QString& FileSelect::getFilePath(QString filename, bool preferbackups)
{
return ui->fileSelect->getFilePath(filename, preferbackups) ;
}
QString& FileSelect::getEditableFilePath(QString filename)
{
return ui->fileSelect->getEditableFilePath(filename) ;
}
QString& FileSelect::getFolderPath(QString foldername)
{
return ui->fileSelect->getFolderPath(foldername) ;
}
QString& FileSelect::getBackupFilePath(bool create)
{
return ui->fileSelect->getBackupFilePath(create) ;
}
QString& FileSelect::getBackupFolderPath()
{
return ui->fileSelect->getBackupFolderPath() ;
}
QString& FileSelect::getTempFolderPath()
{
return ui->fileSelect->getTempFolderPath() ;
}
QString& FileSelect::getFileDescription(bool includefolder, bool includebackupdate)
{
return ui->fileSelect->getFileDescription(includefolder, includebackupdate) ;
}
QString FileSelect::getFileDate()
{
QString filename = getFilePath() ;
QFileInfo inf(filename) ;
QDateTime mod = inf.lastModified() ;
return mod.toString("ddd dd MMM yyyy hh:mm") ;
}
bool FileSelect::isReadOnly()
{
return ui->fileSelect->isBackup() ;
}
bool FileSelect::isFolderEncrypted()
{
return ui->fileSelect->isFolderEncrypted() ;
}
bool FileSelect::isFileEncrypted()
{
return ui->fileSelect->isFileEncrypted() ;
}
int FileSelect::getFileLength(QString path)
{
QFile f(path) ;
int length = f.size() ;
return length ;
}