[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim] kaddressbook: Fix enable/disable action
From: Montel Laurent <montel () kde ! org>
Date: 2015-07-31 20:40:28
Message-ID: E1ZLH6S-0007dT-10 () scm ! kde ! org
[Download RAW message or body]
Git commit e38bf434adc3774d6c736d816820eaa8cbc28f17 by Montel Laurent.
Committed on 31/07/2015 at 20:40.
Pushed by mlaurent into branch 'master'.
Fix enable/disable action
M +23 -5 kaddressbook/mainwidget.cpp
M +3 -0 kaddressbook/mainwidget.h
http://commits.kde.org/kdepim/e38bf434adc3774d6c736d816820eaa8cbc28f17
diff --git a/kaddressbook/mainwidget.cpp b/kaddressbook/mainwidget.cpp
index fefab43..e9ff985 100644
--- a/kaddressbook/mainwidget.cpp
+++ b/kaddressbook/mainwidget.cpp
@@ -323,6 +323,8 @@ MainWidget::MainWidget(KXMLGUIClient *guiClient, QWidget *parent)
SLOT(trigger()));
connect(mItemView->selectionModel(), \
SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, \
SLOT(itemSelectionChanged(QModelIndex,QModelIndex))); + \
connect(mItemView->selectionModel(), \
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, \
SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));
// show the contact details view as default
mDetailsViewStack->setCurrentWidget(mContactDetails);
@@ -713,10 +715,10 @@ void MainWidget::setupActions(KActionCollection *collection)
action->setIcon(KIconLoader::global()->loadIcon(QStringLiteral("mail-message-new"), \
KIconLoader::Small));
connect(action, &QAction::triggered, this, &MainWidget::slotSendMail);
- action = collection->addAction(QStringLiteral("send_vcards"));
- action->setText(i18n("Send vCards..."));
- action->setIcon(KIconLoader::global()->loadIcon(QStringLiteral("mail-message-new"), \
KIconLoader::Small));
- connect(action, &QAction::triggered, this, &MainWidget::slotSendVcards);
+ mSendVcardAction = collection->addAction(QStringLiteral("send_vcards"));
+ mSendVcardAction->setText(i18n("Send vCards..."));
+ mSendVcardAction->setIcon(KIconLoader::global()->loadIcon(QStringLiteral("mail-message-new"), \
KIconLoader::Small)); + connect(mSendVcardAction, &QAction::triggered, this, \
&MainWidget::slotSendVcards);
if (!qgetenv("KDEPIM_BALOO_DEBUG").isEmpty()) {
action = collection->addAction(QStringLiteral("debug_baloo"));
@@ -1148,7 +1150,7 @@ void MainWidget::slotCheckGravatar()
}
}
if (dlg->exec()) {
- KContacts::Picture picture;
+ KContacts::Picture picture = address.photo();
if (dlg->saveUrl()) {
QUrl url = dlg->resolvedUrl();
picture.setUrl(url.toString());
@@ -1173,3 +1175,19 @@ void MainWidget::slotModifyContactFinished(KJob *job)
qCDebug(KADDRESSBOOK_LOG) << "Error while modifying items. " << job->error() \
<< job->errorString(); }
}
+
+void MainWidget::slotSelectionChanged(const QItemSelection &selected, const \
QItemSelection &deselected) +{
+ Q_UNUSED(selected);
+ Q_UNUSED(deselected);
+
+ bool hasUniqSelection = false;
+ bool hasSelection = false;
+ if (mItemView->selectionModel()->selection().count() == 1) {
+ hasUniqSelection = (mItemView->selectionModel()->selection().at(0).height() \
== 1); + hasSelection = true;
+ }
+ mSendVcardAction->setEnabled(hasSelection);
+ mSearchGravatarAction->setEnabled(hasUniqSelection);
+}
+
diff --git a/kaddressbook/mainwidget.h b/kaddressbook/mainwidget.h
index 365d53c..36285dc 100644
--- a/kaddressbook/mainwidget.h
+++ b/kaddressbook/mainwidget.h
@@ -23,6 +23,7 @@
#include "kaddressbook_export.h"
#include <AkonadiCore/Item>
+#include <QItemSelection>
#include <QWidget>
namespace GrantleeTheme
@@ -115,6 +116,7 @@ private Q_SLOTS:
void slotCurrentCollectionChanged(const Akonadi::Collection &col);
void slotCheckGravatar();
void slotModifyContactFinished(KJob *job);
+ void slotSelectionChanged(const QItemSelection &selected, const QItemSelection \
&deselected); private:
const Akonadi::Item::List collectSelectedAllContactsItem(QItemSelectionModel \
*model); void initGrantleeThemeName();
@@ -169,6 +171,7 @@ private:
QAction *mQuickSearchAction;
QAction *mServerSideSubscription;
QAction *mSearchGravatarAction;
+ QAction *mSendVcardAction;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic