BALL 1.5.0
Loading...
Searching...
No Matches
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
10#endif
11
12#ifndef BALL_DATATYPE_HASHMAP_H
14#endif
15
16#ifndef BALL_DATATYPE_HASHSET_H
18#endif
19
20#ifndef 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
31namespace 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
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
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
255
258 bool hasDataset(Dataset* set);
259
262
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
313 QAction* insertMenuEntry_(Position pid, const QString& name, const char* slot,
314 const String& description = "", QKeySequence accel = QKeySequence(),
315 const QString& menu_hint = "",
316 UIOperationMode::OperationMode initial_mode = UIOperationMode::MODE_ALL);
317
320 virtual void deleteDataset_(Dataset*) {};
321
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
#define BALL_EMBEDDABLE(TYPE, BASE)
Definition embeddable.h:31
HashMap class based on the STL map (containing serveral convenience functions)
Composite * getComposite() const
Definition dataset.h:114
Composite * composite_
Definition dataset.h:123
void setName(String name)
Definition dataset.h:99
void setType(String type)
Definition dataset.h:105
void setComposite(Composite *composite)
Definition dataset.h:111
Dataset(const Dataset &dataset)
String getType() const
Definition dataset.h:108
String getName() const
Definition dataset.h:102
void dump(std::ostream &s, Size depth) const
virtual void clear()
void set(const Dataset &v)
virtual bool deleteDatasets()
Delete all Datasets.
String getNameFromFileName_(String filename)
bool hasItem(QTreeWidgetItem *item)
Test if a given QTreeWidgetItem corresponds to a registered Dataset.
DatasetControl * control_
Definition dataset.h:324
void setStatusbarText(const String &text, bool important=false)
vector< Dataset * > getDatasets()
Get all Datasets of this type in the DatasetControl.
Dataset * getDataset(QTreeWidgetItem *item)
Get the Dataset for a QTreeWidgetItem.
QAction * insertMenuEntry_(Position pid, const QString &name, const char *slot, const String &description="", QKeySequence accel=QKeySequence(), const QString &menu_hint="", UIOperationMode::OperationMode initial_mode=UIOperationMode::MODE_ALL)
DatasetControl * getDatasetControl()
Definition dataset.h:215
void setStatusbarText(const QString &text, bool important=false)
virtual void checkMenu(MainControl &mc)
virtual bool write(Dataset *, String, String)
virtual QMenu * buildContextMenu(QTreeWidgetItem *item)
vector< Dataset * > getSelectedDatasets()
Get all selected Datasets of this type in the DatasetControl.
HashMap< QTreeWidgetItem *, Dataset * > item_to_dataset_
Definition dataset.h:327
HashMap< Dataset *, QTreeWidgetItem * > dataset_to_item_
Definition dataset.h:328
virtual bool write()
Show a file dialog for writing the selected Dataset.
vector< String > getSupportedFileFormats()
Definition dataset.h:283
virtual bool deleteDataset()
Delete the currently highlighted Dataset.
vector< QAction * > actions_
Definition dataset.h:325
virtual bool deleteDataset(Dataset *set)
virtual bool insertDataset(Dataset *set)
virtual Dataset * open(String, String)
virtual void deleteDataset_(Dataset *)
Definition dataset.h:320
virtual bool handle(DatasetMessage *msg)
virtual bool createMenuEntries()
vector< String > file_formats_
Definition dataset.h:323
bool hasDataset(Dataset *set)
HashSet< QAction * > actions_for_one_set_
Definition dataset.h:326
#define BALL_VIEW_EXPORT