initial commit

This commit is contained in:
2019-08-15 00:17:33 +02:00
parent b8c7ecb3dd
commit 8f68886c3a
6 changed files with 232 additions and 10 deletions
+34 -2
View File
@@ -97,8 +97,31 @@ void cFileList::parseLine(const QString& curDir, const QString& line)
QDateTime dateTime = QDateTime(QDate::fromString(date, "dd.MM.yyyy"), QTime::fromString(time, "hh:mm"));
if(file.endsWith(".nef", Qt::CaseInsensitive))
add(dir.replace("\\", "/"), file, dateTime, size.toLongLong(), false);
add(dir.replace("\\", "/"), file, dateTime, size.toLongLong(), false);
}
void cFileList::parseDir(const QString& dir, QStatusBar* lpStatusBar)
{
QDir _dir(dir);
if(lpStatusBar)
{
lpStatusBar->showMessage(_dir.path());
qApp->processEvents();
}
QFileInfoList fileList = _dir.entryInfoList(QDir::Files, QDir::Name);
for(QFileInfoList::iterator i = fileList.begin();i != fileList.end();i++)
add(_dir.path(), i->fileName(), i->birthTime(), i->size(), false);
QStringList dirList = _dir.entryList(QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDir::Name);
for(QStringList::iterator i = dirList.begin();i != dirList.end();i++)
{
parseDir(dir + QDir::separator() + *i, lpStatusBar);
}
}
bool cFileList::load(const QString& file, QProgressBar* lpProgressBar)
@@ -147,6 +170,15 @@ bool cFileList::load(const QString& file, QProgressBar* lpProgressBar)
return(true);
}
bool cFileList::load(const QString& dir, QStatusBar* lpStatusBar)
{
clear();
parseDir(dir, lpStatusBar);
return(true);
}
cFile* cFileList::add(const QString& dir, const QString& file, const QDateTime& dateTime, const qint64& size, bool search)
{
cFile* lpFile = nullptr;
+4
View File
@@ -8,6 +8,8 @@
#include <QDateTime>
#include <QObject>
#include <QProgressBar>
#include <QStatusBar>
#include <QDir>
class cFile
@@ -41,6 +43,7 @@ class cFileList : public QList<cFile>
{
public:
bool load(const QString& file, QProgressBar* lpProgressBar = nullptr);
bool load(const QString& dir, QStatusBar* lpStatusBar = nullptr);
cFile* add(const QString& dir, const QString& file, const QDateTime& dateTime, const qint64& size, bool search = true);
cFile* find(const QString& dir, const QString& file, const QDateTime& dateTime, const qint64& size);
@@ -48,6 +51,7 @@ public:
bool contains(cFile& file, bool bDir, bool bFile, bool bDate, bool bSize);
private:
void parseLine(const QString& curDir, const QString& line);
void parseDir(const QString& dir, QStatusBar* lpStatusBar);
};
#endif // CFILE_H
+151 -6
View File
@@ -7,6 +7,9 @@
#include <QDir>
#include <QFileDialog>
#include <QElapsedTimer>
#include <QDebug>
//#define TREEVIEW
@@ -131,6 +134,9 @@ void cMainWindow::createActions()
connect(ui->m_lpLoadListFromFileLeft, &QToolButton::clicked, this, &cMainWindow::onLoadListFromFileLeft);
connect(ui->m_lpLoadListFromFileRight, &QToolButton::clicked, this, &cMainWindow::onLoadListFromFileRight);
connect(ui->m_lpLoadListFromDirLeft, &QToolButton::clicked, this, &cMainWindow::onLoadListFromDirLeft);
connect(ui->m_lpLoadListFromDirRight, &QToolButton::clicked, this, &cMainWindow::onLoadListFromDirRight);
connect(ui->m_lpLeftList->selectionModel(), &QItemSelectionModel::selectionChanged, this, &cMainWindow::onLeftListSelected);
connect(ui->m_lpRightList->selectionModel(), &QItemSelectionModel::selectionChanged, this, &cMainWindow::onRightListSelected);
@@ -138,6 +144,11 @@ void cMainWindow::createActions()
connect(ui->m_lpMatchFile, &QCheckBox::clicked, this, &cMainWindow::onMatchFileChecked);
connect(ui->m_lpMatchDateTime, &QCheckBox::clicked, this, &cMainWindow::onMatchDateTimeChecked);
connect(ui->m_lpMatchSize, &QCheckBox::clicked, this, &cMainWindow::onMatchSizeChecked);
connect(ui->m_lpMarkDifference, &QToolButton::clicked, this, &cMainWindow::onMarkDifference);
connect(ui->m_lpClearSelectionLeft, &QToolButton::clicked, this, &cMainWindow::onClearSelectionLeft);
connect(ui->m_lpClearSelectionRight, &QToolButton::clicked, this, &cMainWindow::onClearSelectionRight);
}
void cMainWindow::createFileActions()
@@ -151,19 +162,23 @@ void cMainWindow::createContextActions()
void cMainWindow::onLoadListFromFileLeft()
{
QSettings settings;
QString szPath = settings.value("main/leftDir", QDir::homePath()).toString();
QString szPath = settings.value("main/leftFile", QDir::homePath()).toString();
QString szFile = QFileDialog::getOpenFileName(this, tr("Open Text File"), szPath, tr("Text Files (*.txt)"));
if(szFile.isEmpty())
return;
settings.setValue("main/leftDir", QVariant::fromValue(szFile.left(szFile.lastIndexOf("/"))));
settings.setValue("main/leftFile", QVariant::fromValue(szFile.left(szFile.lastIndexOf("/"))));
m_loading = true;
m_lpProgressBar->setVisible(true);
// m_listLeft.load("C:\\Users\\VET0572\\Documents\\github\\build-dir2csv-Desktop_Qt_5_13_0_MinGW_64_bit-Release\\deploy\\photos.txt", m_lpProgressBar);
ui->m_lpStatusBar->showMessage("loading list...");
qApp->processEvents();
m_listLeft.load(szFile, m_lpProgressBar);
ui->m_lpStatusBar->showMessage("populating list...");
qApp->processEvents();
displayList(ui->m_lpLeftList, m_lpLeftListModel, m_listLeft);
ui->m_lpStatusBar->showMessage("done.", 5000);
m_lpProgressBar->setVisible(false);
m_loading = false;
}
@@ -171,23 +186,151 @@ void cMainWindow::onLoadListFromFileLeft()
void cMainWindow::onLoadListFromFileRight()
{
QSettings settings;
QString szPath = settings.value("main/rightDir", QDir::homePath()).toString();
QString szPath = settings.value("main/rightFile", QDir::homePath()).toString();
QString szFile = QFileDialog::getOpenFileName(this, tr("Open Text File"), szPath, tr("Text Files (*.txt)"));
if(szFile.isEmpty())
return;
settings.setValue("main/rightDir", QVariant::fromValue(szFile.left(szFile.lastIndexOf("/"))));
settings.setValue("main/rightFile", QVariant::fromValue(szFile.left(szFile.lastIndexOf("/"))));
m_loading = true;
m_lpProgressBar->setVisible(true);
// m_listRight.load("C:\\Users\\VET0572\\Documents\\github\\build-dir2csv-Desktop_Qt_5_13_0_MinGW_64_bit-Release\\deploy\\photos1.txt", m_lpProgressBar);
ui->m_lpStatusBar->showMessage("loading list...");
qApp->processEvents();
m_listRight.load(szFile, m_lpProgressBar);
ui->m_lpStatusBar->showMessage("populating list...");
qApp->processEvents();
displayList(ui->m_lpRightList, m_lpRightListModel, m_listRight);
ui->m_lpStatusBar->showMessage("done.", 5000);
m_lpProgressBar->setVisible(false);
m_loading = false;
}
void cMainWindow::onLoadListFromDirLeft()
{
QSettings settings;
QString szPath = settings.value("main/leftDir", QDir::homePath()).toString();
QString szDir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), szPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(szDir.isEmpty())
return;
settings.setValue("main/leftDir", QVariant::fromValue(szDir));
m_loading = true;
ui->m_lpStatusBar->showMessage("loading list...");
qApp->processEvents();
m_listLeft.load(szDir, ui->m_lpStatusBar);
ui->m_lpStatusBar->showMessage("populating list...");
qApp->processEvents();
displayList(ui->m_lpLeftList, m_lpLeftListModel, m_listLeft);
ui->m_lpStatusBar->showMessage("done.", 5000);
m_loading = false;
}
void cMainWindow::onLoadListFromDirRight()
{
QSettings settings;
QString szPath = settings.value("main/rightDir", QDir::homePath()).toString();
QString szDir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), szPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(szDir.isEmpty())
return;
settings.setValue("main/rightDir", QVariant::fromValue(szDir));
m_loading = true;
ui->m_lpStatusBar->showMessage("loading list...");
qApp->processEvents();
m_listRight.load(szDir, ui->m_lpStatusBar);
ui->m_lpStatusBar->showMessage("populating list...");
qApp->processEvents();
displayList(ui->m_lpRightList, m_lpRightListModel, m_listRight);
ui->m_lpStatusBar->showMessage("done.", 5000);
m_loading = false;
}
void cMainWindow::onMarkDifference()
{
qint64 div = m_lpLeftListModel->rowCount() / 1000;
ui->m_lpStatusBar->showMessage("processing left list...");
m_lpProgressBar->setVisible(true);
m_lpProgressBar->setRange(0, m_lpLeftListModel->rowCount());
QVariant white = QVariant::fromValue(QBrush(QColor(Qt::white)));
QVariant green = QVariant::fromValue(QBrush(QColor(Qt::green)));
for(int i = 0;i < m_lpLeftListModel->rowCount();i++)
{
QStandardItem* lpItem = m_lpLeftListModel->item(i, 0);
cFile* lpFile = lpItem->data(Qt::UserRole+1).value<cFile*>();
QVariant var;
if(m_listRight.contains(*lpFile))
{
lpItem->setData(green, Qt::BackgroundRole);
m_lpLeftListModel->setData(m_lpLeftListModel->index(i, 1), green, Qt::BackgroundRole);
m_lpLeftListModel->setData(m_lpLeftListModel->index(i, 2), green, Qt::BackgroundRole);
#ifndef TREEVIEW
m_lpLeftListModel->setData(m_lpLeftListModel->index(i, 3), green, Qt::BackgroundRole);
#endif
}
if(!(i % div))
{
m_lpProgressBar->setValue(i);
qApp->processEvents();
}
}
div = m_lpRightListModel->rowCount() / 1000;
ui->m_lpStatusBar->showMessage("processing right list...");
m_lpProgressBar->setRange(0, m_lpRightListModel->rowCount());
for(int i = 0;i < m_lpRightListModel->rowCount();i++)
{
QStandardItem* lpItem = m_lpRightListModel->item(i, 0);
cFile* lpFile = lpItem->data(Qt::UserRole+1).value<cFile*>();
QBrush brush(Qt::white);
if(m_listLeft.contains(*lpFile))
{
lpItem->setData(green, Qt::BackgroundRole);
m_lpRightListModel->setData(m_lpRightListModel->index(i, 1), green, Qt::BackgroundRole);
m_lpRightListModel->setData(m_lpRightListModel->index(i, 2), green, Qt::BackgroundRole);
#ifndef TREEVIEW
m_lpRightListModel->setData(m_lpRightListModel->index(i, 3), green, Qt::BackgroundRole);
#endif
}
if(!(i % div))
{
m_lpProgressBar->setValue(i);
qApp->processEvents();
}
}
m_lpProgressBar->setVisible(false);
ui->m_lpStatusBar->showMessage("done.", 5000);
}
void cMainWindow::onClearSelectionLeft()
{
ui->m_lpLeftList->clearSelection();
m_lpRightListProxyModel->setFilterFile(nullptr);
}
void cMainWindow::onClearSelectionRight()
{
ui->m_lpRightList->clearSelection();
m_lpLeftListProxyModel->setFilterFile(nullptr);
}
#ifdef TREEVIEW
QStandardItem* insertPath(QTreeView* lpView, QStandardItem* lpRootItem, QString szPath)
{
@@ -257,6 +400,8 @@ void cMainWindow::displayList(QTreeView* lpView, QStandardItemModel* lpModel, cF
lpModel->setHorizontalHeaderLabels(header);
QStandardItem* lpRoot = lpModel->invisibleRootItem();
m_lpProgressBar->setRange(0, fileList.count());
for(cFileList::iterator i = fileList.begin();i != fileList.end();i++)
{
QList<QStandardItem*> items;
+8
View File
@@ -27,6 +27,9 @@ private slots:
void onLoadListFromFileLeft();
void onLoadListFromFileRight();
void onLoadListFromDirLeft();
void onLoadListFromDirRight();
void onLeftListSelected(const QItemSelection& selection, const QItemSelection& previous);
void onRightListSelected(const QItemSelection& selection, const QItemSelection& previous);
@@ -35,6 +38,11 @@ private slots:
void onMatchDateTimeChecked(bool checked);
void onMatchSizeChecked(bool checked);
void onMarkDifference();
void onClearSelectionLeft();
void onClearSelectionRight();
private:
Ui::cMainWindow* ui;
QStandardItemModel* m_lpLeftListModel;
+35
View File
@@ -47,6 +47,13 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_lpMarkDifference">
<property name="text">
<string>mark difference</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
@@ -71,6 +78,13 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="m_lpLoadListFromDirLeft">
<property name="text">
<string>from dir</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_lpLoadListFromFileLeft">
<property name="text">
@@ -78,6 +92,13 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_lpClearSelectionLeft">
<property name="text">
<string>clear selection</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@@ -106,6 +127,13 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolButton" name="m_lpLoadListFromDirRight">
<property name="text">
<string>from dir</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_lpLoadListFromFileRight">
<property name="text">
@@ -113,6 +141,13 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_lpClearSelectionRight">
<property name="text">
<string>clear selection</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
-2
View File
@@ -24,8 +24,6 @@ bool cSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
if(!m_lpFile)
return(true);
bool bValid = false;
QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
cFile* lpFile = sourceModel()->data(index0, Qt::UserRole+1).value<cFile*>();