Commit 89410d44 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Split widget

parent 44a05d7d
......@@ -50,6 +50,7 @@ set( messagecomposer_recipient_src
recipient/kwindowpositioner.cpp
recipient/distributionlistdialog.cpp
recipient/recipientseditormanager.cpp
recipient/recipientspickerwidget.cpp
)
set( messagecomposer_imagescaling_src
......
......@@ -20,6 +20,7 @@
*/
#include "recipientspicker.h"
#include "recipientspickerwidget.h"
#include "settings/messagecomposersettings.h"
#include <Akonadi/Contact/EmailAddressSelectionWidget>
......@@ -51,12 +52,8 @@ RecipientsPicker::RecipientsPicker(QWidget *parent)
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mView = new Akonadi::EmailAddressSelectionWidget(this);
mView = new RecipientsPickerWidget(this);
mainLayout->addWidget(mView);
mView->view()->setSelectionMode(QAbstractItemView::ExtendedSelection);
mView->view()->setAlternatingRowColors(true);
mView->view()->setSortingEnabled(true);
mView->view()->sortByColumn(0, Qt::AscendingOrder);
mainLayout->setStretchFactor(mView, 1);
connect(mView->view()->selectionModel(), &QItemSelectionModel::selectionChanged,
......@@ -91,7 +88,7 @@ RecipientsPicker::RecipientsPicker(QWidget *parent)
connect(mUser2Button, &QPushButton::clicked, this, &RecipientsPicker::slotCcClicked);
connect(mUser3Button, &QPushButton::clicked, this, &RecipientsPicker::slotToClicked);
mView->searchLineEdit()->setFocus();
mView->emailAddressSelectionWidget()->searchLineEdit()->setFocus();
readConfig();
......@@ -105,7 +102,7 @@ RecipientsPicker::~RecipientsPicker()
void RecipientsPicker::slotSelectionChanged()
{
const bool hasSelection = !mView->selectedAddresses().isEmpty();
const bool hasSelection = !mView->emailAddressSelectionWidget()->selectedAddresses().isEmpty();
mUser1Button->setEnabled(hasSelection);
mUser2Button->setEnabled(hasSelection);
mUser3Button->setEnabled(hasSelection);
......@@ -148,7 +145,7 @@ void RecipientsPicker::pick(Recipient::Type type)
{
qCDebug(MESSAGECOMPOSER_LOG) << int(type);
const Akonadi::EmailAddressSelection::List selections = mView->selectedAddresses();
const Akonadi::EmailAddressSelection::List selections = mView->emailAddressSelectionWidget()->selectedAddresses();
const int count = selections.count();
if (count == 0) {
......@@ -211,7 +208,7 @@ void RecipientsPicker::slotSearchLDAP()
connect(mLdapSearchDialog, &KLDAP::LdapSearchDialog::contactsAdded, this, &RecipientsPicker::ldapSearchResult);
}
mLdapSearchDialog->setSearchText(mView->searchLineEdit()->text());
mLdapSearchDialog->setSearchText(mView->emailAddressSelectionWidget()->searchLineEdit()->text());
mLdapSearchDialog->show();
}
......
......@@ -39,7 +39,7 @@ class LdapSearchDialog;
namespace MessageComposer
{
class RecipientsPickerWidget;
class RecipientsPicker : public QDialog
{
Q_OBJECT
......@@ -73,7 +73,7 @@ protected Q_SLOTS:
void slotSelectionChanged();
private:
Akonadi::EmailAddressSelectionWidget *mView;
MessageComposer::RecipientsPickerWidget *mView;
KLDAP::LdapSearchDialog *mLdapSearchDialog;
......
/*
Copyright (C) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "recipientspickerwidget.h"
#include <QHBoxLayout>
#include <QAbstractItemView>
#include <QTreeView>
#include <Akonadi/Contact/EmailAddressSelectionWidget>
using namespace MessageComposer;
RecipientsPickerWidget::RecipientsPickerWidget(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
mView = new Akonadi::EmailAddressSelectionWidget(this);
layout->addWidget(mView);
mView->view()->setSelectionMode(QAbstractItemView::ExtendedSelection);
mView->view()->setAlternatingRowColors(true);
mView->view()->setSortingEnabled(true);
mView->view()->sortByColumn(0, Qt::AscendingOrder);
}
RecipientsPickerWidget::~RecipientsPickerWidget()
{
}
QTreeView *RecipientsPickerWidget::view() const
{
return mView->view();
}
Akonadi::EmailAddressSelectionWidget *RecipientsPickerWidget::emailAddressSelectionWidget() const
{
return mView;
}
/*
Copyright (C) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef RECIPIENTSPICKERWIDGET_H
#define RECIPIENTSPICKERWIDGET_H
#include <QWidget>
class QTreeView;
namespace Akonadi
{
class EmailAddressSelectionWidget;
}
namespace MessageComposer
{
class RecipientsPickerWidget : public QWidget
{
Q_OBJECT
public:
explicit RecipientsPickerWidget(QWidget *parent = nullptr);
~RecipientsPickerWidget();
QTreeView *view() const;
Akonadi::EmailAddressSelectionWidget *emailAddressSelectionWidget() const;
private:
Akonadi::EmailAddressSelectionWidget *mView;
};
}
#endif // RECIPIENTSPICKERWIDGET_H
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