initial commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#include "cfiledialog.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
|
||||
cFileDialog::cFileDialog(QWidget *parent, const QString &caption, const QString &directory, const QString &filter) :
|
||||
QFileDialog(parent, caption, directory, filter),
|
||||
m_lpCheckBox(nullptr)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
cFileDialog::cFileDialog(QWidget *parent, Qt::WindowFlags flags) :
|
||||
QFileDialog(parent, flags),
|
||||
m_lpCheckBox(nullptr)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void cFileDialog::init()
|
||||
{
|
||||
setOption(QFileDialog::DontUseNativeDialog);
|
||||
}
|
||||
|
||||
void cFileDialog::addCheckbox()
|
||||
{
|
||||
QGridLayout* mainLayout = dynamic_cast <QGridLayout*>(this->layout());
|
||||
if(!mainLayout)
|
||||
return;
|
||||
|
||||
QHBoxLayout* hbl = new QHBoxLayout(nullptr);
|
||||
m_lpCheckBox = new QCheckBox(QString("search recursive"));
|
||||
hbl->addWidget(m_lpCheckBox);
|
||||
int num_rows = mainLayout->rowCount();
|
||||
mainLayout->addLayout(hbl, num_rows, 0, 1, -1);
|
||||
}
|
||||
|
||||
void cFileDialog::setChecked(bool check)
|
||||
{
|
||||
if(m_lpCheckBox)
|
||||
m_lpCheckBox->setChecked(check);
|
||||
}
|
||||
|
||||
bool cFileDialog::checked()
|
||||
{
|
||||
if(m_lpCheckBox)
|
||||
return(m_lpCheckBox->checkState() == Qt::Checked);
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef CFILEDIALOG_H
|
||||
#define CFILEDIALOG_H
|
||||
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QCheckBox>
|
||||
|
||||
|
||||
class cFileDialog : public QFileDialog
|
||||
{
|
||||
public:
|
||||
cFileDialog(QWidget *parent = nullptr, const QString &caption = QString(), const QString &directory = QString(), const QString &filter = QString());
|
||||
cFileDialog(QWidget *parent, Qt::WindowFlags flags);
|
||||
|
||||
void addCheckbox();
|
||||
void setChecked(bool check);
|
||||
bool checked();
|
||||
|
||||
private:
|
||||
QCheckBox* m_lpCheckBox;
|
||||
|
||||
void init();
|
||||
};
|
||||
|
||||
#endif // CFILEDIALOG_H
|
||||
+44
-11
@@ -2,10 +2,9 @@
|
||||
#include "ui_cmainwindow.h"
|
||||
|
||||
#include "cimage.h"
|
||||
|
||||
#include "cexif.h"
|
||||
|
||||
#include "cexportdialog.h"
|
||||
#include "cfiledialog.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
@@ -197,7 +196,7 @@ QString cMainWindow::generateReadList()
|
||||
readList.append(";;");
|
||||
readList.append(i.description);
|
||||
readList.append(" (");
|
||||
readList.append(i.shortName);
|
||||
readList.append(i.extension);
|
||||
readList.append(")");
|
||||
}
|
||||
}
|
||||
@@ -223,7 +222,7 @@ QString cMainWindow::generateWriteList()
|
||||
writeList.append(";;");
|
||||
writeList.append(i.description);
|
||||
writeList.append(" (");
|
||||
writeList.append(i.shortName);
|
||||
writeList.append(i.extension);
|
||||
writeList.append(")");
|
||||
}
|
||||
}
|
||||
@@ -237,7 +236,18 @@ void cMainWindow::onAddFile()
|
||||
QSettings settings;
|
||||
QString path = settings.value("import/oldPath", QVariant::fromValue(QDir::homePath())).toString();
|
||||
|
||||
QStringList fileList = QFileDialog::getOpenFileNames(this, "Import from", path, generateReadList());
|
||||
cFileDialog fileDialog(this);
|
||||
|
||||
fileDialog.setWindowTitle("Import from");
|
||||
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
fileDialog.setDirectory(path);
|
||||
fileDialog.setFileMode(QFileDialog::ExistingFiles);
|
||||
fileDialog.setViewMode(QFileDialog::Detail);
|
||||
fileDialog.setNameFilter(generateReadList());
|
||||
if(!fileDialog.exec())
|
||||
return;
|
||||
|
||||
QStringList fileList = fileDialog.selectedFiles();
|
||||
|
||||
if(fileList.isEmpty())
|
||||
return;
|
||||
@@ -255,15 +265,35 @@ void cMainWindow::onAddFolder()
|
||||
{
|
||||
QSettings settings;
|
||||
QString path = settings.value("import/oldPath", QVariant::fromValue(QDir::homePath())).toString();
|
||||
bool checked = settings.value("import/recursive", QVariant::fromValue(false)).toBool();
|
||||
|
||||
path = QFileDialog::getExistingDirectory(this, "Import from", path);
|
||||
cFileDialog fileDialog(this);
|
||||
|
||||
fileDialog.setWindowTitle("Import from");
|
||||
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
fileDialog.setDirectory(path);
|
||||
fileDialog.setFileMode(QFileDialog::DirectoryOnly);
|
||||
fileDialog.setViewMode(QFileDialog::Detail);
|
||||
fileDialog.addCheckbox();
|
||||
fileDialog.setChecked(checked);
|
||||
|
||||
if(!fileDialog.exec())
|
||||
return;
|
||||
|
||||
path = fileDialog.selectedFiles()[0];
|
||||
|
||||
if(path.isEmpty())
|
||||
return;
|
||||
|
||||
settings.setValue("import/oldPath", QVariant::fromValue(path));
|
||||
checked = fileDialog.checked();
|
||||
|
||||
onAddEntry(path);
|
||||
settings.setValue("import/oldPath", QVariant::fromValue(path));
|
||||
settings.setValue("import/recursive", QVariant::fromValue(checked));
|
||||
|
||||
addPath(path, checked);
|
||||
|
||||
for(int i = 0;i < m_lpFileListModel->columnCount();i++)
|
||||
ui->m_lpFileList->resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
void cMainWindow::onRemoveSelected()
|
||||
@@ -296,14 +326,17 @@ void cMainWindow::onAddEntry(const QString& file)
|
||||
ui->m_lpFileList->resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
void cMainWindow::addPath(const QString& path)
|
||||
void cMainWindow::addPath(const QString& path, bool recursive)
|
||||
{
|
||||
QDir dir(path);
|
||||
QStringList dirList = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||
QStringList fileList = dir.entryList(QDir::Files);
|
||||
|
||||
for(int i = 0;i < dirList.count();i++)
|
||||
addPath(path + "/" + dirList[i]);
|
||||
if(recursive)
|
||||
{
|
||||
for(int i = 0;i < dirList.count();i++)
|
||||
addPath(path + "/" + dirList[i], recursive);
|
||||
}
|
||||
|
||||
for(int i = 0;i < fileList.count();i++)
|
||||
addFile(path + "/" + fileList[i]);
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ private:
|
||||
void createFileActions();
|
||||
void createContextActions();
|
||||
|
||||
void addPath(const QString& path);
|
||||
void addPath(const QString& path, bool recursive = true);
|
||||
void addFile(const QString& file);
|
||||
|
||||
bool isInList(const QString& file);
|
||||
|
||||
@@ -46,6 +46,7 @@ DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
SOURCES += \
|
||||
cexif.cpp \
|
||||
cexportdialog.cpp \
|
||||
cfiledialog.cpp \
|
||||
cimage.cpp \
|
||||
csplashscreen.cpp \
|
||||
ctreeview.cpp \
|
||||
@@ -55,6 +56,7 @@ SOURCES += \
|
||||
HEADERS += \
|
||||
cexif.h \
|
||||
cexportdialog.h \
|
||||
cfiledialog.h \
|
||||
cimage.h \
|
||||
csplashscreen.h \
|
||||
cmainwindow.h \
|
||||
|
||||
Reference in New Issue
Block a user