Add marking and unmark from thumbnails view
This commit is contained in:
+1
-2
@@ -163,8 +163,7 @@ void FITSFileModel::prepareQuery()
|
||||
if(lastError().type() != QSqlError::NoError)
|
||||
qDebug() << lastError();
|
||||
|
||||
QStringList list = m_database->getMarkedFiles();
|
||||
m_markedFiles = QSet<QString>(list.begin(), list.end());
|
||||
m_markedFiles = m_database->getMarkedFiles().toSet();
|
||||
}
|
||||
|
||||
DatabaseTableView::DatabaseTableView(QWidget *parent) : QTableView(parent)
|
||||
|
||||
+1
-1
@@ -261,7 +261,7 @@ QStringList ImageRingList::imageNames() const
|
||||
{
|
||||
QStringList ret;
|
||||
for(auto &img : m_images)
|
||||
ret.push_back(QFileInfo(img->name()).fileName());
|
||||
ret.push_back(img->name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+33
-9
@@ -10,6 +10,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QPainter>
|
||||
#include <QFileInfo>
|
||||
|
||||
struct RawImageType
|
||||
{
|
||||
@@ -45,7 +46,8 @@ void setScrollRange(QScrollBar *scrollBar, int newRange)
|
||||
scrollBar->setValue(relPos*newRange - page/2);
|
||||
}
|
||||
|
||||
ImageWidget::ImageWidget(QWidget *parent) : QOpenGLWidget(parent)
|
||||
ImageWidget::ImageWidget(Database *database, QWidget *parent) : QOpenGLWidget(parent)
|
||||
, m_database(database)
|
||||
{
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
m_range = UINT16_MAX;
|
||||
@@ -117,19 +119,23 @@ void ImageWidget::blockRepaint(bool block)
|
||||
if(!block)update();
|
||||
}
|
||||
|
||||
void ImageWidget::allocateThumbnails(const QStringList &names)
|
||||
void ImageWidget::allocateThumbnails(const QStringList &paths)
|
||||
{
|
||||
int count = names.size();
|
||||
int count = paths.size();
|
||||
m_thumbnailCount = count;
|
||||
m_thumnails.clear();
|
||||
for(auto &name : names)
|
||||
m_thumnails.push_back({name, QSize(0, 0), false});
|
||||
QStringList marked = m_database->getMarkedFiles();
|
||||
for(auto &path : paths)
|
||||
{
|
||||
QString name = QFileInfo(path).fileName();
|
||||
m_thumnails.push_back({name, path, QSize(0, 0), marked.contains(path), false});
|
||||
}
|
||||
|
||||
m_thumbnailTexture->destroy();
|
||||
m_thumbnailTexture->create();
|
||||
m_thumbnailTexture->setFormat(QOpenGLTexture::RGB16_UNorm);
|
||||
m_thumbnailTexture->setSize(THUMB_SIZE, THUMB_SIZE);
|
||||
m_thumbnailTexture->setLayers(names.size());
|
||||
m_thumbnailTexture->setLayers(paths.size());
|
||||
m_thumbnailTexture->allocateStorage();
|
||||
m_bufferSizes->bind();
|
||||
float *tmp = new float[count*3];
|
||||
@@ -440,6 +446,24 @@ void ImageWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
m_selecting = false;
|
||||
event->accept();
|
||||
QStringList mark;
|
||||
QStringList unmark;
|
||||
for(auto &thumb : m_thumnails)
|
||||
{
|
||||
if(thumb.dirty)
|
||||
{
|
||||
if(thumb.selected)
|
||||
mark.append(thumb.path);
|
||||
else
|
||||
unmark.append(thumb.path);
|
||||
|
||||
thumb.dirty = false;
|
||||
}
|
||||
}
|
||||
if(!mark.isEmpty())
|
||||
m_database->mark(mark);
|
||||
if(!unmark.isEmpty())
|
||||
m_database->unmark(unmark);
|
||||
}
|
||||
else
|
||||
event->ignore();
|
||||
@@ -467,19 +491,19 @@ void ImageWidget::thumbSelect(QMouseEvent *event)
|
||||
|
||||
if(newVal != oldVal)
|
||||
{
|
||||
emit thumbSelected(i);
|
||||
m_thumnails[i].selected = newVal;
|
||||
m_thumnails[i].dirty = true;
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImageScrollAreaGL::ImageScrollAreaGL(QWidget *parent) : QWidget(parent)
|
||||
ImageScrollAreaGL::ImageScrollAreaGL(Database *database, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *layout = new QGridLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
m_imageWidget = new ImageWidget(this);
|
||||
m_imageWidget = new ImageWidget(database, this);
|
||||
|
||||
m_verticalScrollBar = new QScrollBar(Qt::Vertical, this);
|
||||
m_horizontalScrollBar = new QScrollBar(Qt::Horizontal, this);
|
||||
|
||||
+7
-4
@@ -13,12 +13,15 @@
|
||||
#include <QTimer>
|
||||
#include "rawimage.h"
|
||||
#include "imageringlist.h"
|
||||
#include "database.h"
|
||||
|
||||
struct ImageThumb
|
||||
{
|
||||
QString name;
|
||||
QString path;
|
||||
QSize size;
|
||||
bool selected;
|
||||
bool dirty;
|
||||
};
|
||||
|
||||
class ImageWidget : public QOpenGLWidget
|
||||
@@ -53,14 +56,15 @@ class ImageWidget : public QOpenGLWidget
|
||||
bool m_selecting;
|
||||
int m_thumbnailCount;
|
||||
QVector<ImageThumb> m_thumnails;
|
||||
Database *m_database;
|
||||
public:
|
||||
explicit ImageWidget(QWidget *parent = nullptr);
|
||||
explicit ImageWidget(Database *database, QWidget *parent = nullptr);
|
||||
~ImageWidget() override;
|
||||
void setImage(const RawImage *image, int index);
|
||||
void setImage(const QPixmap &pixmap);
|
||||
void setScale(float scale);
|
||||
void blockRepaint(bool block);
|
||||
void allocateThumbnails(const QStringList &names);
|
||||
void allocateThumbnails(const QStringList &paths);
|
||||
public slots:
|
||||
void setMTFParams(float low, float mid, float high);
|
||||
void setOffset(int dx, int dy);
|
||||
@@ -81,7 +85,6 @@ protected:
|
||||
void thumbSelect(QMouseEvent *event);
|
||||
signals:
|
||||
void fileDropped(const QString &path);
|
||||
void thumbSelected(int index);
|
||||
};
|
||||
|
||||
class ImageScrollAreaGL : public QWidget
|
||||
@@ -96,7 +99,7 @@ class ImageScrollAreaGL : public QWidget
|
||||
bool m_bestFit;
|
||||
int m_thumbCount;
|
||||
public:
|
||||
explicit ImageScrollAreaGL(QWidget *parent = nullptr);
|
||||
explicit ImageScrollAreaGL(Database *database, QWidget *parent = nullptr);
|
||||
~ImageScrollAreaGL() override;
|
||||
void setImage(RawImage *image, int index);
|
||||
ImageWidget* imageWidget();
|
||||
|
||||
+5
-5
@@ -42,7 +42,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
//setCentralWidget(m_image);
|
||||
resize(800, 600);
|
||||
|
||||
m_imageGL = new ImageScrollAreaGL(this);
|
||||
m_database = new Database(this);
|
||||
if(!m_database->init())
|
||||
QMessageBox::critical(this, tr("Can't open DB"), tr("Can't open SQLITE database"));
|
||||
|
||||
m_imageGL = new ImageScrollAreaGL(m_database, this);
|
||||
setCentralWidget(m_imageGL);
|
||||
|
||||
m_stretchPanel = new StretchToolbar(this);
|
||||
@@ -61,10 +65,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
connect(m_filetree, &Filetree::moveFiles, [this](const QString &path){ copyOrMove(false, path); });
|
||||
connect(m_filetree, &Filetree::indexDirectory, this, static_cast<void (MainWindow::*)(const QString &)>(&MainWindow::indexDir));
|
||||
|
||||
m_database = new Database(this);
|
||||
if(!m_database->init())
|
||||
QMessageBox::critical(this, tr("Can't open DB"), tr("Can't open SQLITE database"));
|
||||
|
||||
m_databaseView = new DataBaseView(m_database, this);
|
||||
connect(m_databaseView, SIGNAL(loadFile(QString)), this, SLOT(loadFile(QString)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user