00001 #ifndef CONTROLLERINTERFACE_H 00002 #define CONTROLLERINTERFACE_H 00003 00004 #include <tools/global.h> 00005 #include <domain/storabledata.h> 00006 #include <ui/lib/uiinterface.h> 00007 00008 #include <QtPlugin> 00009 00010 namespace domain 00011 { 00012 class TaskManagerData; 00013 class User; 00014 } 00015 00016 namespace control 00017 { 00018 00019 class ControllerFactory; 00020 00024 class CONTROL_EXPORT ControllerInterface : public QObject 00025 { 00026 Q_OBJECT 00027 00028 public: 00029 00030 enum ActionType 00031 { 00032 LoadDataAction, 00033 LoadThemeAction, 00034 SaveAction, 00035 CreateAction, 00036 RemoveAction, 00037 ModifyAction, 00038 AssignAction, 00039 UpdateAction, 00040 ManageAction, 00041 SelectAction, 00042 ViewAction, 00043 FocusAction, 00044 CustomAction 00045 }; 00046 00047 enum DataType 00048 { 00049 FileData, 00050 TaskData, 00051 ResourceData, 00052 ProjectData, 00053 ReservationData, 00054 UserData, 00055 InvitationData, 00056 NoData 00057 }; 00058 00059 virtual ~ControllerInterface(); 00060 00064 virtual QString description() const = 0; 00068 virtual QString name() const = 0; 00072 virtual DataType dataType() const = 0; 00076 virtual ActionType actionType() const = 0; 00080 QString dataTypeString() const; 00084 QString actionTypeString() const; 00085 00086 static QString actionTypeToString(ActionType type); 00087 static QString dataTypeToString(DataType type); 00088 00093 virtual bool userCanExecute() const; 00094 00105 virtual void init(domain::TaskManagerData* data, ui::UiInterface* ui, 00106 ControllerFactory* factory); 00107 00117 const domain::User* user() const; 00118 00119 public Q_SLOTS: 00120 00124 void run(); 00125 00131 void run(const domain::StorableData* data); 00132 00133 protected: 00134 00135 bool userHasLoggedIn() const; 00136 bool userIsAdmin() const; 00137 00138 domain::TaskManagerData* data; 00139 ui::UiInterface* ui; 00140 00141 private: 00142 00146 virtual void execute() = 0; 00147 00153 virtual void execute(const domain::StorableData* data); 00154 00155 virtual bool userIsValid() const = 0; 00156 bool checkUser() const; 00157 00158 }; 00159 00160 } 00161 00162 Q_DECLARE_INTERFACE(control::ControllerInterface, 00163 "net.sourceforge.moptaskmanager.control/1.0"); 00164 00165 #endif