Skip to content
Permalink
Browse files

implemented handling of directoryLoaded/directoryBookmarked/focusChan…

…ged event.(refs #78)
  • Loading branch information...
haraki committed Jun 14, 2019
1 parent 2d72167 commit 1a02aa75fac2f0a8bc538b758f611412650835dd
Showing with 177 additions and 8 deletions.
  1. +71 −0 doublefolderpanel.cpp
  2. +10 −0 doublefolderpanel.h
  3. +15 −4 folderform.cpp
  4. +5 −1 folderform.h
  5. +70 −2 mainwindow.cpp
  6. +6 −1 mainwindow.h
@@ -163,6 +163,22 @@ DoubleFolderPanel::DoubleFolderPanel(QWidget* parent/* = Q_NULLPTR*/)
SIGNAL(currentChanged(QFileInfo,QFileInfo)),
this,
SLOT(onRightCurrentChanged(QFileInfo,QFileInfo)));
connect(l_folderForm,
SIGNAL(directoryLoaded(const QString&)),
this,
SLOT(onLeftDirectoryLoaded(const QString&)));
connect(r_folderForm,
SIGNAL(directoryLoaded(const QString&)),
this,
SLOT(onRightDirectoryLoaded(const QString&)));
connect(l_folderForm,
SIGNAL(directoryBookmarked(const QString&, bool)),
this,
SLOT(onLeftDirectoryBookmarked(const QString&, bool)));
connect(r_folderForm,
SIGNAL(directoryBookmarked(const QString&, bool)),
this,
SLOT(onRightDirectoryBookmarked(const QString&, bool)));
connect(l_folderForm,
SIGNAL(focusChanged(bool)),
this,
@@ -721,6 +737,8 @@ void DoubleFolderPanel::onLeftFocusChanged(bool inFocus)
emitStatusChanged(activeForm->getCurrentFileInfo().absoluteFilePath());
}
}

emitFocusChanged(PaneType::Left, inFocus);
}

void DoubleFolderPanel::onRightFocusChanged(bool inFocus)
@@ -737,6 +755,44 @@ void DoubleFolderPanel::onRightFocusChanged(bool inFocus)
emitStatusChanged(activeForm->getCurrentFileInfo().absoluteFilePath());
}
}

emitFocusChanged(PaneType::Right, inFocus);
}

void DoubleFolderPanel::onLeftDirectoryLoaded(const QString& path)
{
qDebug() << "DoubleFolderPanel::onLeftDirectoryLoaded : path : " << path;

emitDirectoryLoaded(PaneType::Left, path);
}

void DoubleFolderPanel::onRightDirectoryLoaded(const QString& path)
{
qDebug() << "DoubleFolderPanel::onRightDirectoryLoaded : path : " << path;

emitDirectoryLoaded(PaneType::Right, path);
}

void DoubleFolderPanel::onLeftDirectoryBookmarked(const QString &path, bool marked)
{
qDebug() << "DoubleFolderPanel::onLeftDirectoryBookmarked : path : " << path << ", marked : " << marked;

FolderForm* folderForm = getRightFolderForm();
Q_ASSERT(folderForm != Q_NULLPTR);
folderForm->checkBookmark();

emitDirectoryBookmarked(PaneType::Left, path, marked);
}

void DoubleFolderPanel::onRightDirectoryBookmarked(const QString &path, bool marked)
{
qDebug() << "DoubleFolderPanel::onRightDirectoryBookmarked : path : " << path << ", marked : " << marked;

FolderForm* folderForm = getLeftFolderForm();
Q_ASSERT(folderForm != Q_NULLPTR);
folderForm->checkBookmark();

emitDirectoryBookmarked(PaneType::Right, path, marked);
}

void DoubleFolderPanel::onOpenFile(const QString& path, ViewerType viewerType/* = ViewerType::Auto*/)
@@ -777,6 +833,21 @@ void DoubleFolderPanel::emitStatusChanged(const QString& statusString)
emit statusChanged(statusString);
}

void DoubleFolderPanel::emitFocusChanged(PaneType pane, bool inFocus)
{
emit focusChanged(pane, inFocus);
}

void DoubleFolderPanel::emitDirectoryLoaded(PaneType pane, const QString& path)
{
emit directoryLoaded(pane, path);
}

void DoubleFolderPanel::emitDirectoryBookmarked(PaneType pane, const QString& path, bool marked)
{
emit directoryBookmarked(pane, path, marked);
}

