Konsole
ManageProfilesDialog.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2007 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 MANAGEPROFILESDIALOG_H 00021 #define MANAGEPROFILESDIALOG_H 00022 00023 // Qt 00024 #include <QtGui/QItemDelegate> 00025 00026 // KDE 00027 #include <KDialog> 00028 00029 class QItemSelection; 00030 class QShowEvent; 00031 class QStandardItem; 00032 class QStandardItemModel; 00033 00034 namespace Ui 00035 { 00036 class ManageProfilesDialog; 00037 } 00038 00039 namespace Konsole 00040 { 00041 00047 class ManageProfilesDialog : public KDialog 00048 { 00049 Q_OBJECT 00050 00051 friend class ProfileItemDelegate; 00052 00053 public: 00055 ManageProfilesDialog(QWidget* parent = 0); 00056 virtual ~ManageProfilesDialog(); 00057 00067 void setShortcutEditorVisible(bool visible); 00068 00069 protected: 00070 virtual void showEvent(QShowEvent* event); 00071 00072 private slots: 00073 void deleteSelected(); 00074 void setSelectedAsDefault(); 00075 void newType(); 00076 void editSelected(); 00077 00078 void itemDataChanged(QStandardItem* item); 00079 00080 // enables or disables Edit/Delete/Set as Default buttons when the 00081 // selection changes 00082 void tableSelectionChanged(const QItemSelection&); 00083 00084 // updates the profile table to be in sync with the 00085 // session manager 00086 void updateTableModel(); 00087 00088 void updateFavoriteStatus(const QString& key , bool favorite); 00089 00090 private: 00091 QString selectedKey() const; // return the key associated with the currently selected 00092 // item in the profile table 00093 00094 void updateDefaultItem(); // updates the font of the items to match 00095 // their default / non-default profile status 00096 Ui::ManageProfilesDialog* _ui; 00097 QStandardItemModel* _sessionModel; 00098 00099 static const int FavoriteStatusColumn = 1; 00100 static const int ShortcutColumn = 2; 00101 static const int ProfileKeyRole = Qt::UserRole + 1; 00102 static const int ShortcutRole = Qt::UserRole + 1; 00103 }; 00104 00105 class ProfileItemDelegate : public QItemDelegate 00106 { 00107 public: 00108 ProfileItemDelegate(QObject* parent = 0); 00109 00110 virtual bool editorEvent(QEvent* event,QAbstractItemModel* model, 00111 const QStyleOptionViewItem& option,const QModelIndex& index); 00112 00113 protected: 00114 virtual void drawDecoration(QPainter*,const QStyleOptionViewItem&,const QRect&, 00115 const QPixmap&) const; 00116 00117 }; 00118 00119 } 00120 #endif // MANAGEPROFILESDIALOG_H 00121
KDE 4.0 API Reference