File indexing completed on 2024-04-28 09:46:47

0001 /*
0002     SPDX-FileCopyrightText: 2008 Robert Knight <robertknight@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef COPYINPUTDIALOG_H
0008 #define COPYINPUTDIALOG_H
0009 
0010 // Qt
0011 #include <QPointer>
0012 #include <QSet>
0013 
0014 // KDE
0015 #include <QDialog>
0016 
0017 // Konsole
0018 #include "konsoleprivate_export.h"
0019 #include "session/Session.h"
0020 #include "session/SessionListModel.h"
0021 #include "session/SessionManager.h"
0022 
0023 namespace Ui
0024 {
0025 class CopyInputDialog;
0026 }
0027 
0028 namespace Konsole
0029 {
0030 class CheckableSessionModel;
0031 
0032 /**
0033  * Dialog which allows the user to mark a list of sessions to copy
0034  * the input from the current session to.  The current session is
0035  * set using setMasterSession().  After the dialog has been executed,
0036  * the set of chosen sessions can be retrieved using chosenSessions()
0037  */
0038 class KONSOLEPRIVATE_EXPORT CopyInputDialog : public QDialog
0039 {
0040     Q_OBJECT
0041 
0042 public:
0043     explicit CopyInputDialog(QWidget *parent = nullptr);
0044     ~CopyInputDialog() override;
0045     /**
0046      * Sets the 'source' session whose input will be copied to
0047      * other sessions.  This session is displayed grayed out in the list
0048      * and cannot be unchecked.
0049      */
0050     void setMasterSession(Session *session);
0051 
0052     /** Sets the sessions in the list which are checked. */
0053     void setChosenSessions(const QSet<Session *> &sessions);
0054     /** Set setChosenSessions() */
0055     QSet<Session *> chosenSessions() const;
0056 
0057 private Q_SLOTS:
0058     void selectAll()
0059     {
0060         setSelectionChecked(true);
0061     }
0062 
0063     void deselectAll()
0064     {
0065         setSelectionChecked(false);
0066     }
0067 
0068 private:
0069     Q_DISABLE_COPY(CopyInputDialog)
0070 
0071     // Checks or unchecks selected sessions.  If there are no
0072     // selected items then all sessions are checked or unchecked
0073     void setSelectionChecked(bool checked);
0074     void setRowChecked(int row, bool checked);
0075 
0076     Ui::CopyInputDialog *_ui;
0077     CheckableSessionModel *_model;
0078     QPointer<Session> _masterSession;
0079 };
0080 
0081 }
0082 
0083 #endif // COPYINPUTDIALOG_H