• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

libkdepim

  • sources
  • kde-4.14
  • kdepim
  • libkdepim
  • multiplyingline
multiplyinglineeditor.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com>
3  Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
4 
5  Refactored from earlier code by:
6  Copyright (c) 2010 Volker Krause <vkrause@kde.org>
7  Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
8 
9  This library is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or (at your
12  option) any later version.
13 
14  This library is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
17  License for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with this library; see the file COPYING.LIB. If not, write to the
21  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  02110-1301, USA.
23 */
24 
25 #include "multiplyinglineeditor.h"
26 #include "multiplyinglineview_p.h"
27 
28 #include <KDebug>
29 #include <KDialog>
30 
31 #include <QHBoxLayout>
32 using namespace KPIM;
33 MultiplyingLineEditor::MultiplyingLineEditor( MultiplyingLineFactory* factory, QWidget *parent )
34  : QWidget( parent ), mModified( false ), mMultiplyingLineFactory( factory )
35 {
36  QBoxLayout *topLayout = new QHBoxLayout();
37  topLayout->setSpacing( KDialog::spacingHint() );
38  topLayout->setMargin( 0 );
39  setLayout( topLayout );
40 
41  mView = new MultiplyingLineView( mMultiplyingLineFactory, this );
42  topLayout->addWidget( mView );
43  connect( mView, SIGNAL(focusUp()), SIGNAL(focusUp()) );
44  connect( mView, SIGNAL(focusDown()), SIGNAL(focusDown()) );
45  connect( mView, SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
46  SIGNAL(completionModeChanged(KGlobalSettings::Completion)) );
47  connect( mView, SIGNAL(lineDeleted(int)), SIGNAL(lineDeleted(int)) );
48  connect( mView, SIGNAL(lineAdded(KPIM::MultiplyingLine*)), SIGNAL(lineAdded(KPIM::MultiplyingLine*)) );
49  connect( mView, SIGNAL(sizeHintChanged()),
50  SIGNAL(sizeHintChanged()) );
51 }
52 
53 MultiplyingLineEditor::~MultiplyingLineEditor()
54 {
55  delete mMultiplyingLineFactory;
56 }
57 
58 bool MultiplyingLineEditor::addData( const MultiplyingLineData::Ptr &data )
59 {
60  MultiplyingLine* line = mView->emptyLine();
61  bool tooManyAddress = false;
62  if( !line )
63  line = mView->addLine();
64  if (!line)
65  tooManyAddress = true;
66  if( line && data )
67  line->setData( data );
68  return tooManyAddress;
69 }
70 
71 void MultiplyingLineEditor::removeData( const MultiplyingLineData::Ptr &data )
72 {
73  mView->removeData( data );
74 }
75 
76 void MultiplyingLineEditor::clear()
77 {
78  foreach ( MultiplyingLine *line, mView->lines() )
79  line->slotPropagateDeletion();
80 }
81 
82 bool MultiplyingLineEditor::isModified()
83 {
84  return mModified || mView->isModified();
85 }
86 
87 void MultiplyingLineEditor::clearModified()
88 {
89  mModified = false;
90  mView->clearModified();
91 }
92 
93 void MultiplyingLineEditor::setFocus()
94 {
95  mView->setFocus();
96 }
97 
98 void MultiplyingLineEditor::setFocusTop()
99 {
100  mView->setFocusTop();
101 }
102 
103 void MultiplyingLineEditor::setFocusBottom()
104 {
105  mView->setFocusBottom();
106 }
107 
108 int MultiplyingLineEditor::setFirstColumnWidth( int w )
109 {
110  return mView->setFirstColumnWidth( w );
111 }
112 
113 void MultiplyingLineEditor::setCompletionMode( KGlobalSettings::Completion mode )
114 {
115  mView->setCompletionMode( mode );
116 }
117 
118 MultiplyingLineFactory* MultiplyingLineEditor::factory() const
119 {
120  return mMultiplyingLineFactory;
121 }
122 
123 QList< MultiplyingLineData::Ptr > MultiplyingLineEditor::allData() const
124 {
125  return mView->allData();
126 }
127 
128 MultiplyingLineData::Ptr MultiplyingLineEditor::activeData() const
129 {
130  return mView->activeLine()->data();
131 }
132 
133 
134 QList< MultiplyingLine* > MultiplyingLineEditor::lines() const
135 {
136  return mView->lines();
137 }
138 
139 MultiplyingLine* MultiplyingLineEditor::activeLine() const
140 {
141  return mView->activeLine();
142 }
143 
144 void MultiplyingLineEditor::setFrameStyle( int shape )
145 {
146  mView->setFrameStyle( shape );
147 }
148 
149 void MultiplyingLineEditor::setAutoResizeView( bool resize )
150 {
151  mView->setAutoResize( resize );
152 }
153 
154 bool MultiplyingLineEditor::autoResizeView()
155 {
156  return mView->autoResize();
157 }
158 
159 void MultiplyingLineEditor::setDynamicSizeHint( bool dynamic )
160 {
161  mView->setDynamicSizeHint( dynamic );
162 }
163 
164 bool MultiplyingLineEditor::dynamicSizeHint() const
165 {
166  return mView->dynamicSizeHint();
167 }
168 
KPIM::MultiplyingLineView::allData
QList< MultiplyingLineData::Ptr > allData() const
KPIM::MultiplyingLineView::setFocusBottom
void setFocusBottom()
KPIM::MultiplyingLineView::setAutoResize
void setAutoResize(bool resize)
Make this widget follow it's children's size.
QWidget
KPIM::MultiplyingLineEditor::setDynamicSizeHint
void setDynamicSizeHint(bool dynamic)
Sets whether the size hint of the editor shall be calculated dynamically by the number of lines...
Definition: multiplyinglineeditor.cpp:159
KPIM::MultiplyingLineEditor::dynamicSizeHint
bool dynamicSizeHint() const
KPIM::MultiplyingLineEditor::lineDeleted
void lineDeleted(int pos)
KPIM::MultiplyingLineView
Definition: multiplyinglineview_p.h:38
KPIM::MultiplyingLineEditor::isModified
bool isModified()
Returns true if the user has made any modifications to the list of recipients.
Definition: multiplyinglineeditor.cpp:82
KPIM::MultiplyingLineView::activeLine
MultiplyingLine * activeLine() const
KPIM::MultiplyingLineView::isModified
bool isModified() const
Returns true if the user has made any modifications to the list of recipients.
KPIM::MultiplyingLineView::lines
QList< MultiplyingLine * > lines() const
KPIM::MultiplyingLineEditor::focusDown
void focusDown()
KPIM::MultiplyingLineView::setFirstColumnWidth
int setFirstColumnWidth(int)
QScrollArea Set the width of the left most column to be the argument width.
QHBoxLayout
KPIM::MultiplyingLineView::removeData
void removeData(const MultiplyingLineData::Ptr &data)
Removes data provided it can be found.
QFrame::setFrameStyle
void setFrameStyle(int style)
KPIM::MultiplyingLineEditor::setAutoResizeView
void setAutoResizeView(bool resize)
Make the line view follow it's children's size.
Definition: multiplyinglineeditor.cpp:149
KPIM::MultiplyingLineView::emptyLine
MultiplyingLine * emptyLine() const
KPIM::MultiplyingLineEditor::setFocusBottom
void setFocusBottom()
Definition: multiplyinglineeditor.cpp:103
KPIM::MultiplyingLineView::dynamicSizeHint
bool dynamicSizeHint() const
KPIM::MultiplyingLineEditor::clearModified
void clearModified()
Resets the modified flag to false.
Definition: multiplyinglineeditor.cpp:87
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QWidget::setLayout
void setLayout(QLayout *layout)
QSharedPointer
KPIM::MultiplyingLineEditor::activeData
MultiplyingLineData::Ptr activeData() const
Retrieve the data of the active line.
Definition: multiplyinglineeditor.cpp:128
KPIM::MultiplyingLineEditor::lineAdded
void lineAdded(KPIM::MultiplyingLine *)
KPIM::MultiplyingLineEditor::~MultiplyingLineEditor
virtual ~MultiplyingLineEditor()
Definition: multiplyinglineeditor.cpp:53
KPIM::MultiplyingLineEditor::sizeHintChanged
void sizeHintChanged()
KPIM::MultiplyingLineEditor::activeLine
virtual MultiplyingLine * activeLine() const
Definition: multiplyinglineeditor.cpp:139
KPIM::MultiplyingLineFactory
An Abstract Base Class used to create MultiplyingLines Subclass this class and MultiplyingLine, then implement newLine() such that it allocates and returns an instance of your MultiplyingLine.
Definition: multiplyinglineeditor.h:45
KPIM::MultiplyingLine::setData
virtual void setData(const MultiplyingLineData::Ptr &data)=0
Set the data of this line.
KPIM::MultiplyingLineEditor::setCompletionMode
void setCompletionMode(KGlobalSettings::Completion mode)
Set completion mode for all lines.
Definition: multiplyinglineeditor.cpp:113
multiplyinglineeditor.h
KPIM::MultiplyingLineEditor::setFirstColumnWidth
int setFirstColumnWidth(int w)
Set the width of the left most column to be the argument width.
Definition: multiplyinglineeditor.cpp:108
QList
QLayout::setMargin
void setMargin(int margin)
KPIM::MultiplyingLineEditor::setFocusTop
void setFocusTop()
Definition: multiplyinglineeditor.cpp:98
KPIM::MultiplyingLineView::setCompletionMode
void setCompletionMode(KGlobalSettings::Completion mode)
KPIM::MultiplyingLineEditor::addData
bool addData(const MultiplyingLineData::Ptr &data=MultiplyingLineData::Ptr())
Adds data to one line of the editor.
Definition: multiplyinglineeditor.cpp:58
KPIM::MultiplyingLineView::setFocus
void setFocus()
KPIM::MultiplyingLineEditor::mModified
bool mModified
Definition: multiplyinglineeditor.h:171
KPIM::MultiplyingLineEditor::allData
QList< MultiplyingLineData::Ptr > allData() const
Retrieve the data from the editor.
Definition: multiplyinglineeditor.cpp:123
KPIM::MultiplyingLine::slotPropagateDeletion
void slotPropagateDeletion()
Definition: multiplyingline.cpp:40
KPIM::MultiplyingLine
Abstract Base Class representing a line in the Multiplying line widget.
Definition: multiplyingline.h:64
KPIM::MultiplyingLineEditor::autoResizeView
bool autoResizeView()
multiplyinglineview_p.h
KPIM::MultiplyingLine::data
virtual MultiplyingLineData::Ptr data() const =0
Retrieve the data.
KPIM::MultiplyingLineView::setDynamicSizeHint
void setDynamicSizeHint(bool dynamic)
Sets whether the size hint of the editor shall be calculated dynamically by the number of lines...
KPIM::MultiplyingLineEditor::MultiplyingLineEditor
MultiplyingLineEditor(MultiplyingLineFactory *factory, QWidget *parent=0)
Definition: multiplyinglineeditor.cpp:33
KPIM::MultiplyingLineEditor::focusUp
void focusUp()
KPIM::MultiplyingLineEditor::completionModeChanged
void completionModeChanged(KGlobalSettings::Completion)
KPIM::MultiplyingLineEditor::removeData
void removeData(const MultiplyingLineData::Ptr &data)
Removes data provided it can be found.
Definition: multiplyinglineeditor.cpp:71
KPIM::MultiplyingLineEditor::factory
MultiplyingLineFactory * factory() const
Get the current line factory for this instance of the widget.
Definition: multiplyinglineeditor.cpp:118
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KPIM::MultiplyingLineEditor::setFocus
void setFocus()
Definition: multiplyinglineeditor.cpp:93
KPIM::MultiplyingLineView::addLine
MultiplyingLine * addLine()
KPIM::MultiplyingLineEditor::lines
virtual QList< MultiplyingLine * > lines() const
Definition: multiplyinglineeditor.cpp:134
QBoxLayout
KPIM::MultiplyingLineView::clearModified
void clearModified()
Resets the modified flag to false.
QBoxLayout::setSpacing
void setSpacing(int spacing)
KPIM::MultiplyingLineView::setFocusTop
void setFocusTop()
KPIM::MultiplyingLineEditor::clear
void clear()
Clear all lines from the widget.
Definition: multiplyinglineeditor.cpp:76
KPIM::MultiplyingLineView::autoResize
bool autoResize()
KPIM::MultiplyingLineEditor::setFrameStyle
void setFrameStyle(int shape)
Set the underlying view's frame shape, default is none.
Definition: multiplyinglineeditor.cpp:144
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdepim

Skip menu "libkdepim"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal