OpenStructure
Loading...
Searching...
No Matches
file_browser.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef OST_GUI_FILE_BROWSER_HH
20#define OST_GUI_FILE_BROWSER_HH
21
22
23#include <ost/gfx/gfx_object.hh>
25#include <ost/gui/widget.hh>
26
27#include <QModelIndex>
28#include <QDir>
29
30class QDirModel;
31class QListView;
32class QComboBox;
33
34namespace ost { namespace gui {
35
36
37
38
40class FileBrowser : public Widget {
41 Q_OBJECT
42public:
43 FileBrowser(QWidget* parent=NULL);
44 FileBrowser(const QString& path, QWidget* parent=NULL);
45
47 virtual bool Save(const QString& prefix);
48 virtual bool Restore(const QString& prefix);
49
50protected:
51 virtual void keyPressEvent(QKeyEvent* event);
52public slots:
53 void Refresh();
54private slots:
55 void Init(const QString& path);
56 void DoubleClicked(const QModelIndex& index);
57 void ChangeToParentDirectory(int index);
58 void Split();
59 void ShowContextMenu(const QPoint& pos);
60 void LoadCurrentObject();
61 void LoadWithSystemEditor();
62 void LoadWithSourceViewer();
63
64private:
65 void LoadObject(const QModelIndex& index);
66 void UpdateMenu(const QString& path);
67 void AddItem(const QDir& directory, const QString& mypath="");
68 QComboBox* menu_;
69 QDirModel* model_;
70 QListView* view_;
71 ActionList action_list_;
72};
73
74}}
75
76#endif
a simplistic file browser
virtual bool Save(const QString &prefix)
virtual ActionList GetActions()
get Widget specific actions
FileBrowser(const QString &path, QWidget *parent=NULL)
FileBrowser(QWidget *parent=NULL)
virtual void keyPressEvent(QKeyEvent *event)
virtual bool Restore(const QString &prefix)
Base class for widgets.
Definition widget.hh:40
QList< QAction * > ActionList
Definition widget.hh:33
Definition base.dox:1