Skip to content
Permalink
Browse files

fixed launch BookmarkEditDialog.

  • Loading branch information...
haraki committed Jun 24, 2019
1 parent 064f0fc commit 88affcc50423a7969cff793281f8a373f5675434
Showing with 30 additions and 22 deletions.
  1. +18 −0 bookmarkeditdialog.cpp
  2. +5 −0 bookmarkeditdialog.h
  3. +7 −21 bookmarkmanagerdialog.cpp
  4. +0 −1 bookmarkmanagerdialog.h
@@ -45,6 +45,24 @@ void BookmarkEditDialog::accept()
QDialog::accept();
}


QDialog::DialogCode BookmarkEditDialog::launchDialog(const QString& currentDirPath, const BookmarkInfo& in, BookmarkInfo& out, QWidget* parent/* = Q_NULLPTR*/)
{
BookmarkEditDialog dialog(currentDirPath, in, parent);

QDialog::DialogCode ret = static_cast<QDialog::DialogCode>(dialog.exec());

if(ret != QDialog::Accepted)
{
return ret;
}

out = dialog.getBookmarkInfo();

return QDialog::Accepted;
}


void BookmarkEditDialog::on_nameLineEdit_textChanged(const QString &arg1)
{
Q_UNUSED(arg1);
@@ -24,6 +24,11 @@ class BookmarkEditDialog : public QDialog

void accept() Q_DECL_OVERRIDE;

static QDialog::DialogCode launchDialog(const QString& currentDirPath,
const BookmarkInfo& in,
BookmarkInfo& out,
QWidget* parent = Q_NULLPTR);

private slots:
void on_nameLineEdit_textChanged(const QString &arg1);
void on_selectPathToolButton_clicked();
@@ -45,7 +45,7 @@ void BookmarkManagerDialog::on_newPushButton_clicked()
qDebug() << "BookmarkManagerDialog::on_newPushButton_clicked()";

BookmarkInfo retInfo;
if(launchBookmarkEditDialog(BookmarkInfo(), retInfo) != QDialog::Accepted)
if(BookmarkEditDialog::launchDialog(m_currentDirPath, BookmarkInfo(), retInfo, this) != QDialog::Accepted)
{
return;
}
@@ -142,10 +142,12 @@ void BookmarkManagerDialog::on_bookmarksTableView_doubleClicked(const QModelInde
void BookmarkManagerDialog::editBookmark(const QModelIndex& index)
{
BookmarkInfo retInfo;
if(launchBookmarkEditDialog({BookmarkInfo::Type::User,
m_bookmarkInfoModel->data(index, BookmarkInfoModel::NameRole).toString(),
m_bookmarkInfoModel->data(index, BookmarkInfoModel::PathRole).toString()},
retInfo) != QDialog::Accepted)
if(BookmarkEditDialog::launchDialog(m_currentDirPath,
{BookmarkInfo::Type::User,
m_bookmarkInfoModel->data(index, BookmarkInfoModel::NameRole).toString(),
m_bookmarkInfoModel->data(index, BookmarkInfoModel::PathRole).toString()},
retInfo,
this) != QDialog::Accepted)
{
return;
}
@@ -155,20 +157,4 @@ void BookmarkManagerDialog::editBookmark(const QModelIndex& index)
m_bookmarkInfoModel->setData(m_bookmarkInfoModel->index(row, 1), retInfo.getPath());
}

QDialog::DialogCode BookmarkManagerDialog::launchBookmarkEditDialog(const BookmarkInfo& in, BookmarkInfo& out)
{
BookmarkEditDialog dialog(m_currentDirPath, in, this);

QDialog::DialogCode ret = static_cast<QDialog::DialogCode>(dialog.exec());

if(ret != QDialog::Accepted)
{
return ret;
}

out = dialog.getBookmarkInfo();

return QDialog::Accepted;
}

} // namespace Farman
@@ -33,7 +33,6 @@ private Q_SLOTS:

private:
void editBookmark(const QModelIndex& index);
QDialog::DialogCode launchBookmarkEditDialog(const BookmarkInfo& in, BookmarkInfo& out);

Ui::BookmarkManagerDialog *ui;

0 comments on commit 88affcc

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