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 00042 class CopyInputDialog : public KDialog 00043 { 00044 Q_OBJECT 00045 00046 public: 00047 CopyInputDialog(QWidget* parent = 0); 00048 00049 void setMasterSession(Session* master); 00050 Session* masterSession() const; 00051 00052 void setChosenSessions(const QSet<Session*>& sessions); 00053 QSet<Session*> chosenSessions() const; 00054 00055 private slots: 00056 void selectAll() { setSelectionChecked(true); }; 00057 void deselectAll() { setSelectionChecked(false); }; 00058 00059 private: 00060 void setSelectionChecked(bool checked); 00061 void setRowChecked(int row, bool checked); 00062 00063 Ui::CopyInputDialog* _ui; 00064 CheckableSessionModel* _model; 00065 QPointer<Session> _masterSession; 00066 }; 00067 00068 class CheckableSessionModel : public SessionListModel 00069 { 00070 Q_OBJECT 00071 00072 public: 00073 CheckableSessionModel(QObject* parent); 00074 00075 void setCheckColumn(int column); 00076 int checkColumn() const; 00077 00078 void setCheckable(Session* session, bool checkable); 00079 00080 void setCheckedSessions(const QSet<Session*> sessions); 00081 QSet<Session*> checkedSessions() const; 00082 00083 virtual Qt::ItemFlags flags(const QModelIndex& index) const; 00084 virtual QVariant data(const QModelIndex& index, int role) const; 00085 virtual bool setData(const QModelIndex& index, const QVariant& value, int role); 00086 00087 protected: 00088 virtual void sessionRemoved(Session*); 00089 00090 private: 00091 QSet<Session*> _checkedSessions; 00092 QSet<Session*> _fixedSessions; 00093 int _checkColumn; 00094 }; 00095 inline int CheckableSessionModel::checkColumn() const 00096 { return _checkColumn; } 00097 00098 } 00099 00100 #endif // COPYINPUTDIALOG 00101