initial commit
This commit is contained in:
+55
-35
@@ -17,16 +17,21 @@
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
|
||||
cFileBrowser::cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpImageFormats, QWidget *parent) :
|
||||
cFileBrowser::cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpImageFormats, QListView* lpSelectedList, QStandardItemModel* lpSelectedListModel, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::cFileBrowser),
|
||||
m_lpSelectedList(lpSelectedList),
|
||||
m_lpFileListModel(nullptr),
|
||||
m_lpSelectedListModel(lpSelectedListModel),
|
||||
m_lpProgressBar(lpProgressBar),
|
||||
m_lpImageFormats(lpImageFormats),
|
||||
m_working(false)
|
||||
@@ -35,8 +40,7 @@ cFileBrowser::cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpIm
|
||||
|
||||
ui->m_lpFileList->setGridSize(QSize(THUMBNAIL_WIDTH+2+4, THUMBNAIL_WIDTH+34+4));
|
||||
|
||||
// m_directoryListModel.setRootPath("");
|
||||
m_directoryListModel.setRootPath("C:/Users/birkeh/Pictures");
|
||||
m_directoryListModel.setRootPath("");
|
||||
m_directoryListModel.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||
ui->m_lpDirectoryList->setModel(&m_directoryListModel);
|
||||
ui->m_lpDirectoryList->setAnimated(false);
|
||||
@@ -46,9 +50,6 @@ cFileBrowser::cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpIm
|
||||
m_lpFileListModel = new QStandardItemModel(0, 0);
|
||||
ui->m_lpFileList->setModel(m_lpFileListModel);
|
||||
|
||||
m_lpSelectedListModel = new QStandardItemModel(0, 0);
|
||||
ui->m_lpSelectedList->setModel(m_lpSelectedListModel);
|
||||
|
||||
m_cacheDB = QSqlDatabase::addDatabase("QSQLITE", "cacheDB");
|
||||
m_cacheDB.setHostName("localhost");
|
||||
m_cacheDB.setDatabaseName(userDir() + "cache.db");
|
||||
@@ -83,6 +84,18 @@ cFileBrowser::cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpIm
|
||||
}
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
QStringList picturesPathList = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
|
||||
QString picturesPath;
|
||||
|
||||
if(picturesPathList.count())
|
||||
picturesPath = picturesPathList[0];
|
||||
|
||||
QString filePath = settings.value("lastPath", QVariant::fromValue(picturesPath)).toString();
|
||||
QModelIndex index = m_directoryListModel.index(filePath);
|
||||
ui->m_lpDirectoryList->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select);
|
||||
directorySelected(filePath);
|
||||
|
||||
connect(ui->m_lpDirectoryList->selectionModel(), &QItemSelectionModel::selectionChanged, this, &cFileBrowser::onDirectoryChanged);
|
||||
}
|
||||
|
||||
@@ -96,31 +109,7 @@ cFileBrowser::~cFileBrowser()
|
||||
|
||||
void cFileBrowser::onDirectoryChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/)
|
||||
{
|
||||
m_working = true;
|
||||
|
||||
m_lpProgressBar->setVisible(true);
|
||||
ui->m_lpDirectoryList->setEnabled(false);
|
||||
|
||||
m_lpFileListModel->clear();
|
||||
|
||||
QFileInfo info = m_directoryListModel.fileInfo(selected.indexes()[0]);
|
||||
QDir dir(info.filePath());
|
||||
|
||||
QFileInfoList list = dir.entryInfoList(generateReadList(*m_lpImageFormats), QDir::Files, QDir::Name);
|
||||
|
||||
m_lpProgressBar->setRange(0, list.count());
|
||||
|
||||
for(int x = 0;x < list.count();x++)
|
||||
{
|
||||
addFile(list[x]);
|
||||
m_lpProgressBar->setValue(x);
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
ui->m_lpDirectoryList->setEnabled(true);
|
||||
m_lpProgressBar->setVisible(false);
|
||||
|
||||
m_working = false;
|
||||
directorySelected(m_directoryListModel.fileInfo(selected.indexes()[0]).filePath());
|
||||
}
|
||||
|
||||
void cFileBrowser::onCountChanged(cFileViewer* fileViewer)
|
||||
@@ -129,7 +118,7 @@ void cFileBrowser::onCountChanged(cFileViewer* fileViewer)
|
||||
|
||||
for(int x = 0;x < m_lpSelectedListModel->rowCount();x++)
|
||||
{
|
||||
lpFileViewer = static_cast<cFileViewer*>(ui->m_lpSelectedList->indexWidget(m_lpSelectedListModel->index(x, 0)));
|
||||
lpFileViewer = static_cast<cFileViewer*>(m_lpSelectedList->indexWidget(m_lpSelectedListModel->index(x, 0)));
|
||||
if(lpFileViewer)
|
||||
{
|
||||
if(lpFileViewer->fileName() == fileViewer->fileName())
|
||||
@@ -153,7 +142,7 @@ void cFileBrowser::onCountChanged(cFileViewer* fileViewer)
|
||||
lpFileViewer1->setCount(fileViewer->count());
|
||||
|
||||
m_lpSelectedListModel->appendRow(lpItem);
|
||||
ui->m_lpSelectedList->setIndexWidget(m_lpSelectedListModel->index(m_lpSelectedListModel->rowCount()-1, 0), lpFileViewer1);
|
||||
m_lpSelectedList->setIndexWidget(m_lpSelectedListModel->index(m_lpSelectedListModel->rowCount()-1, 0), lpFileViewer1);
|
||||
|
||||
connect(lpFileViewer1, &cFileViewer::countChanged, this, &cFileBrowser::onCountChangedSelected);
|
||||
}
|
||||
@@ -179,6 +168,37 @@ void cFileBrowser::onCountChangedSelected(cFileViewer* fileViewer)
|
||||
}
|
||||
}
|
||||
|
||||
void cFileBrowser::directorySelected(const QString& filePath)
|
||||
{
|
||||
m_working = true;
|
||||
|
||||
m_lpProgressBar->setVisible(true);
|
||||
ui->m_lpDirectoryList->setEnabled(false);
|
||||
|
||||
m_lpFileListModel->clear();
|
||||
|
||||
QDir dir(filePath);
|
||||
|
||||
QFileInfoList list = dir.entryInfoList(generateReadList(*m_lpImageFormats), QDir::Files, QDir::Name);
|
||||
|
||||
m_lpProgressBar->setRange(0, list.count());
|
||||
|
||||
for(int x = 0;x < list.count();x++)
|
||||
{
|
||||
addFile(list[x]);
|
||||
m_lpProgressBar->setValue(x);
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
ui->m_lpDirectoryList->setEnabled(true);
|
||||
m_lpProgressBar->setVisible(false);
|
||||
|
||||
QSettings settings;
|
||||
settings.setValue("lastPath", QVariant::fromValue(filePath));
|
||||
|
||||
m_working = false;
|
||||
}
|
||||
|
||||
void cFileBrowser::addFile(const QFileInfo& fileInfo)
|
||||
{
|
||||
cEXIF* lpExif = new cEXIF(&m_exifTAGList, &m_exifCompressionList, &m_exifLightSourceList, &m_exifFlashList, &m_iptcTagList, &m_xmpTagList);
|
||||
@@ -208,7 +228,7 @@ void cFileBrowser::addFile(const QFileInfo& fileInfo)
|
||||
|
||||
for(int x = 0;x < m_lpSelectedListModel->rowCount();x++)
|
||||
{
|
||||
lpFileViewer = static_cast<cFileViewer*>(ui->m_lpSelectedList->indexWidget(m_lpSelectedListModel->index(x, 0)));
|
||||
lpFileViewer = static_cast<cFileViewer*>(m_lpSelectedList->indexWidget(m_lpSelectedListModel->index(x, 0)));
|
||||
if(lpFileViewer)
|
||||
{
|
||||
if(lpFileViewer->fileName() == lpFileViewerNew->fileName())
|
||||
|
||||
+10
-1
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <QListView>
|
||||
#include <QFileSystemModel>
|
||||
#include <QItemSelection>
|
||||
#include <QStandardItemModel>
|
||||
@@ -45,7 +46,7 @@ public:
|
||||
\param lpImageFormats
|
||||
\param parent
|
||||
*/
|
||||
explicit cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpImageFormats, QWidget *parent = nullptr);
|
||||
explicit cFileBrowser(QProgressBar* lpProgressBar, QList<IMAGEFORMAT>* lpImageFormats, QListView* lpSelectedList, QStandardItemModel* lpSelectedListModel, QWidget *parent = nullptr);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -55,6 +56,7 @@ public:
|
||||
|
||||
private:
|
||||
Ui::cFileBrowser* ui; /*!< TODO: describe */
|
||||
QListView* m_lpSelectedList; /*!< TODO: describe */
|
||||
QFileSystemModel m_directoryListModel; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpFileListModel; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpSelectedListModel; /*!< TODO: describe */
|
||||
@@ -74,6 +76,13 @@ private:
|
||||
|
||||
bool m_working; /*!< TODO: describe */
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn directorySelected
|
||||
\param filePath
|
||||
*/
|
||||
void directorySelected(const QString& filePath);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
|
||||
@@ -44,37 +44,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="m_lpSelectedList">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>244</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>244</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="movement">
|
||||
<enum>QListView::Free</enum>
|
||||
</property>
|
||||
<property name="flow">
|
||||
<enum>QListView::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QListView::Adjust</enum>
|
||||
</property>
|
||||
<property name="gridSize">
|
||||
<size>
|
||||
<width>202</width>
|
||||
<height>236</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
+9
-4
@@ -34,6 +34,11 @@ cMainWindow::~cMainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cMainWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
QMainWindow::showEvent(event);
|
||||
}
|
||||
|
||||
void cMainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
// if(m_working)
|
||||
@@ -70,11 +75,11 @@ void cMainWindow::initUI()
|
||||
m_lpProgressBar->setVisible(false);
|
||||
ui->m_lpStatusBar->addPermanentWidget(m_lpProgressBar);
|
||||
|
||||
m_lpFileBrowser = new cFileBrowser(m_lpProgressBar, &m_imageFormats, this);
|
||||
ui->m_lpMainTab->addTab(m_lpFileBrowser, "Files");
|
||||
m_lpSelectedListModel = new QStandardItemModel(0, 0);
|
||||
ui->m_lpSelectedList->setModel(m_lpSelectedListModel);
|
||||
|
||||
// m_lpFileListModel = new QStandardItemModel;
|
||||
// ui->m_lpFileList->setModel(m_lpFileListModel);
|
||||
m_lpFileBrowser = new cFileBrowser(m_lpProgressBar, &m_imageFormats, ui->m_lpSelectedList, m_lpSelectedListModel, this);
|
||||
ui->m_lpMainTab->addTab(m_lpFileBrowser, "Files");
|
||||
|
||||
if(!settings.value("main/maximized").toBool())
|
||||
{
|
||||
|
||||
+12
-4
@@ -42,12 +42,13 @@ public:
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui; /*!< TODO: describe */
|
||||
cSplashScreen* m_lpSplashScreen; /*!< TODO: describe */
|
||||
QProgressBar* m_lpProgressBar; /*!< TODO: describe */
|
||||
cSplashScreen* m_lpSplashScreen; /*!< TODO: describe */
|
||||
QProgressBar* m_lpProgressBar; /*!< TODO: describe */
|
||||
|
||||
cFileBrowser* m_lpFileBrowser; /*!< TODO: describe */
|
||||
cFileBrowser* m_lpFileBrowser; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpSelectedListModel; /*!< TODO: describe */
|
||||
|
||||
QList<IMAGEFORMAT> m_imageFormats; /*!< TODO: describe */
|
||||
QList<IMAGEFORMAT> m_imageFormats; /*!< TODO: describe */
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -93,6 +94,13 @@ private:
|
||||
void addImageFormat(const QString& shortName, const QString& description, const QString& extension, QList<QByteArray>& readList, QList<QByteArray>& writeList);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn showEvent
|
||||
\param event
|
||||
*/
|
||||
void showEvent(QShowEvent *event);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
|
||||
+32
-1
@@ -18,6 +18,37 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="m_lpMainTab"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QListView" name="m_lpSelectedList">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>264</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>264</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="movement">
|
||||
<enum>QListView::Free</enum>
|
||||
</property>
|
||||
<property name="flow">
|
||||
<enum>QListView::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QListView::Adjust</enum>
|
||||
</property>
|
||||
<property name="gridSize">
|
||||
<size>
|
||||
<width>202</width>
|
||||
<height>236</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="m_lpMenuBar">
|
||||
@@ -26,7 +57,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user