Commit ab43bd2d authored by Urs Fleisch's avatar Urs Fleisch
Browse files

New signal directoryOpened() as a replacement for fileRootIndexChanged().

fileRootIndexChanged() is emitted earlier since the last commit.
directoryOpened() is emitted at its old position and shall be used
for slots which need the directory opened.
parent 230265b8
......@@ -283,13 +283,13 @@ void CdCommand::startCommand()
void CdCommand::connectResultSignal()
{
connect(cli()->app(), SIGNAL(fileRootIndexChanged(QModelIndex)),
connect(cli()->app(), SIGNAL(directoryOpened()),
this, SLOT(terminate()));
}
void CdCommand::disconnectResultSignal()
{
disconnect(cli()->app(), SIGNAL(fileRootIndexChanged(QModelIndex)),
disconnect(cli()->app(), SIGNAL(directoryOpened()),
this, SLOT(terminate()));
}
......
......@@ -728,8 +728,8 @@ bool Kid3Cli::parseOptions()
if (paths.isEmpty()) {
paths.append(QDir::currentPath());
}
connect(m_app, SIGNAL(fileRootIndexChanged(QModelIndex)),
this, SLOT(onInitialDirectoryOpened(QModelIndex)));
connect(m_app, SIGNAL(directoryOpened()),
this, SLOT(onInitialDirectoryOpened()));
if (!openDirectory(expandWildcards(paths))) {
writeErrorLine(tr("%1 does not exist").arg(paths.join(QLatin1String(", "))));
}
......@@ -739,14 +739,13 @@ bool Kid3Cli::parseOptions()
/**
* Select files passed as command line arguments after the initial directory has
* been opened. Start execution of commands if existing.
* @param dirIndex file proxy model index of opened directory
*/
void Kid3Cli::onInitialDirectoryOpened(const QModelIndex& dirIndex)
void Kid3Cli::onInitialDirectoryOpened()
{
disconnect(m_app, SIGNAL(fileRootIndexChanged(QModelIndex)),
this, SLOT(onInitialDirectoryOpened(QModelIndex)));
disconnect(m_app, SIGNAL(directoryOpened()),
this, SLOT(onInitialDirectoryOpened()));
if (!m_argCommands.isEmpty()) {
if (!dirIndex.isValid()) {
if (!m_app->getRootIndex().isValid()) {
// Do not execute commands if directory could not be opened.
m_argCommands.clear();
}
......
......@@ -163,9 +163,8 @@ private slots:
/**
* Select files passed as command line arguments after the initial directory has
* been opened. Start execution of commands if existing.
* @param dirIndex file proxy model index of opened directory
*/
void onInitialDirectoryOpened(const QModelIndex& dirIndex);
void onInitialDirectoryOpened();
/**
* Called when a command is finished.
......
......@@ -551,7 +551,7 @@ void Kid3Application::readConfig()
/**
* Open directory.
* When finished fileRootIndexChanged() is emitted, also if false is returned.
* When finished directoryOpened() is emitted, also if false is returned.
*
* @param paths file or directory paths, if multiple paths are given, the
* common directory is opened and the files are selected
......@@ -671,6 +671,8 @@ void Kid3Application::onDirectoryOpened()
}
}
emit directoryOpened();
if (m_dirUpIndex.isValid()) {
m_dirSelectionModel->setCurrentIndex(m_dirUpIndex,
QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
......
......@@ -338,7 +338,7 @@ public:
/**
* Open directory.
* When finished fileRootIndexChanged() is emitted, also if false is returned.
* When finished directoryOpened() is emitted, also if false is returned.
*
* @param paths file or directory paths, if multiple paths are given, the
* common directory is opened and the files are selected
......@@ -1096,6 +1096,12 @@ signals:
*/
void dirRootIndexChanged(const QModelIndex& index);
/**
* Emitted when the directory has been opened, the file and directory proxy
* model root indexes changed and the selection updated.
*/
void directoryOpened();
/**
* Emitted when a confirmed opening of a directory or file is requested.
* @param paths directory or file paths
......
......@@ -135,7 +135,7 @@ BaseMainWindowImpl::BaseMainWindowImpl(QMainWindow* mainWin,
this, SLOT(toggleExpanded(QModelIndex)));
connect(m_app, SIGNAL(expandFileListRequested()),
this, SLOT(expandFileList()));
connect(m_app, SIGNAL(fileRootIndexChanged(QModelIndex)),
connect(m_app, SIGNAL(directoryOpened()),
this, SLOT(onDirectoryOpened()));
connect(m_app, SIGNAL(modifiedChanged(bool)),
this, SLOT(updateWindowCaption()));
......
......@@ -99,15 +99,15 @@ Timer {
/**
* Signal run() after the directory @a paths has been opened.
* This function is used when the script is called stand-alone and the
* This function is used when the script is called stand-alone and
* the directory is passed as a command line parameter.
*/
function openDirectory(paths) {
function onDirectoryOpened() {
app.fileRootIndexChanged.disconnect(onDirectoryOpened)
app.directoryOpened.disconnect(onDirectoryOpened)
run()
}
app.fileRootIndexChanged.connect(onDirectoryOpened)
app.directoryOpened.connect(onDirectoryOpened)
app.openDirectory(paths)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment