00001 /* -*- c++ -*- (for Emacs) 00002 * 00003 * mvccontainers.h 00004 * Digest 00005 * 00006 * Created by Aidan Lane on Sun Aug 28 2005. 00007 * Copyright (c) 2005 Optimisation and Constraint Solving Group, 00008 * Monash University. All rights reserved. 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 00025 #ifndef MVCCONTAINERS_H 00026 #define MVCCONTAINERS_H 00027 00028 00029 #include <QHash> 00030 #include <QSet> 00031 #include <QVariant> 00032 00033 class AbstractModel; 00034 class AbstractView; 00035 class AbstractController; 00036 00037 class AbstractElement; 00038 00039 00040 typedef QSetIterator<AbstractElement*> AbstractElementSetIterator; 00041 00042 class AbstractElementSet : public QSet<AbstractElement*> { 00043 public: 00044 AbstractElementSet() {} 00045 AbstractElementSet( const AbstractElementSet& other ) 00046 : QSet<AbstractElement*>(other) {} 00047 AbstractElementSet( const QSet<AbstractElement*>& other ) 00048 : QSet<AbstractElement*>(other) {} 00049 AbstractElementSet( AbstractElement* element ) { 00050 insert( element ); 00051 } 00052 }; 00053 00054 00055 class AbstractModelContainer { 00056 public: 00057 AbstractModelContainer( AbstractModel* model ) 00058 : m_model(model) {} 00059 AbstractModel* model() const { return m_model; } 00060 private: 00061 AbstractModel* m_model; 00062 }; 00063 00064 00065 class AbstractViewContainer { 00066 public: 00067 AbstractViewContainer( AbstractView* view ) 00068 : m_view(view) {} 00069 AbstractView* view() const { return m_view; } 00070 private: 00071 AbstractView* m_view; 00072 }; 00073 00074 00075 class AbstractControllerContainer { 00076 public: 00077 AbstractControllerContainer( AbstractController* controller ) 00078 : m_controller(controller) {} 00079 AbstractController* controller() const { return m_controller; } 00080 private: 00081 AbstractController* m_controller; 00082 }; 00083 00084 00092 class AbstractElementSetContainer { 00093 public: 00094 AbstractElementSetContainer( const AbstractElementSet& elements ) 00095 : m_elements(elements) {} 00096 const AbstractElementSet& elements() const { return m_elements; } 00097 private: 00098 const AbstractElementSet m_elements; 00099 }; 00100 00101 00102 class ElementOrderActionContainer { 00103 public: 00104 enum Action { 00105 BringToFront, SendToBack, BringForward, SendBackward 00106 }; 00107 ElementOrderActionContainer( Action action ) 00108 : m_action(action) {} 00109 Action action() const { return m_action; } 00110 private: 00111 Action m_action; 00112 }; 00113 00114 00120 class AttributeTypesContainer { 00121 public: 00122 AttributeTypesContainer( const QSet<int>& attributeTypes ) 00123 : m_attributeTypes(attributeTypes) {} 00124 AttributeTypesContainer( int type ) { 00125 m_attributeTypes += type; 00126 } 00127 const QSet<int>& attributeTypes() const { return m_attributeTypes; } 00128 private: 00129 QSet<int> m_attributeTypes; 00130 }; 00131 00132 00137 class AttributesContainer { 00138 public: 00139 AttributesContainer( const QHash<int, QVariant>& attributes ) 00140 : m_attributes(attributes) {} 00141 AttributesContainer( int attributeType, 00142 const QVariant& attributeValue ) { 00143 m_attributes.insert( attributeType, attributeValue ); 00144 } 00145 const QHash<int, QVariant>& attributes() const { 00146 return m_attributes; 00147 } 00148 private: 00149 QHash<int, QVariant> m_attributes; 00150 }; 00151 00152 00153 00154 #endif // ! MVCCONTAINERS_H
1.5.2