Konsole
CopyInputDialog.h
Go to the documentation of this file.00001 /* 00002 Copyright 2008 by Robert Knight <robertknight@gmail.com> 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301 USA. 00018 */ 00019 00020 #ifndef COPYINPUTDIALOG 00021 #define COPYINPUTDIALOG 00022 00023 // Qt 00024 #include <QPointer> 00025 00026 // KDE 00027 #include <KDialog> 00028 00029 // Konsole 00030 #include "SessionManager.h" 00031 #include "Session.h" 00032 00033 namespace Ui 00034 { 00035 class CopyInputDialog; 00036 } 00037 00038 namespace Konsole 00039 { 00040 class CheckableSessionModel; 00041 00048 class CopyInputDialog : public KDialog 00049 { 00050 Q_OBJECT 00051 00052 public: 00053 CopyInputDialog(QWidget* parent = 0); 00054 00060 void setMasterSession(Session* master); 00062 Session* masterSession() const; 00063 00065 void setChosenSessions(const QSet<Session*>& sessions); 00067 QSet<Session*> chosenSessions() const; 00068 00069 private slots: 00070 void selectAll() { setSelectionChecked(true); }; 00071 void deselectAll() { setSelectionChecked(false); }; 00072 00073 private: 00074 // Checks or unchecks selected sessions. If there are no 00075 // selected items then all sessions are checked or unchecked 00076 void setSelectionChecked(bool checked); 00077 void setRowChecked(int row, bool checked); 00078 00079 Ui::CopyInputDialog* _ui; 00080 CheckableSessionModel* _model; 00081 QPointer<Session> _masterSession; 00082 }; 00083 00089 class CheckableSessionModel : public SessionListModel 00090 { 00091 Q_OBJECT 00092 00093 public: 00094 CheckableSessionModel(QObject* parent); 00095 00096 void setCheckColumn(int column); 00097 int checkColumn() const; 00098 00103 void setCheckable(Session* session, bool checkable); 00104 00106 void setCheckedSessions(const QSet<Session*> sessions); 00108 QSet<Session*> checkedSessions() const; 00109 00110 // reimplemented from QAbstractItemModel 00111 virtual Qt::ItemFlags flags(const QModelIndex& index) const; 00112 virtual QVariant data(const QModelIndex& index, int role) const; 00113 virtual bool setData(const QModelIndex& index, const QVariant& value, int role); 00114 00115 protected: 00116 virtual void sessionRemoved(Session*); 00117 00118 private: 00119 QSet<Session*> _checkedSessions; 00120 QSet<Session*> _fixedSessions; 00121 int _checkColumn; 00122 }; 00123 inline int CheckableSessionModel::checkColumn() const 00124 { return _checkColumn; } 00125 00126 } 00127 00128 #endif // COPYINPUTDIALOG 00129