MyBooks
stdstoragedialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  * This file is part of the CuteReport project *
3  * Copyright (C) 2012-2017 by Alexander Mikhalov *
4  * alexander.mikhalov@gmail.com *
5  * *
6  ** GNU General Public License Usage **
7  * *
8  * This library is free software: you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation, either version 3 of the License, or *
11  * (at your option) any later version. *
12  * You should have received a copy of the GNU General Public License *
13  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
14  * *
15  ** GNU Lesser General Public License **
16  * *
17  * This library is free software: you can redistribute it and/or modify *
18  * it under the terms of the GNU Lesser General Public License as *
19  * published by the Free Software Foundation, either version 3 of the *
20  * License, or (at your option) any later version. *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library. *
23  * If not, see <http://www.gnu.org/licenses/>. *
24  * *
25  * This library is distributed in the hope that it will be useful, *
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
28  * GNU General Public License for more details. *
29  ****************************************************************************/
30 #ifndef STDSTORAGEDIALOG_H
31 #define STDSTORAGEDIALOG_H
32 
33 #include "widgets_export.h"
34 
35 #include <QDialog>
36 #include <QPointer>
37 #include <QTreeWidgetItem>
38 
39 namespace Ui {
40 class StdStorageDialog;
41 }
42 
43 //class QTreeWidgetItem;
44 
45 namespace CuteReport {
46 
47 class StorageInterface;
48 class ReportInterface;
49 class ReportCore;
50 
51 
52 class WIDGET_EXPORTS StdStorageDialog : public QDialog
53 {
54  Q_OBJECT
55 
56 public:
57  enum ViewOption {
58  ShowNothing = 0x00,
59  ShowStorageSelect = 0x01,
60  ShowAll = 0xff
61  };
62  Q_DECLARE_FLAGS(ViewOptions, ViewOption)
63 
64  explicit StdStorageDialog(ReportCore * reportCore, QWidget *parent, const QString &windowTitle = QString());
65  explicit StdStorageDialog(ReportCore * reportCore, ReportInterface * report, QWidget *parent = 0, const QString &windowTitle = QString());
67 
68  void setUrl(const QString & url);
69 
70  void setViewOptions(ViewOptions f);
71  void setExtensionAutocomplete(bool b);
72 
73  void setCurrentStorage(const QString & storageName, bool exclusive = false);
74  QString currentStorageName();
75 
77 // void setUrlHint(const QString & urlHint);
78 // void setUrlHints(const QStringList & urlHints); // first has more priority
79 
81 // void setObjectHint(const QString & objectHint);
82 
83  void setNameFilters(const QStringList & nameFilters, bool addAllFilesOption = true);
84  QString currentNameFilter() const;
85 
86  void setRootDir(const QString & dir, bool canGoOutRoot = false);
87  QString rootDir() const;
88 
89  QString currentFolderUrl() const;
90  QString currentObjectUrl() const;
91 
92  bool currentObjectExists() const;
93 
94  bool populate();
95 
96 private slots:
97  void currentStoragetIndexChanged(int index);
98  void currentFiltertIndexChanged(int index);
99  void currentItemChanged ( QTreeWidgetItem * current, QTreeWidgetItem * previous );
100  void itemDoubleClicked ( QTreeWidgetItem * current, int);
101  void itemActivated ( QTreeWidgetItem * item, int column );
102  void toRootDir();
103  void dirUp();
104  void showEvent ( QShowEvent * event );
105  void filenameEdited(const QString & filename);
106  void filenameCursorPositionChanged(int oldPos, int newPos);
107 
108 private:
109  void initMe();
110  QPixmap formPreviewPixmap(const QTreeWidgetItem *item);
111 
112  Ui::StdStorageDialog *ui;
114  QPointer<StorageInterface> m_storage;
115  QPointer<ReportInterface> m_report;
116 // QStringList m_urlHints;
117 // QString m_objectHint;
118  QString m_rootDir;
120  QString m_currentPath;
122  QStringList m_urlBackward;
123 // QString m_previousUrl;
124  typedef QMap<const QTreeWidgetItem *, QPixmap> FormPixmapCache;
125  FormPixmapCache m_formPixmapCache;
129 };
130 
131 } //namespace
132 
133 Q_DECLARE_OPERATORS_FOR_FLAGS(CuteReport::StdStorageDialog::ViewOptions)
134 
135 #endif // STDSTORAGEDIALOG_H
Definition: abstractpainterdelegate.h:42
QPointer< StorageInterface > m_storage
Definition: stdstoragedialog.h:114
bool m_useAllFilesFilter
Definition: stdstoragedialog.h:126
Definition: reportpreview.h:30
QString m_proposedFileName
Definition: stdstoragedialog.h:121
TODO v2: rename to ReportObject.
Definition: reportinterface.h:71
QPointer< ReportInterface > m_report
Definition: stdstoragedialog.h:115
#define WIDGET_EXPORTS
Definition: widgets_export.h:17
QString m_rootDir
Definition: stdstoragedialog.h:118
Ui::StdStorageDialog * ui
Definition: stdstoragedialog.h:112
FormPixmapCache m_formPixmapCache
Definition: stdstoragedialog.h:125
QString m_extensionAutocomplete
Definition: stdstoragedialog.h:127
QStringList m_urlBackward
Definition: stdstoragedialog.h:122
QMap< const QTreeWidgetItem *, QPixmap > FormPixmapCache
Definition: stdstoragedialog.h:124
bool m_currentFileNameIsManuallyEntered
Definition: stdstoragedialog.h:128
Definition: stdstoragedialog.h:52
ViewOption
Definition: stdstoragedialog.h:57
bool m_canGoOutRoot
Definition: stdstoragedialog.h:119
CuteReport::ReportCore * m_reportCore
Definition: stdstoragedialog.h:113
Definition: reportcore.h:83
QString m_currentPath
Definition: stdstoragedialog.h:120