void DoubleFolderPanel::emitOpenFile(const QString& path, ViewerType viewerType/* = ViewerType::Auto*/)
{
emit openFile(path, viewerType);
@@ -51,6 +51,9 @@ class DoubleFolderPanel : public QWidget
Q_SIGNALS:
void outputConsole(const QString& consoleString);
void statusChanged(const QString& statusString);
void directoryLoaded(PaneType pane, const QString& path);
void directoryBookmarked(PaneType pane, const QString &path, bool marked);
void focusChanged(PaneType pane, bool inFocus);

void openFile(const QString& path, ViewerType viewerType = ViewerType::Auto);
void openWithApp(const QString& path);
@@ -72,6 +75,10 @@ protected Q_SLOTS:
void onRightCurrentChanged(const QFileInfo& newFileInfo, const QFileInfo& oldFileInfo);
void onLeftFocusChanged(bool inFocus);
void onRightFocusChanged(bool inFocus);
void onLeftDirectoryLoaded(const QString& path);
void onRightDirectoryLoaded(const QString& path);
void onLeftDirectoryBookmarked(const QString &path, bool marked);
void onRightDirectoryBookmarked(const QString &path, bool marked);

void onOpenFile(const QString& path, ViewerType viewerType = ViewerType::Auto);
void onOpenWithApp(const QString& path);
@@ -84,6 +91,9 @@ protected Q_SLOTS:

void emitOutputConsole(const QString& consoleString);
void emitStatusChanged(const QString& statusString);
void emitFocusChanged(PaneType pane, bool inFocus);
void emitDirectoryLoaded(PaneType pane, const QString& path);
void emitDirectoryBookmarked(PaneType pane, const QString &path, bool marked);

void emitOpenFile(const QString& path, ViewerType viewerType = ViewerType::Auto);
void emitOpenWithApp(const QString& path);
@@ -302,6 +302,8 @@ void FolderForm::onDirectoryLoaded(const QString& path)
}

checkBookmark();

emitDirectoryLoaded(path);
}

void FolderForm::onLayoutChanged(const QList<QPersistentModelIndex> &parents/* = QList<QPersistentModelIndex>()*/, QAbstractItemModel::LayoutChangeHint hint/* = QAbstractItemModel::NoLayoutChangeHint*/)
@@ -388,10 +390,9 @@ int FolderForm::onSelectDir()
return setPath(dirPath);
}

int FolderForm::onBookmarkDir(bool marked)
void FolderForm::onBookmarkDir(bool marked)
{
const QModelIndex currentDirIndex = ui->folderView->rootIndex();
const QString currentPath = m_folderModel->filePath(currentDirIndex);
const QString currentPath = getCurrentDirPath();
int index = Settings::getInstance()->searchBookmarkDirPath(currentPath);

if(marked)
@@ -409,7 +410,7 @@ int FolderForm::onBookmarkDir(bool marked)
}
}

return 0;
emitDirectoryBookmarked(currentPath, marked);
}

void FolderForm::checkBookmark()
@@ -474,9 +475,19 @@ void FolderForm::emitCurrentChanged(const QFileInfo& newFileInfo, const QFileInf
emit currentChanged(newFileInfo, oldFileInfo);
}

void FolderForm::emitDirectoryLoaded(const QString &path)
{
emit directoryLoaded(path);
}

void FolderForm::emitFocusChanged(bool inFocus)
{
emit focusChanged(inFocus);
}

void FolderForm::emitDirectoryBookmarked(const QString &path, bool marked)
{
emit directoryBookmarked(path, marked);
}

} // namespace Farman
@@ -67,15 +67,17 @@ class FolderForm : public QWidget
int onGoToChildDir();
int onGoToParentDir();
int onSelectDir();
int onBookmarkDir(bool marked);
void onBookmarkDir(bool marked);

void checkBookmark();

void refresh(bool clearSelected = false);

Q_SIGNALS:
void currentChanged(const QFileInfo& newFileInfo, const QFileInfo& oldFileInfo);
void directoryLoaded(const QString &path);
void focusChanged(bool inFocus);
void directoryBookmarked(const QString &path, bool marked);

protected Q_SLOTS:
void onCurrentChanged(const QModelIndex& newIndex, const QModelIndex& oldIndex);
@@ -88,7 +90,9 @@ private Q_SLOTS:
void on_bookmarkToolButton_toggled(bool checked);

void emitCurrentChanged(const QFileInfo& newFileInfo, const QFileInfo& oldFileInfo);
void emitDirectoryLoaded(const QString &path);
void emitFocusChanged(bool inFocus);
void emitDirectoryBookmarked(const QString &path, bool marked);

private:
bool eventFilter(QObject *watched, QEvent *e) Q_DECL_OVERRIDE;
@@ -39,14 +39,26 @@ MainWindow::MainWindow(QWidget *parent/* = Q_NULLPTR*/)
this,
SLOT(onOutputConsole(const QString&)));

