Libkdepim

multiplyinglineeditor.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Casey Link <unnamedrambler@gmail.com>
3 SPDX-FileCopyrightText: 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
4
5 Refactored from earlier code by:
6 SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org>
7 SPDX-FileCopyrightText: 2004 Cornelius Schumacher <schumacher@kde.org>
8
9 SPDX-License-Identifier: LGPL-2.0-or-later
10*/
11
12#include "multiplyinglineeditor.h"
13#include "multiplyinglineview_p.h"
14
15#include <QHBoxLayout>
16using namespace KPIM;
17MultiplyingLineEditor::MultiplyingLineEditor(MultiplyingLineFactory *factory, QWidget *parent)
18 : QWidget(parent)
19 , mMultiplyingLineFactory(factory)
20{
21 auto topLayout = new QHBoxLayout(this);
22 topLayout->setContentsMargins(0, 0, 0, 0);
23
24 mView = new MultiplyingLineView(mMultiplyingLineFactory, this);
25 topLayout->addWidget(mView);
26 connect(mView, &MultiplyingLineView::focusUp, this, &MultiplyingLineEditor::focusUp);
27 connect(mView, &MultiplyingLineView::focusDown, this, &MultiplyingLineEditor::focusDown);
28 connect(mView, &MultiplyingLineView::completionModeChanged, this, &MultiplyingLineEditor::completionModeChanged);
29 connect(mView, &MultiplyingLineView::lineDeleted, this, &MultiplyingLineEditor::lineDeleted);
30 connect(mView, &MultiplyingLineView::lineAdded, this, &MultiplyingLineEditor::lineAdded);
31 connect(mView, &MultiplyingLineView::sizeHintChanged, this, &MultiplyingLineEditor::sizeHintChanged);
32}
33
34MultiplyingLineEditor::~MultiplyingLineEditor()
35{
36 delete mMultiplyingLineFactory;
37}
38
39bool MultiplyingLineEditor::addData(const MultiplyingLineData::Ptr &data, bool showDialogBox)
40{
41 MultiplyingLine *line = mView->emptyLine();
42 bool tooManyAddress = false;
43 if (!line) {
44 line = mView->addLine(showDialogBox);
45 }
46 if (!line) {
47 tooManyAddress = true;
48 }
49 if (line && data) {
50 line->setData(data);
51 }
52 return tooManyAddress;
53}
54
56{
57 mView->removeData(data);
58}
59
61{
62 const auto lstLines = mView->lines();
63 for (MultiplyingLine *line : lstLines) {
64 line->slotPropagateDeletion();
65 }
66}
67
69{
70 return mModified || mView->isModified();
71}
72
74{
75 mModified = false;
76 mView->clearModified();
77}
78
79void MultiplyingLineEditor::setFocus()
80{
81 mView->setFocus();
82}
83
84void MultiplyingLineEditor::setFocusTop()
85{
86 mView->setFocusTop();
87}
88
89void MultiplyingLineEditor::setFocusBottom()
90{
91 mView->setFocusBottom();
92}
93
95{
96 return mView->setFirstColumnWidth(w);
97}
98
100{
101 mView->setCompletionMode(mode);
102}
103
105{
106 return mMultiplyingLineFactory;
107}
108
110{
111 return mView->allData();
112}
113
115{
116 return mView->activeLine()->data();
117}
118
119QList<MultiplyingLine *> MultiplyingLineEditor::lines() const
120{
121 return mView->lines();
122}
123
124#include "moc_multiplyinglineeditor.cpp"
void clear()
Clear all lines from the widget.
QList< MultiplyingLineData::Ptr > allData() const
Retrieve the data from the editor.
MultiplyingLineData::Ptr activeData() const
Retrieve the data of the active line.
MultiplyingLineFactory * factory() const
Get the current line factory for this instance of the widget.
void removeData(const MultiplyingLineData::Ptr &data)
Removes data provided it can be found.
bool addData(const MultiplyingLineData::Ptr &data=MultiplyingLineData::Ptr(), bool showDialogBox=true)
Adds data to one line of the editor.
int setFirstColumnWidth(int w)
Set the width of the left most column to be the argument width.
void clearModified()
Resets the modified flag to false.
void setCompletionMode(KCompletion::CompletionMode mode)
Set completion mode for all lines.
bool isModified() const
Returns true if the user has made any modifications to the list of recipients.
An Abstract Base Class used to create MultiplyingLines Subclass this class and MultiplyingLine,...
Abstract Base Class representing a line in the Multiplying line widget.
virtual void setData(const MultiplyingLineData::Ptr &data)=0
Set the data of this line.
Class KCheckComboBox::KCheckComboBoxPrivate.
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:36:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.