Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / konsole / src / CopyInputDialog.h
blob3ac6edd123a77aa17c7c1e0991619f9c4b26fa1a
1 /*
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
17 02110-1301 USA.
20 #ifndef COPYINPUTDIALOG
21 #define COPYINPUTDIALOG
23 // Qt
24 #include <QPointer>
26 // KDE
27 #include <KDialog>
29 // Konsole
30 #include "SessionManager.h"
31 #include "Session.h"
33 namespace Ui
35 class CopyInputDialog;
38 namespace Konsole
40 class CheckableSessionModel;
42 /**
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
50 Q_OBJECT
52 public:
53 CopyInputDialog(QWidget* parent = 0);
55 /**
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;
69 private slots:
70 void selectAll() { setSelectionChecked(true); };
71 void deselectAll() { setSelectionChecked(false); };
73 private:
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;
84 /**
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
91 Q_OBJECT
93 public:
94 CheckableSessionModel(QObject* parent);
96 void setCheckColumn(int column);
97 int checkColumn() const;
99 /**
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);
115 protected:
116 virtual void sessionRemoved(Session*);
118 private:
119 QSet<Session*> _checkedSessions;
120 QSet<Session*> _fixedSessions;
121 int _checkColumn;
123 inline int CheckableSessionModel::checkColumn() const
124 { return _checkColumn; }
128 #endif // COPYINPUTDIALOG