fleshed out view modes for project panel
This commit is contained in:
@@ -20,5 +20,11 @@ set(OLIVE_SOURCES
|
||||
widget/projectexplorer/projectexplorer.cpp
|
||||
widget/projectexplorer/projectexplorertreeview.h
|
||||
widget/projectexplorer/projectexplorertreeview.cpp
|
||||
widget/projectexplorer/projectexplorerlistview.h
|
||||
widget/projectexplorer/projectexplorerlistview.cpp
|
||||
widget/projectexplorer/projectexplorerlistviewbase.h
|
||||
widget/projectexplorer/projectexplorerlistviewbase.cpp
|
||||
widget/projectexplorer/projectexplorericonview.h
|
||||
widget/projectexplorer/projectexplorericonview.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -28,9 +28,13 @@ ProjectExplorer::ProjectExplorer(QWidget *parent) :
|
||||
model_(this)
|
||||
{
|
||||
tree_view_ = new ProjectExplorerTreeView(this);
|
||||
tree_view_->setModel(&model_);
|
||||
connect(tree_view_, SIGNAL(DoubleClickedView(const QModelIndex&)), this, SLOT(DoubleClickViewSlot(const QModelIndex&)));
|
||||
addWidget(tree_view_);
|
||||
AddView(tree_view_);
|
||||
|
||||
list_view_ = new ProjectExplorerListView(this);
|
||||
AddView(list_view_);
|
||||
|
||||
icon_view_ = new ProjectExplorerIconView(this);
|
||||
AddView(icon_view_);
|
||||
}
|
||||
|
||||
const olive::ProjectViewType &ProjectExplorer::view_type()
|
||||
@@ -41,6 +45,16 @@ const olive::ProjectViewType &ProjectExplorer::view_type()
|
||||
void ProjectExplorer::set_view_type(olive::ProjectViewType type)
|
||||
{
|
||||
view_type_ = type;
|
||||
|
||||
// Enum values correspond to the index of the widget in this stacked widget
|
||||
setCurrentIndex(view_type_);
|
||||
}
|
||||
|
||||
void ProjectExplorer::AddView(QAbstractItemView *view)
|
||||
{
|
||||
view->setModel(&model_);
|
||||
connect(view, SIGNAL(DoubleClickedView(const QModelIndex&)), this, SLOT(DoubleClickViewSlot(const QModelIndex&)));
|
||||
addWidget(view);
|
||||
}
|
||||
|
||||
void ProjectExplorer::DoubleClickViewSlot(const QModelIndex &index)
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "project/project.h"
|
||||
#include "project/projectviewmodel.h"
|
||||
#include "project/projectviewtype.h"
|
||||
#include "widget/projectexplorer/projectexplorericonview.h"
|
||||
#include "widget/projectexplorer/projectexplorerlistview.h"
|
||||
#include "widget/projectexplorer/projectexplorertreeview.h"
|
||||
|
||||
/**
|
||||
@@ -64,6 +66,19 @@ signals:
|
||||
void DoubleClickedItem(Item* item);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Simple convenience function for adding a view to this stacked widget
|
||||
*
|
||||
* Mainly for use in the constructor. Adds the view, connects its signals/slots, and sets the model.
|
||||
*
|
||||
* @param view
|
||||
*
|
||||
* View to add to the stack
|
||||
*/
|
||||
void AddView(QAbstractItemView* view);
|
||||
|
||||
ProjectExplorerIconView* icon_view_;
|
||||
ProjectExplorerListView* list_view_;
|
||||
ProjectExplorerTreeView* tree_view_;
|
||||
|
||||
olive::ProjectViewType view_type_;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "projectexplorericonview.h"
|
||||
|
||||
ProjectExplorerIconView::ProjectExplorerIconView(QWidget *parent) :
|
||||
ProjectExplorerListViewBase(parent)
|
||||
{
|
||||
setViewMode(QListView::IconMode);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERICONVIEW_H
|
||||
#define PROJECTEXPLORERICONVIEW_H
|
||||
|
||||
#include "projectexplorerlistviewbase.h"
|
||||
|
||||
class ProjectExplorerIconView : public ProjectExplorerListViewBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectExplorerIconView(QWidget* parent);
|
||||
};
|
||||
|
||||
#endif // PROJECTEXPLORERICONVIEW_H
|
||||
@@ -0,0 +1,27 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "projectexplorerlistview.h"
|
||||
|
||||
ProjectExplorerListView::ProjectExplorerListView(QWidget *parent) :
|
||||
ProjectExplorerListViewBase(parent)
|
||||
{
|
||||
setViewMode(QListView::ListMode);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERLISTVIEW_H
|
||||
#define PROJECTEXPLORERLISTVIEW_H
|
||||
|
||||
#include "projectexplorerlistviewbase.h"
|
||||
|
||||
class ProjectExplorerListView : public ProjectExplorerListViewBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectExplorerListView(QWidget* parent);
|
||||
};
|
||||
|
||||
#endif // PROJECTEXPLORERLISTVIEW_H
|
||||
@@ -0,0 +1,51 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "projectexplorerlistviewbase.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
ProjectExplorerListViewBase::ProjectExplorerListViewBase(QWidget *parent) :
|
||||
QListView(parent)
|
||||
{
|
||||
// FIXME Is this necessary?
|
||||
setMovement(QListView::Free);
|
||||
|
||||
// Set selection mode (allows multiple item selection)
|
||||
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
// Set resize mode
|
||||
setResizeMode(QListView::Adjust);
|
||||
|
||||
// Set widget to emit a signal on right click
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
||||
void ProjectExplorerListViewBase::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
// Perform default double click functions
|
||||
QListView::mouseDoubleClickEvent(event);
|
||||
|
||||
// Get the index at whatever position was double clicked
|
||||
QModelIndex index = indexAt(event->pos());
|
||||
|
||||
// Emit the signal with this index
|
||||
emit DoubleClickedView(index);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERLISTVIEWBASE_H
|
||||
#define PROJECTEXPLORERLISTVIEWBASE_H
|
||||
|
||||
#include <QListView>
|
||||
|
||||
class ProjectExplorerListViewBase : public QListView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectExplorerListViewBase(QWidget* parent);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Double click event override
|
||||
*
|
||||
* Function that signals DoubleClickedView().
|
||||
*
|
||||
* FIXME: This code is the same as the code in ProjectExplorerTreeView. Is there a way to merge these two through
|
||||
* subclassing?
|
||||
*/
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Unconditional double click signal
|
||||
*
|
||||
* Emits a signal when the view is double clicked, regardless of whether the double clicked index was valid.
|
||||
*/
|
||||
void DoubleClickedView(const QModelIndex& index);
|
||||
};
|
||||
|
||||
#endif // PROJECTEXPLORERLISTVIEWBASE_H
|
||||
@@ -1,3 +1,23 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "projectexplorertreeview.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
@@ -5,6 +25,8 @@
|
||||
ProjectExplorerTreeView::ProjectExplorerTreeView(QWidget *parent) :
|
||||
QTreeView(parent)
|
||||
{
|
||||
// Set selection mode (allows multiple item selection)
|
||||
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
}
|
||||
|
||||
void ProjectExplorerTreeView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERTREEVIEW_H
|
||||
#define PROJECTEXPLORERTREEVIEW_H
|
||||
|
||||
@@ -16,9 +36,22 @@ public:
|
||||
ProjectExplorerTreeView(QWidget* parent);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Double click event override
|
||||
*
|
||||
* Function that signals DoubleClickedView().
|
||||
*
|
||||
* FIXME: This code is the same as the code in ProjectExplorerListViewBase. Is there a way to merge these two through
|
||||
*
|
||||
*/
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Unconditional double click signal
|
||||
*
|
||||
* Emits a signal when the view is double clicked, regardless of whether the double clicked index was valid.
|
||||
*/
|
||||
void DoubleClickedView(const QModelIndex& index);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user