connect(doubleFolderPanel,
SIGNAL(statusChanged(const QString&)),
this,
SLOT(onStatusChanged(const QString&)));
connect(doubleFolderPanel,
SIGNAL(outputConsole(const QString&)),
this,
SLOT(onOutputConsole(const QString&)));
connect(doubleFolderPanel,
SIGNAL(statusChanged(const QString&)),
SIGNAL(focusChanged(PaneType, bool)),
this,
SLOT(onStatusChanged(const QString&)));
SLOT(onFocusChanged(PaneType, bool)));
connect(doubleFolderPanel,
SIGNAL(directoryLoaded(PaneType, const QString&)),
this,
SLOT(onDirectoryLoaded(PaneType, const QString&)));
connect(doubleFolderPanel,
SIGNAL(directoryBookmarked(PaneType, const QString&, bool)),
this,
SLOT(onDirectoryBookmarked(PaneType, const QString&, bool)));

connect(doubleFolderPanel,
SIGNAL(openFile(const QString&, ViewerType)),
@@ -262,6 +274,42 @@ void MainWindow::onOutputConsole(const QString& consoleString)
ui->consolePlainTextEdit->moveCursor(QTextCursor::End);
}

void MainWindow::onFocusChanged(PaneType pane, bool inFocus)
{
Q_ASSERT(pane == PaneType::Left || pane == PaneType::Right);

qDebug() << "MainWindow::onFocusChanged : pane : "
<< (pane == PaneType::Left ? "left" : pane == PaneType::Right ? "right" : "unknown") << ", inFocus : " << inFocus;

if(!inFocus)
{
return;
}

checkBookmark();
}

void MainWindow::onDirectoryLoaded(PaneType pane, const QString& path)
{
Q_ASSERT(pane == PaneType::Left || pane == PaneType::Right);

qDebug() << "MainWindow::onDirectoryLoaded : pane : "
<< (pane == PaneType::Left ? "left" : pane == PaneType::Right ? "right" : "unknown") << ", path : " << path;

checkBookmark();
}

void MainWindow::onDirectoryBookmarked(PaneType pane, const QString &path, bool marked)
{
Q_ASSERT(pane == PaneType::Left || pane == PaneType::Right);

qDebug() << "MainWindow::onDirectoryBookmarked : pane : "
<< (pane == PaneType::Left ? "left" : pane == PaneType::Right ? "right" : "unknown")
<< ", path : " << path << ", marked : " << marked;

checkBookmark();
}

void MainWindow::on_actionOpen_triggered()
{
qDebug() << "MainWindow::on_actionOpen_triggered()";
@@ -764,6 +812,26 @@ bool MainWindow::launchExternalApp(const QString& command, const QString dirPath
return true;
}

void MainWindow::checkBookmark()
{
DoubleFolderPanel* doubleFolderPanel = ui->mainWidget->findChild<DoubleFolderPanel*>("DoubleFolderPanel");
Q_ASSERT(doubleFolderPanel != Q_NULLPTR);

FolderForm* activeFolderForm = doubleFolderPanel->getActiveFolderForm();
Q_ASSERT(activeFolderForm != Q_NULLPTR);

ui->actionBookmark->blockSignals(true);
if(Settings::getInstance()->searchBookmarkDirPath(activeFolderForm->getCurrentDirPath()) >= 0)
{
ui->actionBookmark->setChecked(true);
}
else
{
ui->actionBookmark->setChecked(false);
}
ui->actionBookmark->blockSignals(false);
}

void MainWindow::about()
{
QMessageBox::about(this,
@@ -45,6 +45,8 @@ class MainWindow : public QMainWindow
QDialog::DialogCode launchPreferencesDialog(PreferencesDialogTabPage page = PreferencesDialogTabPage::General);
bool launchExternalApp(const QString& command, const QString dirPath);

void checkBookmark();

void about();

Q_SIGNALS:
@@ -60,8 +62,11 @@ private Q_SLOTS:
void onOpenWithApp(const QString& path);
void onOpenWithTextEditor(const QString& dirPath, const QStringList& filePaths);
void onCreateNewFileFinished(const QString& filePath);
void onStatusChanged(const QString& statusString);
void onOutputConsole(const QString& consoleString);
void onStatusChanged(const QString& statusString);
void onFocusChanged(PaneType pane, bool inFocus);
void onDirectoryLoaded(PaneType pane, const QString& path);
void onDirectoryBookmarked(PaneType pane, const QString &path, bool marked);

void on_actionOpen_triggered();
void on_actionOpenWithTextViewer_triggered();

0 comments on commit 1a02aa7

Please sign in to comment.
You can’t perform that action at this time.