00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_VIEW_DATATYPE_DATASET_H
00008 #define BALL_VIEW_DATATYPE_DATASET_H
00009
00010 #ifndef BALL_DATATYPE_STRING_H
00011 # include <BALL/DATATYPE/string.h>
00012 #endif
00013
00014 #ifndef BALL_DATATYPE_HASHMAP_H
00015 # include <BALL/DATATYPE/hashMap.h>
00016 #endif
00017
00018 #ifndef BALL_DATATYPE_HASHSET_H
00019 # include <BALL/DATATYPE/hashSet.h>
00020 #endif
00021
00022 #ifndef BALL_CONCEPT_EMBEDDABLE_H
00023 # include <BALL/CONCEPT/embeddable.h>
00024 #endif
00025
00026 #include <QtGui/QMenu>
00027 #include <QtGui/QTreeWidgetItem>
00028
00029 namespace BALL
00030 {
00031 class Composite;
00032
00033 namespace VIEW
00034 {
00035 class DatasetControl;
00036 class DatasetMessage;
00037 class MainControl;
00038 class DataMessage;
00039
00058 class BALL_VIEW_EXPORT Dataset
00059 {
00060 public:
00061
00065
00068 Dataset();
00069
00072 Dataset(const Dataset& dataset);
00073
00076 virtual ~Dataset();
00077
00080 virtual void clear();
00081
00083
00086
00089 void set(const Dataset& v);
00090
00094 const Dataset& operator = (const Dataset& v);
00095
00097 void setName(String name) { name_ = name;}
00098
00100 String getName() const { return name_;}
00101
00103 void setType(String type) { type_ = type;}
00104
00106 String getType() const { return type_;}
00107
00109 void setComposite(Composite* composite) { composite_ = composite;}
00110
00112 Composite* getComposite() const { return composite_;}
00113
00115 void dump(std::ostream& s, Size depth) const;
00116
00118
00119 protected:
00120
00121 Composite* composite_;
00122 String name_;
00123 String type_;
00124 };
00125
00126
00129 #define BALL_CREATE_DATASET(TYPE)\
00130 class BALL_VIEW_EXPORT TYPE##Dataset\
00131 : public Dataset\
00132 {\
00133 public :\
00134 \
00135 TYPE##Dataset(TYPE* data = 0)\
00136 : Dataset(),\
00137 data_(data)\
00138 {}\
00139 \
00140 TYPE##Dataset(const TYPE##Dataset& set)\
00141 : Dataset(set),\
00142 data_(set.data_)\
00143 {}\
00144 \
00145 TYPE* getData() { return data_;}\
00146 \
00147 void setData(TYPE* data) { data_ = data;}\
00148 \
00149 TYPE* data_;\
00150 };
00151
00152
00188 class BALL_VIEW_EXPORT DatasetController
00189 : public QObject,
00190 public Embeddable
00191 {
00192 Q_OBJECT
00193
00194 friend class DatasetControl;
00195
00196 public:
00197
00198 BALL_EMBEDDABLE(DatasetController,Embeddable)
00199
00200
00201 DatasetController();
00202
00204 DatasetController(DatasetController& dc);
00205
00207 virtual ~DatasetController();
00208
00210 void setDatasetControl(DatasetControl* dc) { control_ = dc;}
00211
00213 DatasetControl* getDatasetControl() { return control_;}
00214
00223 virtual bool handle(DatasetMessage* msg);
00224
00226 virtual bool insertDataset(Dataset* set);
00227
00229 virtual bool deleteDataset(Dataset* set);
00230
00235 virtual bool createMenuEntries();
00236
00241 virtual QMenu* buildContextMenu(QTreeWidgetItem* item);
00242
00244 vector<Dataset*> getDatasets();
00245
00247 vector<Dataset*> getSelectedDatasets();
00248
00252 Dataset* getSelectedDataset();
00253
00256 bool hasDataset(Dataset* set);
00257
00259 bool hasItem(QTreeWidgetItem* item);
00260
00262 Dataset* getDataset(QTreeWidgetItem* item);
00263
00266 String getType() { return type_;}
00267
00274 virtual void checkMenu(MainControl& mc);
00275
00281 vector<String> getSupportedFileFormats() { return file_formats_;}
00282
00283 public slots:
00284
00286 bool write();
00287
00292 bool open();
00293
00295 virtual bool deleteDatasets();
00296
00298 virtual bool deleteDataset();
00299
00300 protected:
00301
00303 void setStatusbarText(const String& text, bool important = false);
00304
00305 virtual bool write(Dataset* , String , String );
00306 virtual Dataset* open(String , String );
00307
00308 String getFileTypes_();
00309 String getNameFromFileName_(String filename);
00310 QAction* insertMenuEntry_(Position pid, const String& name, const char* slot,
00311 const String& description = "", QKeySequence accel = QKeySequence());
00312
00315 virtual void deleteDataset_(Dataset*) {};
00316
00317 String type_;
00318 vector<String> file_formats_;
00319 DatasetControl* control_;
00320 vector<QAction*> actions_;
00321 HashSet<QAction*> actions_for_one_set_;
00322 HashMap<QTreeWidgetItem*, Dataset*> item_to_dataset_;
00323 HashMap<Dataset*, QTreeWidgetItem*> dataset_to_item_;
00324 };
00325
00326 }
00327 }
00328
00329 #endif // BALL_VIEW_DATATYPE_DATASET_H