BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <QtGui/QMenu>
29 #include <QtGui/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 
206  DatasetController(DatasetController& dc);
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 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
HashMap< QTreeWidgetItem *, Dataset * > item_to_dataset_
Definition: dataset.h:327
vector< String > file_formats_
Definition: dataset.h:323
void setComposite(Composite *composite)
Definition: dataset.h:111
HashMap< Dataset *, QTreeWidgetItem * > dataset_to_item_
Definition: dataset.h:328
String getType() const
Definition: dataset.h:108
HashSet< QAction * > actions_for_one_set_
Definition: dataset.h:326
vector< QAction * > actions_
Definition: dataset.h:325
DatasetControl * control_
Definition: dataset.h:324
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
void setType(String type)
Definition: dataset.h:105
#define BALL_EMBEDDABLE(TYPE, BASE)
Definition: embeddable.h:31
void setName(String name)
Definition: dataset.h:99
String getName() const
Definition: dataset.h:102
DatasetControl * getDatasetControl()
Definition: dataset.h:215
Composite * composite_
Definition: dataset.h:123
Composite * getComposite() const
Definition: dataset.h:114
vector< String > getSupportedFileFormats()
Definition: dataset.h:283
HashMap class based on the STL map (containing serveral convenience functions)
Definition: hashMap.h:73