• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Konsole

  • kde-4.14
  • applications
  • konsole
  • src
ManageProfilesDialog.h
Go to the documentation of this file.
1 /*
2  Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301 USA.
18 */
19 
20 #ifndef MANAGEPROFILESDIALOG_H
21 #define MANAGEPROFILESDIALOG_H
22 
23 // Qt
24 #include <QStyledItemDelegate>
25 #include <QtCore/QSet>
26 
27 // KDE
28 #include <KDialog>
29 
30 // Konsole
31 #include "Profile.h"
32 
33 class QItemSelection;
34 class QShowEvent;
35 class QStandardItem;
36 class QStandardItemModel;
37 
38 namespace Ui
39 {
40 class ManageProfilesDialog;
41 }
42 
43 namespace Konsole
44 {
50 class KONSOLEPRIVATE_EXPORT ManageProfilesDialog : public KDialog
51 {
52  Q_OBJECT
53 
54  friend class FavoriteItemDelegate;
55  friend class ShortcutItemDelegate;
56 
57 public:
59  explicit ManageProfilesDialog(QWidget* parent = 0);
60  virtual ~ManageProfilesDialog();
61 
71  void setShortcutEditorVisible(bool visible);
72 
73 protected:
74  virtual void showEvent(QShowEvent* event);
75 
76 private slots:
77  void deleteSelected();
78  void setSelectedAsDefault();
79  void createProfile();
80  void editSelected();
81  void moveUpSelected();
82  void moveDownSelected();
83 
84  void itemDataChanged(QStandardItem* item);
85 
86  // enables or disables Edit/Delete/Set as Default buttons when the
87  // selection changes
88  void tableSelectionChanged(const QItemSelection&);
89 
90  void updateFavoriteStatus(Profile::Ptr profile, bool favorite);
91 
92  void addItems(const Profile::Ptr);
93  void updateItems(const Profile::Ptr);
94  void removeItems(const Profile::Ptr);
95 
96 private:
97  Profile::Ptr currentProfile() const;
98  QList<Profile::Ptr> selectedProfiles() const;
99  bool isProfileDeletable(Profile::Ptr profile) const;
100 
101  // updates the font of the items to match
102  // their default / non-default profile status
103  void updateDefaultItem();
104  void updateItemsForProfile(const Profile::Ptr profile, QList<QStandardItem*>& items) const;
105  // updates the profile table to be in sync with the
106  // session manager
107  void populateTable();
108  int rowForProfile(const Profile::Ptr profile) const;
109 
110  Ui::ManageProfilesDialog* _ui;
111  QStandardItemModel* _sessionModel;
112 
113  static const int ProfileNameColumn = 0;
114  static const int FavoriteStatusColumn = 1;
115  static const int ShortcutColumn = 2;
116  static const int ProfileKeyRole = Qt::UserRole + 1;
117  static const int ShortcutRole = Qt::UserRole + 1;
118 };
119 
120 class StyledBackgroundPainter
121 {
122 public:
123  static void drawBackground(QPainter* painter, const QStyleOptionViewItem& option,
124  const QModelIndex& index);
125 };
126 
127 class FavoriteItemDelegate : public QStyledItemDelegate
128 {
129 public:
130  explicit FavoriteItemDelegate(QObject* parent = 0);
131 
132  virtual bool editorEvent(QEvent* event, QAbstractItemModel* model,
133  const QStyleOptionViewItem& option, const QModelIndex& index);
134  virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
135  const QModelIndex& index) const;
136 };
137 
138 class ShortcutItemDelegate : public QStyledItemDelegate
139 {
140  Q_OBJECT
141 
142 public:
143  explicit ShortcutItemDelegate(QObject* parent = 0);
144 
145  virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
146  virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
147  const QModelIndex& index) const;
148  virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
149  const QModelIndex& index) const;
150 
151 private slots:
152  void editorModified(const QKeySequence& keys);
153 
154 private:
155  mutable QSet<QWidget*> _modifiedEditors;
156  mutable QSet<QModelIndex> _itemsBeingEdited;
157 };
158 }
159 #endif // MANAGEPROFILESDIALOG_H
160 
Konsole::ManageProfilesDialog
A dialog which lists the available types of profiles and allows the user to add new profiles...
Definition: ManageProfilesDialog.h:50
QModelIndex
QEvent
QStandardItemModel
QWidget
Konsole::ShortcutItemDelegate
Definition: ManageProfilesDialog.h:138
Konsole::ShortcutItemDelegate::paint
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: ManageProfilesDialog.cpp:534
Konsole::FavoriteItemDelegate
Definition: ManageProfilesDialog.h:127
KDialog
Konsole::StyledBackgroundPainter
Definition: ManageProfilesDialog.h:120
Konsole::ShortcutItemDelegate::ShortcutItemDelegate
ShortcutItemDelegate(QObject *parent=0)
Definition: ManageProfilesDialog.cpp:492
QObject::event
virtual bool event(QEvent *e)
Konsole::StyledBackgroundPainter::drawBackground
static void drawBackground(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)
Definition: ManageProfilesDialog.cpp:445
Konsole::FavoriteItemDelegate::paint
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: ManageProfilesDialog.cpp:460
QStyleOptionViewItem
QShowEvent
QObject
QPainter
Konsole::ShortcutItemDelegate::createEditor
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: ManageProfilesDialog.cpp:521
QSet< QWidget * >
QList
Konsole::FavoriteItemDelegate::editorEvent
virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
Definition: ManageProfilesDialog.cpp:478
Konsole::Profile::Ptr
KSharedPtr< Profile > Ptr
Definition: Profile.h:67
QItemSelection
Konsole::ShortcutItemDelegate::setModelData
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Definition: ManageProfilesDialog.cpp:507
QKeySequence
KONSOLEPRIVATE_EXPORT
#define KONSOLEPRIVATE_EXPORT
Definition: konsole_export.h:33
QAbstractItemModel
QStandardItem
QObject::parent
QObject * parent() const
Konsole::FavoriteItemDelegate::FavoriteItemDelegate
FavoriteItemDelegate(QObject *parent=0)
Definition: ManageProfilesDialog.cpp:456
Profile.h
QStyledItemDelegate
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal