Commit 426c3f02 authored by Laurent Montel's avatar Laurent Montel 😁

Clean up

parent e9d84ad1
...@@ -1196,16 +1196,11 @@ void KMMainWidget::updateMoveAction(bool hasUnreadMails) ...@@ -1196,16 +1196,11 @@ void KMMainWidget::updateMoveAction(bool hasUnreadMails)
void KMMainWidget::updateAllToTrashAction(int statistics) void KMMainWidget::updateAllToTrashAction(int statistics)
{ {
bool multiFolder = false;
if (mFolderTreeWidget) {
multiFolder = mFolderTreeWidget->selectedCollections().count() > 1;
}
if (mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)) { if (mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)) {
const bool folderWithContent = mCurrentFolderSettings && !mCurrentFolderSettings->isStructural(); const bool folderWithContent = mCurrentFolderSettings && !mCurrentFolderSettings->isStructural();
mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)->setEnabled(folderWithContent mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)->setEnabled(folderWithContent
&& (statistics > 0) && (statistics > 0)
&& mCurrentFolderSettings->canDeleteMessages() && mCurrentFolderSettings->canDeleteMessages());
&& !multiFolder);
} }
} }
...@@ -3901,17 +3896,12 @@ void KMMainWidget::updateMessageActionsDelayed() ...@@ -3901,17 +3896,12 @@ void KMMainWidget::updateMessageActionsDelayed()
void KMMainWidget::slotAkonadiStandardActionUpdated() void KMMainWidget::slotAkonadiStandardActionUpdated()
{ {
bool multiFolder = false;
if (mFolderTreeWidget) {
multiFolder = mFolderTreeWidget->selectedCollections().count() > 1;
}
if (mCollectionProperties) { if (mCollectionProperties) {
if (mCurrentCollection.isValid()) { if (mCurrentCollection.isValid()) {
const Akonadi::AgentInstance instance const Akonadi::AgentInstance instance
= Akonadi::AgentManager::self()->instance(mCurrentCollection.resource()); = Akonadi::AgentManager::self()->instance(mCurrentCollection.resource());
mCollectionProperties->setEnabled(!multiFolder mCollectionProperties->setEnabled(!mCurrentFolderSettings->isStructural()
&& !mCurrentFolderSettings->isStructural()
&& (instance.status() != Akonadi::AgentInstance::Broken)); && (instance.status() != Akonadi::AgentInstance::Broken));
} else { } else {
mCollectionProperties->setEnabled(false); mCollectionProperties->setEnabled(false);
...@@ -3928,7 +3918,6 @@ void KMMainWidget::slotAkonadiStandardActionUpdated() ...@@ -3928,7 +3918,6 @@ void KMMainWidget::slotAkonadiStandardActionUpdated()
if (mAkonadiStandardActionManager->action(Akonadi::StandardActionManager::DeleteCollections)) { if (mAkonadiStandardActionManager->action(Akonadi::StandardActionManager::DeleteCollections)) {
mAkonadiStandardActionManager->action(Akonadi::StandardActionManager::DeleteCollections)->setEnabled(mCurrentFolderSettings mAkonadiStandardActionManager->action(Akonadi::StandardActionManager::DeleteCollections)->setEnabled(mCurrentFolderSettings
&& !multiFolder
&& (mCurrentCollection.rights() & Collection::CanDeleteCollection) && (mCurrentCollection.rights() & Collection::CanDeleteCollection)
&& !mCurrentFolderSettings->isSystemFolder() && !mCurrentFolderSettings->isSystemFolder()
&& folderWithContent); && folderWithContent);
...@@ -3937,8 +3926,7 @@ void KMMainWidget::slotAkonadiStandardActionUpdated() ...@@ -3937,8 +3926,7 @@ void KMMainWidget::slotAkonadiStandardActionUpdated()
if (mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)) { if (mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)) {
mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)->setEnabled(folderWithContent mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)->setEnabled(folderWithContent
&& (mCurrentFolderSettings->count() > 0) && (mCurrentFolderSettings->count() > 0)
&& mCurrentFolderSettings->canDeleteMessages() && mCurrentFolderSettings->canDeleteMessages());
&& !multiFolder);
mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)->setText((mCurrentFolderSettings mAkonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MoveAllToTrash)->setText((mCurrentFolderSettings
&& CommonKernel->folderIsTrash(mCurrentCollection)) ? i18n("E&mpty Trash") : i18n( && CommonKernel->folderIsTrash(mCurrentCollection)) ? i18n("E&mpty Trash") : i18n(
"&Move All Messages to Trash")); "&Move All Messages to Trash"));
...@@ -3989,25 +3977,19 @@ void KMMainWidget::slotAkonadiStandardActionUpdated() ...@@ -3989,25 +3977,19 @@ void KMMainWidget::slotAkonadiStandardActionUpdated()
void KMMainWidget::updateHtmlMenuEntry() void KMMainWidget::updateHtmlMenuEntry()
{ {
if (mDisplayMessageFormatMenu && mPreferHtmlLoadExtAction) { if (mDisplayMessageFormatMenu && mPreferHtmlLoadExtAction) {
bool multiFolder = false;
if (mFolderTreeWidget) {
multiFolder = mFolderTreeWidget->selectedCollections().count() > 1;
}
// the visual ones only make sense if we are showing a message list // the visual ones only make sense if we are showing a message list
const bool enabledAction = (mFolderTreeWidget const bool enabledAction = (mFolderTreeWidget
&& mFolderTreeWidget->folderTreeView()->currentFolder().isValid() && mFolderTreeWidget->folderTreeView()->currentFolder().isValid());
&& !multiFolder);
mDisplayMessageFormatMenu->setEnabled(enabledAction); mDisplayMessageFormatMenu->setEnabled(enabledAction);
const bool isEnabled = (mFolderTreeWidget const bool isEnabled = (mFolderTreeWidget
&& mFolderTreeWidget->folderTreeView()->currentFolder().isValid() && mFolderTreeWidget->folderTreeView()->currentFolder().isValid());
&& !multiFolder);
const bool useHtml = (mFolderDisplayFormatPreference == MessageViewer::Viewer::Html || (mHtmlGlobalSetting && mFolderDisplayFormatPreference == MessageViewer::Viewer::UseGlobalSetting)); const bool useHtml = (mFolderDisplayFormatPreference == MessageViewer::Viewer::Html || (mHtmlGlobalSetting && mFolderDisplayFormatPreference == MessageViewer::Viewer::UseGlobalSetting));
mPreferHtmlLoadExtAction->setEnabled(isEnabled && useHtml); mPreferHtmlLoadExtAction->setEnabled(isEnabled && useHtml);
mDisplayMessageFormatMenu->setDisplayMessageFormat(mFolderDisplayFormatPreference); mDisplayMessageFormatMenu->setDisplayMessageFormat(mFolderDisplayFormatPreference);
mPreferHtmlLoadExtAction->setChecked(!multiFolder && (mHtmlLoadExtGlobalSetting ? !mFolderHtmlLoadExtPreference : mFolderHtmlLoadExtPreference)); mPreferHtmlLoadExtAction->setChecked((mHtmlLoadExtGlobalSetting ? !mFolderHtmlLoadExtPreference : mFolderHtmlLoadExtPreference));
} }
} }
...@@ -4022,12 +4004,7 @@ void KMMainWidget::updateFolderMenu() ...@@ -4022,12 +4004,7 @@ void KMMainWidget::updateFolderMenu()
const bool folderWithContent = mCurrentFolderSettings const bool folderWithContent = mCurrentFolderSettings
&& !mCurrentFolderSettings->isStructural() && !mCurrentFolderSettings->isStructural()
&& mCurrentFolderSettings->isValid(); && mCurrentFolderSettings->isValid();
bool multiFolder = false;
if (mFolderTreeWidget) {
multiFolder = mFolderTreeWidget->selectedCollections().count() > 1;
}
mFolderMailingListPropertiesAction->setEnabled(folderWithContent mFolderMailingListPropertiesAction->setEnabled(folderWithContent
&& !multiFolder
&& !mCurrentFolderSettings->isSystemFolder()); && !mCurrentFolderSettings->isSystemFolder());
QList< QAction * > actionlist; QList< QAction * > actionlist;
...@@ -4048,7 +4025,7 @@ void KMMainWidget::updateFolderMenu() ...@@ -4048,7 +4025,7 @@ void KMMainWidget::updateFolderMenu()
mAkonadiStandardActionManager->action(Akonadi::StandardActionManager::DeleteCollections)->setText(i18n("&Delete Search")); mAkonadiStandardActionManager->action(Akonadi::StandardActionManager::DeleteCollections)->setText(i18n("&Delete Search"));
} }
mArchiveFolderAction->setEnabled(mCurrentFolderSettings && !multiFolder && folderWithContent); mArchiveFolderAction->setEnabled(mCurrentFolderSettings && folderWithContent);
bool isInTrashFolder = (mCurrentFolderSettings && CommonKernel->folderIsTrash(mCurrentCollection)); bool isInTrashFolder = (mCurrentFolderSettings && CommonKernel->folderIsTrash(mCurrentCollection));
QAction *moveToTrash = akonadiStandardAction(Akonadi::StandardMailActionManager::MoveToTrash); QAction *moveToTrash = akonadiStandardAction(Akonadi::StandardMailActionManager::MoveToTrash);
...@@ -4064,14 +4041,13 @@ void KMMainWidget::updateFolderMenu() ...@@ -4064,14 +4041,13 @@ void KMMainWidget::updateFolderMenu()
mExpireConfigAction->setEnabled(mCurrentFolderSettings mExpireConfigAction->setEnabled(mCurrentFolderSettings
&& !mCurrentFolderSettings->isStructural() && !mCurrentFolderSettings->isStructural()
&& !multiFolder
&& mCurrentFolderSettings->canDeleteMessages() && mCurrentFolderSettings->canDeleteMessages()
&& folderWithContent && folderWithContent
&& !MailCommon::Util::isVirtualCollection(mCurrentCollection)); && !MailCommon::Util::isVirtualCollection(mCurrentCollection));
updateHtmlMenuEntry(); updateHtmlMenuEntry();
mShowFolderShortcutDialogAction->setEnabled(!multiFolder && folderWithContent); mShowFolderShortcutDialogAction->setEnabled(folderWithContent);
actionlist << akonadiStandardAction(Akonadi::StandardActionManager::ManageLocalSubscriptions); actionlist << akonadiStandardAction(Akonadi::StandardActionManager::ManageLocalSubscriptions);
bool imapFolderIsOnline = false; bool imapFolderIsOnline = false;
if (mCurrentFolderSettings && PimCommon::MailUtil::isImapFolder(mCurrentCollection, imapFolderIsOnline)) { if (mCurrentFolderSettings && PimCommon::MailUtil::isImapFolder(mCurrentCollection, imapFolderIsOnline)) {
...@@ -4083,7 +4059,7 @@ void KMMainWidget::updateFolderMenu() ...@@ -4083,7 +4059,7 @@ void KMMainWidget::updateFolderMenu()
mGUIClient->unplugActionList(QStringLiteral("collectionview_actionlist")); mGUIClient->unplugActionList(QStringLiteral("collectionview_actionlist"));
mGUIClient->plugActionList(QStringLiteral("collectionview_actionlist"), actionlist); mGUIClient->plugActionList(QStringLiteral("collectionview_actionlist"), actionlist);
const bool folderIsValid = folderWithContent && !multiFolder; const bool folderIsValid = folderWithContent;
mApplyAllFiltersFolderAction->setEnabled(folderIsValid); mApplyAllFiltersFolderAction->setEnabled(folderIsValid);
mApplyFilterFolderActionsMenu->setEnabled(folderIsValid); mApplyFilterFolderActionsMenu->setEnabled(folderIsValid);
mApplyFilterFolderRecursiveActionsMenu->setEnabled(folderIsValid); mApplyFilterFolderRecursiveActionsMenu->setEnabled(folderIsValid);
......
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