Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 5db1c0e5 authored by Laurent Montel's avatar Laurent Montel 😁

Fix open dialog

parent 5476cf3f
......@@ -36,7 +36,9 @@ void SelectImapFolderModelTest::shouldNotCreateModelIfAccountIsNotValid()
SelectImapFolderModel model;
KSieveUi::SieveImapAccountSettings account;
QVERIFY(!account.isValid());
QVERIFY(!model.folderModel(account));
bool modelIsInitialized = false;
QVERIFY(!model.folderModel(account, modelIsInitialized));
QVERIFY(!modelIsInitialized);
}
QTEST_MAIN(SelectImapFolderModelTest)
......@@ -89,7 +89,7 @@ void SelectImapFolderModel::reloadFolderModel(const KSieveUi::SieveImapAccountSe
}
}
QStandardItemModel *SelectImapFolderModel::folderModel(const KSieveUi::SieveImapAccountSettings &account)
QStandardItemModel *SelectImapFolderModel::folderModel(const KSieveUi::SieveImapAccountSettings &account, bool &modelIsInitialized)
{
QStandardItemModel *model = nullptr;
if (account.isValid()) {
......@@ -99,8 +99,12 @@ QStandardItemModel *SelectImapFolderModel::folderModel(const KSieveUi::SieveImap
model = new QStandardItemModel(this);
fillModel(account, model);
mHashFolderModel.insert(identifier, model);
modelIsInitialized = false;
} else {
modelIsInitialized = true;
}
} else {
modelIsInitialized = false;
qCWarning(IMAPFOLDERCOMPLETIONPLUGIN_LOG) << "account is invalid";
}
return model;
......
......@@ -35,7 +35,7 @@ public:
static SelectImapFolderModel *self();
QStandardItemModel *folderModel(const KSieveUi::SieveImapAccountSettings &account);
QStandardItemModel *folderModel(const KSieveUi::SieveImapAccountSettings &account, bool &modelIsInitialized);
void reloadFolderModel(const KSieveUi::SieveImapAccountSettings &account);
......
......@@ -65,7 +65,8 @@ SelectImapFolderWidget::SelectImapFolderWidget(const KSieveUi::SieveImapAccountS
: QWidget(parent)
, mAccount(account)
{
mModel = SelectImapFolderModel::self()->folderModel(mAccount);
bool modelIsInitialized = false;
mModel = SelectImapFolderModel::self()->folderModel(mAccount, modelIsInitialized);
connect(SelectImapFolderModel::self(), &SelectImapFolderModel::modelLoaded, this, &SelectImapFolderWidget::slotModelLoaded);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
......@@ -107,6 +108,9 @@ SelectImapFolderWidget::SelectImapFolderWidget(const KSieveUi::SieveImapAccountS
connect(mSearchLineEdit, &QLineEdit::textChanged, this, &SelectImapFolderWidget::slotSearchPattern);
connect(mTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &SelectImapFolderWidget::slotCurrentChanged);
if (modelIsInitialized) {
mTreeView->setStatus(SelectImapFolderTreeView::Success);
}
}
SelectImapFolderWidget::~SelectImapFolderWidget()
......
......@@ -29,7 +29,9 @@ SelectImapLineEditCompleterModel::SelectImapLineEditCompleterModel(const KSieveU
mFlatProxy = new KDescendantsProxyModel(this);
mFlatProxy->setDisplayAncestorData(true);
mFlatProxy->setAncestorSeparator(QStringLiteral("/"));
mFlatProxy->setSourceModel(SelectImapFolderModel::self()->folderModel(account));
bool modelIsInitalized = false;
mFlatProxy->setSourceModel(SelectImapFolderModel::self()->folderModel(account, modelIsInitalized));
//TODO
}
SelectImapLineEditCompleterModel::~SelectImapLineEditCompleterModel()
......
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