Libkdepim

multiplyingline.h
1 /*
2  SPDX-FileCopyrightText: 2010 Casey Link <[email protected]>
3  SPDX-FileCopyrightText: 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <[email protected]>
4 
5  Refactored from earlier code by:
6  SPDX-FileCopyrightText: 2010 Volker Krause <[email protected]>
7  SPDX-FileCopyrightText: 2004 Cornelius Schumacher <[email protected]>
8 
9  SPDX-License-Identifier: LGPL-2.0-or-later
10 */
11 
12 #pragma once
13 
14 #include "kdepim_export.h"
15 
16 #include <KCompletion>
17 #include <QSharedPointer>
18 #include <QWidget>
19 
20 namespace KPIM
21 {
22 /**
23  @short ABC representing line data
24  @author Casey Link
25 */
26 class KDEPIM_EXPORT MultiplyingLineData
27 {
28 public:
30  virtual ~MultiplyingLineData() = default;
31 
32  /**
33  Clear data, reset to defaults
34  */
35  virtual void clear() = 0;
36  /**
37  Is the data empty?
38  */
39  virtual bool isEmpty() const = 0;
40 };
41 
42 /**
43  @short Abstract Base Class representing a line in the Multiplying line widget.
44  This class (and its subclasses) represent the lines in the MultiplyingLineEditor. Users of the
45  MultiplyingLineEditor widget should subclass this class, and add their own input widgets as members,
46  then implement the pure virtual methods and connect all the appropriate slots.
47  @author Casey Link
48 */
49 class KDEPIM_EXPORT MultiplyingLine : public QWidget
50 {
51  Q_OBJECT
52 public:
53  explicit MultiplyingLine(QWidget *parent);
54  ~MultiplyingLine() override = default;
55 
56  /**
57  This line is being activated. Focus should be set
58  on the first or most important widget in the line.
59  */
60  virtual void activate() = 0;
61  /**
62  Check if whatever receives focus in activate()
63  currently has focus.
64  @return true if this line is active
65  */
66  virtual bool isActive() const = 0;
67 
68  /**
69  Determine if this line was modified.
70  @return true if the user has made any modifications to this
71  MultiplyingLine.
72  */
73  virtual bool isModified() const = 0;
74 
75  /**
76  Resets the modified flag to false.
77  */
78  virtual void clearModified() = 0;
79 
80  /**
81  Retrieve the data.
82  @return the data associated with this line.
83  */
84  virtual MultiplyingLineData::Ptr data() const = 0;
85  /**
86  Set the data of this line. The containing widgets should be
87  populated accordingly.
88  @param data the data to populate this line with
89  */
90  virtual void setData(const MultiplyingLineData::Ptr &data) = 0;
91 
92  /**
93  Whether this line is empty or not. Usually there is a primary widget
94  that can be tested (such as a line edit).
95  @return true if this line is empty, false otherwise.
96  */
97  virtual bool isEmpty() const = 0;
98 
99  virtual bool canDeleteLineEdit() const = 0;
100 
101  /**
102  Set the width of the left most column to be the argument width.
103  This method allows other widgets to align their label/combobox column with ours
104  by communicating how many pixels that first column is for them.
105  @param w the width to set the left most column to.
106  @return the width that is actually being used.
107  */
108  virtual int setColumnWidth(int w) = 0;
109 
110  /**
111  Used to set setup the correct chain of widgets to focus on
112  when the user presses tab.
113  @param previous the previous widget (probably from the preceding line)
114 
115  Example with a 3 widget line:
116 
117  void YourLine::fixTabOrder( QWidget *previous ) {
118  setTabOrder( previous, mLeftMost );
119  setTabOrder( mLeftMost, mMiddle);
120  setTabOrder( mMiddle, mRightMost);
121  }
122  */
123  virtual void fixTabOrder(QWidget *previous) = 0;
124 
125  /**
126  @return The final widget in this line on which if the user presses
127  tab focus should be given to the next line. This will commonly
128  be used as the parameter of fixTabOrder( QWidget *previous ).
129  @see fixTabOrder( QWidget *previous )
130  */
131  virtual QWidget *tabOut() const = 0;
132 
133  /**
134  Clear the contents of this line. Reset to default state
135  */
136  virtual void clear() = 0;
137 
138  /**
139  Sets the type of completion to be used for KLineEdits in this line
140  @param mode the completion mode
141  */
142  virtual void setCompletionMode(KCompletion::CompletionMode mode) = 0;
143 
144  /**
145  * Re implement this method if you need to do something
146  * before a line is deleted.
147  *
148  * Default implementation does nothing.
149  */
150  virtual void aboutToBeDeleted();
151 
152 Q_SIGNALS:
153  /**
154  Emitted when the return/enter key is pressed
155  */
156  void returnPressed(KPIM::MultiplyingLine *);
157  /**
158  Emitted when the down key is pressed
159  */
160  void downPressed(KPIM::MultiplyingLine *);
161  /**
162  Emitted when the up key is pressed
163  */
164  void upPressed(KPIM::MultiplyingLine *);
165  /**
166  Emitted when the right key is pressed
167  */
168  void rightPressed();
169  /**
170  Should be emitted when the line should be deleted
171  */
172  void deleteLine(KPIM::MultiplyingLine *);
173  /**
174  Emitted when the completion mode changes
175  */
176  void completionModeChanged(KCompletion::CompletionMode);
177 public Q_SLOTS:
178  void slotPropagateDeletion();
179 
180 protected Q_SLOTS:
181  void slotReturnPressed();
182  void slotFocusUp();
183  void slotFocusDown();
184 
185 protected:
186  /**
187  Handles key press events on this line.
188  Default behavior handles Up and Down presses.
189  */
190  void keyPressEvent(QKeyEvent *) override;
191 };
192 }
ABC representing line data.
Class KCheckComboBox::KCheckComboBoxPrivate.
Abstract Base Class representing a line in the Multiplying line widget.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 30 2023 03:58:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.