Improve file selection in file system widget
This commit is contained in:
@@ -17,7 +17,7 @@ FilesystemWidget::FilesystemWidget(QAbstractItemModel *model, QWidget *parent) :
|
|||||||
|
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
connect(m_listView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(fileClicked(QModelIndex)));
|
connect(m_listView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FilesystemWidget::fileClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemWidget::setDir(const QString &dir)
|
void FilesystemWidget::setDir(const QString &dir)
|
||||||
@@ -34,8 +34,9 @@ void FilesystemWidget::selectFile(int row)
|
|||||||
m_listView->scrollTo(index);
|
m_listView->scrollTo(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemWidget::fileClicked(const QModelIndex &index)
|
void FilesystemWidget::fileClicked(const QModelIndex &index, const QModelIndex &)
|
||||||
{
|
{
|
||||||
|
if(index.isValid())
|
||||||
emit fileSelected(index.row());
|
emit fileSelected(index.row());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ public:
|
|||||||
void setDir(const QString &dir);
|
void setDir(const QString &dir);
|
||||||
private slots:
|
private slots:
|
||||||
void selectFile(int row);
|
void selectFile(int row);
|
||||||
void fileClicked(const QModelIndex &index);
|
void fileClicked(const QModelIndex &index, const QModelIndex &);
|
||||||
signals:
|
signals:
|
||||||
void fileSelected(int row);
|
void fileSelected(int row);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -209,6 +209,13 @@ AnalyzeLevel ImageRingList::analyzeLevel() const
|
|||||||
void ImageRingList::loadFile(int row)
|
void ImageRingList::loadFile(int row)
|
||||||
{
|
{
|
||||||
if(row < m_images.size())
|
if(row < m_images.size())
|
||||||
|
{
|
||||||
|
int diff = m_currImage != m_images.end() ? row - (m_currImage - m_images.begin()) : -100;
|
||||||
|
if(diff == 1)
|
||||||
|
increment();
|
||||||
|
else if(diff == -1)
|
||||||
|
decrement();
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_firstImage = m_currImage = m_lastImage = m_images.begin()+row;
|
m_firstImage = m_currImage = m_lastImage = m_images.begin()+row;
|
||||||
if(m_images.empty())
|
if(m_images.empty())
|
||||||
@@ -237,6 +244,7 @@ void ImageRingList::loadFile(int row)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageRingList::loadThumbnails()
|
void ImageRingList::loadThumbnails()
|
||||||
@@ -333,6 +341,7 @@ void ImageRingList::setFiles(const QStringList files, const QString ¤tFile
|
|||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
m_currImage = m_images.end();
|
||||||
loadFile(index);
|
loadFile(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,9 +216,11 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
|
|||||||
switch (event->key())
|
switch (event->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
|
case Qt::Key_Up:
|
||||||
m_ringList->decrement();
|
m_ringList->decrement();
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
|
case Qt::Key_Down:
|
||||||
m_ringList->increment();
|
m_ringList->increment();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user