ZIMA CAD Parts
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
productview.h
Go to the documentation of this file.
1 /*
2  ZIMA-CAD-Parts
3  http://www.zima-construction.cz/software/ZIMA-Parts
4 
5  Copyright (C) 2011-2012 Jakub Skokan <aither@havefun.cz>
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef PRODUCTVIEW_H
22 #define PRODUCTVIEW_H
23 
24 #include "../../zima-cad-parts.h"
25 
26 #include <QWidget>
27 #include "ui_productview.h"
28 #include "abstractproductview.h"
29 #include "failbackproductview.h"
30 
31 #include "../../item.h"
32 
33 namespace Ui {
34 class ProductView;
35 }
36 
44 class ProductView : public QDialog
45 {
46  Q_OBJECT
47 
48 public:
49  explicit ProductView(QWidget *parent = 0);
50  ~ProductView();
51 
56  bool expectFile(File* f);
58  bool canHandle(File::FileTypes t);
59 
60 public slots:
62  void fileDownloaded(File* f);
63 
64 protected:
65  void hideEvent(QHideEvent *e);
66  void showEvent(QShowEvent *e);
67 
68 private:
69  Ui::ProductView *ui;
70  File *expectedFile;
71  QHash<File::FileTypes, AbstractProductView*> providers;
72  AbstractProductView *currentProvider;
73  FailbackProductView *failbackProvider;
74 
76  template <class T> void addProviders()
77  {
78  T *provider = new T(this);
79  provider->hide();
80  foreach(File::FileTypes i, provider->canHandle())
81  providers[i] = provider;
82  }
83 
84  void saveSettings();
85 };
86 
87 #endif // PRODUCTVIEW_H
void showEvent(QShowEvent *e)
Definition: productview.cpp:76
bool canHandle(File::FileTypes t)
Returns true if the one of registered product views can handle given file type.
Definition: productview.cpp:65
The FailbackProductView class is a product view for unhandled files.
Definition: failbackproductview.h:15
void fileDownloaded(File *f)
Finally display the file.
Definition: productview.cpp:104
ProductView(QWidget *parent=0)
Definition: productview.cpp:30
The user interface for Product Views.
Definition: productview.h:44
bool expectFile(File *f)
Set the file which will be downloaded.
Definition: productview.cpp:93
The abstract base for all &quot;file preview&quot; processing.
Definition: abstractproductview.h:17
Definition: item.h:41
FileTypes
Definition: item.h:43
void hideEvent(QHideEvent *e)
Definition: productview.cpp:70
~ProductView()
Definition: productview.cpp:49