BALL  1.5.0
dataset.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_VIEW_DATATYPE_DATASET_H
6 #define BALL_VIEW_DATATYPE_DATASET_H
7 
8 #ifndef BALL_DATATYPE_STRING_H
9 # include <BALL/DATATYPE/string.h>
10 #endif
11 
12 #ifndef BALL_DATATYPE_HASHMAP_H
13 # include <BALL/DATATYPE/hashMap.h>
14 #endif
15 
16 #ifndef BALL_DATATYPE_HASHSET_H
17 # include <BALL/DATATYPE/hashSet.h>
18 #endif
19 
20 #ifndef BALL_CONCEPT_EMBEDDABLE_H
21 # include <BALL/CONCEPT/embeddable.h>
22 #endif
23 
24 #ifndef BALL_VIEW_KERNEL_UIOPERATIONMODE_H
26 #endif
27 
28 #include <QtWidgets/QMenu>
29 #include <QtWidgets/QTreeWidgetItem>
30 
31 namespace BALL
32 {
33  class Composite;
34 
35  namespace VIEW
36  {
37  class DatasetControl;
38  class DatasetMessage;
39  class MainControl;
40  class DataMessage;
41 
61  {
62  public:
63 
67 
70  Dataset();
71 
74  Dataset(const Dataset& dataset);
75 
78  virtual ~Dataset();
79 
82  virtual void clear();
83 
85 
88 
91  void set(const Dataset& v);
92 
96  const Dataset& operator = (const Dataset& v);
97 
99  void setName(String name) { name_ = name;}
100 
102  String getName() const { return name_;}
103 
105  void setType(String type) { type_ = type;}
106 
108  String getType() const { return type_;}
109 
111  void setComposite(Composite* composite) { composite_ = composite;}
112 
114  Composite* getComposite() const { return composite_;}
115 
117  void dump(std::ostream& s, Size depth) const;
118  //
120 
121  protected:
122 
126  };
127 
128 
131 #define BALL_CREATE_DATASET(TYPE)\
132  class BALL_VIEW_EXPORT TYPE##Dataset\
133  : public Dataset\
134  {\
135  public :\
136  \
137  TYPE##Dataset(TYPE* data = 0)\
138  : Dataset(),\
139  data_(data)\
140  {}\
141  \
142  TYPE##Dataset(const TYPE##Dataset& set)\
143  : Dataset(set),\
144  data_(set.data_)\
145  {}\
146  \
147  TYPE* getData() { return data_;}\
148  \
149  void setData(TYPE* data) { data_ = data;}\
150  \
151  TYPE* data_;\
152  };
153 
154 
191  : public QObject,
192  public Embeddable
193  {
194  Q_OBJECT
195 
196  friend class DatasetControl;
197 
198  public:
199 
201 
202 
204 
207 
209  virtual ~DatasetController();
210 
212  void setDatasetControl(DatasetControl* dc) { control_ = dc;}
213 
215  DatasetControl* getDatasetControl() { return control_;}
216 
225  virtual bool handle(DatasetMessage* msg);
226 
228  virtual bool insertDataset(Dataset* set);
229 
231  virtual bool deleteDataset(Dataset* set);
232 
237  virtual bool createMenuEntries();
238 
243  virtual QMenu* buildContextMenu(QTreeWidgetItem* item);
244 
246  vector<Dataset*> getDatasets();
247 
249  vector<Dataset*> getSelectedDatasets();
250 
254  Dataset* getSelectedDataset();
255 
258  bool hasDataset(Dataset* set);
259 
261  bool hasItem(QTreeWidgetItem* item);
262 
264  Dataset* getDataset(QTreeWidgetItem* item);
265 
268  String getType() { return type_;}
269 
276  virtual void checkMenu(MainControl& mc);
277 
283  vector<String> getSupportedFileFormats() { return file_formats_;}
284 
285  public Q_SLOTS:
286 
288  virtual bool write();
289 
294  bool open();
295 
297  virtual bool deleteDatasets();
298 
300  virtual bool deleteDataset();
301 
302  protected:
303 
305  void setStatusbarText(const String& text, bool important = false);
306  void setStatusbarText(const QString& text, bool important = false);
307 
308  virtual bool write(Dataset* /*set*/, String /*filetype*/, String /*filename*/);
309  virtual Dataset* open(String /*filetype*/, String /*filename*/);
310 
311  String getFileTypes_();
312  String getNameFromFileName_(String filename);
313  QAction* insertMenuEntry_(Position pid, const QString& name, const char* slot,
314  const String& description = "", QKeySequence accel = QKeySequence(),
315  const QString& menu_hint = "",
317 
320  virtual void deleteDataset_(Dataset*) {};
321 
322  String type_;
323  vector<String> file_formats_;
325  vector<QAction*> actions_;
329  };
330 
331  } // namespace VIEW
332 } // namespace BALL
333 
334 #endif // BALL_VIEW_DATATYPE_DATASET_H
BALL::VIEW::DatasetController::setDatasetControl
void setDatasetControl(DatasetControl *dc)
Definition: dataset.h:212
BALL::VIEW::Dataset::setName
void setName(String name)
Definition: dataset.h:99
BALL::VIEW::Dataset::getType
String getType() const
Definition: dataset.h:108
BALL::VIEW::Dataset::getName
String getName() const
Definition: dataset.h:102
BALL::VIEW::DatasetController::getType
String getType()
Definition: dataset.h:268
hashMap.h
BALL::HashMap
HashMap class based on the STL map (containing serveral convenience functions)
Definition: hashMap.h:73
QObject
BALL::VIEW::DatasetController::control_
DatasetControl * control_
Definition: dataset.h:324
BALL::VIEW::Dataset::getComposite
Composite * getComposite() const
Definition: dataset.h:114
BALL::VIEW::DatasetController::actions_
vector< QAction * > actions_
Definition: dataset.h:325
BALL::String
Definition: string.h:56
BALL_EMBEDDABLE
#define BALL_EMBEDDABLE(TYPE, BASE)
Definition: embeddable.h:31
BALL::VIEW::MainControl
Definition: mainControl.h:114
BALL::VIEW::DatasetController::item_to_dataset_
HashMap< QTreeWidgetItem *, Dataset * > item_to_dataset_
Definition: dataset.h:327
BALL
Definition: constants.h:12
embeddable.h
BALL::VIEW::DatasetController
Definition: dataset.h:190
BALL::VIEW::Dataset::name_
String name_
Definition: dataset.h:124
BALL::HashSet< QAction * >
BALL::VIEW::DatasetController::actions_for_one_set_
HashSet< QAction * > actions_for_one_set_
Definition: dataset.h:326
BALL::VIEW::DatasetControl
Definition: datasetControl.h:36
UIOperationMode.h
BALL::Composite
Definition: composite.h:71
BALL_SIZE_TYPE
BALL::VIEW::Dataset::setType
void setType(String type)
Definition: dataset.h:105
hashSet.h
BALL::VIEW::UIOperationMode::OperationMode
OperationMode
Definition: UIOperationMode.h:29
string.h
BALL::VIEW::Dataset
Definition: dataset.h:60
BALL::VIEW::DatasetController::getSupportedFileFormats
vector< String > getSupportedFileFormats()
Definition: dataset.h:283
BALL::VIEW::UIOperationMode::MODE_ALL
@ MODE_ALL
Definition: UIOperationMode.h:34
QTreeWidgetItem
BALL::VIEW::Dataset::composite_
Composite * composite_
Definition: dataset.h:123
BALL::VIEW::DatasetController::dataset_to_item_
HashMap< Dataset *, QTreeWidgetItem * > dataset_to_item_
Definition: dataset.h:328
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
BALL::Embeddable
Definition: embeddable.h:81
BALL::VIEW::DatasetController::file_formats_
vector< String > file_formats_
Definition: dataset.h:323
BALL::VIEW::DatasetController::getDatasetControl
DatasetControl * getDatasetControl()
Definition: dataset.h:215
BALL::VIEW::DatasetMessage
Definition: message.h:137
BALL::VIEW::Dataset::setComposite
void setComposite(Composite *composite)
Definition: dataset.h:111
BALL::VIEW::Dataset::type_
String type_
Definition: dataset.h:125