Warning, file /education/khipu/src/spacesdelegate.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /************************************************************************************* 0002 * Copyright (C) 2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License * 0006 * as published by the Free Software Foundation; either version 2 * 0007 * of the License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the Free Software * 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 0017 *************************************************************************************/ 0018 0019 #ifndef GPLACS_DASHBOARD_H_DEL 0020 #define GPLACS_DASHBOARD_H_DEL 0021 0022 //Qt includes 0023 #include <QWidget> 0024 #include <QStackedWidget> 0025 #include <QStyledItemDelegate> 0026 #include <QListView> 0027 #include <QLineEdit> 0028 0029 //KDE includes 0030 #include <KWidgetItemDelegate> 0031 0032 class QSortFilterProxyModel; 0033 class QItemSelection; 0034 class QResizeEvent; 0035 class QFocusEvent; 0036 class QToolButton; 0037 0038 class SpaceItem; 0039 class DataStore; 0040 class SpacesView; 0041 0042 class LineEdit : public QLineEdit 0043 { 0044 Q_OBJECT 0045 0046 public : 0047 explicit LineEdit(QWidget* parent = nullptr); 0048 0049 signals: 0050 void editingFinished(const QString &newtext); 0051 0052 private slots: 0053 void procsSditingFinished(); 0054 0055 }; 0056 0057 /// This delegate only works if the view is a SpacesView (wich is a listview) and the viewmode is IconMode 0058 class SpacesDelegate : public QStyledItemDelegate 0059 { 0060 Q_OBJECT 0061 0062 friend class SpacesView; 0063 0064 public: 0065 static const int FrameThickness = 5; 0066 static const int ItemMargin = 4; 0067 0068 explicit SpacesDelegate(SpacesView *itemView, QObject *parent = nullptr); 0069 ~SpacesDelegate() override; 0070 0071 public slots: 0072 //NOTE ejecutar este metodo cuando se a cambiado de filtro en el proxy ... es decir ejecutarlo desde afuera de esta clase 0073 void filterEvent(); // se supone que el proxy emite esta signal layoutchanged y este slots debe ocultar los botnes y editores 0074 void setCurrentSpace(const QModelIndex& index); 0075 0076 public: 0077 QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override; 0078 void setEditorData(QWidget* editor, const QModelIndex& index) const override; 0079 void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; 0080 0081 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0082 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0083 0084 void setDocument(DataStore *doc); 0085 0086 /// call this when you want to update the delegate state, by rebind a new model 0087 void hideOperatorBar(); 0088 0089 signals: 0090 void showSpace(const QModelIndex &index); 0091 void saveDictionary(const QModelIndex &index); 0092 0093 private: 0094 QListView *m_itemView; 0095 bool eventFilter(QObject *watched, QEvent *event) override; 0096 void setupOperationBar(); 0097 void updateOperationBarPos(const QModelIndex &idx); 0098 0099 private slots: 0100 void editCurrentSpace(); 0101 void removeCurrentSpace(); 0102 void finishEditingTitle(const QString &newtitle = QString()); // save current index data 0103 void invalidClick(const QModelIndex &index); 0104 void exportSpace(); 0105 0106 private: 0107 DataStore *m_document; 0108 mutable bool m_isEditing; 0109 QWidget *m_operationBar; 0110 LineEdit *m_titleEditor; 0111 0112 mutable QModelIndex m_currentEditingIndex; // current editing index 0113 QPoint m_currentCurPos; 0114 }; 0115 0116 class SpacesView : public QListView 0117 { 0118 Q_OBJECT 0119 0120 public: 0121 explicit SpacesView(QWidget* parent = nullptr); 0122 0123 protected: 0124 void resizeEvent(QResizeEvent* e) override; 0125 }; 0126 0127 0128 0129 #endif