Konsole
ManageProfilesDialog.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MANAGEPROFILESDIALOG_H
00021 #define MANAGEPROFILESDIALOG_H
00022
00023
00024 #include <QtGui/QStyledItemDelegate>
00025 #include <QtCore/QSet>
00026
00027
00028 #include <KDialog>
00029
00030
00031 #include "Profile.h"
00032
00033 class QItemSelection;
00034 class QShowEvent;
00035 class QStandardItem;
00036 class QStandardItemModel;
00037
00038 namespace Ui
00039 {
00040 class ManageProfilesDialog;
00041 }
00042
00043 namespace Konsole
00044 {
00045
00051 class ManageProfilesDialog : public KDialog
00052 {
00053 Q_OBJECT
00054
00055 friend class FavoriteItemDelegate;
00056 friend class ShortcutItemDelegate;
00057
00058 public:
00060 ManageProfilesDialog(QWidget* parent = 0);
00061 virtual ~ManageProfilesDialog();
00062
00072 void setShortcutEditorVisible(bool visible);
00073
00074 protected:
00075 virtual void showEvent(QShowEvent* event);
00076
00077 private slots:
00078 void deleteSelected();
00079 void setSelectedAsDefault();
00080 void newType();
00081 void editSelected();
00082
00083 void itemDataChanged(QStandardItem* item);
00084
00085
00086
00087 void tableSelectionChanged(const QItemSelection&);
00088
00089 void updateFavoriteStatus(Profile::Ptr profile, bool favorite);
00090
00091 void addItems(const Profile::Ptr);
00092 void updateItems(const Profile::Ptr);
00093 void removeItems(const Profile::Ptr);
00094
00095 private:
00096 Profile::Ptr currentProfile() const;
00097 QList<Profile::Ptr> selectedProfiles() const;
00098
00099
00100
00101 void updateDefaultItem();
00102 void updateItemsForProfile(const Profile::Ptr profile, QList<QStandardItem*>& items) const;
00103
00104
00105 void populateTable();
00106 int rowForProfile(const Profile::Ptr info) const;
00107
00108 Ui::ManageProfilesDialog* _ui;
00109 QStandardItemModel* _sessionModel;
00110
00111 static const int ProfileNameColumn = 0;
00112 static const int FavoriteStatusColumn = 1;
00113 static const int ShortcutColumn = 2;
00114 static const int ProfileKeyRole = Qt::UserRole + 1;
00115 static const int ShortcutRole = Qt::UserRole + 1;
00116 };
00117
00118 class StyledBackgroundPainter
00119 {
00120 public:
00121 static void drawBackground(QPainter* painter, const QStyleOptionViewItem& option,
00122 const QModelIndex& index);
00123 };
00124
00125 class FavoriteItemDelegate : public QStyledItemDelegate
00126 {
00127 public:
00128 FavoriteItemDelegate(QObject* parent = 0);
00129
00130 virtual bool editorEvent(QEvent* event,QAbstractItemModel* model,
00131 const QStyleOptionViewItem& option,const QModelIndex& index);
00132 virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
00133 const QModelIndex& index) const;
00134 };
00135
00136 class ShortcutItemDelegate : public QStyledItemDelegate
00137 {
00138 Q_OBJECT
00139
00140 public:
00141 ShortcutItemDelegate(QObject* parent = 0);
00142
00143 virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
00144 virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
00145 const QModelIndex& index) const;
00146 virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
00147 const QModelIndex& index) const;
00148
00149 private slots:
00150 void editorModified(const QKeySequence& keys);
00151
00152 private:
00153 mutable QSet<QWidget*> _modifiedEditors;
00154 mutable QSet<QModelIndex> _itemsBeingEdited;
00155 };
00156
00157 }
00158 #endif // MANAGEPROFILESDIALOG_H
00159