1 /* This file is part of the KDE project 2 Copyright (C) 2005-2014 Jarosław Staniek <staniek@kde.org> 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (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 GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this program; see the file COPYING. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef KEXIDATAAWAREVIEW_H 21 #define KEXIDATAAWAREVIEW_H 22 23 #include "kexidataviewcommon_export.h" 24 #include <KexiView.h> 25 #include <core/kexisearchandreplaceiface.h> 26 27 class KexiDataAwareObjectInterface; 28 class KexiSharedActionClient; 29 30 /*! @short Provides a view displaying record-based data. 31 32 The KexiDataAwareView is used to implement differently-looking views 33 for displaying record-based data in a consistent way: 34 - tabular data views 35 - form data view 36 37 Action implementations like data editing and deleting are shared for different 38 view types to keep even better consistency. 39 The view also implements KexiSearchAndReplaceViewInterface to support search/replace features 40 used by shared KexiFindDialog. 41 */ 42 class KEXIDATAVIEWCOMMON_EXPORT KexiDataAwareView : public KexiView, 43 public KexiSearchAndReplaceViewInterface 44 { 45 Q_OBJECT 46 47 public: 48 explicit KexiDataAwareView(QWidget *parent = 0); 49 50 virtual ~KexiDataAwareView(); 51 52 QWidget* mainWidget() const; 53 54 virtual QSize minimumSizeHint() const; 55 56 virtual QSize sizeHint() const; 57 58 KexiDataAwareObjectInterface* dataAwareObject() const; 59 60 /*! Sets up data for find/replace dialog, based on view's data model. 61 Implemented for KexiSearchAndReplaceViewInterface. */ 62 virtual bool setupFindAndReplace(QStringList& columnNames, QStringList& columnCaptions, 63 QString& currentColumnName); 64 65 /*! Finds \a valueToFind within the view. 66 Implemented for KexiSearchAndReplaceViewInterface. */ 67 virtual tristate find(const QVariant& valueToFind, 68 const KexiSearchAndReplaceViewInterface::Options& options, bool next); 69 70 /*! Finds \a valueToFind within the view and replaces with \a replacement. 71 Implemented for KexiSearchAndReplaceViewInterface. */ 72 virtual tristate findNextAndReplace(const QVariant& valueToFind, 73 const QVariant& replacement, 74 const KexiSearchAndReplaceViewInterface::Options& options, bool replaceAll); 75 76 public Q_SLOTS: 77 void deleteAllRecords(); 78 void deleteCurrentRecord(); 79 void deleteAndStartEditCurrentCell(); 80 void startEditOrToggleValue(); 81 bool acceptRecordEditing(); 82 bool cancelRecordEditing(); 83 void sortAscending(); 84 void sortDescending(); 85 void copySelection(); 86 void cutSelection(); 87 void paste(); 88 void slotGoToFirstRecord(); 89 void slotGoToPreviusRecord(); 90 void slotGoToNextRecord(); 91 void slotGoToLastRecord(); 92 void slotGoToNewRecord(); 93 94 /*! @return true if data editing is in progress. 95 * Implemented for KexiView. */ 96 bool isDataEditingInProgress() const; 97 98 /*! Identical to acceptRecordEditing() 99 * @todo replace acceptRecordEditing() with this method 100 * Implemented for KexiView. */ 101 virtual tristate saveDataChanges(); 102 103 /*! Identical to cancelRecordEditing() 104 * @todo replace cancelRecordEditing() with this method 105 * Implemented for KexiView. */ 106 virtual tristate cancelDataChanges(); 107 108 protected Q_SLOTS: 109 void slotCellSelected(int record, int column); 110 void reloadActions(); 111 void slotUpdateRecordActions(int record); 112 //! Updates 'save/cancel record changes' actions 113 void slotUpdateSaveCancelActions(); 114 void slotClosing(bool* cancel); 115 116 protected: 117 void init(QWidget* viewWidget, KexiSharedActionClient* actionClient, 118 KexiDataAwareObjectInterface* dataAwareObject, 119 // temporary, for KexiFormView in design mode 120 bool noDataAware = false 121 ); 122 void initActions(); 123 virtual void updateActions(bool activated); 124 125 QWidget* internalView() const; 126 127 virtual bool eventFilter(QObject *o, QEvent *e); 128 QAction* sharedActionRequested(QKeyEvent *ke, const char *actionName); 129 130 private: 131 class Private; 132 Private * const d; 133 }; 134 135 #endif 136