CopyInputDialog.h 2.49 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
    Copyright 2008 by Robert Knight <robertknight@gmail.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301  USA.
*/

20
21
#ifndef COPYINPUTDIALOG_H
#define COPYINPUTDIALOG_H
22
23

// Qt
24
25
#include <QPointer>
#include <QSet>
26
27

// KDE
Laurent Montel's avatar
Laurent Montel committed
28
#include <QDialog>
29
30

// Konsole
31
32
33
#include "session/SessionManager.h"
#include "session/Session.h"
#include "session/SessionListModel.h"
34

Kurt Hindenburg's avatar
Kurt Hindenburg committed
35
namespace Ui {
Kurt Hindenburg's avatar
Kurt Hindenburg committed
36
class CopyInputDialog;
37
38
}

Kurt Hindenburg's avatar
Kurt Hindenburg committed
39
namespace Konsole {
40
41
class CheckableSessionModel;

42
43
/**
 * Dialog which allows the user to mark a list of sessions to copy
Jekyll Wu's avatar
Jekyll Wu committed
44
 * the input from the current session to.  The current session is
45
46
47
 * set using setMasterSession().  After the dialog has been executed,
 * the set of chosen sessions can be retrieved using chosenSessions()
 */
Laurent Montel's avatar
Laurent Montel committed
48
class CopyInputDialog : public QDialog
49
{
Kurt Hindenburg's avatar
Kurt Hindenburg committed
50
    Q_OBJECT
51
52

public:
Kurt Hindenburg's avatar
Kurt Hindenburg committed
53
    explicit CopyInputDialog(QWidget *parent = nullptr);
54
    ~CopyInputDialog() override;
Jekyll Wu's avatar
Jekyll Wu committed
55
56
    /**
     * Sets the 'source' session whose input will be copied to
Kurt Hindenburg's avatar
Kurt Hindenburg committed
57
     * other sessions.  This session is displayed grayed out in the list
58
59
     * and cannot be unchecked.
     */
60
    void setMasterSession(Session *session);
61

62
    /** Sets the sessions in the list which are checked. */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
63
    void setChosenSessions(const QSet<Session *> &sessions);
64
    /** Set setChosenSessions() */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
65
    QSet<Session *> chosenSessions() const;
66

67
private Q_SLOTS:
Kurt Hindenburg's avatar
Kurt Hindenburg committed
68
69
    void selectAll()
    {
Kurt Hindenburg's avatar
Kurt Hindenburg committed
70
        setSelectionChecked(true);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
71
    }
Kurt Hindenburg's avatar
Kurt Hindenburg committed
72
73
74

    void deselectAll()
    {
Kurt Hindenburg's avatar
Kurt Hindenburg committed
75
        setSelectionChecked(false);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
76
    }
77
78

private:
79
80
    Q_DISABLE_COPY(CopyInputDialog)

81
82
    // Checks or unchecks selected sessions.  If there are no
    // selected items then all sessions are checked or unchecked
83
84
    void setSelectionChecked(bool checked);
    void setRowChecked(int row, bool checked);
85

Kurt Hindenburg's avatar
Kurt Hindenburg committed
86
87
    Ui::CopyInputDialog *_ui;
    CheckableSessionModel *_model;
88
    QPointer<Session> _masterSession;
89
90
91
92
};

}

93
#endif // COPYINPUTDIALOG_H