1 /*************************************************************************** 2 * * 3 * copyright : (C) 2007 The University of Toronto * 4 * netterfield@astro.utoronto.ca * 5 * * 6 * This program is free software; you can redistribute it and/or modify * 7 * it under the terms of the GNU General Public License as published by * 8 * the Free Software Foundation; either version 2 of the License, or * 9 * (at your option) any later version. * 10 * * 11 ***************************************************************************/ 12 13 #ifndef DATADIALOG_H 14 #define DATADIALOG_H 15 16 #include "dialog.h" 17 18 #include "kst_export.h" 19 20 #include "dataobject.h" 21 22 class QLineEdit; 23 class QCheckBox; 24 class QLabel; 25 26 namespace Kst { 27 28 class DataTab; 29 class Document; 30 class EditMultipleWidget; 31 32 class DataDialog : public Dialog { 33 Q_OBJECT 34 public: 35 friend class DialogLauncherSI; 36 friend class DialogSI; 37 enum EditMode { New, Edit, EditMultiple }; 38 explicit DataDialog(ObjectPtr dataObject = 0, QWidget *parent = 0, bool edit_multiple = true); 39 virtual ~DataDialog(); 40 editMode()41 EditMode editMode() const { return _mode; } 42 void addDataTab(DataTab *tab); 43 QString dataObjectName() const; 44 45 void editMultiple(const QList<ObjectPtr> &objects); 46 47 protected: 48 virtual QString tagString() const; 49 void setTagString(const QString &tagString); 50 void setShortName(const QString &name); 51 52 bool tagStringAuto() const; 53 dataObject()54 ObjectPtr dataObject() const { return _dataObject; } setDataObject(ObjectPtr dataObject)55 void setDataObject(ObjectPtr dataObject) { _dataObject = dataObject; } 56 57 virtual ObjectPtr createNewDataObject() = 0; 58 virtual ObjectPtr editExistingDataObject() const = 0; 59 60 Document *_document; 61 EditMultipleWidget *_editMultipleWidget; 62 QString _dataObjectName; 63 dialogValid()64 virtual bool dialogValid() const {return true;} 65 public Q_SLOTS: 66 void slotEditMultiple(); 67 68 private Q_SLOTS: 69 void slotApply(); 70 void modified(); 71 void clearModified(); 72 73 Q_SIGNALS: 74 void editMultipleMode(); 75 void editSingleMode(); 76 77 private: 78 void createGui(bool edit_multiple = true); 79 void updateApplyButton(); 80 81 private: 82 QLineEdit *_tagString; 83 QCheckBox *_tagStringAuto; 84 QLabel *_shortName; 85 QLabel *_nameLabel; 86 QPushButton *_editMultipleButton; 87 ObjectPtr _dataObject; 88 EditMode _mode; 89 bool _modified; 90 int _coreWindowWidth; 91 }; 92 93 } 94 95 #endif 96 97 // vim: ts=2 sw=2 et 98