summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-11-18 13:31:30 +0100
committerMontel Laurent <[email protected]>2015-11-18 13:31:30 +0100
commit6e59cba77ee872b6ca447a5e3349632b69eff827 (patch)
treead6e5b2c83aef0e4161c8725998399580c753648
parent78fac0ea769b26a5c6e68e590ab8bba810079868 (diff)
Improve order
-rw-r--r--kmail/kmmainwidget.cpp18
-rw-r--r--kmail/kmmainwidget.h2
-rw-r--r--kmail/widgets/kactionmenuaccount.cpp17
3 files changed, 21 insertions, 16 deletions
diff --git a/kmail/kmmainwidget.cpp b/kmail/kmmainwidget.cpp
index d934182..872ab8c 100644
--- a/kmail/kmmainwidget.cpp
+++ b/kmail/kmmainwidget.cpp
@@ -224,7 +224,8 @@ KMMainWidget::KMMainWidget(QWidget *parent, KXMLGUIClient *aGUIClient,
mSearchMessages(Q_NULLPTR),
mManageShowCollectionProperties(new ManageShowCollectionProperties(this, this)),
mShowIntroductionAction(Q_NULLPTR),
- mMarkAllMessageAsReadAndInAllSubFolder(Q_NULLPTR)
+ mMarkAllMessageAsReadAndInAllSubFolder(Q_NULLPTR),
+ mAccountActionMenu(Q_NULLPTR)
{
mLaunchExternalComponent = new KMLaunchExternalComponent(this, this);
// must be the first line of the constructor:
@@ -857,6 +858,7 @@ void KMMainWidget::readConfig()
updateMessageMenu();
updateFileMenu();
kmkernel->toggleSystemTray();
+ mAccountActionMenu->setAccountOrder(MailCommon::MailCommonSettings::self()->order());
connect(Akonadi::AgentManager::self(), &AgentManager::instanceAdded,
this, &KMMainWidget::updateFileMenu);
@@ -2856,14 +2858,14 @@ void KMMainWidget::setupActions()
actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL + Qt::Key_L));
}
- KActionMenuAccount *actActionMenu = new KActionMenuAccount(this);
- actActionMenu->setIcon(QIcon::fromTheme(QStringLiteral("mail-receive")));
- actActionMenu->setText(i18n("Check Mail In"));
+ mAccountActionMenu = new KActionMenuAccount(this);
+ mAccountActionMenu->setIcon(QIcon::fromTheme(QStringLiteral("mail-receive")));
+ mAccountActionMenu->setText(i18n("Check Mail In"));
- actActionMenu->setIconText(i18n("Check Mail"));
- actActionMenu->setToolTip(i18n("Check Mail"));
- actionCollection()->addAction(QStringLiteral("check_mail_in"), actActionMenu);
- connect(actActionMenu, &KActionMenu::triggered, this, &KMMainWidget::slotCheckMail);
+ mAccountActionMenu->setIconText(i18n("Check Mail"));
+ mAccountActionMenu->setToolTip(i18n("Check Mail"));
+ actionCollection()->addAction(QStringLiteral("check_mail_in"), mAccountActionMenu);
+ connect(mAccountActionMenu, &KActionMenu::triggered, this, &KMMainWidget::slotCheckMail);
mSendQueued = new QAction(QIcon::fromTheme(QStringLiteral("mail-send")), i18n("&Send Queued Messages"), this);
actionCollection()->addAction(QStringLiteral("send_queued"), mSendQueued);
diff --git a/kmail/kmmainwidget.h b/kmail/kmmainwidget.h
index 0d86ad0..06b36f6 100644
--- a/kmail/kmmainwidget.h
+++ b/kmail/kmmainwidget.h
@@ -66,6 +66,7 @@ class KMMoveCommand;
class KRecentFilesAction;
class ManageShowCollectionProperties;
class KActionMenuTransport;
+class KActionMenuAccount;
template <typename T, typename S> class QMap;
namespace KIO
@@ -659,6 +660,7 @@ private:
QAction *mShowIntroductionAction;
KToggleAction *mLowBandwithAction;
QAction *mMarkAllMessageAsReadAndInAllSubFolder;
+ KActionMenuAccount *mAccountActionMenu;
};
#endif
diff --git a/kmail/widgets/kactionmenuaccount.cpp b/kmail/widgets/kactionmenuaccount.cpp
index 2a5b12a..dc8edbc 100644
--- a/kmail/widgets/kactionmenuaccount.cpp
+++ b/kmail/widgets/kactionmenuaccount.cpp
@@ -91,21 +91,22 @@ void KActionMenuAccount::updateAccountMenu()
menu()->clear();
const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances();
QVector<AgentIdentifier> vector;
+ vector.reserve(lst.count());
- QMap<QString, QString> listAgent;
Q_FOREACH (const Akonadi::AgentInstance &type, lst) {
// Explicitly make a copy, as we're not changing values of the list but only
// the local copy which is passed to action.
- listAgent.insert(QString(type.name()).replace(QLatin1Char('&'), QStringLiteral("&&")), type.identifier());
- AgentIdentifier id(type.identifier(), QString(type.name()).replace(QLatin1Char('&'), QStringLiteral("&&")));
+ const QString identifierName = type.identifier();
+ const int index = mOrderIdentifier.indexOf(identifierName);
+ const AgentIdentifier id(identifierName, QString(type.name()).replace(QLatin1Char('&'), QStringLiteral("&&")),index);
vector << id;
}
qSort( vector.begin(), vector.end(), orderAgentIdentifier);
- QMapIterator<QString, QString> i(listAgent);
- while (i.hasNext()) {
- i.next();
- QAction *action = menu()->addAction(i.key());
- action->setData(i.value());
+ const int numberOfAccount(vector.size());
+ for (int i = 0; i < numberOfAccount; ++i) {
+ const AgentIdentifier id = vector.at(i);
+ QAction *action = menu()->addAction(id.mName);
+ action->setData(id.mIdentifier);
}
}
}