Sync file browser after change via Drag & Drop
This commit is contained in:
parent
5010d3621d
commit
c525a6acd9
|
@ -76,7 +76,7 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent)
|
||||||
connect(m_ui->abortPushButton, &QPushButton::clicked, this, &DbQueryWidget::abortSearch);
|
connect(m_ui->abortPushButton, &QPushButton::clicked, this, &DbQueryWidget::abortSearch);
|
||||||
connect(m_ui->startPushButton, &QPushButton::clicked, this, &DbQueryWidget::startSearch);
|
connect(m_ui->startPushButton, &QPushButton::clicked, this, &DbQueryWidget::startSearch);
|
||||||
connect(m_ui->applyPushButton, &QPushButton::clicked, this, &DbQueryWidget::applyResults);
|
connect(m_ui->applyPushButton, &QPushButton::clicked, this, &DbQueryWidget::applyResults);
|
||||||
connect(m_tagEditorWidget, &TagEditorWidget::fileStatusChange, this, &DbQueryWidget::fileStatusChanged);
|
connect(m_tagEditorWidget, &TagEditorWidget::fileStatusChanged, this, &DbQueryWidget::fileStatusChanged);
|
||||||
connect(m_ui->resultsTreeView, &QTreeView::customContextMenuRequested, this, &DbQueryWidget::showResultsContextMenu);
|
connect(m_ui->resultsTreeView, &QTreeView::customContextMenuRequested, this, &DbQueryWidget::showResultsContextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ MediaFileInfo &MainWindow::fileInfo()
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent, Qt::Window),
|
QMainWindow(parent, Qt::Window),
|
||||||
m_ui(new Ui::MainWindow()),
|
m_ui(new Ui::MainWindow()),
|
||||||
|
m_internalFileSelection(false),
|
||||||
m_aboutDlg(nullptr),
|
m_aboutDlg(nullptr),
|
||||||
m_settingsDlg(nullptr),
|
m_settingsDlg(nullptr),
|
||||||
m_dbQueryWidget(nullptr)
|
m_dbQueryWidget(nullptr)
|
||||||
|
@ -137,9 +138,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
connect(m_ui->actionAbout, &QAction::triggered, this, &MainWindow::showAboutDlg);
|
connect(m_ui->actionAbout, &QAction::triggered, this, &MainWindow::showAboutDlg);
|
||||||
// tag editor widget
|
// tag editor widget
|
||||||
connect(m_ui->tagEditorWidget, &TagEditorWidget::nextFileSelected, this, static_cast<void(MainWindow::*)(void)>(&MainWindow::selectNextFile));
|
connect(m_ui->tagEditorWidget, &TagEditorWidget::nextFileSelected, this, static_cast<void(MainWindow::*)(void)>(&MainWindow::selectNextFile));
|
||||||
connect(m_ui->tagEditorWidget, &TagEditorWidget::fileStatusChange, this, &MainWindow::handleFileStatusChange);
|
connect(m_ui->tagEditorWidget, &TagEditorWidget::fileStatusChanged, this, &MainWindow::handleFileStatusChange);
|
||||||
connect(m_ui->tagEditorWidget, &TagEditorWidget::statusMessage, m_ui->statusBar, &QStatusBar::showMessage);
|
connect(m_ui->tagEditorWidget, &TagEditorWidget::statusMessage, m_ui->statusBar, &QStatusBar::showMessage);
|
||||||
connect(m_ui->tagEditorWidget, &TagEditorWidget::fileSaved, this, &MainWindow::handleFileSaved);
|
connect(m_ui->tagEditorWidget, &TagEditorWidget::currentPathChanged, this, &MainWindow::handleCurrentPathChanged);
|
||||||
// misc
|
// misc
|
||||||
connect(m_ui->pathLineEdit, &QLineEdit::textEdited, this, &MainWindow::pathEntered);
|
connect(m_ui->pathLineEdit, &QLineEdit::textEdited, this, &MainWindow::pathEntered);
|
||||||
connect(m_ui->filesTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::fileSelected);
|
connect(m_ui->filesTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::fileSelected);
|
||||||
|
@ -209,9 +210,9 @@ bool MainWindow::event(QEvent *event)
|
||||||
*/
|
*/
|
||||||
void MainWindow::pathEntered()
|
void MainWindow::pathEntered()
|
||||||
{
|
{
|
||||||
QString path = m_ui->pathLineEdit->text();
|
const QString path = m_ui->pathLineEdit->text();
|
||||||
if(!path.isEmpty()) {
|
if(!path.isEmpty()) {
|
||||||
QModelIndex index = m_fileFilterModel->mapFromSource(m_fileModel->index(path));
|
const QModelIndex index = m_fileFilterModel->mapFromSource(m_fileModel->index(path));
|
||||||
if(index.isValid()) {
|
if(index.isValid()) {
|
||||||
m_ui->filesTreeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect);
|
m_ui->filesTreeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect);
|
||||||
m_ui->pathLineEdit->setProperty("classNames", QStringList());
|
m_ui->pathLineEdit->setProperty("classNames", QStringList());
|
||||||
|
@ -224,23 +225,26 @@ void MainWindow::pathEntered()
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief This private slot is called when the selected file or directory changes.
|
* \brief This private slot is called when the selected file or directory changes.
|
||||||
|
*
|
||||||
* If a directory is selected the m_ui->pathLineEdit will be updated.
|
* If a directory is selected the m_ui->pathLineEdit will be updated.
|
||||||
* If a file is selected it will be opened.
|
* If a file is selected it will be opened.
|
||||||
*/
|
*/
|
||||||
void MainWindow::fileSelected()
|
void MainWindow::fileSelected()
|
||||||
{
|
{
|
||||||
QModelIndexList selectedIndexes = m_ui->filesTreeView->selectionModel()->selectedRows();
|
if(!m_internalFileSelection) {
|
||||||
if(selectedIndexes.count() == 1) {
|
const QModelIndexList selectedIndexes = m_ui->filesTreeView->selectionModel()->selectedRows();
|
||||||
QString path(m_fileModel->filePath(m_fileFilterModel->mapToSource(selectedIndexes.at(0))));
|
if(selectedIndexes.count() == 1) {
|
||||||
QFileInfo fileInfo(path);
|
QString path(m_fileModel->filePath(m_fileFilterModel->mapToSource(selectedIndexes.at(0))));
|
||||||
if(fileInfo.isFile()) {
|
QFileInfo fileInfo(path);
|
||||||
startParsing(path);
|
if(fileInfo.isFile()) {
|
||||||
m_ui->pathLineEdit->setText(fileInfo.dir().path());
|
startParsing(path);
|
||||||
} else if(fileInfo.isDir()) {
|
m_ui->pathLineEdit->setText(fileInfo.dir().path());
|
||||||
m_ui->pathLineEdit->setText(path);
|
} else if(fileInfo.isDir()) {
|
||||||
|
m_ui->pathLineEdit->setText(path);
|
||||||
|
}
|
||||||
|
m_ui->pathLineEdit->setProperty("classNames", QStringList());
|
||||||
|
updateStyle(m_ui->pathLineEdit);
|
||||||
}
|
}
|
||||||
m_ui->pathLineEdit->setProperty("classNames", QStringList());
|
|
||||||
updateStyle(m_ui->pathLineEdit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,13 +266,18 @@ void MainWindow::handleFileStatusChange(bool opened, bool hasTag)
|
||||||
setWindowTitle(Dialogs::generateWindowTitle(opened ? DocumentStatus::Saved : DocumentStatus::NoDocument, m_ui->tagEditorWidget->currentPath()));
|
setWindowTitle(Dialogs::generateWindowTitle(opened ? DocumentStatus::Saved : DocumentStatus::NoDocument, m_ui->tagEditorWidget->currentPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::handleFileSaved(const QString ¤tPath)
|
/*!
|
||||||
|
* \brief Handles that the current path has changed by the tag editor widget itself.
|
||||||
|
*/
|
||||||
|
void MainWindow::handleCurrentPathChanged(const QString ¤tPath)
|
||||||
{
|
{
|
||||||
// ensure the current file is still selected
|
// ensure the current file is still selected
|
||||||
|
m_internalFileSelection = true;
|
||||||
const QModelIndex index = m_fileFilterModel->mapFromSource(m_fileModel->index(currentPath));
|
const QModelIndex index = m_fileFilterModel->mapFromSource(m_fileModel->index(currentPath));
|
||||||
if(index.isValid()) {
|
if(index.isValid()) {
|
||||||
m_ui->filesTreeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect);
|
m_ui->filesTreeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect);
|
||||||
}
|
}
|
||||||
|
m_internalFileSelection = false;
|
||||||
// ensure this is the active window
|
// ensure this is the active window
|
||||||
activateWindow();
|
activateWindow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ private slots:
|
||||||
void showSaveAsDlg();
|
void showSaveAsDlg();
|
||||||
void saveFileInformation();
|
void saveFileInformation();
|
||||||
void handleFileStatusChange(bool opened, bool hasTag);
|
void handleFileStatusChange(bool opened, bool hasTag);
|
||||||
void handleFileSaved(const QString ¤tPath);
|
void handleCurrentPathChanged(const QString ¤tPath);
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
void showSettingsDlg();
|
void showSettingsDlg();
|
||||||
|
@ -81,6 +81,7 @@ private:
|
||||||
// models
|
// models
|
||||||
QFileSystemModel *m_fileModel;
|
QFileSystemModel *m_fileModel;
|
||||||
FileFilterProxyModel *m_fileFilterModel;
|
FileFilterProxyModel *m_fileFilterModel;
|
||||||
|
bool m_internalFileSelection;
|
||||||
// dialogs
|
// dialogs
|
||||||
Dialogs::AboutDialog *m_aboutDlg;
|
Dialogs::AboutDialog *m_aboutDlg;
|
||||||
Dialogs::SettingsDialog *m_settingsDlg;
|
Dialogs::SettingsDialog *m_settingsDlg;
|
||||||
|
|
|
@ -221,6 +221,7 @@ bool TagEditorWidget::event(QEvent *event)
|
||||||
}
|
}
|
||||||
startParsing(path, true);
|
startParsing(path, true);
|
||||||
#else
|
#else
|
||||||
|
emit currentPathChanged(url.path());
|
||||||
startParsing(url.path(), true);
|
startParsing(url.path(), true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -457,7 +458,7 @@ void TagEditorWidget::updateFileStatusStatus()
|
||||||
m_infoTreeView->setEnabled(opened);
|
m_infoTreeView->setEnabled(opened);
|
||||||
}
|
}
|
||||||
// inform the main window about the file status change as well
|
// inform the main window about the file status change as well
|
||||||
emit fileStatusChange(opened, hasTag);
|
emit fileStatusChanged(opened, hasTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -1150,7 +1151,7 @@ void TagEditorWidget::showSavingResult(bool processingError, bool ioError)
|
||||||
m_fileOperationMutex.unlock();
|
m_fileOperationMutex.unlock();
|
||||||
// let the main window know that the current file has been saved
|
// let the main window know that the current file has been saved
|
||||||
// -> the main window will ensure the current file is still selected
|
// -> the main window will ensure the current file is still selected
|
||||||
emit fileSaved(m_currentPath);
|
emit currentPathChanged(m_currentPath);
|
||||||
// show next file (only if there are critical notifications)
|
// show next file (only if there are critical notifications)
|
||||||
if(!critical && m_nextFileAfterSaving) {
|
if(!critical && m_nextFileAfterSaving) {
|
||||||
emit nextFileSelected();
|
emit nextFileSelected();
|
||||||
|
|
|
@ -43,7 +43,7 @@ class FileInfoModel;
|
||||||
class TagEditorWidget : public QWidget
|
class TagEditorWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString currentPath READ currentPath)
|
Q_PROPERTY(QString currentPath READ currentPath NOTIFY currentPathChanged)
|
||||||
Q_PROPERTY(QByteArray fileInfoHtml READ fileInfoHtml)
|
Q_PROPERTY(QByteArray fileInfoHtml READ fileInfoHtml)
|
||||||
Q_PROPERTY(bool fileNameVisible READ isFileNameVisible WRITE setFileNameVisible)
|
Q_PROPERTY(bool fileNameVisible READ isFileNameVisible WRITE setFileNameVisible)
|
||||||
Q_PROPERTY(bool buttonsVisible READ areButtonsVisible WRITE setButtonVisible)
|
Q_PROPERTY(bool buttonsVisible READ areButtonsVisible WRITE setButtonVisible)
|
||||||
|
@ -79,25 +79,14 @@ public slots:
|
||||||
void applySettingsFromDialog();
|
void applySettingsFromDialog();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/*!
|
/// \brief Emitted when loading the next file has been triggered.
|
||||||
* \brief Emitted when loading the next file has been triggered.
|
|
||||||
*/
|
|
||||||
void nextFileSelected();
|
void nextFileSelected();
|
||||||
|
/// \brief Emitted to show a status message.
|
||||||
/*!
|
|
||||||
* \brief Emitted to show a status message.
|
|
||||||
*/
|
|
||||||
void statusMessage(const QString &message, int timeout = 0);
|
void statusMessage(const QString &message, int timeout = 0);
|
||||||
|
/// \brief Emmited when the file status (opened/closed) has changed.
|
||||||
/*!
|
void fileStatusChanged(bool opened, bool hasTag);
|
||||||
* \brief Emmited when the file status (opened/closed) has changed.
|
/// \brief Emitted when the current path has changed; always emitted a saving.
|
||||||
*/
|
void currentPathChanged(const QString &newPath);
|
||||||
void fileStatusChange(bool opened, bool hasTag);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Emitted when the current path changed.
|
|
||||||
*/
|
|
||||||
void fileSaved(const QString &newPath);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *event);
|
bool event(QEvent *event);
|
||||||
|
@ -151,9 +140,7 @@ private:
|
||||||
Media::MediaFileInfo m_fileInfo;
|
Media::MediaFileInfo m_fileInfo;
|
||||||
std::vector<Media::Tag *> m_tags;
|
std::vector<Media::Tag *> m_tags;
|
||||||
QByteArray m_fileInfoHtml;
|
QByteArray m_fileInfoHtml;
|
||||||
/*!
|
/// \brief This is the actual direcotry of the opened file which may differ from the directory selected in the tree view of the main window.
|
||||||
* \brief This is the actual direcotry of the opened file which may differ from the directory selected in the tree view of the main window.
|
|
||||||
*/
|
|
||||||
QString m_currentDir;
|
QString m_currentDir;
|
||||||
QString m_lastDir;
|
QString m_lastDir;
|
||||||
QString m_saveFilePath;
|
QString m_saveFilePath;
|
||||||
|
|
Loading…
Reference in New Issue