Don't offer to restart a Running (=busy) agent, it won't work.
[kdepim.git] / libkdepim / multiplyinglineview_p.h
blob2462cd64c68e85b7db42f071fe45d2548c776ccb
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>
5 Refactored from earlier code by:
6 Copyright (c) 2010 Volker Krause <vkrause@kde.org>
7 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
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.
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.
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.
25 #ifndef MULTIPLYINGLINEEDITOR_P_H
26 #define MULTIPLYINGLINEEDITOR_P_H
28 #include "multiplyingline.h"
29 #include "multiplyinglineeditor.h"
31 #include <KGlobalSettings>
33 #include <QPointer>
34 #include <QScrollArea>
36 namespace KPIM {
38 class MultiplyingLineView : public QScrollArea
40 Q_OBJECT
41 public:
42 MultiplyingLineView( MultiplyingLineFactory* factory, MultiplyingLineEditor *parent );
43 ~MultiplyingLineView(){}
45 QSize minimumSizeHint() const;
46 QSize sizeHint() const;
48 MultiplyingLine *activeLine() const;
50 MultiplyingLine *emptyLine() const;
52 QList<MultiplyingLineData::Ptr> allData() const;
54 /** Removes data provided it can be found. The Data class must support operator==
55 @param data The data you want to remove.
57 void removeData( const MultiplyingLineData::Ptr &data );
59 /** Returns true if the user has made any modifications to the list of
60 recipients.
61 @return whether the view is modified or not.
63 bool isModified() const;
65 /** Resets the modified flag to false.
67 void clearModified();
69 /** Activates the line */
70 void activateLine( MultiplyingLine *line );
72 /**QScrollArea
73 * Set the width of the left most column to be the argument width.
74 * This method allows other widgets to align their label/combobox column with ours
75 * by communicating how many pixels that first column is for them.
76 * Returns the width that is actually being used.
78 int setFirstColumnWidth( int );
80 /**
81 Make this widget follow it's children's size
82 @param resize turn on or off this behavior of auto resizing
84 void setAutoResize( bool resize );
85 bool autoResize();
87 /**
88 * Sets whether the size hint of the editor shall be calculated
89 * dynamically by the number of lines. Default is @c true.
91 void setDynamicSizeHint( bool dynamic );
92 bool dynamicSizeHint() const;
94 QList<MultiplyingLine*> lines() const;
96 public slots:
97 void setCompletionMode( KGlobalSettings::Completion mode );
98 MultiplyingLine *addLine();
100 void setFocus();
101 void setFocusTop();
102 void setFocusBottom();
104 signals:
105 void focusUp();
106 void focusDown();
107 void focusRight();
108 void completionModeChanged( KGlobalSettings::Completion );
109 void sizeHintChanged();
110 void lineDeleted( int pos );
111 void lineAdded( KPIM::MultiplyingLine * );
113 protected:
114 void resizeEvent( QResizeEvent * );
115 void resizeView();
117 protected slots:
118 void slotReturnPressed( KPIM::MultiplyingLine * );
119 void slotDownPressed( KPIM::MultiplyingLine * );
120 void slotUpPressed( KPIM::MultiplyingLine * );
121 void slotDecideLineDeletion( KPIM::MultiplyingLine * );
122 void slotDeleteLine();
123 void moveCompletionPopup();
124 void moveScrollBarToEnd();
126 private:
127 QList<MultiplyingLine*> mLines;
128 QPointer<MultiplyingLine> mCurDelLine;
129 int mLineHeight;
130 int mFirstColumnWidth;
131 bool mModified;
132 KGlobalSettings::Completion mCompletionMode;
133 QWidget *mPage;
134 QLayout *mTopLayout;
135 MultiplyingLineFactory *mMultiplyingLineFactory;
136 bool mAutoResize;
137 bool mDynamicSizeHint;
141 #endif //MULTIPLYINGLINEEDITOR_P_H