style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -50,12 +50,12 @@ namespace olive
|
||||
|
||||
namespace
|
||||
{
|
||||
QVector<Footage *> GetSelectedProxyFootage(const QVector<Node *> &items)
|
||||
QVector<Footage *> get_selected_proxy_footage(const QVector<Node *> &items)
|
||||
{
|
||||
QVector<Footage *> footage;
|
||||
for (Node *node : items) {
|
||||
Footage *candidate = dynamic_cast<Footage *>(node);
|
||||
if (!candidate || !candidate->GetFirstEnabledVideoStream().is_valid() ||
|
||||
if (!candidate || !candidate->get_first_enabled_video_stream().is_valid() ||
|
||||
footage.contains(candidate)) {
|
||||
continue;
|
||||
}
|
||||
@@ -76,10 +76,10 @@ ProjectExplorer::ProjectExplorer(QWidget *parent)
|
||||
|
||||
// Set up navigation bar
|
||||
nav_bar_ = new ProjectExplorerNavigation(this);
|
||||
connect(nav_bar_, &ProjectExplorerNavigation::SizeChanged, this,
|
||||
&ProjectExplorer::SizeChangedSlot);
|
||||
connect(nav_bar_, &ProjectExplorerNavigation::DirectoryUpClicked, this,
|
||||
&ProjectExplorer::DirUpSlot);
|
||||
connect(nav_bar_, &ProjectExplorerNavigation::size_changed, this,
|
||||
&ProjectExplorer::size_changed_slot);
|
||||
connect(nav_bar_, &ProjectExplorerNavigation::directory_up_clicked, this,
|
||||
&ProjectExplorer::dir_up_slot);
|
||||
layout->addWidget(nav_bar_);
|
||||
|
||||
// Set up stacked widget
|
||||
@@ -89,39 +89,39 @@ ProjectExplorer::ProjectExplorer(QWidget *parent)
|
||||
// Set up sort filter proxy model
|
||||
sort_model_.setSourceModel(&model_);
|
||||
sort_model_.setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
sort_model_.setSortRole(ProjectViewModel::kInnerTextRole);
|
||||
sort_model_.setSortRole(ProjectViewModel::k_inner_text_role);
|
||||
|
||||
// Add tree view to stacked widget
|
||||
tree_view_ = new ProjectExplorerTreeView(stacked_widget_);
|
||||
tree_view_->setSortingEnabled(true);
|
||||
tree_view_->sortByColumn(0, Qt::AscendingOrder);
|
||||
tree_view_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
AddView(tree_view_);
|
||||
add_view(tree_view_);
|
||||
|
||||
// Add list view to stacked widget
|
||||
list_view_ = new ProjectExplorerListView(stacked_widget_);
|
||||
list_view_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
AddView(list_view_);
|
||||
add_view(list_view_);
|
||||
|
||||
// Add icon view to stacked widget
|
||||
icon_view_ = new ProjectExplorerIconView(stacked_widget_);
|
||||
icon_view_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
AddView(icon_view_);
|
||||
add_view(icon_view_);
|
||||
|
||||
// Set default view to tree view
|
||||
set_view_type(ProjectToolbar::TreeView);
|
||||
set_view_type(ProjectToolbar::tree_view);
|
||||
|
||||
// Set default icon size
|
||||
SizeChangedSlot(kProjectIconSizeDefault);
|
||||
size_changed_slot(k_project_icon_size_default);
|
||||
|
||||
connect(tree_view_, &ProjectExplorerTreeView::customContextMenuRequested,
|
||||
this, &ProjectExplorer::ShowContextMenu);
|
||||
this, &ProjectExplorer::show_context_menu);
|
||||
connect(list_view_, &ProjectExplorerListView::customContextMenuRequested,
|
||||
this, &ProjectExplorer::ShowContextMenu);
|
||||
this, &ProjectExplorer::show_context_menu);
|
||||
connect(icon_view_, &ProjectExplorerIconView::customContextMenuRequested,
|
||||
this, &ProjectExplorer::ShowContextMenu);
|
||||
this, &ProjectExplorer::show_context_menu);
|
||||
|
||||
UpdateNavBarText();
|
||||
update_nav_bar_text();
|
||||
}
|
||||
|
||||
const ProjectToolbar::ViewType &ProjectExplorer::view_type() const
|
||||
@@ -135,54 +135,54 @@ void ProjectExplorer::set_view_type(ProjectToolbar::ViewType type)
|
||||
|
||||
// Set widget based on view type
|
||||
switch (view_type_) {
|
||||
case ProjectToolbar::TreeView:
|
||||
case ProjectToolbar::tree_view:
|
||||
stacked_widget_->setCurrentWidget(tree_view_);
|
||||
nav_bar_->setVisible(false);
|
||||
break;
|
||||
case ProjectToolbar::ListView:
|
||||
case ProjectToolbar::list_view:
|
||||
stacked_widget_->setCurrentWidget(list_view_);
|
||||
nav_bar_->setVisible(true);
|
||||
break;
|
||||
case ProjectToolbar::IconView:
|
||||
case ProjectToolbar::icon_view:
|
||||
stacked_widget_->setCurrentWidget(icon_view_);
|
||||
nav_bar_->setVisible(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::Edit(Node *item)
|
||||
void ProjectExplorer::edit(Node *item)
|
||||
{
|
||||
CurrentView()->edit(
|
||||
sort_model_.mapFromSource(model_.CreateIndexFromItem(item)));
|
||||
current_view()->edit(
|
||||
sort_model_.mapFromSource(model_.create_index_from_item(item)));
|
||||
}
|
||||
|
||||
void ProjectExplorer::AddView(QAbstractItemView *view)
|
||||
void ProjectExplorer::add_view(QAbstractItemView *view)
|
||||
{
|
||||
view->setModel(&sort_model_);
|
||||
view->setEditTriggers(QAbstractItemView::SelectedClicked);
|
||||
connect(view, &QAbstractItemView::doubleClicked, this,
|
||||
&ProjectExplorer::ItemDoubleClickedSlot);
|
||||
&ProjectExplorer::item_double_clicked_slot);
|
||||
connect(view->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
this, &ProjectExplorer::ViewSelectionChanged);
|
||||
connect(view, SIGNAL(DoubleClickedEmptyArea()), this,
|
||||
SLOT(ViewEmptyAreaDoubleClickedSlot()));
|
||||
this, &ProjectExplorer::view_selection_changed);
|
||||
connect(view, SIGNAL(double_clicked_empty_area()), this,
|
||||
SLOT(view_empty_area_double_clicked_slot()));
|
||||
stacked_widget_->addWidget(view);
|
||||
}
|
||||
|
||||
void ProjectExplorer::BrowseToFolder(const QModelIndex &index)
|
||||
void ProjectExplorer::browse_to_folder(const QModelIndex &index)
|
||||
{
|
||||
// Set appropriate views to this index
|
||||
icon_view_->setRootIndex(index);
|
||||
list_view_->setRootIndex(index);
|
||||
|
||||
// Set navbar text to folder's name
|
||||
UpdateNavBarText();
|
||||
update_nav_bar_text();
|
||||
|
||||
// Set directory up enabled button based on whether we're in root or not
|
||||
nav_bar_->set_dir_up_enabled(index.isValid());
|
||||
}
|
||||
|
||||
int ProjectExplorer::ConfirmItemDeletion(Node *item)
|
||||
int ProjectExplorer::confirm_item_deletion(Node *item)
|
||||
{
|
||||
QMessageBox msgbox(this);
|
||||
msgbox.setWindowTitle(tr("Confirm Item Deletion"));
|
||||
@@ -193,7 +193,7 @@ int ProjectExplorer::ConfirmItemDeletion(Node *item)
|
||||
item->output_connections()) {
|
||||
if (!dynamic_cast<Folder *>(connected.second.node())) {
|
||||
connected_nodes_names.append(
|
||||
GetHumanReadableNodeName(connected.second.node()));
|
||||
get_human_readable_node_name(connected.second.node()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ int ProjectExplorer::ConfirmItemDeletion(Node *item)
|
||||
tr("The item \"%1\" is currently connected to the following nodes:\n\n"
|
||||
"%2\n\n"
|
||||
"Are you sure you wish to delete this footage?")
|
||||
.arg(GetHumanReadableNodeName(item),
|
||||
.arg(get_human_readable_node_name(item),
|
||||
connected_nodes_names.join('\n')));
|
||||
|
||||
// Set up buttons
|
||||
@@ -214,7 +214,7 @@ int ProjectExplorer::ConfirmItemDeletion(Node *item)
|
||||
return msgbox.exec();
|
||||
}
|
||||
|
||||
bool ProjectExplorer::DeleteItemsInternal(const QVector<Node *> &selected,
|
||||
bool ProjectExplorer::delete_items_internal(const QVector<Node *> &selected,
|
||||
bool &check_if_item_is_in_use,
|
||||
MultiUndoCommand *command)
|
||||
{
|
||||
@@ -230,7 +230,7 @@ bool ProjectExplorer::DeleteItemsInternal(const QVector<Node *> &selected,
|
||||
Folder *folder_test = dynamic_cast<Folder *>(oc.second.node());
|
||||
if (!folder_test) {
|
||||
// This sequence outputs to SOMETHING, confirm the user if they want to delete this
|
||||
int r = ConfirmItemDeletion(node);
|
||||
int r = confirm_item_deletion(node);
|
||||
|
||||
switch (r) {
|
||||
case QMessageBox::No:
|
||||
@@ -249,7 +249,7 @@ bool ProjectExplorer::DeleteItemsInternal(const QVector<Node *> &selected,
|
||||
if (can_delete_item) {
|
||||
Sequence *sequence = dynamic_cast<Sequence *>(node);
|
||||
if (sequence &&
|
||||
Core::instance()->main_window()->IsSequenceOpen(sequence)) {
|
||||
Core::instance()->main_window()->is_sequence_open(sequence)) {
|
||||
command->add_child(new CloseSequenceCommand(sequence));
|
||||
}
|
||||
|
||||
@@ -266,23 +266,23 @@ bool ProjectExplorer::DeleteItemsInternal(const QVector<Node *> &selected,
|
||||
return true;
|
||||
}
|
||||
|
||||
QString ProjectExplorer::GetHumanReadableNodeName(Node *node)
|
||||
QString ProjectExplorer::get_human_readable_node_name(Node *node)
|
||||
{
|
||||
if (node->GetLabel().isEmpty()) {
|
||||
return node->Name();
|
||||
if (node->get_label().isEmpty()) {
|
||||
return node->name();
|
||||
} else {
|
||||
return tr("%1 (%2)").arg(node->GetLabel(), node->Name());
|
||||
return tr("%1 (%2)").arg(node->get_label(), node->name());
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::UpdateNavBarText()
|
||||
void ProjectExplorer::update_nav_bar_text()
|
||||
{
|
||||
QString absolute;
|
||||
|
||||
Folder *f = static_cast<Folder *>(
|
||||
sort_model_.mapToSource(list_view_->rootIndex()).internalPointer());
|
||||
while (f && f != project()->root()) {
|
||||
absolute.prepend(QStringLiteral("%1 / ").arg(f->GetLabel()));
|
||||
absolute.prepend(QStringLiteral("%1 / ").arg(f->get_label()));
|
||||
f = f->folder();
|
||||
}
|
||||
|
||||
@@ -291,17 +291,17 @@ void ProjectExplorer::UpdateNavBarText()
|
||||
nav_bar_->set_text(absolute);
|
||||
}
|
||||
|
||||
QAbstractItemView *ProjectExplorer::CurrentView() const
|
||||
QAbstractItemView *ProjectExplorer::current_view() const
|
||||
{
|
||||
return static_cast<QAbstractItemView *>(stacked_widget_->currentWidget());
|
||||
}
|
||||
|
||||
void ProjectExplorer::ViewEmptyAreaDoubleClickedSlot()
|
||||
void ProjectExplorer::view_empty_area_double_clicked_slot()
|
||||
{
|
||||
emit DoubleClickedItem(nullptr);
|
||||
emit double_clicked_item(nullptr);
|
||||
}
|
||||
|
||||
void ProjectExplorer::ItemDoubleClickedSlot(const QModelIndex &index)
|
||||
void ProjectExplorer::item_double_clicked_slot(const QModelIndex &index)
|
||||
{
|
||||
// Retrieve source item from index
|
||||
Node *i =
|
||||
@@ -309,65 +309,65 @@ void ProjectExplorer::ItemDoubleClickedSlot(const QModelIndex &index)
|
||||
|
||||
// If the item is a folder, browse to it
|
||||
if (dynamic_cast<Folder *>(i) &&
|
||||
(view_type() == ProjectToolbar::ListView ||
|
||||
view_type() == ProjectToolbar::IconView)) {
|
||||
BrowseToFolder(index);
|
||||
(view_type() == ProjectToolbar::list_view ||
|
||||
view_type() == ProjectToolbar::icon_view)) {
|
||||
browse_to_folder(index);
|
||||
}
|
||||
|
||||
// Emit a signal
|
||||
emit DoubleClickedItem(i);
|
||||
emit double_clicked_item(i);
|
||||
}
|
||||
|
||||
void ProjectExplorer::SizeChangedSlot(int s)
|
||||
void ProjectExplorer::size_changed_slot(int s)
|
||||
{
|
||||
icon_view_->setGridSize(QSize(s, s));
|
||||
|
||||
list_view_->setIconSize(QSize(s, s));
|
||||
}
|
||||
|
||||
void ProjectExplorer::DirUpSlot()
|
||||
void ProjectExplorer::dir_up_slot()
|
||||
{
|
||||
QModelIndex current_root = icon_view_->rootIndex();
|
||||
|
||||
if (current_root.isValid()) {
|
||||
QModelIndex parent = current_root.parent();
|
||||
|
||||
BrowseToFolder(parent);
|
||||
browse_to_folder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::RenameSelectedItem()
|
||||
void ProjectExplorer::rename_selected_item()
|
||||
{
|
||||
auto indexes = CurrentView()->selectionModel()->selectedRows();
|
||||
auto indexes = current_view()->selectionModel()->selectedRows();
|
||||
if (!indexes.empty()) {
|
||||
CurrentView()->edit(indexes.first());
|
||||
current_view()->edit(indexes.first());
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::SetSearchFilter(const QString &s)
|
||||
void ProjectExplorer::set_search_filter(const QString &s)
|
||||
{
|
||||
sort_model_.setFilterFixedString(s);
|
||||
}
|
||||
|
||||
void ProjectExplorer::ShowContextMenu()
|
||||
void ProjectExplorer::show_context_menu()
|
||||
{
|
||||
Menu menu;
|
||||
Menu new_menu;
|
||||
|
||||
context_menu_items_ = SelectedItems();
|
||||
context_menu_items_ = selected_items();
|
||||
|
||||
if (context_menu_items_.isEmpty()) {
|
||||
// Items to show if no items are selected
|
||||
|
||||
// "New" menu
|
||||
new_menu.setTitle(tr("&New"));
|
||||
MenuShared::instance()->AddItemsForNewMenu(&new_menu);
|
||||
MenuShared::instance()->add_items_for_new_menu(&new_menu);
|
||||
menu.addMenu(&new_menu);
|
||||
|
||||
// "Import" action
|
||||
QAction *import_action = menu.addAction(tr("&Import..."));
|
||||
connect(import_action, &QAction::triggered, Core::instance(),
|
||||
&Core::DialogImportShow);
|
||||
&Core::dialog_import_show);
|
||||
} else {
|
||||
// Actions to add when only one item is selected
|
||||
if (context_menu_items_.size() == 1) {
|
||||
@@ -377,12 +377,12 @@ void ProjectExplorer::ShowContextMenu()
|
||||
QAction *open_in_new_tab =
|
||||
menu.addAction(tr("Open in New Tab"));
|
||||
connect(open_in_new_tab, &QAction::triggered, this,
|
||||
&ProjectExplorer::OpenContextMenuItemInNewTab);
|
||||
&ProjectExplorer::open_context_menu_item_in_new_tab);
|
||||
|
||||
QAction *open_in_new_window =
|
||||
menu.addAction(tr("Open in New Window"));
|
||||
connect(open_in_new_window, &QAction::triggered, this,
|
||||
&ProjectExplorer::OpenContextMenuItemInNewWindow);
|
||||
&ProjectExplorer::open_context_menu_item_in_new_window);
|
||||
|
||||
} else if (dynamic_cast<Footage *>(context_menu_item)) {
|
||||
QString reveal_text;
|
||||
@@ -397,11 +397,11 @@ void ProjectExplorer::ShowContextMenu()
|
||||
|
||||
QAction *reveal_action = menu.addAction(reveal_text);
|
||||
connect(reveal_action, &QAction::triggered, this,
|
||||
&ProjectExplorer::RevealSelectedFootage);
|
||||
&ProjectExplorer::reveal_selected_footage);
|
||||
|
||||
QAction *replace_action = menu.addAction(tr("Replace Footage"));
|
||||
connect(replace_action, &QAction::triggered, this,
|
||||
&ProjectExplorer::ReplaceSelectedFootage);
|
||||
&ProjectExplorer::replace_selected_footage);
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
@@ -416,7 +416,7 @@ void ProjectExplorer::ShowContextMenu()
|
||||
Sequence *sequence_cast_test = dynamic_cast<Sequence *>(i);
|
||||
|
||||
if (footage_cast_test &&
|
||||
!footage_cast_test->HasEnabledVideoStreams()) {
|
||||
!footage_cast_test->has_enabled_video_streams()) {
|
||||
all_items_have_video_streams = false;
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ void ProjectExplorer::ShowContextMenu()
|
||||
|
||||
if (all_items_are_footage && all_items_have_video_streams) {
|
||||
const QVector<Footage *> proxy_footage =
|
||||
GetSelectedProxyFootage(context_menu_items_);
|
||||
get_selected_proxy_footage(context_menu_items_);
|
||||
|
||||
Menu *proxy_menu = new Menu(tr("Proxy"), &menu);
|
||||
menu.addMenu(proxy_menu);
|
||||
@@ -440,7 +440,7 @@ void ProjectExplorer::ShowContextMenu()
|
||||
proxy_menu->addAction(tr("Generate Proxy"));
|
||||
generate_proxy->setEnabled(!proxy_footage.isEmpty());
|
||||
connect(generate_proxy, &QAction::triggered, this,
|
||||
&ProjectExplorer::GenerateProxiesForSelectedFootage);
|
||||
&ProjectExplorer::generate_proxies_for_selected_footage);
|
||||
|
||||
QAction *use_proxy = proxy_menu->addAction(tr("Use Proxy"));
|
||||
use_proxy->setCheckable(true);
|
||||
@@ -452,7 +452,7 @@ void ProjectExplorer::ShowContextMenu()
|
||||
return footage->proxy_enabled();
|
||||
}));
|
||||
connect(use_proxy, &QAction::triggered, this,
|
||||
&ProjectExplorer::SetSelectedFootageProxyEnabled);
|
||||
&ProjectExplorer::set_selected_footage_proxy_enabled);
|
||||
|
||||
QAction *reveal_proxy = proxy_menu->addAction(tr("Reveal Proxy"));
|
||||
reveal_proxy->setEnabled(
|
||||
@@ -461,7 +461,7 @@ void ProjectExplorer::ShowContextMenu()
|
||||
return !footage->proxy_path().isEmpty();
|
||||
}));
|
||||
connect(reveal_proxy, &QAction::triggered, this,
|
||||
&ProjectExplorer::RevealProxyForSelectedFootage);
|
||||
&ProjectExplorer::reveal_proxy_for_selected_footage);
|
||||
|
||||
QAction *delete_proxy = proxy_menu->addAction(tr("Delete Proxy"));
|
||||
delete_proxy->setEnabled(
|
||||
@@ -470,12 +470,12 @@ void ProjectExplorer::ShowContextMenu()
|
||||
return !footage->proxy_path().isEmpty();
|
||||
}));
|
||||
connect(delete_proxy, &QAction::triggered, this,
|
||||
&ProjectExplorer::DeleteProxiesForSelectedFootage);
|
||||
&ProjectExplorer::delete_proxies_for_selected_footage);
|
||||
|
||||
QAction *proxy_settings =
|
||||
proxy_menu->addAction(tr("Proxy Settings..."));
|
||||
connect(proxy_settings, &QAction::triggered, this,
|
||||
&ProjectExplorer::ShowProxyDialogForSelectedFootage);
|
||||
&ProjectExplorer::show_proxy_dialog_for_selected_footage);
|
||||
}
|
||||
|
||||
Q_UNUSED(all_items_are_footage_or_sequence)
|
||||
@@ -485,26 +485,26 @@ void ProjectExplorer::ShowContextMenu()
|
||||
|
||||
auto rename_action = menu.addAction(tr("Rename"));
|
||||
connect(rename_action, &QAction::triggered, this,
|
||||
&ProjectExplorer::RenameSelectedItem);
|
||||
&ProjectExplorer::rename_selected_item);
|
||||
}
|
||||
|
||||
auto delete_action = menu.addAction(tr("Delete"));
|
||||
connect(delete_action, &QAction::triggered, this,
|
||||
&ProjectExplorer::DeleteSelected);
|
||||
&ProjectExplorer::delete_selected);
|
||||
|
||||
if (context_menu_items_.size() == 1) {
|
||||
menu.addSeparator();
|
||||
|
||||
QAction *properties_action = menu.addAction(tr("P&roperties"));
|
||||
connect(properties_action, &QAction::triggered, this,
|
||||
&ProjectExplorer::ShowItemPropertiesDialog);
|
||||
&ProjectExplorer::show_item_properties_dialog);
|
||||
}
|
||||
}
|
||||
|
||||
menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void ProjectExplorer::ShowItemPropertiesDialog()
|
||||
void ProjectExplorer::show_item_properties_dialog()
|
||||
{
|
||||
Node *sel = context_menu_items_.first();
|
||||
|
||||
@@ -514,16 +514,16 @@ void ProjectExplorer::ShowItemPropertiesDialog()
|
||||
fpd.exec();
|
||||
|
||||
} else if (dynamic_cast<Folder *>(sel)) {
|
||||
Core::instance()->LabelNodes(context_menu_items_);
|
||||
Core::instance()->label_nodes(context_menu_items_);
|
||||
|
||||
} else if (dynamic_cast<Sequence *>(sel)) {
|
||||
SequenceDialog sd(static_cast<Sequence *>(sel),
|
||||
SequenceDialog::kExisting, this);
|
||||
SequenceDialog::k_existing, this);
|
||||
sd.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::RevealSelectedFootage()
|
||||
void ProjectExplorer::reveal_selected_footage()
|
||||
{
|
||||
Footage *footage = static_cast<Footage *>(context_menu_items_.first());
|
||||
|
||||
@@ -549,15 +549,15 @@ void ProjectExplorer::RevealSelectedFootage()
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProjectExplorer::ReplaceSelectedFootage()
|
||||
void ProjectExplorer::replace_selected_footage()
|
||||
{
|
||||
Footage *footage = static_cast<Footage *>(context_menu_items_.first());
|
||||
|
||||
QString file =
|
||||
QFileDialog::getOpenFileName(this, tr("Replace Footage"), QString(),
|
||||
Core::FootageFileDialogFilter());
|
||||
Core::footage_file_dialog_filter());
|
||||
if (!file.isEmpty()) {
|
||||
if (!Core::IsFootageExtensionAllowed(file)) {
|
||||
if (!Core::is_footage_extension_allowed(file)) {
|
||||
QMessageBox::warning(
|
||||
this, tr("Unsupported media"),
|
||||
tr("This file type is not allowed by the current media type "
|
||||
@@ -570,10 +570,10 @@ void ProjectExplorer::ReplaceSelectedFootage()
|
||||
// Change filename parameter
|
||||
p->add_child(new NodeParamSetStandardValueCommand(
|
||||
NodeKeyframeTrackReference(
|
||||
NodeInput(footage, Footage::kFilenameInput)),
|
||||
NodeInput(footage, Footage::k_filename_input)),
|
||||
file));
|
||||
|
||||
if (QFileInfo(footage->filename()).fileName() == footage->GetLabel()) {
|
||||
if (QFileInfo(footage->filename()).fileName() == footage->get_label()) {
|
||||
// Footage label == filename, change label too
|
||||
p->add_child(
|
||||
new NodeRenameCommand(footage, QFileInfo(file).fileName()));
|
||||
@@ -583,19 +583,19 @@ void ProjectExplorer::ReplaceSelectedFootage()
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::OpenContextMenuItemInNewTab()
|
||||
void ProjectExplorer::open_context_menu_item_in_new_tab()
|
||||
{
|
||||
Core::instance()->main_window()->OpenFolder(
|
||||
Core::instance()->main_window()->open_folder(
|
||||
static_cast<Folder *>(context_menu_items_.first()), false);
|
||||
}
|
||||
|
||||
void ProjectExplorer::OpenContextMenuItemInNewWindow()
|
||||
void ProjectExplorer::open_context_menu_item_in_new_window()
|
||||
{
|
||||
Core::instance()->main_window()->OpenFolder(
|
||||
Core::instance()->main_window()->open_folder(
|
||||
static_cast<Folder *>(context_menu_items_.first()), true);
|
||||
}
|
||||
|
||||
void ProjectExplorer::GenerateProxiesForSelectedFootage()
|
||||
void ProjectExplorer::generate_proxies_for_selected_footage()
|
||||
{
|
||||
if (!ProxyManager::instance() || !project()) {
|
||||
qWarning()
|
||||
@@ -604,12 +604,12 @@ void ProjectExplorer::GenerateProxiesForSelectedFootage()
|
||||
}
|
||||
|
||||
const QVector<Footage *> footage =
|
||||
GetSelectedProxyFootage(context_menu_items_);
|
||||
get_selected_proxy_footage(context_menu_items_);
|
||||
qDebug()
|
||||
<< "GenerateProxiesForSelectedFootage: starting proxy generation for"
|
||||
<< footage.size() << "footage item(s)";
|
||||
for (Footage *item : footage) {
|
||||
const VideoParams video = item->GetFirstEnabledVideoStream();
|
||||
const VideoParams video = item->get_first_enabled_video_stream();
|
||||
if (!video.is_valid()) {
|
||||
qWarning()
|
||||
<< "GenerateProxiesForSelectedFootage: skipping item with no valid video stream"
|
||||
@@ -617,25 +617,25 @@ void ProjectExplorer::GenerateProxiesForSelectedFootage()
|
||||
continue;
|
||||
}
|
||||
|
||||
ProxyManager::ProxyParams params = item->GetEffectiveProxyParams();
|
||||
ProxyManager::ProxyParams params = item->get_effective_proxy_params();
|
||||
const ProxyManager::Proxy proxy =
|
||||
ProxyManager::instance()->GetOrStartProxy(
|
||||
ProxyManager::instance()->get_or_start_proxy(
|
||||
item->project()->cache_path(), item->filename(),
|
||||
video.stream_index(), params);
|
||||
qDebug() << "GenerateProxiesForSelectedFootage: proxy state="
|
||||
<< ProxyManager::ProxyStateToString(proxy.state)
|
||||
<< ProxyManager::proxy_state_to_string(proxy.state)
|
||||
<< "file=" << proxy.filename
|
||||
<< "cache=" << item->project()->cache_path();
|
||||
item->SetProxy(proxy.filename, proxy.state, video.stream_index(),
|
||||
item->set_proxy(proxy.filename, proxy.state, video.stream_index(),
|
||||
params.version, true);
|
||||
item->InvalidateAll(Footage::kFilenameInput);
|
||||
item->invalidate_all(Footage::k_filename_input);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::SetSelectedFootageProxyEnabled(bool enabled)
|
||||
void ProjectExplorer::set_selected_footage_proxy_enabled(bool enabled)
|
||||
{
|
||||
const QVector<Footage *> footage =
|
||||
GetSelectedProxyFootage(context_menu_items_);
|
||||
get_selected_proxy_footage(context_menu_items_);
|
||||
qDebug() << "ProjectExplorer::SetSelectedFootageProxyEnabled:" << enabled
|
||||
<< "footage count=" << footage.size();
|
||||
for (Footage *item : footage) {
|
||||
@@ -646,14 +646,14 @@ void ProjectExplorer::SetSelectedFootageProxyEnabled(bool enabled)
|
||||
}
|
||||
|
||||
item->set_proxy_enabled(enabled);
|
||||
item->InvalidateAll(Footage::kFilenameInput);
|
||||
item->invalidate_all(Footage::k_filename_input);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::RevealProxyForSelectedFootage()
|
||||
void ProjectExplorer::reveal_proxy_for_selected_footage()
|
||||
{
|
||||
const QVector<Footage *> footage =
|
||||
GetSelectedProxyFootage(context_menu_items_);
|
||||
get_selected_proxy_footage(context_menu_items_);
|
||||
for (Footage *item : footage) {
|
||||
if (item->proxy_path().isEmpty()) {
|
||||
continue;
|
||||
@@ -681,28 +681,28 @@ void ProjectExplorer::RevealProxyForSelectedFootage()
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::DeleteProxiesForSelectedFootage()
|
||||
void ProjectExplorer::delete_proxies_for_selected_footage()
|
||||
{
|
||||
const QVector<Footage *> footage =
|
||||
GetSelectedProxyFootage(context_menu_items_);
|
||||
get_selected_proxy_footage(context_menu_items_);
|
||||
for (Footage *item : footage) {
|
||||
if (item->proxy_path().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QFile::remove(item->proxy_path());
|
||||
item->ClearProxy();
|
||||
item->InvalidateAll(Footage::kFilenameInput);
|
||||
item->clear_proxy();
|
||||
item->invalidate_all(Footage::k_filename_input);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::ShowProxyDialogForSelectedFootage()
|
||||
void ProjectExplorer::show_proxy_dialog_for_selected_footage()
|
||||
{
|
||||
ProxyDialog d(this, GetSelectedProxyFootage(context_menu_items_));
|
||||
ProxyDialog d(this, get_selected_proxy_footage(context_menu_items_));
|
||||
d.exec();
|
||||
}
|
||||
|
||||
void ProjectExplorer::ViewSelectionChanged()
|
||||
void ProjectExplorer::view_selection_changed()
|
||||
{
|
||||
QItemSelectionModel *model = static_cast<QItemSelectionModel *>(sender());
|
||||
|
||||
@@ -722,7 +722,7 @@ void ProjectExplorer::ViewSelectionChanged()
|
||||
nodes.append(get_root());
|
||||
}
|
||||
|
||||
emit SelectionChanged(nodes);
|
||||
emit selection_changed(nodes);
|
||||
}
|
||||
|
||||
Project *ProjectExplorer::project() const
|
||||
@@ -749,17 +749,17 @@ Folder *ProjectExplorer::get_root() const
|
||||
void ProjectExplorer::set_root(Folder *item)
|
||||
{
|
||||
QModelIndex index =
|
||||
sort_model_.mapFromSource(model_.CreateIndexFromItem(item));
|
||||
sort_model_.mapFromSource(model_.create_index_from_item(item));
|
||||
|
||||
BrowseToFolder(index);
|
||||
browse_to_folder(index);
|
||||
tree_view_->setRootIndex(index);
|
||||
}
|
||||
|
||||
QVector<Node *> ProjectExplorer::SelectedItems() const
|
||||
QVector<Node *> ProjectExplorer::selected_items() const
|
||||
{
|
||||
// Determine which view is active and get its selected indexes
|
||||
QModelIndexList index_list =
|
||||
CurrentView()->selectionModel()->selectedRows();
|
||||
current_view()->selectionModel()->selectedRows();
|
||||
|
||||
// Convert indexes to item objects
|
||||
QVector<Node *> selected_items;
|
||||
@@ -775,7 +775,7 @@ QVector<Node *> ProjectExplorer::SelectedItems() const
|
||||
return selected_items;
|
||||
}
|
||||
|
||||
Folder *ProjectExplorer::GetSelectedFolder() const
|
||||
Folder *ProjectExplorer::get_selected_folder() const
|
||||
{
|
||||
if (project() == nullptr) {
|
||||
return nullptr;
|
||||
@@ -784,7 +784,7 @@ Folder *ProjectExplorer::GetSelectedFolder() const
|
||||
Folder *folder = nullptr;
|
||||
|
||||
// Get the selected items from the panel
|
||||
QVector<Node *> selected_items = SelectedItems();
|
||||
QVector<Node *> selected_nodes = selected_items();
|
||||
|
||||
// Heuristic for finding the selected folder:
|
||||
//
|
||||
@@ -793,8 +793,8 @@ Folder *ProjectExplorer::GetSelectedFolder() const
|
||||
// - Otherwise, if all folders found are the same, we'll use that to import into.
|
||||
// - If more than one folder is found, we play it safe and import into the root folder
|
||||
|
||||
for (int i = 0; i < selected_items.size(); i++) {
|
||||
Node *sel_item = selected_items.at(i);
|
||||
for (int i = 0; i < selected_nodes.size(); i++) {
|
||||
Node *sel_item = selected_nodes.at(i);
|
||||
|
||||
// If this item is not a folder, presumably it's parent is
|
||||
if (!dynamic_cast<Folder *>(sel_item)) {
|
||||
@@ -825,19 +825,19 @@ ProjectViewModel *ProjectExplorer::model()
|
||||
return &model_;
|
||||
}
|
||||
|
||||
void ProjectExplorer::SelectAll()
|
||||
void ProjectExplorer::select_all()
|
||||
{
|
||||
CurrentView()->selectAll();
|
||||
current_view()->selectAll();
|
||||
}
|
||||
|
||||
void ProjectExplorer::DeselectAll()
|
||||
void ProjectExplorer::deselect_all()
|
||||
{
|
||||
CurrentView()->selectionModel()->clearSelection();
|
||||
current_view()->selectionModel()->clearSelection();
|
||||
}
|
||||
|
||||
void ProjectExplorer::DeleteSelected()
|
||||
void ProjectExplorer::delete_selected()
|
||||
{
|
||||
QVector<Node *> selected = SelectedItems();
|
||||
QVector<Node *> selected = selected_items();
|
||||
|
||||
if (selected.isEmpty()) {
|
||||
return;
|
||||
@@ -847,7 +847,7 @@ void ProjectExplorer::DeleteSelected()
|
||||
|
||||
bool check_if_item_is_in_use = true;
|
||||
|
||||
if (DeleteItemsInternal(selected, check_if_item_is_in_use, command)) {
|
||||
if (delete_items_internal(selected, check_if_item_is_in_use, command)) {
|
||||
Core::instance()->undo_stack()->push(
|
||||
command, tr("Deleted %1 Item(s)").arg(selected.size()));
|
||||
} else {
|
||||
@@ -855,29 +855,29 @@ void ProjectExplorer::DeleteSelected()
|
||||
}
|
||||
}
|
||||
|
||||
bool ProjectExplorer::SelectItem(Node *n, bool deselect_all_first)
|
||||
bool ProjectExplorer::select_item(Node *n, bool deselect_all_first)
|
||||
{
|
||||
if (deselect_all_first) {
|
||||
DeselectAll();
|
||||
deselect_all();
|
||||
}
|
||||
|
||||
QModelIndex index = model_.CreateIndexFromItem(n);
|
||||
QModelIndex index = model_.create_index_from_item(n);
|
||||
|
||||
if (index.isValid()) {
|
||||
index = sort_model_.mapFromSource(index);
|
||||
|
||||
QModelIndex parent = index.parent();
|
||||
if (view_type() == ProjectToolbar::TreeView) {
|
||||
if (view_type() == ProjectToolbar::tree_view) {
|
||||
// Expand all folders until this index is visible
|
||||
while (parent.isValid()) {
|
||||
tree_view_->expand(parent);
|
||||
parent = parent.parent();
|
||||
}
|
||||
} else {
|
||||
BrowseToFolder(parent);
|
||||
browse_to_folder(parent);
|
||||
}
|
||||
|
||||
CurrentView()->selectionModel()->select(
|
||||
current_view()->selectionModel()->select(
|
||||
index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORER_H
|
||||
#define PROJECTEXPLORER_H
|
||||
#ifndef OAK_PROJECTEXPLORER_H
|
||||
#define OAK_PROJECTEXPLORER_H
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStackedWidget>
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
Folder *get_root() const;
|
||||
void set_root(Folder *item);
|
||||
|
||||
QVector<Node *> SelectedItems() const;
|
||||
QVector<Node *> selected_items() const;
|
||||
|
||||
/**
|
||||
* @brief Use a heuristic to determine which (if any) folder is selected
|
||||
@@ -73,29 +73,29 @@ public:
|
||||
* A folder that's heuristically been determined as "selected", or the root directory if none, or nullptr if no
|
||||
* project is open.
|
||||
*/
|
||||
Folder *GetSelectedFolder() const;
|
||||
Folder *get_selected_folder() const;
|
||||
|
||||
/**
|
||||
* @brief Access the ViewModel model of the project
|
||||
*/
|
||||
ProjectViewModel *model();
|
||||
|
||||
void SelectAll();
|
||||
void select_all();
|
||||
|
||||
void DeselectAll();
|
||||
void deselect_all();
|
||||
|
||||
void DeleteSelected();
|
||||
void delete_selected();
|
||||
|
||||
bool SelectItem(Node *n, bool deselect_all_first = true);
|
||||
bool select_item(Node *n, bool deselect_all_first = true);
|
||||
|
||||
public slots:
|
||||
void set_view_type(ProjectToolbar::ViewType type);
|
||||
|
||||
void Edit(Node *item);
|
||||
void edit(Node *item);
|
||||
|
||||
void RenameSelectedItem();
|
||||
void rename_selected_item();
|
||||
|
||||
void SetSearchFilter(const QString &s);
|
||||
void set_search_filter(const QString &s);
|
||||
|
||||
signals:
|
||||
/**
|
||||
@@ -105,9 +105,9 @@ signals:
|
||||
*
|
||||
* The Item that was double clicked, or nullptr if empty area was double clicked
|
||||
*/
|
||||
void DoubleClickedItem(Node *item);
|
||||
void double_clicked_item(Node *item);
|
||||
|
||||
void SelectionChanged(const QVector<Node *> &selected);
|
||||
void selection_changed(const QVector<Node *> &selected);
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
*
|
||||
* Ignores blocks that depend on multiple inputs
|
||||
*/
|
||||
QList<Block *> GetFootageBlocks(QList<Node *> nodes);
|
||||
QList<Block *> get_footage_blocks(QList<Node *> nodes);
|
||||
|
||||
/**
|
||||
* @brief Simple convenience function for adding a view to this stacked widget
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
*
|
||||
* View to add to the stack
|
||||
*/
|
||||
void AddView(QAbstractItemView *view);
|
||||
void add_view(QAbstractItemView *view);
|
||||
|
||||
/**
|
||||
* @brief Browse to a specific folder index in the model
|
||||
@@ -137,22 +137,22 @@ private:
|
||||
*
|
||||
* Either an invalid index to return to the project root, or an index to a valid Folder object.
|
||||
*/
|
||||
void BrowseToFolder(const QModelIndex &index);
|
||||
void browse_to_folder(const QModelIndex &index);
|
||||
|
||||
int ConfirmItemDeletion(Node *item);
|
||||
int confirm_item_deletion(Node *item);
|
||||
|
||||
bool DeleteItemsInternal(const QVector<Node *> &selected,
|
||||
bool delete_items_internal(const QVector<Node *> &selected,
|
||||
bool &check_if_item_is_in_use,
|
||||
MultiUndoCommand *command);
|
||||
|
||||
static QString GetHumanReadableNodeName(Node *node);
|
||||
static QString get_human_readable_node_name(Node *node);
|
||||
|
||||
void UpdateNavBarText();
|
||||
void update_nav_bar_text();
|
||||
|
||||
/**
|
||||
* @brief Get the currently active QAbstractItemView
|
||||
*/
|
||||
QAbstractItemView *CurrentView() const;
|
||||
QAbstractItemView *current_view() const;
|
||||
|
||||
QStackedWidget *stacked_widget_;
|
||||
|
||||
@@ -170,39 +170,39 @@ private:
|
||||
QVector<Node *> context_menu_items_;
|
||||
|
||||
private slots:
|
||||
void ViewEmptyAreaDoubleClickedSlot();
|
||||
void view_empty_area_double_clicked_slot();
|
||||
|
||||
void ItemDoubleClickedSlot(const QModelIndex &index);
|
||||
void item_double_clicked_slot(const QModelIndex &index);
|
||||
|
||||
void SizeChangedSlot(int s);
|
||||
void size_changed_slot(int s);
|
||||
|
||||
void DirUpSlot();
|
||||
void dir_up_slot();
|
||||
|
||||
void ShowContextMenu();
|
||||
void show_context_menu();
|
||||
|
||||
void ShowItemPropertiesDialog();
|
||||
void show_item_properties_dialog();
|
||||
|
||||
void RevealSelectedFootage();
|
||||
void reveal_selected_footage();
|
||||
|
||||
void ReplaceSelectedFootage();
|
||||
void replace_selected_footage();
|
||||
|
||||
void OpenContextMenuItemInNewTab();
|
||||
void open_context_menu_item_in_new_tab();
|
||||
|
||||
void OpenContextMenuItemInNewWindow();
|
||||
void open_context_menu_item_in_new_window();
|
||||
|
||||
void GenerateProxiesForSelectedFootage();
|
||||
void generate_proxies_for_selected_footage();
|
||||
|
||||
void SetSelectedFootageProxyEnabled(bool enabled);
|
||||
void set_selected_footage_proxy_enabled(bool enabled);
|
||||
|
||||
void RevealProxyForSelectedFootage();
|
||||
void reveal_proxy_for_selected_footage();
|
||||
|
||||
void DeleteProxiesForSelectedFootage();
|
||||
void delete_proxies_for_selected_footage();
|
||||
|
||||
void ShowProxyDialogForSelectedFootage();
|
||||
void show_proxy_dialog_for_selected_footage();
|
||||
|
||||
void ViewSelectionChanged();
|
||||
void view_selection_changed();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORER_H
|
||||
#endif // OAK_PROJECTEXPLORER_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERICONVIEW_H
|
||||
#define PROJECTEXPLORERICONVIEW_H
|
||||
#ifndef OAK_PROJECTEXPLORERICONVIEW_H
|
||||
#define OAK_PROJECTEXPLORERICONVIEW_H
|
||||
|
||||
#include "projectexplorerlistviewbase.h"
|
||||
#include "projectexplorericonviewitemdelegate.h"
|
||||
@@ -42,4 +42,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORERICONVIEW_H
|
||||
#endif // OAK_PROJECTEXPLORERICONVIEW_H
|
||||
|
||||
@@ -72,7 +72,7 @@ void ProjectExplorerIconViewItemDelegate::paint(
|
||||
|
||||
QString duration_str = index.data(Qt::UserRole).toString();
|
||||
|
||||
int timecode_width = QtUtils::QFontMetricsWidth(fm, duration_str);
|
||||
int timecode_width = QtUtils::q_font_metrics_width(fm, duration_str);
|
||||
|
||||
int max_name_width = option.rect.width();
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERICONVIEWITEMDELEGATE_H
|
||||
#define PROJECTEXPLORERICONVIEWITEMDELEGATE_H
|
||||
#ifndef OAK_PROJECTEXPLORERICONVIEWITEMDELEGATE_H
|
||||
#define OAK_PROJECTEXPLORERICONVIEWITEMDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
@@ -44,4 +44,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORERICONVIEWITEMDELEGATE_H
|
||||
#endif // OAK_PROJECTEXPLORERICONVIEWITEMDELEGATE_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERLISTVIEW_H
|
||||
#define PROJECTEXPLORERLISTVIEW_H
|
||||
#ifndef OAK_PROJECTEXPLORERLISTVIEW_H
|
||||
#define OAK_PROJECTEXPLORERLISTVIEW_H
|
||||
|
||||
#include "projectexplorerlistviewbase.h"
|
||||
#include "projectexplorerlistviewitemdelegate.h"
|
||||
@@ -42,4 +42,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORERLISTVIEW_H
|
||||
#endif // OAK_PROJECTEXPLORERLISTVIEW_H
|
||||
|
||||
@@ -52,7 +52,7 @@ void ProjectExplorerListViewBase::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
// QAbstractItemView already has a doubleClicked() signal, but we emit another here for double clicking empty space
|
||||
if (!item_at_location) {
|
||||
emit DoubleClickedEmptyArea();
|
||||
emit double_clicked_empty_area();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERLISTVIEWBASE_H
|
||||
#define PROJECTEXPLORERLISTVIEWBASE_H
|
||||
#ifndef OAK_PROJECTEXPLORERLISTVIEWBASE_H
|
||||
#define OAK_PROJECTEXPLORERLISTVIEWBASE_H
|
||||
|
||||
#include <QListView>
|
||||
|
||||
@@ -55,9 +55,9 @@ signals:
|
||||
*
|
||||
* Emits a signal when the view is double clicked but not on any particular item
|
||||
*/
|
||||
void DoubleClickedEmptyArea();
|
||||
void double_clicked_empty_area();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORERLISTVIEWBASE_H
|
||||
#endif // OAK_PROJECTEXPLORERLISTVIEWBASE_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
|
||||
#define PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
|
||||
#ifndef OAK_PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
|
||||
#define OAK_PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
@@ -44,4 +44,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
|
||||
#endif // OAK_PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
|
||||
|
||||
@@ -43,7 +43,7 @@ ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent)
|
||||
dir_up_btn_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
layout->addWidget(dir_up_btn_);
|
||||
connect(dir_up_btn_, SIGNAL(clicked(bool)), this,
|
||||
SIGNAL(DirectoryUpClicked()));
|
||||
SIGNAL(directory_up_clicked()));
|
||||
|
||||
// Create directory tree label
|
||||
dir_lbl_ = new QLabel(this);
|
||||
@@ -56,10 +56,10 @@ ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent)
|
||||
size_slider_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
layout->addWidget(size_slider_);
|
||||
connect(size_slider_, SIGNAL(valueChanged(int)), this,
|
||||
SIGNAL(SizeChanged(int)));
|
||||
SIGNAL(size_changed(int)));
|
||||
|
||||
Retranslate();
|
||||
UpdateIcons();
|
||||
retranslate();
|
||||
update_icons();
|
||||
}
|
||||
|
||||
void ProjectExplorerNavigation::set_text(const QString &s)
|
||||
@@ -80,24 +80,24 @@ void ProjectExplorerNavigation::set_size_value(int s)
|
||||
void ProjectExplorerNavigation::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
retranslate();
|
||||
} else if (e->type() == QEvent::StyleChange) {
|
||||
UpdateIcons();
|
||||
update_icons();
|
||||
}
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
void ProjectExplorerNavigation::Retranslate()
|
||||
void ProjectExplorerNavigation::retranslate()
|
||||
{
|
||||
dir_up_btn_->setToolTip(tr("Go to parent folder"));
|
||||
}
|
||||
|
||||
void ProjectExplorerNavigation::UpdateIcons()
|
||||
void ProjectExplorerNavigation::update_icons()
|
||||
{
|
||||
dir_up_btn_->setIcon(icon::DirUp);
|
||||
size_slider_->setMinimum(kProjectIconSizeMinimum);
|
||||
size_slider_->setMaximum(kProjectIconSizeMaximum);
|
||||
size_slider_->setValue(kProjectIconSizeDefault);
|
||||
dir_up_btn_->setIcon(icon::dir_up);
|
||||
size_slider_->setMinimum(k_project_icon_size_minimum);
|
||||
size_slider_->setMaximum(k_project_icon_size_maximum);
|
||||
size_slider_->setValue(k_project_icon_size_default);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERLISTVIEWTOOLBAR_H
|
||||
#define PROJECTEXPLORERLISTVIEWTOOLBAR_H
|
||||
#ifndef OAK_PROJECTEXPLORERLISTVIEWTOOLBAR_H
|
||||
#define OAK_PROJECTEXPLORERLISTVIEWTOOLBAR_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
@@ -87,7 +87,7 @@ signals:
|
||||
/**
|
||||
* @brief Signal emitted when the directory up button is clicked
|
||||
*/
|
||||
void DirectoryUpClicked();
|
||||
void directory_up_clicked();
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when the icon size slider changes value
|
||||
@@ -96,15 +96,15 @@ signals:
|
||||
*
|
||||
* New size set in the slider
|
||||
*/
|
||||
void SizeChanged(int size);
|
||||
void size_changed(int size);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *) override;
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
void retranslate();
|
||||
|
||||
void UpdateIcons();
|
||||
void update_icons();
|
||||
|
||||
QPushButton *dir_up_btn_;
|
||||
|
||||
@@ -115,4 +115,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORERLISTVIEWTOOLBAR_H
|
||||
#endif // OAK_PROJECTEXPLORERLISTVIEWTOOLBAR_H
|
||||
|
||||
@@ -52,7 +52,7 @@ void ProjectExplorerTreeView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
// QAbstractItemView already has a doubleClicked() signal, but we emit another here for double clicking empty space
|
||||
if (!indexAt(event->pos()).isValid()) {
|
||||
emit DoubleClickedEmptyArea();
|
||||
emit double_clicked_empty_area();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERTREEVIEW_H
|
||||
#define PROJECTEXPLORERTREEVIEW_H
|
||||
#ifndef OAK_PROJECTEXPLORERTREEVIEW_H
|
||||
#define OAK_PROJECTEXPLORERTREEVIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
@@ -57,9 +57,9 @@ signals:
|
||||
*
|
||||
* Emits a signal when the view is double clicked but not on any particular item
|
||||
*/
|
||||
void DoubleClickedEmptyArea();
|
||||
void double_clicked_empty_area();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORERTREEVIEW_H
|
||||
#endif // OAK_PROJECTEXPLORERTREEVIEW_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PROJECTEXPLORERUNDO_H
|
||||
#define PROJECTEXPLORERUNDO_H
|
||||
#ifndef OAK_PROJECTEXPLORERUNDO_H
|
||||
#define OAK_PROJECTEXPLORERUNDO_H
|
||||
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
@@ -29,4 +29,4 @@ namespace olive
|
||||
|
||||
}
|
||||
|
||||
#endif // PROJECTEXPLORERUNDO_H
|
||||
#endif // OAK_PROJECTEXPLORERUNDO_H
|
||||
|
||||
@@ -48,13 +48,13 @@ void ProjectViewModel::set_project(Project *p)
|
||||
beginResetModel();
|
||||
|
||||
if (project_) {
|
||||
DisconnectItem(project_->root());
|
||||
disconnect_item(project_->root());
|
||||
}
|
||||
|
||||
project_ = p;
|
||||
|
||||
if (project_) {
|
||||
ConnectItem(project_->root());
|
||||
connect_item(project_->root());
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
@@ -69,7 +69,7 @@ QModelIndex ProjectViewModel::index(int row, int column,
|
||||
}
|
||||
|
||||
// Get the parent object, we assume it's a folder since only folders can have children
|
||||
Folder *item_parent = static_cast<Folder *>(GetItemObjectFromIndex(parent));
|
||||
Folder *item_parent = static_cast<Folder *>(get_item_object_from_index(parent));
|
||||
|
||||
// Return an index to this object
|
||||
return createIndex(row, column, item_parent->item_child(row));
|
||||
@@ -78,7 +78,7 @@ QModelIndex ProjectViewModel::index(int row, int column,
|
||||
QModelIndex ProjectViewModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
// Get the Item object from the index
|
||||
Node *item = GetItemObjectFromIndex(child);
|
||||
Node *item = get_item_object_from_index(child);
|
||||
|
||||
// Get Item's parent object
|
||||
Folder *par = item->folder();
|
||||
@@ -89,7 +89,7 @@ QModelIndex ProjectViewModel::parent(const QModelIndex &child) const
|
||||
}
|
||||
|
||||
// Otherwise return a true index to its parent
|
||||
int parent_index = IndexOfChild(par);
|
||||
int parent_index = index_of_child(par);
|
||||
|
||||
// Make sure the index is valid (there's no reason it shouldn't be)
|
||||
Q_ASSERT(parent_index > -1);
|
||||
@@ -111,7 +111,7 @@ int ProjectViewModel::rowCount(const QModelIndex &parent) const
|
||||
}
|
||||
|
||||
// Otherwise, the index must contain a valid pointer, so we just return its child count
|
||||
return static_cast<Folder *>(GetItemObjectFromIndex(parent))
|
||||
return static_cast<Folder *>(get_item_object_from_index(parent))
|
||||
->item_child_count();
|
||||
}
|
||||
|
||||
@@ -124,33 +124,33 @@ int ProjectViewModel::columnCount(const QModelIndex &parent) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
return kColumnCount;
|
||||
return k_column_count;
|
||||
}
|
||||
|
||||
QVariant ProjectViewModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
Node *internal_item = GetItemObjectFromIndex(index);
|
||||
Node *internal_item = get_item_object_from_index(index);
|
||||
|
||||
ColumnType column_type = static_cast<ColumnType>(index.column());
|
||||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
case kInnerTextRole: {
|
||||
case k_inner_text_role: {
|
||||
// Standard text role
|
||||
|
||||
switch (column_type) {
|
||||
case kName:
|
||||
return internal_item->GetLabel();
|
||||
case kDuration:
|
||||
return internal_item->data(Node::DURATION);
|
||||
case kRate:
|
||||
return internal_item->data(Node::FREQUENCY_RATE);
|
||||
case kLastModified:
|
||||
case kCreatedTime: {
|
||||
case k_name:
|
||||
return internal_item->get_label();
|
||||
case k_duration:
|
||||
return internal_item->data(Node::duration);
|
||||
case k_rate:
|
||||
return internal_item->data(Node::frequency_rate);
|
||||
case k_last_modified:
|
||||
case k_created_time: {
|
||||
qint64 using_time =
|
||||
(column_type == kLastModified) ?
|
||||
internal_item->data(Node::MODIFIED_TIME).toLongLong() :
|
||||
internal_item->data(Node::CREATED_TIME).toLongLong();
|
||||
(column_type == k_last_modified) ?
|
||||
internal_item->data(Node::modified_time).toLongLong() :
|
||||
internal_item->data(Node::created_time).toLongLong();
|
||||
|
||||
if (using_time == 0) {
|
||||
// 0 is the null value, return nothing
|
||||
@@ -159,34 +159,34 @@ QVariant ProjectViewModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
QVariant ret;
|
||||
|
||||
if (role == kInnerTextRole) {
|
||||
if (role == k_inner_text_role) {
|
||||
// Use time value directly for correct sorting
|
||||
ret = using_time;
|
||||
} else {
|
||||
// Display role, format to a human readable string
|
||||
ret = QtUtils::GetFormattedDateTime(
|
||||
ret = QtUtils::get_formatted_date_time(
|
||||
QDateTime::fromSecsSinceEpoch(using_time));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
case kColumnCount:
|
||||
case k_column_count:
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
case Qt::EditRole:
|
||||
if (column_type == kName) {
|
||||
return internal_item->GetLabel();
|
||||
if (column_type == k_name) {
|
||||
return internal_item->get_label();
|
||||
}
|
||||
break;
|
||||
case Qt::DecorationRole:
|
||||
// If this is the first column, return the Item's icon
|
||||
if (column_type == kName) {
|
||||
return internal_item->data(Node::ICON);
|
||||
if (column_type == k_name) {
|
||||
return internal_item->data(Node::icon);
|
||||
}
|
||||
break;
|
||||
case Qt::ToolTipRole:
|
||||
return internal_item->data(Node::TOOLTIP);
|
||||
return internal_item->data(Node::tooltip);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
@@ -202,17 +202,17 @@ QVariant ProjectViewModel::headerData(int section, Qt::Orientation orientation,
|
||||
|
||||
// Return the name based on the column's current type
|
||||
switch (column_type) {
|
||||
case kName:
|
||||
case k_name:
|
||||
return tr("Name");
|
||||
case kDuration:
|
||||
case k_duration:
|
||||
return tr("Duration");
|
||||
case kRate:
|
||||
case k_rate:
|
||||
return tr("Rate");
|
||||
case kLastModified:
|
||||
case k_last_modified:
|
||||
return tr("Modified");
|
||||
case kCreatedTime:
|
||||
case k_created_time:
|
||||
return tr("Created");
|
||||
case kColumnCount:
|
||||
case k_column_count:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -224,7 +224,7 @@ bool ProjectViewModel::hasChildren(const QModelIndex &parent) const
|
||||
{
|
||||
// If it's a folder, we always return TRUE in order to always show the "expand triangle" icon,
|
||||
// even when there are no "physical" children
|
||||
Node *item = GetItemObjectFromIndex(parent);
|
||||
Node *item = get_item_object_from_index(parent);
|
||||
|
||||
return dynamic_cast<Folder *>(item);
|
||||
}
|
||||
@@ -233,19 +233,19 @@ bool ProjectViewModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
int role)
|
||||
{
|
||||
// The name is editable
|
||||
if (index.isValid() && index.column() == kName && role == Qt::EditRole) {
|
||||
Node *item = GetItemObjectFromIndex(index);
|
||||
if (index.isValid() && index.column() == k_name && role == Qt::EditRole) {
|
||||
Node *item = get_item_object_from_index(index);
|
||||
|
||||
QString new_name = value.toString();
|
||||
|
||||
if (!new_name.isEmpty()) {
|
||||
NodeRenameCommand *nrc = new NodeRenameCommand();
|
||||
|
||||
nrc->AddNode(item, value.toString());
|
||||
nrc->add_node(item, value.toString());
|
||||
|
||||
Core::instance()->undo_stack()->push(
|
||||
nrc, tr("Renamed Item \"%1\" to \"%2\"")
|
||||
.arg(item->GetLabel(), new_name));
|
||||
.arg(item->get_label(), new_name));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -269,12 +269,12 @@ Qt::ItemFlags ProjectViewModel::flags(const QModelIndex &index) const
|
||||
|
||||
Qt::ItemFlags f = Qt::ItemIsDragEnabled | QAbstractItemModel::flags(index);
|
||||
|
||||
if (dynamic_cast<Folder *>(GetItemObjectFromIndex(index))) {
|
||||
if (dynamic_cast<Folder *>(get_item_object_from_index(index))) {
|
||||
f |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
// If the column is the kName column, that means it's editable
|
||||
if (index.column() == kName) {
|
||||
if (index.column() == k_name) {
|
||||
f |= Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ Qt::ItemFlags ProjectViewModel::flags(const QModelIndex &index) const
|
||||
QStringList ProjectViewModel::mimeTypes() const
|
||||
{
|
||||
// Allow data from this model and a file list from external sources
|
||||
return { Project::kItemMimeType, QStringLiteral("text/uri-list") };
|
||||
return { Project::k_item_mime_type, QStringLiteral("text/uri-list") };
|
||||
}
|
||||
|
||||
QMimeData *ProjectViewModel::mimeData(const QModelIndexList &indexes) const
|
||||
@@ -315,7 +315,7 @@ QMimeData *ProjectViewModel::mimeData(const QModelIndexList &indexes) const
|
||||
|
||||
if (ViewerOutput *footage =
|
||||
dynamic_cast<ViewerOutput *>(item)) {
|
||||
streams = footage->GetEnabledStreamsAsReferences();
|
||||
streams = footage->get_enabled_streams_as_references();
|
||||
}
|
||||
|
||||
stream << streams << reinterpret_cast<quintptr>(item);
|
||||
@@ -326,7 +326,7 @@ QMimeData *ProjectViewModel::mimeData(const QModelIndexList &indexes) const
|
||||
}
|
||||
|
||||
// Set byte array as the mime data and return the mime data
|
||||
data->setData(Project::kItemMimeType, encoded_data);
|
||||
data->setData(Project::k_item_mime_type, encoded_data);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -347,16 +347,16 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data,
|
||||
// Probe mime data for its format
|
||||
QStringList mime_formats = data->formats();
|
||||
|
||||
if (mime_formats.contains(Project::kItemMimeType)) {
|
||||
if (mime_formats.contains(Project::k_item_mime_type)) {
|
||||
// Data is drag/drop data from this model
|
||||
QByteArray model_data = data->data(Project::kItemMimeType);
|
||||
QByteArray model_data = data->data(Project::k_item_mime_type);
|
||||
|
||||
// Use QDataStream to deserialize the data
|
||||
QDataStream stream(&model_data, QIODevice::ReadOnly);
|
||||
|
||||
// Get the Item object that the items were dropped on
|
||||
Folder *drop_location =
|
||||
dynamic_cast<Folder *>(GetItemObjectFromIndex(drop));
|
||||
dynamic_cast<Folder *>(get_item_object_from_index(drop));
|
||||
|
||||
// If this is not a folder, we cannot drop these items here
|
||||
if (!drop_location) {
|
||||
@@ -382,11 +382,11 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data,
|
||||
|
||||
if (item != drop_location && item->folder() != drop_location &&
|
||||
(!dynamic_cast<Folder *>(item) ||
|
||||
!ItemIsParentOfChild(static_cast<Folder *>(item),
|
||||
!item_is_parent_of_child(static_cast<Folder *>(item),
|
||||
drop_location))) {
|
||||
move_command->add_child(new NodeEdgeRemoveCommand(
|
||||
item,
|
||||
NodeInput(item->folder(), Folder::kChildInput,
|
||||
NodeInput(item->folder(), Folder::k_child_input,
|
||||
item->folder()->index_of_child_in_array(item))));
|
||||
move_command->add_child(
|
||||
new FolderAddChild(drop_location, item));
|
||||
@@ -417,7 +417,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data,
|
||||
}
|
||||
|
||||
// Get folder dropped onto
|
||||
Node *drop_item = GetItemObjectFromIndex(drop);
|
||||
Node *drop_item = get_item_object_from_index(drop);
|
||||
|
||||
// If we didn't drop onto an item, find the nearest parent folder (should eventually terminate at root either way)
|
||||
if (!dynamic_cast<Folder *>(drop_item)) {
|
||||
@@ -430,7 +430,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data,
|
||||
}
|
||||
|
||||
// Trigger an import
|
||||
Core::instance()->ImportFiles(urls, static_cast<Folder *>(drop_item));
|
||||
Core::instance()->import_files(urls, static_cast<Folder *>(drop_item));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -438,7 +438,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data,
|
||||
return false;
|
||||
}
|
||||
|
||||
int ProjectViewModel::IndexOfChild(Node *item) const
|
||||
int ProjectViewModel::index_of_child(Node *item) const
|
||||
{
|
||||
// Find parent's index within its own parent
|
||||
Folder *parent = item->folder();
|
||||
@@ -450,7 +450,7 @@ int ProjectViewModel::IndexOfChild(Node *item) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
Node *ProjectViewModel::GetItemObjectFromIndex(const QModelIndex &index) const
|
||||
Node *ProjectViewModel::get_item_object_from_index(const QModelIndex &index) const
|
||||
{
|
||||
if (index.isValid()) {
|
||||
return static_cast<Node *>(index.internalPointer());
|
||||
@@ -459,7 +459,7 @@ Node *ProjectViewModel::GetItemObjectFromIndex(const QModelIndex &index) const
|
||||
return project_ ? project_->root() : nullptr;
|
||||
}
|
||||
|
||||
bool ProjectViewModel::ItemIsParentOfChild(Folder *parent, Node *child) const
|
||||
bool ProjectViewModel::item_is_parent_of_child(Folder *parent, Node *child) const
|
||||
{
|
||||
// Loop through parent hierarchy checking if `parent` is one of its parents
|
||||
do {
|
||||
@@ -473,100 +473,100 @@ bool ProjectViewModel::ItemIsParentOfChild(Folder *parent, Node *child) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void ProjectViewModel::ConnectItem(Node *n)
|
||||
void ProjectViewModel::connect_item(Node *n)
|
||||
{
|
||||
connect(n, &Node::LabelChanged, this, &ProjectViewModel::ItemRenamed);
|
||||
connect(n, &Node::label_changed, this, &ProjectViewModel::item_renamed);
|
||||
|
||||
Folder *f = dynamic_cast<Folder *>(n);
|
||||
if (f) {
|
||||
connect(f, &Folder::BeginInsertItem, this,
|
||||
&ProjectViewModel::FolderBeginInsertItem);
|
||||
connect(f, &Folder::EndInsertItem, this,
|
||||
&ProjectViewModel::FolderEndInsertItem);
|
||||
connect(f, &Folder::BeginRemoveItem, this,
|
||||
&ProjectViewModel::FolderBeginRemoveItem);
|
||||
connect(f, &Folder::EndRemoveItem, this,
|
||||
&ProjectViewModel::FolderEndRemoveItem);
|
||||
connect(f, &Folder::begin_insert_item, this,
|
||||
&ProjectViewModel::folder_begin_insert_item);
|
||||
connect(f, &Folder::end_insert_item, this,
|
||||
&ProjectViewModel::folder_end_insert_item);
|
||||
connect(f, &Folder::begin_remove_item, this,
|
||||
&ProjectViewModel::folder_begin_remove_item);
|
||||
connect(f, &Folder::end_remove_item, this,
|
||||
&ProjectViewModel::folder_end_remove_item);
|
||||
|
||||
foreach (Node *c, f->children()) {
|
||||
ConnectItem(c);
|
||||
connect_item(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectViewModel::DisconnectItem(Node *n)
|
||||
void ProjectViewModel::disconnect_item(Node *n)
|
||||
{
|
||||
disconnect(n, &Node::LabelChanged, this, &ProjectViewModel::ItemRenamed);
|
||||
disconnect(n, &Node::label_changed, this, &ProjectViewModel::item_renamed);
|
||||
|
||||
Folder *f = dynamic_cast<Folder *>(n);
|
||||
if (f) {
|
||||
disconnect(f, &Folder::BeginInsertItem, this,
|
||||
&ProjectViewModel::FolderBeginInsertItem);
|
||||
disconnect(f, &Folder::EndInsertItem, this,
|
||||
&ProjectViewModel::FolderEndInsertItem);
|
||||
disconnect(f, &Folder::BeginRemoveItem, this,
|
||||
&ProjectViewModel::FolderBeginRemoveItem);
|
||||
disconnect(f, &Folder::EndRemoveItem, this,
|
||||
&ProjectViewModel::FolderEndRemoveItem);
|
||||
disconnect(f, &Folder::begin_insert_item, this,
|
||||
&ProjectViewModel::folder_begin_insert_item);
|
||||
disconnect(f, &Folder::end_insert_item, this,
|
||||
&ProjectViewModel::folder_end_insert_item);
|
||||
disconnect(f, &Folder::begin_remove_item, this,
|
||||
&ProjectViewModel::folder_begin_remove_item);
|
||||
disconnect(f, &Folder::end_remove_item, this,
|
||||
&ProjectViewModel::folder_end_remove_item);
|
||||
|
||||
foreach (Node *c, f->children()) {
|
||||
DisconnectItem(c);
|
||||
disconnect_item(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectViewModel::FolderBeginInsertItem(Node *n, int insert_index)
|
||||
void ProjectViewModel::folder_begin_insert_item(Node *n, int insert_index)
|
||||
{
|
||||
Folder *folder = static_cast<Folder *>(sender());
|
||||
|
||||
ConnectItem(n);
|
||||
connect_item(n);
|
||||
|
||||
QModelIndex index;
|
||||
|
||||
if (folder != project_->root()) {
|
||||
index = CreateIndexFromItem(folder);
|
||||
index = create_index_from_item(folder);
|
||||
}
|
||||
|
||||
beginInsertRows(index, insert_index, insert_index);
|
||||
}
|
||||
|
||||
void ProjectViewModel::FolderEndInsertItem()
|
||||
void ProjectViewModel::folder_end_insert_item()
|
||||
{
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void ProjectViewModel::FolderBeginRemoveItem(Node *n, int child_index)
|
||||
void ProjectViewModel::folder_begin_remove_item(Node *n, int child_index)
|
||||
{
|
||||
Folder *folder = static_cast<Folder *>(sender());
|
||||
|
||||
DisconnectItem(n);
|
||||
disconnect_item(n);
|
||||
|
||||
QModelIndex index;
|
||||
|
||||
if (folder != project_->root()) {
|
||||
index = CreateIndexFromItem(folder);
|
||||
index = create_index_from_item(folder);
|
||||
}
|
||||
|
||||
beginRemoveRows(index, child_index, child_index);
|
||||
}
|
||||
|
||||
void ProjectViewModel::FolderEndRemoveItem()
|
||||
void ProjectViewModel::folder_end_remove_item()
|
||||
{
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
void ProjectViewModel::ItemRenamed()
|
||||
void ProjectViewModel::item_renamed()
|
||||
{
|
||||
Node *item = static_cast<Node *>(sender());
|
||||
|
||||
QModelIndex index = CreateIndexFromItem(item);
|
||||
QModelIndex index = create_index_from_item(item);
|
||||
|
||||
emit dataChanged(index, index, { Qt::DisplayRole, Qt::EditRole });
|
||||
}
|
||||
|
||||
QModelIndex ProjectViewModel::CreateIndexFromItem(Node *item, int column)
|
||||
QModelIndex ProjectViewModel::create_index_from_item(Node *item, int column)
|
||||
{
|
||||
return createIndex(IndexOfChild(item), column, item);
|
||||
return createIndex(index_of_child(item), column, item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef VIEWMODEL_H
|
||||
#define VIEWMODEL_H
|
||||
#ifndef OAK_VIEWMODEL_H
|
||||
#define OAK_VIEWMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
@@ -44,25 +44,25 @@ class ProjectViewModel : public QAbstractItemModel {
|
||||
public:
|
||||
enum ColumnType {
|
||||
/// Media name
|
||||
kName,
|
||||
k_name,
|
||||
|
||||
/// Media duration
|
||||
kDuration,
|
||||
k_duration,
|
||||
|
||||
/// Media rate (frame rate for video, sample rate for audio)
|
||||
kRate,
|
||||
k_rate,
|
||||
|
||||
/// Last modified time (for footage/files)
|
||||
kLastModified,
|
||||
k_last_modified,
|
||||
|
||||
/// Creation time (for footage/files)
|
||||
kCreatedTime,
|
||||
k_created_time,
|
||||
|
||||
/// Count
|
||||
kColumnCount
|
||||
k_column_count
|
||||
};
|
||||
|
||||
static const int kInnerTextRole = Qt::UserRole + 1;
|
||||
static const int k_inner_text_role = Qt::UserRole + 1;
|
||||
|
||||
/**
|
||||
* @brief ProjectViewModel Constructor
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
/**
|
||||
* @brief Convenience function for creating QModelIndexes from an Item object
|
||||
*/
|
||||
QModelIndex CreateIndexFromItem(Node *item, int column = 0);
|
||||
QModelIndex create_index_from_item(Node *item, int column = 0);
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -137,40 +137,40 @@ private:
|
||||
*
|
||||
* Index of the specified item, or -1 if the item is root (in which case it has no parent).
|
||||
*/
|
||||
int IndexOfChild(Node *item) const;
|
||||
int index_of_child(Node *item) const;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the Item object from a given index
|
||||
*
|
||||
* A convenience function for retrieving Item objects. If the index is not valid, this returns the root Item.
|
||||
*/
|
||||
Node *GetItemObjectFromIndex(const QModelIndex &index) const;
|
||||
Node *get_item_object_from_index(const QModelIndex &index) const;
|
||||
|
||||
/**
|
||||
* @brief Check if an Item is a parent of a Child
|
||||
*
|
||||
* Checks entire "parent hierarchy" of `child` to see if `parent` is one of its parents.
|
||||
*/
|
||||
bool ItemIsParentOfChild(Folder *parent, Node *child) const;
|
||||
bool item_is_parent_of_child(Folder *parent, Node *child) const;
|
||||
|
||||
void ConnectItem(Node *n);
|
||||
void connect_item(Node *n);
|
||||
|
||||
void DisconnectItem(Node *n);
|
||||
void disconnect_item(Node *n);
|
||||
|
||||
Project *project_;
|
||||
|
||||
private slots:
|
||||
void FolderBeginInsertItem(Node *n, int insert_index);
|
||||
void folder_begin_insert_item(Node *n, int insert_index);
|
||||
|
||||
void FolderEndInsertItem();
|
||||
void folder_end_insert_item();
|
||||
|
||||
void FolderBeginRemoveItem(Node *n, int child_index);
|
||||
void folder_begin_remove_item(Node *n, int child_index);
|
||||
|
||||
void FolderEndRemoveItem();
|
||||
void folder_end_remove_item();
|
||||
|
||||
void ItemRenamed();
|
||||
void item_renamed();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // VIEWMODEL_H
|
||||
#endif // OAK_VIEWMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user