C:/Projets/hexamonkey/gui/tree/treewidget.h
Go to the documentation of this file.
00001 //This file is part of the HexaMonkey project, a multimedia analyser
00002 //Copyright (C) 2013  Sevan Drapeau-Martin, Nicolas Fleury
00003 
00004 //This program is free software; you can redistribute it and/or
00005 //modify it under the terms of the GNU General Public License
00006 //as published by the Free Software Foundation; either version 2
00007 //of the License, or (at your option) any later version.
00008 
00009 //This program is distributed in the hope that it will be useful,
00010 //but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //GNU General Public License for more details.
00013 
00014 //You should have received a copy of the GNU General Public License
00015 //along with this program; if not, write to the Free Software
00016 //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017 
00018 #ifndef TREEWIDGET_H
00019 #define TREEWIDGET_H
00020 
00021 #include <QTreeView>
00022 #include <QGridLayout>
00023 #include <QString>
00024 
00025 #include "gui/tree/treemodel.h"
00026 #include "gui/tree/treeview.h"
00027 #include "gui/tree/htmldelegate.h"
00028 #include "gui/tree/filterwidget.h"
00029 
00030 class ProgramLoader;
00031 class TreeItem;
00032 
00045 class TreeWidget : public QWidget
00046 {
00047     Q_OBJECT
00048 public:
00049     explicit TreeWidget(const ProgramLoader &programLoader, QWidget *parent = 0);
00050     QSize sizeHint() const;
00051     void setColumnsWidths();
00052     TreeItem& currentItem() const;
00053     void copy() const;
00054     void openStream();
00055     void dumpStreamToFile();
00056     void closeFile();
00057     void dumpToFile();
00058     TreeModel* getModel();
00059 
00060 signals:
00061     void pathChanged(QString);
00062     void positionChanged(qint64, qint64);
00063     void eventDropped(QDropEvent*);
00064     void openFragmentedFile(Object&);
00065 
00066 public slots:
00067     QModelIndex addFile(File* file, const Module &module);
00068     void updatePath(QModelIndex currentIndex);
00069     void updatePosition(QModelIndex currentIndex);
00070     void setCurrentIndex(QModelIndex index);
00071     void displayMenu(const QPoint &pos);
00072     void updateByFilePosition(qint64 position);
00073 
00074 private:
00075     virtual void dropEvent(QDropEvent *event) final;
00076     virtual void dragEnterEvent(QDragEnterEvent* event) final;
00077     virtual void dragMoveEvent(QDragMoveEvent* event) final;
00078     virtual void dragLeaveEvent(QDragLeaveEvent* event) final;
00079 
00080     TreeView* view;
00081     TreeModel* model;
00082     HTMLDelegate* delegate;
00083     FilterWidget* filterWidget;
00084 
00085     QString path;
00086     quint64 position;
00087     quint64 size;
00088 };
00089 
00090 #endif // TREEWIDGET_H