various small code cleanups and improvements
Largely refactoring work to make the code somewhat nicer to work with.
This commit is contained in:
@@ -18,7 +18,6 @@ set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/projectexplorer/projectexplorer.h
|
||||
widget/projectexplorer/projectexplorer.cpp
|
||||
widget/projectexplorer/projectexplorerdefines.h
|
||||
widget/projectexplorer/projectexplorertreeview.h
|
||||
widget/projectexplorer/projectexplorertreeview.cpp
|
||||
widget/projectexplorer/projectexplorerlistview.h
|
||||
|
||||
@@ -24,12 +24,11 @@
|
||||
#include <QMenu>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "common/define.h"
|
||||
#include "dialog/footageproperties/footageproperties.h"
|
||||
#include "projectexplorerdefines.h"
|
||||
|
||||
ProjectExplorer::ProjectExplorer(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
view_type_(olive::TreeView),
|
||||
model_(this)
|
||||
{
|
||||
// Create layout
|
||||
@@ -63,40 +62,40 @@ ProjectExplorer::ProjectExplorer(QWidget *parent) :
|
||||
AddView(icon_view_);
|
||||
|
||||
// Set default view to tree view
|
||||
set_view_type(olive::TreeView);
|
||||
set_view_type(ProjectToolbar::TreeView);
|
||||
|
||||
// Set default icon size
|
||||
SizeChangedSlot(olive::kProjectIconSizeDefault);
|
||||
SizeChangedSlot(kProjectIconSizeDefault);
|
||||
|
||||
// Set rename timer timeout
|
||||
rename_timer_.setInterval(500);
|
||||
connect(&rename_timer_, SIGNAL(timeout()), this, SLOT(RenameTimerSlot()));
|
||||
connect(&rename_timer_, &QTimer::timeout, this, &ProjectExplorer::RenameTimerSlot);
|
||||
|
||||
connect(tree_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu()));
|
||||
connect(list_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu()));
|
||||
connect(icon_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu()));
|
||||
connect(tree_view_, &ProjectExplorerTreeView::customContextMenuRequested, this, &ProjectExplorer::ShowContextMenu);
|
||||
connect(list_view_, &ProjectExplorerListView::customContextMenuRequested, this, &ProjectExplorer::ShowContextMenu);
|
||||
connect(icon_view_, &ProjectExplorerIconView::customContextMenuRequested, this, &ProjectExplorer::ShowContextMenu);
|
||||
}
|
||||
|
||||
const olive::ProjectViewType &ProjectExplorer::view_type()
|
||||
const ProjectToolbar::ViewType &ProjectExplorer::view_type()
|
||||
{
|
||||
return view_type_;
|
||||
}
|
||||
|
||||
void ProjectExplorer::set_view_type(olive::ProjectViewType type)
|
||||
void ProjectExplorer::set_view_type(ProjectToolbar::ViewType type)
|
||||
{
|
||||
view_type_ = type;
|
||||
|
||||
// Set widget based on view type
|
||||
switch (view_type_) {
|
||||
case olive::TreeView:
|
||||
case ProjectToolbar::TreeView:
|
||||
stacked_widget_->setCurrentWidget(tree_view_);
|
||||
nav_bar_->setVisible(false);
|
||||
break;
|
||||
case olive::ListView:
|
||||
case ProjectToolbar::ListView:
|
||||
stacked_widget_->setCurrentWidget(list_view_);
|
||||
nav_bar_->setVisible(true);
|
||||
break;
|
||||
case olive::IconView:
|
||||
case ProjectToolbar::IconView:
|
||||
stacked_widget_->setCurrentWidget(icon_view_);
|
||||
nav_bar_->setVisible(true);
|
||||
break;
|
||||
@@ -172,7 +171,7 @@ void ProjectExplorer::DoubleClickViewSlot(const QModelIndex &index)
|
||||
|
||||
// If the item is a folder, browse to it
|
||||
if (i->CanHaveChildren()
|
||||
&& (view_type() == olive::ListView || view_type() == olive::IconView)) {
|
||||
&& (view_type() == ProjectToolbar::ListView || view_type() == ProjectToolbar::IconView)) {
|
||||
|
||||
BrowseToFolder(index);
|
||||
|
||||
@@ -232,12 +231,12 @@ void ProjectExplorer::ShowContextMenu()
|
||||
if (selected_items.isEmpty()) {
|
||||
// FIXME: These are both duplicates of items from MainMenu, is there any way to re-use the code?
|
||||
QAction* import_action = menu.addAction(tr("&Import..."));
|
||||
connect(import_action, SIGNAL(triggered(bool)), &olive::core, SLOT(DialogImportShow()));
|
||||
connect(import_action, SIGNAL(triggered(bool)), Core::instance(), SLOT(DialogImportShow()));
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
QAction* project_properties = menu.addAction(tr("&Project Properties..."));
|
||||
connect(project_properties, SIGNAL(triggered(bool)), &olive::core, SLOT(DialogProjectPropertiesShow()));
|
||||
connect(project_properties, SIGNAL(triggered(bool)), Core::instance(), SLOT(DialogProjectPropertiesShow()));
|
||||
} else {
|
||||
QAction* properties_action = menu.addAction(tr("P&roperties"));
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
|
||||
#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"
|
||||
#include "widget/projectexplorer/projectexplorernavigation.h"
|
||||
#include "widget/projecttoolbar/projecttoolbar.h"
|
||||
|
||||
/**
|
||||
* @brief A widget for browsing through a Project structure.
|
||||
@@ -47,7 +47,7 @@ class ProjectExplorer : public QWidget
|
||||
public:
|
||||
ProjectExplorer(QWidget* parent);
|
||||
|
||||
const olive::ProjectViewType& view_type();
|
||||
const ProjectToolbar::ViewType& view_type();
|
||||
|
||||
Project* project();
|
||||
void set_project(Project* p);
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
ProjectViewModel* model();
|
||||
|
||||
public slots:
|
||||
void set_view_type(olive::ProjectViewType type);
|
||||
void set_view_type(ProjectToolbar::ViewType type);
|
||||
|
||||
void Edit(Item* item);
|
||||
|
||||
@@ -124,7 +124,7 @@ private:
|
||||
ProjectExplorerListView* list_view_;
|
||||
ProjectExplorerTreeView* tree_view_;
|
||||
|
||||
olive::ProjectViewType view_type_;
|
||||
ProjectToolbar::ViewType view_type_;
|
||||
|
||||
ProjectViewModel model_;
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef PROJECTEXPLORERDEFINES_H
|
||||
#define PROJECTEXPLORERDEFINES_H
|
||||
|
||||
namespace olive {
|
||||
|
||||
/// The minimum size an icon in ProjectExplorer can be
|
||||
const int kProjectIconSizeMinimum = 16;
|
||||
|
||||
/// The maximum size an icon in ProjectExplorer can be
|
||||
const int kProjectIconSizeMaximum = 256;
|
||||
|
||||
/// The default size an icon in ProjectExplorer can be
|
||||
const int kProjectIconSizeDefault = 64;
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORERDEFINES_H
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "common/define.h"
|
||||
#include "ui/icons/icons.h"
|
||||
#include "widget/projectexplorer/projectexplorerdefines.h"
|
||||
|
||||
ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
@@ -89,7 +89,7 @@ void ProjectExplorerNavigation::Retranslate()
|
||||
void ProjectExplorerNavigation::UpdateIcons()
|
||||
{
|
||||
dir_up_btn_->setIcon(icon::DirUp);
|
||||
size_slider_->setMinimum(olive::kProjectIconSizeMinimum);
|
||||
size_slider_->setMaximum(olive::kProjectIconSizeMaximum);
|
||||
size_slider_->setValue(olive::kProjectIconSizeDefault);
|
||||
size_slider_->setMinimum(kProjectIconSizeMinimum);
|
||||
size_slider_->setMaximum(kProjectIconSizeMaximum);
|
||||
size_slider_->setValue(kProjectIconSizeDefault);
|
||||
}
|
||||
|
||||
@@ -35,15 +35,15 @@
|
||||
* * Double clicking a Folder in those views will enter that folder
|
||||
* * This navigation bar offers a "directory up" button for leaving a folder
|
||||
*
|
||||
* This navbar also provides an icon size slider for those views (between olive::kProjectIconSizeMinimum and
|
||||
* olive::kProjectIconSizeMaximum) as well as text that's intended to be set to the current Folder's name (or
|
||||
* This navbar also provides an icon size slider for those views (between kProjectIconSizeMinimum and
|
||||
* kProjectIconSizeMaximum) as well as text that's intended to be set to the current Folder's name (or
|
||||
* empty for the root folder).
|
||||
*
|
||||
* This widget does not actually communicate to Project or ProjectExplorer classes. It is simply UI widgets that are
|
||||
* intended to be connected in ways that do. This is the primarily responsibility of ProjectExplorer.
|
||||
*
|
||||
* By default, the directory up button is disabled (assuming root folder), the text is empty, and the icon size slider
|
||||
* is set to olive::kProjectIconSizeDefault.
|
||||
* is set to kProjectIconSizeDefault.
|
||||
*/
|
||||
class ProjectExplorerNavigation : public QWidget
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user