File indexing completed on 2024-04-21 15:08:21

0001 //
0002 // C++ Interface: clisteditor
0003 //
0004 // Description: 
0005 //
0006 /*
0007 Copyright 2008-2011 Tomas Mecir <kmuddy@kmuddy.com>
0008 
0009 This program is free software; you can redistribute it and/or
0010 modify it under the terms of the GNU General Public License as
0011 published by the Free Software Foundation; either version 2 of 
0012 the License, or (at your option) any later version.
0013 
0014 This program is distributed in the hope that it will be useful,
0015 but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 GNU General Public License for more details.
0018 
0019 You should have received a copy of the GNU General Public License
0020 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 
0023 #ifndef CLISTEDITOR_H
0024 #define CLISTEDITOR_H
0025 
0026 #include <kmuddy_export.h>
0027 #include <clistobject.h>
0028 #include <map>
0029 
0030 #include <QWidget>
0031 
0032 /** cListEditor - base class for the single object editor */
0033 
0034 class KMUDDY_EXPORT cListEditor : public QWidget {
0035   Q_OBJECT
0036  public:
0037   /** constructor */
0038   cListEditor (QWidget *parent);
0039   /** destructor */
0040   ~cListEditor () override;
0041 
0042   /** Change the edited object. */
0043   void setObject (cListObject *obj);
0044   /** Returns the currently edited object. */
0045   cListObject *object ();
0046 
0047   /** Do we hold a valid object ? */
0048   bool objectValid ();
0049 
0050   /** Are there unsaved changes ? */
0051   bool changed ();
0052   void saveChanges ();
0053  protected slots:
0054   void saveClicked ();
0055   void undoClicked ();
0056   void objectChanged (cListObject *obj);
0057  protected:
0058 
0059   /** Create the GUI, with the given object as parent.
0060     IMPORTANT: this must also create a layout for the parent widget, as it has none !!! */
0061   virtual void createGUI(QWidget *parent) = 0;
0062   QWidget *createCommonAttribEditor (QWidget *parent);
0063   void fillCommonAttribEditor (const cListObjectData &data);
0064   void getDataFromCommonAttribEditor (cListObjectData *data);
0065   
0066   /** Load data from the object. */
0067   void loadDataFromObject ();
0068   /** Save the changes back to the object. */
0069   void saveDataToObject ();
0070 
0071   /** prepares the structure and calls getDataFromGUI */
0072   void getGUIData ();
0073 
0074   /** Fill in the GUI. */
0075   virtual void fillGUI (const cListObjectData &data) = 0;
0076   /** Read the data from the GUI, fill in the data structure. */
0077   virtual void getDataFromGUI (cListObjectData *data) = 0;
0078 
0079 private:
0080   struct Private;
0081   Private *d;
0082 
0083 };
0084 
0085 
0086 #endif  // CLISTEDITOR_H