2 Copyright 2008 by Robert Knight <robertknight@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #ifndef COPYINPUTDIALOG
21 #define COPYINPUTDIALOG
30 #include "SessionManager.h"
35 class CopyInputDialog
;
40 class CheckableSessionModel
;
43 * Dialog which allows the user to mark a list of sessions to copy
44 * the input from the current session to. The current session is
45 * set using setMasterSession(). After the dialog has been executed,
46 * the set of chosen sessions can be retrieved using chosenSessions()
48 class CopyInputDialog
: public KDialog
53 CopyInputDialog(QWidget
* parent
= 0);
56 * Sets the 'source' session whoose input will be copied to
57 * other sessions. This session is displayed grayed out in the list
58 * and cannot be unchecked.
60 void setMasterSession(Session
* master
);
61 /** See setMasterSession() */
62 Session
* masterSession() const;
64 /** Sets the sessions in the list which are checked. */
65 void setChosenSessions(const QSet
<Session
*>& sessions
);
66 /** Set setChosenSessions() */
67 QSet
<Session
*> chosenSessions() const;
70 void selectAll() { setSelectionChecked(true); };
71 void deselectAll() { setSelectionChecked(false); };
74 // Checks or unchecks selected sessions. If there are no
75 // selected items then all sessions are checked or unchecked
76 void setSelectionChecked(bool checked
);
77 void setRowChecked(int row
, bool checked
);
79 Ui::CopyInputDialog
* _ui
;
80 CheckableSessionModel
* _model
;
81 QPointer
<Session
> _masterSession
;
85 * A list of sessions with a checkbox next to each one which allows the
86 * user to select a subset of the available sessions to perform
87 * some action on them.
89 class CheckableSessionModel
: public SessionListModel
94 CheckableSessionModel(QObject
* parent
);
96 void setCheckColumn(int column
);
97 int checkColumn() const;
100 * Sets whether a session can be checked or un-checked.
101 * Non-checkable items have the Qt::ItemIsEnabled flag unset.
103 void setCheckable(Session
* session
, bool checkable
);
105 /** Sets the list of sessions which are currently checked. */
106 void setCheckedSessions(const QSet
<Session
*> sessions
);
107 /** Returns the set of checked sessions. */
108 QSet
<Session
*> checkedSessions() const;
110 // reimplemented from QAbstractItemModel
111 virtual Qt::ItemFlags
flags(const QModelIndex
& index
) const;
112 virtual QVariant
data(const QModelIndex
& index
, int role
) const;
113 virtual bool setData(const QModelIndex
& index
, const QVariant
& value
, int role
);
116 virtual void sessionRemoved(Session
*);
119 QSet
<Session
*> _checkedSessions
;
120 QSet
<Session
*> _fixedSessions
;
123 inline int CheckableSessionModel::checkColumn() const
124 { return _checkColumn
; }
128 #endif // COPYINPUTDIALOG