[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
klflibbrowser.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klflibbrowser.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
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 2 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, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klflibbrowser.h 603 2011-02-26 23:14:55Z phfaist $ */
23 
24 
25 #ifndef KLFLIBBROWSER_H
26 #define KLFLIBBROWSER_H
27 
28 #include <QWidget>
29 #include <QMovie>
30 #include <QMenu>
31 #include <QPushButton>
32 #include <QLabel>
33 
34 #include <klflib.h>
35 
36 
37 namespace Ui { class KLFLibBrowser; }
38 
41 
42 class KLFAbstractLibView;
43 
44 class KLF_EXPORT KLFLibBrowser : public QWidget
45 {
46  Q_OBJECT
47 public:
48  KLFLibBrowser(QWidget *parent = NULL);
49  virtual ~KLFLibBrowser();
50 
52  NoRoleFlag = 0x00000000,
53 
54  NoCloseRoleFlag = 0x00000001,
55 
56  HistoryRoleFlag = 0x00010000,
57  ArchiveRoleFlag = 0x00020000,
58  SpecialResourceRoleMask = 0x00ff0000,
59 
60  NoChangeFlag = 0x01000000,
61  OpenNoRaise = 0x02000000,
62  NowMask = 0xff000000
63  };
64 
65  virtual bool eventFilter(QObject *object, QEvent *event);
66 
67  QList<QUrl> openUrls() const;
69  QUrl currentUrl();
71  int currentUrlIndex();
72 
78  KLFLibResourceEngine * getOpenResource(const QUrl& url);
79 
83  KLFAbstractLibView * getView(const QUrl& url);
84 
88  KLFAbstractLibView * getView(KLFLibResourceEngine *resource);
89 
90  QVariantMap saveGuiState();
91  void loadGuiState(const QVariantMap& state, bool openURLs = true);
92 
93  static QString displayTitle(KLFLibResourceEngine *resource);
94 
95 signals:
96  void requestRestore(const KLFLibEntry& entry, uint restoreFlags);
97  void requestRestoreStyle(const KLFStyle& style);
98 
99  void resourceTabChanged(const QUrl& currentUrl);
100  void libEntriesSelected(const KLFLibEntryList& entries);
101 
102 public slots:
115  bool openResource(const QUrl& url, uint resourceRoleFlags = NoChangeFlag,
116  const QString& viewTypeIdentifier = QString());
117 
121  bool openResource(const QString& url, uint resourceRoleFlags = NoChangeFlag,
122  const QString& viewTypeIdentifier = QString());
123 
131  bool openResource(KLFLibResourceEngine *resource, uint resourceRoleFlags = NoChangeFlag,
132  const QString& viewTypeIdentifier = QString());
133 
143  bool openResourceFromGuiState(const QUrl& url, const QVariantMap& guiState);
144 
145  bool closeResource(const QUrl& url);
146 
147  void retranslateUi(bool alsoBaseUi = true);
148 
149 protected slots:
150 
151  void slotRestoreWithStyle();
152  void slotRestoreLatexOnly();
153  void slotDeleteSelected();
154 
155  void slotRefreshResourceActionsEnabled();
156 
157  void slotTabResourceShown(int tabIndex);
158  void slotShowTabContextMenu(const QPoint& pos);
159 
160  void slotResourceRename();
161  void slotResourceRenameSubResource();
165  void slotResourceRename(bool renameSubResource);
166  void slotResourceRenameFinished();
167  bool slotResourceClose(KLFLibBrowserViewContainer *view = NULL, bool force = false);
168  void slotResourceProperties();
169  bool slotResourceNewSubRes();
170  bool slotResourceDelSubRes();
171  bool slotResourceOpen();
172  bool slotResourceNew();
173  bool slotResourceSaveTo();
174 
176  void slotResourceDataChanged(const QList<KLFLib::entryId>& entryIdList);
178  void slotResourcePropertyChanged(int propId);
179  void slotUpdateForResourceProperty(KLFLibResourceEngine *resource, int propId);
181  void slotSubResourcePropertyChanged(const QString& subResource, int propId);
183  void slotDefaultSubResourceChanged(const QString& subResource);
184 
185 
186  void slotEntriesSelected(const KLFLibEntryList& entries);
187  void slotAddCategorySuggestions(const QStringList& catlist);
188  void slotShowContextMenu(const QPoint& pos);
189 
190  void slotMetaInfoChanged(const QMap<int,QVariant>& props);
191 
193  void slotCopyToResource();
195  void slotMoveToResource();
197  void slotCopyMoveToResource(QObject *sender, bool move);
198  void slotCopyMoveToResource(KLFAbstractLibView *dest, KLFAbstractLibView *source, bool move);
199 
200  void slotCut();
201  void slotCopy();
202  void slotPaste();
203 
204  void slotOpenAll();
205  bool slotExport();
206  bool slotExportSelection();
207 
208  void slotStartProgress(KLFProgressReporter *progressReporter, const QString& text);
209 
210 
211 protected:
212  KLFLibBrowserViewContainer * findOpenUrl(const QUrl& url);
213  KLFLibBrowserViewContainer * findOpenResource(KLFLibResourceEngine *resource);
214  KLFLibBrowserViewContainer * curView();
215  KLFAbstractLibView * curLibView();
216  KLFLibBrowserViewContainer * viewForTabIndex(int tab);
217 
218  QList<KLFLibBrowserViewContainer*> findByRoleFlags(uint flags, uint mask);
219 
220  inline KLFLibBrowserViewContainer *findSpecialResource(uint specialResourceRoleFlag)
221  { QList<KLFLibBrowserViewContainer*> l = findByRoleFlags(specialResourceRoleFlag, SpecialResourceRoleMask);
222  if (l.isEmpty()) { return NULL; } return l[0]; }
223 
224  bool event(QEvent *event);
225  void showEvent(QShowEvent *event);
226  void timerEvent(QTimerEvent *event);
227 
228 private:
229  Ui::KLFLibBrowser *u;
231 
232  QMenu *pResourceMenu;
233  QMenu *pImportExportMenu;
234 
235  QPushButton *pTabCornerButton;
236 
237 private slots:
238  void updateResourceRoleFlags(KLFLibBrowserViewContainer *view, uint flags);
239 };
240 
241 
242 
243 
244 #endif
showEvent(QShowEvent *event)
A view widget to display a library resource&#39;s contents.
Definition: klflibview.h:82
KLFLibBrowserViewContainer * findSpecialResource(uint specialResourceRoleFlag)
An entry (single formula) in the library.
Definition: klflib.h:55
An abstract resource engine.
Definition: klflib.h:440
event(QEvent *event)

Generated by doxygen 1.8.5