Warning, file /sdk/ktechlab/src/gui/itemeditor/propertyeditor.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) 2002 Lucijan Busch <lucijan@gmx.at> * 0003 * Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> * 0004 * Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> * 0005 * Copyright (C) 2006 by David Saxton david@bluehaze.org * 0006 * * 0007 * This program is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published by * 0009 * the Free Software Foundation; either version 2 of the License, or * 0010 * (at your option) any later version. * 0011 ***************************************************************************/ 0012 0013 #ifndef PROPERTYEDITOR_H 0014 #define PROPERTYEDITOR_H 0015 0016 #include <QPointer> 0017 #include <QTableWidget> 0018 #include <QVariant> 0019 0020 // #include <q3dict.h> 0021 //#include <q3listview.h> // 2018.08.13 - ported to QTableWidget 0022 0023 #include "propertyeditoritem.h" 0024 0025 class ItemGroup; 0026 class Variant; 0027 class PropertySubEditor; 0028 class QPushButton; 0029 class QStyledItemDelegate; 0030 0031 //! A list view to edit any type of properties 0032 class PropertyEditor : public QTableWidget // K3ListView 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 /*! Creates an empty PropertyEditor with \a parent as parent widget. 0038 */ 0039 PropertyEditor(QWidget *parent = nullptr); 0040 ~PropertyEditor() override; 0041 0042 /*! Reset the list, ie clears all items in the list. 0043 if \a editorOnly is true, then only the current editor will be cleared, not the whole list. 0044 */ 0045 void reset() override; 0046 0047 /** 0048 * Updates the list of Property editors from the items selected in 0049 * \a itemGroup. 0050 */ 0051 void create(ItemGroup *itemGroup); 0052 0053 QSize sizeHint() const override; 0054 /** 0055 * @internal used by PropertySubEditor and PropertyEditor. 0056 */ 0057 bool handleKeyPress(QKeyEvent *ev); 0058 /** 0059 * Updates the default button for the current editor. 0060 */ 0061 void updateDefaultsButton(); 0062 0063 public slots: 0064 /** 0065 * On focus: 0066 * \li previously focused editor is activated 0067 * \li first visible item is activated if no item was active 0068 */ 0069 virtual void setFocus(); 0070 0071 protected slots: 0072 /** 0073 * This slot resets the value of an item, using Property::oldValue(). 0074 * It is called when pressing the "Revert to defaults" button 0075 */ 0076 void resetItem(); 0077 /** 0078 * This slot updates the positions of current editor and revert button. 0079 * It is called when double-clicking list's header. 0080 */ 0081 void moveEditor(); 0082 /** 0083 * Fills the list with an item for each property in the buffer. 0084 * You shouldn't need to call this, as it is automatically called in create(). 0085 */ 0086 void fill(); 0087 /** 0088 * This slot updates editor and revert buttons position and size when 0089 * the columns are resized. 0090 */ 0091 void slotColumnSizeChanged(int section, int oldS, int newS); 0092 void slotColumnSizeChanged(int section); 0093 /** 0094 * This slot is called when the user clicks the list view. It takes care 0095 * of deleting current editor and creating a new editor for the newly 0096 * selected item. 0097 */ 0098 void slotClicked(const QModelIndex &index); 0099 /** 0100 * Used to fix selection when unselectable item was activated. 0101 */ 0102 void slotCurrentChanged(QTableWidgetItem *); 0103 0104 void slotCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn); 0105 0106 void slotExpanded(QTableWidgetItem *item); 0107 void slotCollapsed(QTableWidgetItem *item); 0108 0109 protected: 0110 /** 0111 * Creates an editor for the list item \a i in the rect \a geometry, and 0112 * displays revert button if property is modified (ie 0113 * PropertyEditorItem::modified() == true). The editor type depends on 0114 * Property::type() of the item's property. 0115 */ 0116 void createEditor(const QModelIndex &index); //, const QRect &geometry); 0117 /** 0118 * Reimplemented from K3ListView to update editor and revert button 0119 * position. 0120 */ 0121 void resizeEvent(QResizeEvent *ev) override; 0122 0123 void showDefaultsButton(bool show); 0124 0125 int baseRowHeight() const 0126 { 0127 return m_baseRowHeight; 0128 } 0129 0130 PropertyEditorItem *selectedItem(); 0131 0132 QPointer<ItemGroup> m_pItemGroup; 0133 QPointer<PropertySubEditor> m_currentEditor; 0134 PropertyEditorItem *m_editItem; 0135 PropertyEditorItem *m_topItem; // The top item is used to control the drawing of every branches. 0136 QPushButton *m_defaults; // "Revert to defaults" button 0137 // PropertyEditorItem::Dict m_items; // 2018.08.13 - unused 0138 int m_baseRowHeight; 0139 //! Used in setFocus() to prevent scrolling to previously selected item on mouse click 0140 bool justClickedItem; 0141 0142 int m_lastCellWidgetRow; 0143 int m_lastCellWidgetCol; 0144 0145 QStyledItemDelegate *m_colPropertyDelegate; 0146 QStyledItemDelegate *m_colValueDelegate; 0147 0148 friend class PropertyEditorItem; 0149 friend class PropertySubEditor; 0150 }; 0151 0152 #endif