changed mainwindow from ui to code

This commit is contained in:
itsmattkc
2018-12-30 14:59:01 +11:00
parent 5e81565ec5
commit 6130db2713
15 changed files with 3249 additions and 4110 deletions
+16 -17
View File
@@ -19,9 +19,8 @@
#include <QMessageBox>
#include <QCheckBox>
ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, SourceTable *table, Media *old_media) :
ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, Media *old_media) :
QDialog(parent),
source_table(table),
media(old_media)
{
resize(300, 400);
@@ -30,11 +29,11 @@ ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, SourceTable *tab
layout->addWidget(new QLabel("Select which media you want to replace this media's clips with:"));
tree = new QTreeView();
tree = new QTreeView();
layout->addWidget(tree);
use_same_media_in_points = new QCheckBox("Keep the same media in-points");
use_same_media_in_points = new QCheckBox("Keep the same media in-points");
use_same_media_in_points->setChecked(true);
layout->addWidget(use_same_media_in_points);
@@ -56,34 +55,34 @@ ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, SourceTable *tab
setLayout(layout);
tree->setModel(&project_model);
tree->setModel(&project_model);
//copy_tree(NULL, NULL);
//copy_tree(NULL, NULL);
}
void ReplaceClipMediaDialog::replace() {
QModelIndexList selected_items = tree->selectionModel()->selectedRows();
if (selected_items.size() != 1) {
QModelIndexList selected_items = panel_project->get_current_selected();
if (selected_items.size() != 1) {
QMessageBox::critical(this, "No media selected", "Please select a media to replace with or click 'Cancel'.", QMessageBox::Ok);
} else {
Media* new_item = static_cast<Media*>(selected_items.at(0).internalPointer());
Media* new_item = static_cast<Media*>(selected_items.at(0).internalPointer());
if (media == new_item) {
QMessageBox::critical(this, "Same media selected", "You selected the same media that you're replacing. Please select a different one or click 'Cancel'.", QMessageBox::Ok);
} else if (new_item->get_type() == MEDIA_TYPE_FOLDER) {
} else if (new_item->get_type() == MEDIA_TYPE_FOLDER) {
QMessageBox::critical(this, "Folder selected", "You cannot replace footage with a folder.", QMessageBox::Ok);
} else {
if (new_item->get_type() == MEDIA_TYPE_SEQUENCE && sequence == new_item->to_sequence()) {
if (new_item->get_type() == MEDIA_TYPE_SEQUENCE && sequence == new_item->to_sequence()) {
QMessageBox::critical(this, "Active sequence selected", "You cannot insert a sequence into itself.", QMessageBox::Ok);
} else {
} else {
ReplaceClipMediaCommand* rcmc = new ReplaceClipMediaCommand(
media,
new_item,
media,
new_item,
use_same_media_in_points->isChecked()
);
for (int i=0;i<sequence->clips.size();i++) {
Clip* c = sequence->clips.at(i);
if (c != NULL && c->media == media) {
for (int i=0;i<sequence->clips.size();i++) {
Clip* c = sequence->clips.at(i);
if (c != NULL && c->media == media) {
rcmc->clips.append(c);
}
}
+4 -5
View File
@@ -11,14 +11,13 @@ class QCheckBox;
class ReplaceClipMediaDialog : public QDialog {
Q_OBJECT
public:
ReplaceClipMediaDialog(QWidget* parent, SourceTable* table, Media *old_media);
ReplaceClipMediaDialog(QWidget* parent, Media *old_media);
private slots:
void replace();
private:
SourceTable* source_table;
QTreeView* tree;
Media* media;
QCheckBox* use_same_media_in_points;
Media* media;
QTreeView* tree;
QCheckBox* use_same_media_in_points;
};
#endif // REPLACECLIPMEDIADIALOG_H
+765 -617
View File
File diff suppressed because it is too large Load Diff
+116 -172
View File
@@ -8,18 +8,14 @@ class EffectControls;
class Viewer;
class Timeline;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
void updateTitle(const QString &url);
~MainWindow();
void updateTitle(const QString &url);
~MainWindow();
public slots:
void undo();
@@ -28,199 +24,147 @@ public slots:
void cut();
void copy();
void paste();
void new_project();
void autorecover_interval();
void on_actionNest_triggered();
void on_actionClear_In_Out_triggered();
void toggle_full_screen();
void new_project();
void autorecover_interval();
void nest();
void toggle_full_screen();
protected:
void closeEvent(QCloseEvent *);
void paintEvent(QPaintEvent *event);
private slots:
void on_action_Import_triggered();
void show_about();
void delete_slot();
void select_all();
void on_actionExit_triggered();
void new_sequence();
void on_actionAbout_triggered();
void zoom_in();
void zoom_out();
void export_dialog();
void ripple_delete();
void on_actionDelete_triggered();
void open_project();
bool save_project_as();
bool save_project();
void on_actionSelect_All_triggered();
void go_to_start();
void prev_frame();
void playpause();
void next_frame();
void go_to_end();
void prev_cut();
void next_cut();
void on_actionSequence_triggered();
void reset_layout();
void on_actionZoom_In_triggered();
void preferences();
void on_actionZoom_out_triggered();
void zoom_in_tracks();
void on_actionExport_triggered();
void zoom_out_tracks();
void on_actionProject_2_triggered();
void fileMenu_About_To_Be_Shown();
void editMenu_About_To_Be_Shown();
void windowMenu_About_To_Be_Shown();
void viewMenu_About_To_Be_Shown();
void toolMenu_About_To_Be_Shown();
void on_actionEffect_Controls_triggered();
void duplicate();
void on_actionViewer_triggered();
void add_default_transition();
void on_actionTimeline_triggered();
void new_folder();
void on_actionRipple_Delete_triggered();
void load_recent_project();
void on_actionSplit_at_Playhead_triggered();
void ripple_to_in_point();
void ripple_to_out_point();
void on_action_Save_Project_triggered();
void set_in_point();
void set_out_point();
void on_action_Open_Project_triggered();
void clear_inout();
void delete_inout();
void ripple_delete_inout();
void on_actionSave_Project_As_triggered();
void on_actionDefault_triggered();
void on_actionOff_triggered();
void on_action4_3_triggered();
void on_action16_9_triggered();
void on_actionCustom_triggered();
void on_actionDeselect_All_triggered();
void set_marker();
void on_actionGo_to_start_triggered();
void on_actionReset_to_default_layout_triggered();
void on_actionPrevious_Frame_triggered();
void on_actionNext_Frame_triggered();
void on_actionGo_to_End_triggered();
void on_actionPlay_Pause_triggered();
void on_actionEdit_Tool_triggered();
void on_actionToggle_Snapping_triggered();
void on_actionPointer_Tool_triggered();
void on_actionRazor_Tool_triggered();
void on_actionRipple_Tool_triggered();
void on_actionRolling_Tool_triggered();
void on_actionSlip_Tool_triggered();
void on_actionGo_to_Previous_Cut_triggered();
void on_actionGo_to_Next_Cut_triggered();
void on_actionPreferences_triggered();
void on_actionIncrease_Track_Height_triggered();
void on_actionDecrease_Track_Height_triggered();
void windowMenu_About_To_Be_Shown();
void on_actionFrames_triggered();
void on_actionDrop_Frame_triggered();
void on_actionNon_Drop_Frame_triggered();
void viewMenu_About_To_Be_Shown();
void on_actionEdit_Tool_Selects_Links_triggered();
void on_actionEdit_Tool_Also_Seeks_triggered();
void toolMenu_About_To_Be_Shown();
void on_actionDuplicate_triggered();
void on_actionSelecting_Also_Seeks_triggered();
void on_actionSeek_to_the_End_of_Pastes_triggered();
void on_actionAdd_Default_Transition_triggered();
void on_actionSlide_Tool_triggered();
void on_actionFolder_triggered();
void editMenu_About_To_Be_Shown();
void fileMenu_About_To_Be_Shown();
void load_recent_project();
void on_actionScroll_Wheel_Zooms_triggered();
void on_actionLink_Unlink_triggered();
void on_actionRipple_To_In_Point_triggered();
void on_actionRipple_to_Out_Point_triggered();
void on_actionSet_In_Point_triggered();
void on_actionSet_Out_Point_triggered();
void on_actionDelete_In_Out_triggered();
void on_actionRipple_Delete_In_Out_triggered();
void on_actionTimeline_Track_Lines_triggered();
void on_actionRectified_Waveforms_triggered();
void on_actionDefault_triggered();
void on_actionOff_triggered();
void on_action4_3_triggered();
void on_action16_9_triggered();
void on_actionCustom_triggered();
void on_actionEnable_Drag_Files_to_Timeline_triggered();
void on_actionAuto_scale_by_Default_triggered();
void on_actionSet_Edit_Marker_triggered();
void on_actionEnable_Disable_Clip_triggered();
void on_actionEnable_Seek_to_Import_triggered();
void on_actionAudio_Scrubbing_triggered();
void on_actionTransition_Tool_triggered();
void on_actionEdit_to_In_Point_triggered();
void on_actionEdit_to_Out_Point_triggered();
void on_actionToggle_Show_All_triggered();
void on_actionEnable_Drop_on_Media_to_Replace_triggered();
void on_actionFootage_Viewer_triggered();
void on_actionPasteInsert_triggered();
void on_actionNo_autoscroll_triggered();
void on_actionPage_Autoscroll_triggered();
void on_actionSmooth_Auto_scroll_triggered();
void on_actionMilliseconds_triggered();
void on_actionEnable_Hover_Focus_triggered();
void on_actionHand_Tool_triggered();
void toggle_enable_clips();
void edit_to_in_point();
void edit_to_out_point();
void paste_insert();
void toggle_bool_action();
void set_autoscroll();
void menu_click_button();
void toggle_panel_visibility();
void set_timecode_view();
private:
Ui::MainWindow *ui;
void setup_layout(bool reset);
bool save_project_as();
bool save_project();
bool can_close_project();
void setup_layout(bool reset);
bool can_close_project();
void setup_menus();
// menu bar menus
QMenu* window_menu;
// file menu actions
QMenu* open_recent;
// view menu actions
QAction* track_lines;
QAction* frames_action;
QAction* drop_frame_action;
QAction* nondrop_frame_action;
QAction* milliseconds_action;
QAction* no_autoscroll;
QAction* page_autoscroll;
QAction* smooth_autoscroll;
QAction* title_safe_off;
QAction* title_safe_default;
QAction* title_safe_43;
QAction* title_safe_169;
QAction* title_safe_custom;
QAction* full_screen;
QAction* show_all;
// tool menu actions
QAction* pointer_tool_action;
QAction* edit_tool_action;
QAction* ripple_tool_action;
QAction* razor_tool_action;
QAction* slip_tool_action;
QAction* slide_tool_action;
QAction* hand_tool_action;
QAction* transition_tool_action;
QAction* snap_toggle;
QAction* selecting_also_seeks;
QAction* edit_tool_also_seeks;
QAction* edit_tool_selects_links;
QAction* seek_to_end_of_pastes;
QAction* scroll_wheel_zooms;
QAction* rectified_waveforms;
QAction* enable_drag_files_to_timeline;
QAction* autoscale_by_default;
QAction* enable_seek_to_import;
QAction* enable_audio_scrubbing;
QAction* enable_drop_on_media_to_replace;
QAction* enable_hover_focus;
// edit menu actions
QAction* undo_action;
QAction* redo_action;
void set_bool_action_checked(QAction* a);
void set_int_action_checked(QAction* a, const int& i);
void set_button_action_checked(QAction* a);
};
extern MainWindow* mainWindow;
-964
View File
@@ -1,964 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>653</width>
<height>394</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>653</width>
<height>16</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
<property name="title">
<string>&amp;File</string>
</property>
<widget class="QMenu" name="menu_New">
<property name="title">
<string>&amp;New</string>
</property>
<addaction name="actionProject"/>
<addaction name="separator"/>
<addaction name="actionSequence"/>
<addaction name="actionFolder"/>
</widget>
<widget class="QMenu" name="menuOpen_Recent">
<property name="title">
<string>Open Recent</string>
</property>
</widget>
<addaction name="menu_New"/>
<addaction name="action_Open_Project"/>
<addaction name="menuOpen_Recent"/>
<addaction name="action_Save_Project"/>
<addaction name="actionSave_Project_As"/>
<addaction name="separator"/>
<addaction name="action_Import"/>
<addaction name="separator"/>
<addaction name="actionExport"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>&amp;Edit</string>
</property>
<addaction name="action_Undo"/>
<addaction name="action_Redo"/>
<addaction name="separator"/>
<addaction name="actionCu_t"/>
<addaction name="actionCop_y"/>
<addaction name="action_Paste"/>
<addaction name="actionPasteInsert"/>
<addaction name="actionDuplicate"/>
<addaction name="actionDelete"/>
<addaction name="actionRipple_Delete"/>
<addaction name="separator"/>
<addaction name="actionSelect_All"/>
<addaction name="actionDeselect_All"/>
<addaction name="separator"/>
<addaction name="actionAdd_Default_Transition"/>
<addaction name="actionLink_Unlink"/>
<addaction name="actionRipple_To_In_Point"/>
<addaction name="actionRipple_to_Out_Point"/>
<addaction name="actionEdit_to_In_Point"/>
<addaction name="actionEdit_to_Out_Point"/>
<addaction name="actionSplit_at_Playhead"/>
<addaction name="separator"/>
<addaction name="actionSet_In_Point"/>
<addaction name="actionSet_Out_Point"/>
<addaction name="actionClear_In_Out"/>
<addaction name="actionDelete_In_Out"/>
<addaction name="actionRipple_Delete_In_Out"/>
<addaction name="separator"/>
<addaction name="actionSet_Edit_Marker"/>
<addaction name="actionEnable_Disable_Clip"/>
<addaction name="actionNest"/>
</widget>
<widget class="QMenu" name="menuWindow">
<property name="title">
<string>&amp;Window</string>
</property>
<addaction name="actionProject_2"/>
<addaction name="actionEffect_Controls"/>
<addaction name="actionFootage_Viewer"/>
<addaction name="actionViewer"/>
<addaction name="actionTimeline"/>
<addaction name="separator"/>
<addaction name="actionReset_to_default_layout"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<widget class="QMenu" name="menu_View">
<property name="title">
<string>&amp;View</string>
</property>
<widget class="QMenu" name="menuTitle_Action_Safe_Area">
<property name="title">
<string>Title/Action Safe Area</string>
</property>
<addaction name="actionOff"/>
<addaction name="actionDefault"/>
<addaction name="action4_3"/>
<addaction name="action16_9"/>
<addaction name="actionCustom"/>
</widget>
<addaction name="actionTimeline_Track_Lines"/>
<addaction name="actionZoom_In"/>
<addaction name="actionZoom_out"/>
<addaction name="actionIncrease_Track_Height"/>
<addaction name="actionDecrease_Track_Height"/>
<addaction name="actionToggle_Show_All"/>
<addaction name="separator"/>
<addaction name="actionFrames"/>
<addaction name="actionDrop_Frame"/>
<addaction name="actionNon_Drop_Frame"/>
<addaction name="actionMilliseconds"/>
<addaction name="separator"/>
<addaction name="menuTitle_Action_Safe_Area"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionFull_Screen"/>
</widget>
<widget class="QMenu" name="menuPlayback">
<property name="title">
<string>&amp;Playback</string>
</property>
<addaction name="actionGo_to_start"/>
<addaction name="actionPrevious_Frame"/>
<addaction name="actionPlay_Pause"/>
<addaction name="actionNext_Frame"/>
<addaction name="actionGo_to_End"/>
<addaction name="separator"/>
<addaction name="actionGo_to_Previous_Cut"/>
<addaction name="actionGo_to_Next_Cut"/>
</widget>
<widget class="QMenu" name="menu_Tools">
<property name="title">
<string>&amp;Tools</string>
</property>
<addaction name="separator"/>
<addaction name="actionPointer_Tool"/>
<addaction name="actionEdit_Tool"/>
<addaction name="actionRipple_Tool"/>
<addaction name="actionRolling_Tool"/>
<addaction name="actionRazor_Tool"/>
<addaction name="actionSlip_Tool"/>
<addaction name="actionSlide_Tool"/>
<addaction name="actionHand_Tool"/>
<addaction name="actionTransition_Tool"/>
<addaction name="separator"/>
<addaction name="actionToggle_Snapping"/>
<addaction name="actionSelecting_Also_Seeks"/>
<addaction name="actionEdit_Tool_Also_Seeks"/>
<addaction name="actionEdit_Tool_Selects_Links"/>
<addaction name="actionSeek_to_the_End_of_Pastes"/>
<addaction name="actionScroll_Wheel_Zooms"/>
<addaction name="actionRectified_Waveforms"/>
<addaction name="actionEnable_Drag_Files_to_Timeline"/>
<addaction name="actionAuto_scale_by_Default"/>
<addaction name="actionEnable_Seek_to_Import"/>
<addaction name="actionAudio_Scrubbing"/>
<addaction name="actionEnable_Drop_on_Media_to_Replace"/>
<addaction name="actionEnable_Hover_Focus"/>
<addaction name="separator"/>
<addaction name="actionNo_autoscroll"/>
<addaction name="actionPage_Autoscroll"/>
<addaction name="actionSmooth_Auto_scroll"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/>
<addaction name="actionCrash"/>
<addaction name="separator"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menuEdit"/>
<addaction name="menu_View"/>
<addaction name="menuPlayback"/>
<addaction name="menuWindow"/>
<addaction name="menu_Tools"/>
<addaction name="menu_Help"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="action_Open_Project">
<property name="text">
<string>&amp;Open Project</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
<action name="action_Save_Project">
<property name="text">
<string>&amp;Save Project</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="actionSave_Project_As">
<property name="text">
<string>Save Project &amp;As</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+S</string>
</property>
</action>
<action name="action_Import">
<property name="text">
<string>&amp;Import...</string>
</property>
<property name="shortcut">
<string>Ctrl+I</string>
</property>
</action>
<action name="actionExport">
<property name="text">
<string>&amp;Export...</string>
</property>
<property name="shortcut">
<string>Ctrl+M</string>
</property>
</action>
<action name="actionExit">
<property name="text">
<string>E&amp;xit</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>About...</string>
</property>
</action>
<action name="action_Undo">
<property name="text">
<string>&amp;Undo</string>
</property>
<property name="shortcut">
<string>Ctrl+Z</string>
</property>
</action>
<action name="action_Redo">
<property name="text">
<string>&amp;Redo</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+Z</string>
</property>
</action>
<action name="actionCu_t">
<property name="text">
<string>Cu&amp;t</string>
</property>
<property name="shortcut">
<string>Ctrl+X</string>
</property>
</action>
<action name="actionCop_y">
<property name="text">
<string>Cop&amp;y</string>
</property>
<property name="shortcut">
<string>Ctrl+C</string>
</property>
</action>
<action name="action_Paste">
<property name="text">
<string>&amp;Paste</string>
</property>
<property name="shortcut">
<string>Ctrl+V</string>
</property>
</action>
<action name="actionPasteInsert">
<property name="text">
<string>Paste Insert</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+V</string>
</property>
</action>
<action name="actionDelete">
<property name="text">
<string>Delete</string>
</property>
<property name="shortcut">
<string>Del</string>
</property>
</action>
<action name="actionSelect_All">
<property name="text">
<string>Select &amp;All</string>
</property>
<property name="shortcut">
<string>Ctrl+A</string>
</property>
</action>
<action name="actionTimeline_Track_Lines">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Track Lines</string>
</property>
</action>
<action name="actionProject">
<property name="text">
<string>Project...</string>
</property>
<property name="shortcut">
<string>Ctrl+N</string>
</property>
</action>
<action name="actionSequence">
<property name="text">
<string>Sequence...</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+N</string>
</property>
</action>
<action name="actionZoom_In">
<property name="text">
<string>Zoom In</string>
</property>
<property name="shortcut">
<string>=</string>
</property>
</action>
<action name="actionZoom_out">
<property name="text">
<string>Zoom Out</string>
</property>
<property name="shortcut">
<string>-</string>
</property>
</action>
<action name="actionProject_2">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Project</string>
</property>
</action>
<action name="actionEffect_Controls">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Effect Controls</string>
</property>
</action>
<action name="actionViewer">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Sequence Viewer</string>
</property>
</action>
<action name="actionTimeline">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Timeline</string>
</property>
</action>
<action name="actionRipple_Delete">
<property name="text">
<string>Ripple Delete</string>
</property>
<property name="shortcut">
<string>Shift+Del</string>
</property>
</action>
<action name="actionSplit_at_Playhead">
<property name="text">
<string>Split at Playhead</string>
</property>
<property name="shortcut">
<string>Ctrl+K</string>
</property>
</action>
<action name="actionDeselect_All">
<property name="text">
<string>Deselect All</string>
</property>
</action>
<action name="actionGo_to_start">
<property name="text">
<string>Go to Start</string>
</property>
<property name="shortcut">
<string>Home</string>
</property>
</action>
<action name="actionReset_to_default_layout">
<property name="text">
<string>Reset to default layout</string>
</property>
</action>
<action name="actionPrevious_Frame">
<property name="text">
<string>Previous Frame</string>
</property>
<property name="shortcut">
<string>Left</string>
</property>
</action>
<action name="actionPlay_Pause">
<property name="text">
<string>Play/Pause</string>
</property>
<property name="shortcut">
<string>Space</string>
</property>
</action>
<action name="actionNext_Frame">
<property name="text">
<string>Next Frame</string>
</property>
<property name="shortcut">
<string>Right</string>
</property>
</action>
<action name="actionGo_to_End">
<property name="text">
<string>Go to End</string>
</property>
<property name="shortcut">
<string>End</string>
</property>
</action>
<action name="actionCrash">
<property name="text">
<string>Crash</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</action>
<action name="actionPointer_Tool">
<property name="text">
<string>Pointer Tool</string>
</property>
<property name="shortcut">
<string>V</string>
</property>
</action>
<action name="actionEdit_Tool">
<property name="text">
<string>Edit Tool</string>
</property>
<property name="shortcut">
<string>X</string>
</property>
</action>
<action name="actionRazor_Tool">
<property name="text">
<string>Razor Tool</string>
</property>
<property name="shortcut">
<string>C</string>
</property>
</action>
<action name="actionRipple_Tool">
<property name="text">
<string>Ripple Tool</string>
</property>
<property name="shortcut">
<string>B</string>
</property>
</action>
<action name="actionRolling_Tool">
<property name="text">
<string>Rolling Tool</string>
</property>
<property name="shortcut">
<string>N</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</action>
<action name="actionPreferences">
<property name="text">
<string>Preferences</string>
</property>
<property name="shortcut">
<string>Ctrl+.</string>
</property>
</action>
<action name="actionToggle_Snapping">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Snapping</string>
</property>
<property name="toolTip">
<string>Snapping</string>
</property>
<property name="shortcut">
<string>S</string>
</property>
</action>
<action name="actionSlip_Tool">
<property name="text">
<string>Slip Tool</string>
</property>
<property name="shortcut">
<string>Y</string>
</property>
</action>
<action name="actionGo_to_Previous_Cut">
<property name="text">
<string>Go to Previous Cut</string>
</property>
<property name="shortcut">
<string>Up</string>
</property>
</action>
<action name="actionGo_to_Next_Cut">
<property name="text">
<string>Go to Next Cut</string>
</property>
<property name="shortcut">
<string>Down</string>
</property>
</action>
<action name="actionEdit_Tool_Also_Seeks">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Edit Tool Also Seeks</string>
</property>
</action>
<action name="actionIncrease_Track_Height">
<property name="text">
<string>Increase Track Height</string>
</property>
<property name="shortcut">
<string>Ctrl+=</string>
</property>
</action>
<action name="actionDecrease_Track_Height">
<property name="text">
<string>Decrease Track Height</string>
</property>
<property name="shortcut">
<string>Ctrl+-</string>
</property>
</action>
<action name="actionFrames">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Frames</string>
</property>
</action>
<action name="actionDrop_Frame">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Drop-Frame</string>
</property>
</action>
<action name="actionNon_Drop_Frame">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Non-Drop Frame</string>
</property>
</action>
<action name="actionEdit_Tool_Selects_Links">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Edit Tool Selects Links</string>
</property>
</action>
<action name="actionDuplicate">
<property name="text">
<string>Duplicate</string>
</property>
<property name="shortcut">
<string>Ctrl+D</string>
</property>
</action>
<action name="actionSelecting_Also_Seeks">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Selecting Also Seeks</string>
</property>
</action>
<action name="actionSeek_to_the_End_of_Pastes">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Seek to the End of Pastes</string>
</property>
</action>
<action name="actionAdd_Default_Transition">
<property name="text">
<string>Add Default Transition</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+D</string>
</property>
</action>
<action name="actionSlide_Tool">
<property name="text">
<string>Slide Tool</string>
</property>
<property name="shortcut">
<string>U</string>
</property>
</action>
<action name="actionFolder">
<property name="text">
<string>Folder</string>
</property>
</action>
<action name="actionClear_Recent_List">
<property name="text">
<string>Clear Recent List</string>
</property>
</action>
<action name="actionScroll_Wheel_Zooms">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Scroll Wheel Zooms</string>
</property>
</action>
<action name="actionLink_Unlink">
<property name="text">
<string>Link/Unlink</string>
</property>
<property name="shortcut">
<string>Ctrl+L</string>
</property>
</action>
<action name="actionRipple_To_In_Point">
<property name="text">
<string>Ripple to In Point</string>
</property>
<property name="shortcut">
<string>Q</string>
</property>
</action>
<action name="actionRipple_to_Out_Point">
<property name="text">
<string>Ripple to Out Point</string>
</property>
<property name="shortcut">
<string>W</string>
</property>
</action>
<action name="actionSet_In_Point">
<property name="text">
<string>Set In Point</string>
</property>
<property name="shortcut">
<string>I</string>
</property>
</action>
<action name="actionSet_Out_Point">
<property name="text">
<string>Set Out Point</string>
</property>
<property name="shortcut">
<string>O</string>
</property>
</action>
<action name="actionClear_In_Out">
<property name="text">
<string>Clear In/Out</string>
</property>
<property name="shortcut">
<string>G</string>
</property>
</action>
<action name="actionDelete_In_Out">
<property name="text">
<string>Delete In/Out</string>
</property>
<property name="shortcut">
<string>;</string>
</property>
</action>
<action name="actionRipple_Delete_In_Out">
<property name="text">
<string>Ripple Delete In/Out</string>
</property>
<property name="shortcut">
<string>'</string>
</property>
</action>
<action name="actionRectified_Waveforms">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Rectified Waveforms</string>
</property>
</action>
<action name="actionDefault">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Default</string>
</property>
</action>
<action name="actionOff">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Off</string>
</property>
</action>
<action name="action4_3">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>4:3</string>
</property>
</action>
<action name="action16_9">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>16:9</string>
</property>
</action>
<action name="actionCustom">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Custom</string>
</property>
</action>
<action name="actionEnable_Drag_Files_to_Timeline">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Enable Drag Files to Timeline</string>
</property>
</action>
<action name="actionAuto_scale_by_Default">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Auto-scale by Default</string>
</property>
</action>
<action name="actionSet_Edit_Marker">
<property name="text">
<string>Set/Edit Marker</string>
</property>
<property name="shortcut">
<string>M</string>
</property>
</action>
<action name="actionEnable_Disable_Clip">
<property name="text">
<string>Enable/Disable Clip</string>
</property>
<property name="shortcut">
<string>Shift+E</string>
</property>
</action>
<action name="actionEnable_Seek_to_Import">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Enable Seek to Import</string>
</property>
</action>
<action name="actionAudio_Scrubbing">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Audio Scrubbing</string>
</property>
</action>
<action name="actionTransition_Tool">
<property name="text">
<string>Transition Tool</string>
</property>
<property name="shortcut">
<string>T</string>
</property>
</action>
<action name="actionEdit_to_In_Point">
<property name="text">
<string>Edit to In Point</string>
</property>
<property name="shortcut">
<string>Ctrl+Alt+Q</string>
</property>
</action>
<action name="actionEdit_to_Out_Point">
<property name="text">
<string>Edit to Out Point</string>
</property>
<property name="shortcut">
<string>Ctrl+Alt+W</string>
</property>
</action>
<action name="actionNest">
<property name="text">
<string>Nest</string>
</property>
</action>
<action name="actionToggle_Show_All">
<property name="text">
<string>Toggle Show All</string>
</property>
<property name="shortcut">
<string>\</string>
</property>
</action>
<action name="actionEnable_Drop_on_Media_to_Replace">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Enable Drop File on Media to Replace</string>
</property>
</action>
<action name="actionFootage_Viewer">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Footage Viewer</string>
</property>
</action>
<action name="actionNo_autoscroll">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>No Auto-scroll</string>
</property>
</action>
<action name="actionPage_Autoscroll">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Page Auto-scroll</string>
</property>
</action>
<action name="actionSmooth_Auto_scroll">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Smooth Auto-scroll</string>
</property>
</action>
<action name="actionMilliseconds">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Milliseconds</string>
</property>
</action>
<action name="actionEnable_Hover_Focus">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Enable Hover Focus for Zooming</string>
</property>
</action>
<action name="actionFull_Screen">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Full Screen</string>
</property>
<property name="shortcut">
<string>F11</string>
</property>
</action>
<action name="actionHand_Tool">
<property name="text">
<string>Hand Tool</string>
</property>
<property name="shortcut">
<string>H</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
-1
View File
@@ -188,7 +188,6 @@ HEADERS += \
ui/keyframenavigator.h
FORMS += \
mainwindow.ui \
panels/effectcontrols.ui \
panels/viewer.ui \
panels/timeline.ui \
+574 -568
View File
File diff suppressed because it is too large Load Diff
+46 -46
View File
@@ -48,81 +48,81 @@ class Project : public QDockWidget {
public:
explicit Project(QWidget *parent = 0);
~Project();
bool is_focused();
bool is_focused();
void clear();
Media* new_sequence(ComboAction *ca, Sequence* s, bool open, Media* parent);
QString get_next_sequence_name(QString start = 0);
void process_file_list(QStringList& files, bool recursive = false, Media* replace = NULL, Media *parent = NULL);
void replace_media(Media* item, QString filename);
Media *get_selected_folder();
bool reveal_media(Media *media, QModelIndex parent = QModelIndex());
void add_recent_project(QString url);
Media* new_sequence(ComboAction *ca, Sequence* s, bool open, Media* parent);
QString get_next_sequence_name(QString start = 0);
void process_file_list(QStringList& files, bool recursive = false, Media* replace = NULL, Media *parent = NULL);
void replace_media(Media* item, QString filename);
Media *get_selected_folder();
bool reveal_media(Media *media, QModelIndex parent = QModelIndex());
void add_recent_project(QString url);
void new_project();
void load_project(bool autorecovery);
void save_project(bool autorecovery);
void new_project();
void load_project(bool autorecovery);
void save_project(bool autorecovery);
Media* new_folder(QString name);
Media* item_to_media(const QModelIndex& index);
Media* new_folder(QString name);
Media* item_to_media(const QModelIndex& index);
void save_recent_projects();
void save_recent_projects();
QVector<Media*> list_all_project_sequences();
QVector<Media*> list_all_project_sequences();
SourceTable* tree_view;
SourceIconView* icon_view;
SourcesCommon* sources_common;
SourceTable* tree_view;
SourceIconView* icon_view;
SourcesCommon* sources_common;
QSortFilterProxyModel* sorter;
QSortFilterProxyModel* sorter;
QVector<Media*> last_imported_media;
QVector<Media*> last_imported_media;
//Media *new_item();
QModelIndexList get_current_selected();
void start_preview_generator(Media* item, bool replacing);
public slots:
void import_dialog();
void delete_selected_media();
void duplicate_selected();
void delete_selected_media();
void duplicate_selected();
void delete_clips_using_selected_media();
void replace_selected_file();
void replace_clip_media();
void open_properties();
private:
void save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, const QModelIndex &parent = QModelIndex());
int folder_id;
int media_id;
int sequence_id;
void get_all_media_from_table(QList<Media *> items, QList<Media *> &list, int type);
void list_all_sequences_worker(QVector<Media *> *list, Media* parent);
void save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, const QModelIndex &parent = QModelIndex());
int folder_id;
int media_id;
int sequence_id;
void get_all_media_from_table(QList<Media *> items, QList<Media *> &list, int type);
void list_all_sequences_worker(QVector<Media *> *list, Media* parent);
QString get_file_name_from_path(const QString &path);
QDir proj_dir;
QWidget* icon_view_container;
QPushButton* directory_up;
QDir proj_dir;
QWidget* icon_view_container;
QPushButton* directory_up;
private slots:
void update_view_type();
void set_icon_view();
void set_tree_view();
void update_view_type();
void set_icon_view();
void set_tree_view();
void clear_recent_projects();
void set_icon_view_size(int);
void set_up_dir_enabled();
void go_up_dir();
void set_icon_view_size(int);
void set_up_dir_enabled();
void go_up_dir();
};
class MediaThrobber : public QObject {
Q_OBJECT
Q_OBJECT
public:
MediaThrobber(Media*);
MediaThrobber(Media*);
public slots:
void start();
void start();
void stop(int, bool replace);
private slots:
void animation_update();
void animation_update();
private:
QPixmap pixmap;
int animation;
Media* item;
QTimer* animator;
QPixmap pixmap;
int animation;
Media* item;
QTimer* animator;
};
#endif // PROJECT_H
+86 -86
View File
@@ -38,7 +38,7 @@ bool selection_contains_transition(const Selection& s, Clip* c, int type);
void move_clip(ComboAction *ca, Clip *c, long iin, long iout, long iclip_in, int itrack, bool verify_transitions = true);
struct Ghost {
int clip;
int clip;
long in;
long out;
int track;
@@ -50,17 +50,17 @@ struct Ghost {
long old_clip_in;
// importing variables
Media* media;
int media_stream;
Media* media;
int media_stream;
// other variables
long ghost_length;
long media_length;
bool trim_in;
bool trimming;
bool trim_in;
bool trimming;
// transition trimming
Transition* transition;
Transition* transition;
};
namespace Ui {
@@ -74,35 +74,31 @@ public:
explicit Timeline(QWidget *parent = 0);
~Timeline();
bool focused();
void set_zoom(bool in);
void copy(bool del);
void paste(bool insert);
void deselect();
Clip* split_clip(ComboAction* ca, int p, long frame);
Clip* split_clip(ComboAction* ca, int p, long frame, long post_in);
bool split_selection(ComboAction* ca);
void split_at_playhead();
bool split_all_clips_at_point(ComboAction *ca, long point);
bool split_clip_and_relink(ComboAction* ca, int clip, long frame, bool relink);
void clean_up_selections(QVector<Selection>& areas);
bool focused();
void set_zoom(bool in);
void copy(bool del);
void paste(bool insert);
Clip* split_clip(ComboAction* ca, int p, long frame);
Clip* split_clip(ComboAction* ca, int p, long frame, long post_in);
bool split_selection(ComboAction* ca);
bool split_all_clips_at_point(ComboAction *ca, long point);
bool split_clip_and_relink(ComboAction* ca, int clip, long frame, bool relink);
void clean_up_selections(QVector<Selection>& areas);
void deselect_area(long in, long out, int track);
void delete_areas_and_relink(ComboAction *ca, QVector<Selection>& areas);
void relink_clips_using_ids(QVector<int>& old_clips, QVector<Clip*>& new_clips);
void update_sequence();
void increase_track_height();
void decrease_track_height();
void add_transition();
QVector<int> get_tracks_of_linked_clips(int i);
bool has_clip_been_split(int c);
void toggle_links();
void delete_areas_and_relink(ComboAction *ca, QVector<Selection>& areas);
void relink_clips_using_ids(QVector<int>& old_clips, QVector<Clip*>& new_clips);
void update_sequence();
void increase_track_height();
void decrease_track_height();
void add_transition();
QVector<int> get_tracks_of_linked_clips(int i);
bool has_clip_been_split(int c);
void ripple_to_in_point(bool in, bool ripple);
void delete_in_out(bool ripple);
void delete_in_out(bool ripple);
void previous_cut();
void next_cut();
void toggle_show_all();
void create_ghosts_from_media(Sequence *seq, long entry_point, QVector<Media *> &media_list);
void create_ghosts_from_media(Sequence *seq, long entry_point, QVector<Media *> &media_list);
void add_clips_from_ghosts(ComboAction *ca, Sequence *s);
int getTimelineScreenPointFromFrame(long frame);
@@ -111,114 +107,118 @@ public:
long getDisplayFrameFromScreenPoint(int x);
int get_snap_range();
bool snap_to_point(long point, long* l);
bool snap_to_point(long point, long* l);
bool snap_to_timeline(long* l, bool use_playhead, bool use_markers, bool use_workarea);
void set_marker();
// shared information
// shared information
int tool;
long cursor_frame;
int cursor_track;
double zoom;
bool zoom_just_changed;
long cursor_frame;
int cursor_track;
double zoom;
bool zoom_just_changed;
long drag_frame_start;
int drag_track_start;
void update_effect_controls();
bool showing_all;
double old_zoom;
QVector<int> video_track_heights;
QVector<int> audio_track_heights;
int get_track_height_size(bool video);
int calculate_track_height(int track, int height);
QVector<int> video_track_heights;
QVector<int> audio_track_heights;
int get_track_height_size(bool video);
int calculate_track_height(int track, int height);
// snapping
bool snapping;
bool snapped;
long snap_point;
// snapping
bool snapping;
bool snapped;
long snap_point;
// selecting functions
bool selecting;
int selection_offset;
bool is_clip_selected(Clip* clip, bool containing);
int selection_offset;
bool is_clip_selected(Clip* clip, bool containing);
void delete_selection(QVector<Selection> &selections, bool ripple);
void select_all();
bool rect_select_init;
bool rect_select_proc;
int rect_select_x;
int rect_select_y;
int rect_select_w;
int rect_select_h;
bool rect_select_init;
bool rect_select_proc;
int rect_select_x;
int rect_select_y;
int rect_select_w;
int rect_select_h;
// moving
bool moving_init;
bool moving_proc;
QVector<Ghost> ghosts;
bool video_ghosts;
bool audio_ghosts;
QVector<Ghost> ghosts;
bool video_ghosts;
bool audio_ghosts;
bool move_insert;
// trimming
int trim_target;
bool trim_in_point;
bool trim_in_point;
int transition_select;
// splitting
bool splitting;
QVector<int> split_tracks;
QVector<int> split_cache;
QVector<int> split_tracks;
QVector<int> split_cache;
// importing
bool importing;
bool importing;
bool importing_files;
// creating variables
bool creating;
int creating_object;
// transition variables
bool transition_tool_init;
bool transition_tool_proc;
int transition_tool_pre_clip;
int transition_tool_post_clip;
int transition_tool_type;
// transition variables
bool transition_tool_init;
bool transition_tool_proc;
int transition_tool_pre_clip;
int transition_tool_post_clip;
int transition_tool_type;
const EffectMeta* transition_tool_meta;
int transition_tool_side;
// hand tool variables
bool hand_moving;
int drag_x_start;
int drag_y_start;
// hand tool variables
bool hand_moving;
int drag_x_start;
int drag_y_start;
bool block_repaints;
bool block_repaints;
Ui::Timeline *ui;
Ui::Timeline *ui;
void resizeEvent(QResizeEvent *event);
void resizeEvent(QResizeEvent *event);
public slots:
void repaint_timeline();
void toggle_show_all();
void deselect();
void toggle_links();
void split_at_playhead();
private slots:
void on_pushButton_4_clicked();
void on_pushButton_5_clicked();
void on_pushButton_5_clicked();
void on_snappingButton_toggled(bool checked);
void on_snappingButton_toggled(bool checked);
void on_toolSlideButton_clicked();
void on_toolSlideButton_clicked();
void on_toolArrowButton_clicked();
void on_toolArrowButton_clicked();
void on_toolEditButton_clicked();
void on_toolEditButton_clicked();
void on_toolRippleButton_clicked();
void on_toolRippleButton_clicked();
void on_toolRollingButton_clicked();
void on_toolRollingButton_clicked();
void on_toolRazorButton_clicked();
void on_toolRazorButton_clicked();
void on_toolSlipButton_clicked();
void on_toolSlipButton_clicked();
void on_addButton_clicked();
@@ -232,18 +232,18 @@ private slots:
void transition_menu_select(QAction*);
void resize_move(double d);
void resize_move(double d);
void on_toolHandButton_clicked();
void on_toolHandButton_clicked();
private:
void set_zoom_value(double v);
QVector<QPushButton*> tool_buttons;
void decheck_tool_buttons(QObject* sender);
void set_tool(int tool);
void set_tool(int tool);
long last_frame;
int scroll;
void set_sb_max();
int scroll;
void set_sb_max();
int default_track_height;
};
+100 -96
View File
@@ -7,172 +7,176 @@
#include "debug.h"
ProjectModel::ProjectModel(QObject *parent) : QAbstractItemModel(parent), root_item(NULL) {
root_item = new Media(0);
root_item->root = true;
root_item = new Media(0);
root_item->root = true;
}
ProjectModel::~ProjectModel() {
destroy_root();
ProjectModel::~ProjectModel() {
destroy_root();
}
void ProjectModel::destroy_root() {
if (panel_sequence_viewer != NULL) panel_sequence_viewer->viewer_widget->delete_function();
if (panel_footage_viewer != NULL) panel_footage_viewer->viewer_widget->delete_function();
if (panel_sequence_viewer != NULL) panel_sequence_viewer->viewer_widget->delete_function();
if (panel_footage_viewer != NULL) panel_footage_viewer->viewer_widget->delete_function();
if (root_item != NULL) {
delete root_item;
}
if (root_item != NULL) {
delete root_item;
}
}
void ProjectModel::clear() {
beginResetModel();
destroy_root();
root_item = new Media(0);
root_item->root = true;
endResetModel();
beginResetModel();
destroy_root();
root_item = new Media(0);
root_item->root = true;
endResetModel();
}
Media *ProjectModel::get_root() {
return root_item;
return root_item;
}
QVariant ProjectModel::data(const QModelIndex &index, int role) const {
if (!index.isValid())
return QVariant();
if (!index.isValid())
return QVariant();
return static_cast<Media*>(index.internalPointer())->data(index.column(), role);
return static_cast<Media*>(index.internalPointer())->data(index.column(), role);
}
Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const {
if (!index.isValid())
return Qt::ItemIsDropEnabled;
if (!index.isValid())
return Qt::ItemIsDropEnabled;
return QAbstractItemModel::flags(index) | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable;
return QAbstractItemModel::flags(index) | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable;
}
QVariant ProjectModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return root_item->data(section, role);
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return root_item->data(section, role);
return QVariant();
return QVariant();
}
QModelIndex ProjectModel::index(int row, int column, const QModelIndex &parent) const {
if (!hasIndex(row, column, parent))
return QModelIndex();
if (!hasIndex(row, column, parent))
return QModelIndex();
Media *parentItem;
Media *parentItem;
if (!parent.isValid())
parentItem = root_item;
else
parentItem = static_cast<Media*>(parent.internalPointer());
if (!parent.isValid())
parentItem = root_item;
else
parentItem = static_cast<Media*>(parent.internalPointer());
Media *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
else
return QModelIndex();
Media *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
else
return QModelIndex();
}
QModelIndex ProjectModel::create_index(int arow, int acolumn, void* aid) {
return createIndex(arow, acolumn, aid);
}
QModelIndex ProjectModel::parent(const QModelIndex &index) const {
if (!index.isValid())
return QModelIndex();
if (!index.isValid())
return QModelIndex();
Media *childItem = static_cast<Media*>(index.internalPointer());
Media *parentItem = childItem->parentItem();
Media *childItem = static_cast<Media*>(index.internalPointer());
Media *parentItem = childItem->parentItem();
if (parentItem == root_item)
return QModelIndex();
if (parentItem == root_item)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
return createIndex(parentItem->row(), 0, parentItem);
}
bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int role) {
if (role != Qt::EditRole)
return false;
if (role != Qt::EditRole)
return false;
Media *item = static_cast<Media*>(index.internalPointer());
bool result = item->setData(index.column(), value);
Media *item = static_cast<Media*>(index.internalPointer());
bool result = item->setData(index.column(), value);
if (result)
emit dataChanged(index, index);
if (result)
emit dataChanged(index, index);
return result;
return result;
}
int ProjectModel::rowCount(const QModelIndex &parent) const {
Media *parentItem;
if (parent.column() > 0)
return 0;
Media *parentItem;
if (parent.column() > 0)
return 0;
if (!parent.isValid()) {
parentItem = root_item;
} else {
parentItem = static_cast<Media*>(parent.internalPointer());
}
if (!parent.isValid()) {
parentItem = root_item;
} else {
parentItem = static_cast<Media*>(parent.internalPointer());
}
return parentItem->childCount();
return parentItem->childCount();
}
int ProjectModel::columnCount(const QModelIndex &parent) const {
if (parent.isValid())
return static_cast<Media*>(parent.internalPointer())->columnCount();
else
return root_item->columnCount();
if (parent.isValid())
return static_cast<Media*>(parent.internalPointer())->columnCount();
else
return root_item->columnCount();
}
Media *ProjectModel::getItem(const QModelIndex &index) const {
if (index.isValid()) {
Media *item = static_cast<Media*>(index.internalPointer());
if (item)
return item;
}
return root_item;
if (index.isValid()) {
Media *item = static_cast<Media*>(index.internalPointer());
if (item)
return item;
}
return root_item;
}
void ProjectModel::set_icon(Media* m, const QIcon &ico) {
QModelIndex index = createIndex(m->row(), 0, m);
m->set_icon(ico);
emit dataChanged(index, index);
QModelIndex index = createIndex(m->row(), 0, m);
m->set_icon(ico);
emit dataChanged(index, index);
}
void ProjectModel::appendChild(Media *parent, Media *child) {
if (parent == NULL) parent = root_item;
beginInsertRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), parent->childCount(), parent->childCount());
parent->appendChild(child);
endInsertRows();
if (parent == NULL) parent = root_item;
beginInsertRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), parent->childCount(), parent->childCount());
parent->appendChild(child);
endInsertRows();
}
void ProjectModel::moveChild(Media *child, Media *to) {
if (to == NULL) to = root_item;
Media* from = child->parentItem();
beginMoveRows(
from == root_item ? QModelIndex() : createIndex(from->row(), 0, from),
child->row(),
child->row(),
to == root_item ? QModelIndex() : createIndex(to->row(), 0, to),
to->childCount()
);
from->removeChild(child->row());
to->appendChild(child);
endMoveRows();
if (to == NULL) to = root_item;
Media* from = child->parentItem();
beginMoveRows(
from == root_item ? QModelIndex() : createIndex(from->row(), 0, from),
child->row(),
child->row(),
to == root_item ? QModelIndex() : createIndex(to->row(), 0, to),
to->childCount()
);
from->removeChild(child->row());
to->appendChild(child);
endMoveRows();
}
void ProjectModel::removeChild(Media* parent, Media* m) {
if (parent == NULL) parent = root_item;
beginRemoveRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), m->row(), m->row());
parent->removeChild(m->row());
endRemoveRows();
if (parent == NULL) parent = root_item;
beginRemoveRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), m->row(), m->row());
parent->removeChild(m->row());
endRemoveRows();
}
Media* ProjectModel::child(int i, Media* parent) {
if (parent == NULL) parent = root_item;
return parent->child(i);
if (parent == NULL) parent = root_item;
return parent->child(i);
}
int ProjectModel::childCount(Media *parent) {
if (parent == NULL) parent = root_item;
return parent->childCount();
if (parent == NULL) parent = root_item;
return parent->childCount();
}
+25 -24
View File
@@ -7,35 +7,36 @@ class Media;
class ProjectModel : public QAbstractItemModel
{
Q_OBJECT
Q_OBJECT
public:
ProjectModel(QObject* parent = 0);
~ProjectModel() override;
ProjectModel(QObject* parent = 0);
~ProjectModel() override;
void destroy_root();
void clear();
Media* get_root();
QVariant data(const QModelIndex &index, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Media *getItem(const QModelIndex &index) const;
void destroy_root();
void clear();
Media* get_root();
QVariant data(const QModelIndex &index, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex create_index(int arow, int acolumn, void *aid);
QModelIndex parent(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Media *getItem(const QModelIndex &index) const;
void appendChild(Media* parent, Media* child);
void moveChild(Media *child, Media *to);
void removeChild(Media *parent, Media* m);
Media *child(int i, Media* parent = NULL);
int childCount(Media* parent = NULL);
void set_icon(Media* m, const QIcon &ico);
void appendChild(Media* parent, Media* child);
void moveChild(Media *child, Media *to);
void removeChild(Media *parent, Media* m);
Media *child(int i, Media* parent = NULL);
int childCount(Media* parent = NULL);
void set_icon(Media* m, const QIcon &ico);
private:
Media* root_item;
Media* root_item;
};
#endif // PROJECTMODEL_H
+199 -199
View File
@@ -18,263 +18,263 @@
#include <QDesktopServices>
SourcesCommon::SourcesCommon(Project* parent) :
project_parent(parent),
editing_item(NULL)
project_parent(parent),
editing_item(NULL)
{
rename_timer.setInterval(1000);
connect(&rename_timer, SIGNAL(timeout()), this, SLOT(rename_interval()));
rename_timer.setInterval(1000);
connect(&rename_timer, SIGNAL(timeout()), this, SLOT(rename_interval()));
}
void SourcesCommon::create_seq_from_selected() {
if (!selected_items.isEmpty()) {
QVector<Media*> media_list;
for (int i=0;i<selected_items.size();i++) {
media_list.append(project_parent->item_to_media(selected_items.at(i)));
}
if (!selected_items.isEmpty()) {
QVector<Media*> media_list;
for (int i=0;i<selected_items.size();i++) {
media_list.append(project_parent->item_to_media(selected_items.at(i)));
}
ComboAction* ca = new ComboAction();
Sequence* s = create_sequence_from_media(media_list);
ComboAction* ca = new ComboAction();
Sequence* s = create_sequence_from_media(media_list);
// add clips to it
panel_timeline->create_ghosts_from_media(s, 0, media_list);
panel_timeline->add_clips_from_ghosts(ca, s);
// add clips to it
panel_timeline->create_ghosts_from_media(s, 0, media_list);
panel_timeline->add_clips_from_ghosts(ca, s);
project_parent->new_sequence(ca, s, true, NULL);
undo_stack.push(ca);
}
project_parent->new_sequence(ca, s, true, NULL);
undo_stack.push(ca);
}
}
void SourcesCommon::show_context_menu(QWidget* parent, const QModelIndexList& items) {
QMenu menu(parent);
QMenu menu(parent);
selected_items = items;
selected_items = items;
QAction* import_action = menu.addAction("Import...");
QObject::connect(import_action, SIGNAL(triggered(bool)), project_parent, SLOT(import_dialog()));
QAction* import_action = menu.addAction("Import...");
QObject::connect(import_action, SIGNAL(triggered(bool)), project_parent, SLOT(import_dialog()));
QAction* new_folder_action = menu.addAction("New Folder...");
QObject::connect(new_folder_action, SIGNAL(triggered(bool)), mainWindow, SLOT(on_actionFolder_triggered()));
QAction* new_folder_action = menu.addAction("New Folder...");
QObject::connect(new_folder_action, SIGNAL(triggered(bool)), mainWindow, SLOT(new_folder()));
if (items.size() > 0) {
Media* m = project_parent->item_to_media(items.at(0));
if (items.size() > 0) {
Media* m = project_parent->item_to_media(items.at(0));
if (items.size() == 1) {
// replace footage
int type = m->get_type();
if (type == MEDIA_TYPE_FOOTAGE) {
QAction* replace_action = menu.addAction("Replace/Relink Media");
QObject::connect(replace_action, SIGNAL(triggered(bool)), project_parent, SLOT(replace_selected_file()));
if (items.size() == 1) {
// replace footage
int type = m->get_type();
if (type == MEDIA_TYPE_FOOTAGE) {
QAction* replace_action = menu.addAction("Replace/Relink Media");
QObject::connect(replace_action, SIGNAL(triggered(bool)), project_parent, SLOT(replace_selected_file()));
#if defined(Q_OS_WIN)
QAction* reveal_in_explorer = menu.addAction("Reveal in Explorer");
QAction* reveal_in_explorer = menu.addAction("Reveal in Explorer");
#elif defined(Q_OS_MAC)
QAction* reveal_in_explorer = menu.addAction("Reveal in Finder");
QAction* reveal_in_explorer = menu.addAction("Reveal in Finder");
#else
QAction* reveal_in_explorer = menu.addAction("Reveal in File Manager");
QAction* reveal_in_explorer = menu.addAction("Reveal in File Manager");
#endif
QObject::connect(reveal_in_explorer, SIGNAL(triggered(bool)), this, SLOT(reveal_in_browser()));
}
if (type != MEDIA_TYPE_FOLDER) {
QAction* replace_clip_media = menu.addAction("Replace Clips Using This Media");
QObject::connect(replace_clip_media, SIGNAL(triggered(bool)), project_parent, SLOT(replace_clip_media()));
}
}
QObject::connect(reveal_in_explorer, SIGNAL(triggered(bool)), this, SLOT(reveal_in_browser()));
}
if (type != MEDIA_TYPE_FOLDER) {
QAction* replace_clip_media = menu.addAction("Replace Clips Using This Media");
QObject::connect(replace_clip_media, SIGNAL(triggered(bool)), project_parent, SLOT(replace_clip_media()));
}
}
// duplicate item
bool all_sequences = true;
bool all_footage = true;
for (int i=0;i<items.size();i++) {
if (m->get_type() != MEDIA_TYPE_SEQUENCE) {
all_sequences = false;
}
if (m->get_type() != MEDIA_TYPE_FOOTAGE) {
all_footage = false;
}
}
// duplicate item
bool all_sequences = true;
bool all_footage = true;
for (int i=0;i<items.size();i++) {
if (m->get_type() != MEDIA_TYPE_SEQUENCE) {
all_sequences = false;
}
if (m->get_type() != MEDIA_TYPE_FOOTAGE) {
all_footage = false;
}
}
// create sequence from
QAction* create_seq_from = menu.addAction("Create Sequence With This Media");
QObject::connect(create_seq_from, SIGNAL(triggered(bool)), this, SLOT(create_seq_from_selected()));
// create sequence from
QAction* create_seq_from = menu.addAction("Create Sequence With This Media");
QObject::connect(create_seq_from, SIGNAL(triggered(bool)), this, SLOT(create_seq_from_selected()));
// ONLY sequences are selected
if (all_sequences) {
// ONLY sequences are selected
QAction* duplicate_action = menu.addAction("Duplicate");
QObject::connect(duplicate_action, SIGNAL(triggered(bool)), project_parent, SLOT(duplicate_selected()));
}
// ONLY sequences are selected
if (all_sequences) {
// ONLY sequences are selected
QAction* duplicate_action = menu.addAction("Duplicate");
QObject::connect(duplicate_action, SIGNAL(triggered(bool)), project_parent, SLOT(duplicate_selected()));
}
// ONLY footage is selected
if (all_footage) {
QAction* delete_footage_from_sequences = menu.addAction("Delete All Clips Using This Media");
QObject::connect(delete_footage_from_sequences, SIGNAL(triggered(bool)), project_parent, SLOT(delete_clips_using_selected_media()));
}
// ONLY footage is selected
if (all_footage) {
QAction* delete_footage_from_sequences = menu.addAction("Delete All Clips Using This Media");
QObject::connect(delete_footage_from_sequences, SIGNAL(triggered(bool)), project_parent, SLOT(delete_clips_using_selected_media()));
}
// delete media
QAction* delete_action = menu.addAction("Delete");
QObject::connect(delete_action, SIGNAL(triggered(bool)), project_parent, SLOT(delete_selected_media()));
// delete media
QAction* delete_action = menu.addAction("Delete");
QObject::connect(delete_action, SIGNAL(triggered(bool)), project_parent, SLOT(delete_selected_media()));
if (items.size() == 1) {
QAction* properties_action = menu.addAction("Properties...");
QObject::connect(properties_action, SIGNAL(triggered(bool)), project_parent, SLOT(open_properties()));
}
}
if (items.size() == 1) {
QAction* properties_action = menu.addAction("Properties...");
QObject::connect(properties_action, SIGNAL(triggered(bool)), project_parent, SLOT(open_properties()));
}
}
menu.addSeparator();
menu.addSeparator();
QAction* tree_view_action = menu.addAction("Tree View");
connect(tree_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_tree_view()));
QAction* tree_view_action = menu.addAction("Tree View");
connect(tree_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_tree_view()));
QAction* icon_view_action = menu.addAction("Icon View");
connect(icon_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_icon_view()));
QAction* icon_view_action = menu.addAction("Icon View");
connect(icon_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_icon_view()));
menu.exec(QCursor::pos());
menu.exec(QCursor::pos());
}
void SourcesCommon::mousePressEvent(QMouseEvent *) {
stop_rename_timer();
stop_rename_timer();
}
void SourcesCommon::item_click(Media *m, const QModelIndex& index) {
if (editing_item == m) {
rename_timer.start();
} else {
editing_item = m;
editing_index = index;
}
if (editing_item == m) {
rename_timer.start();
} else {
editing_item = m;
editing_index = index;
}
}
void SourcesCommon::mouseDoubleClickEvent(QMouseEvent *e, const QModelIndexList& selected_items) {
stop_rename_timer();
if (selected_items.size() == 0) {
project_parent->import_dialog();
} else if (selected_items.size() == 1) {
Media* item = project_parent->item_to_media(selected_items.at(0));
switch (item->get_type()) {
case MEDIA_TYPE_FOOTAGE:
panel_footage_viewer->set_media(item);
panel_footage_viewer->setFocus();
break;
case MEDIA_TYPE_SEQUENCE:
undo_stack.push(new ChangeSequenceAction(item->to_sequence()));
break;
}
}
stop_rename_timer();
if (selected_items.size() == 0) {
project_parent->import_dialog();
} else if (selected_items.size() == 1) {
Media* item = project_parent->item_to_media(selected_items.at(0));
switch (item->get_type()) {
case MEDIA_TYPE_FOOTAGE:
panel_footage_viewer->set_media(item);
panel_footage_viewer->setFocus();
break;
case MEDIA_TYPE_SEQUENCE:
undo_stack.push(new ChangeSequenceAction(item->to_sequence()));
break;
}
}
}
void SourcesCommon::dropEvent(QWidget* parent, QDropEvent *event, const QModelIndex& drop_item, const QModelIndexList& items) {
const QMimeData* mimeData = event->mimeData();
Media* m = project_parent->item_to_media(drop_item);
if (mimeData->hasUrls()) {
// drag files in from outside
QList<QUrl> urls = mimeData->urls();
if (!urls.isEmpty()) {
QStringList paths;
for (int i=0;i<urls.size();i++) {
paths.append(urls.at(i).toLocalFile());
}
bool replace = false;
if (urls.size() == 1
&& drop_item.isValid()
&& m->get_type() == MEDIA_TYPE_FOOTAGE
&& !QFileInfo(paths.at(0)).isDir()
&& config.drop_on_media_to_replace
&& QMessageBox::question(parent, "Replace Media", "You dropped a file onto '" + m->get_name() + "'. Would you like to replace it with the dropped file?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
replace = true;
project_parent->replace_media(m, paths.at(0));
}
if (!replace) {
QModelIndex parent;
if (drop_item.isValid()) {
if (m->get_type() == MEDIA_TYPE_FOLDER) {
parent = drop_item;
} else {
parent = drop_item.parent();
}
}
project_parent->process_file_list(paths, false, NULL, panel_project->item_to_media(parent));
}
}
event->acceptProposedAction();
} else {
event->ignore();
const QMimeData* mimeData = event->mimeData();
Media* m = project_parent->item_to_media(drop_item);
if (mimeData->hasUrls()) {
// drag files in from outside
QList<QUrl> urls = mimeData->urls();
if (!urls.isEmpty()) {
QStringList paths;
for (int i=0;i<urls.size();i++) {
paths.append(urls.at(i).toLocalFile());
}
bool replace = false;
if (urls.size() == 1
&& drop_item.isValid()
&& m->get_type() == MEDIA_TYPE_FOOTAGE
&& !QFileInfo(paths.at(0)).isDir()
&& config.drop_on_media_to_replace
&& QMessageBox::question(parent, "Replace Media", "You dropped a file onto '" + m->get_name() + "'. Would you like to replace it with the dropped file?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
replace = true;
project_parent->replace_media(m, paths.at(0));
}
if (!replace) {
QModelIndex parent;
if (drop_item.isValid()) {
if (m->get_type() == MEDIA_TYPE_FOLDER) {
parent = drop_item;
} else {
parent = drop_item.parent();
}
}
project_parent->process_file_list(paths, false, NULL, panel_project->item_to_media(parent));
}
}
event->acceptProposedAction();
} else {
event->ignore();
// dragging files within project
// if we dragged to the root OR dragged to a folder
if (!drop_item.isValid() || (drop_item.isValid() && m->get_type() == MEDIA_TYPE_FOLDER)) {
QVector<Media*> move_items;
for (int i=0;i<items.size();i++) {
const QModelIndex& item = items.at(i);
const QModelIndex& parent = item.parent();
Media* s = project_parent->item_to_media(item);
if (parent != drop_item && item != drop_item) {
bool ignore = false;
if (parent.isValid()) {
// if child belongs to a selected parent, assume the user is just moving the parent and ignore the child
QModelIndex par = parent;
while (par.isValid() && !ignore) {
for (int j=0;j<items.size();j++) {
if (par == items.at(j)) {
ignore = true;
break;
}
}
par = par.parent();
}
}
if (!ignore) {
move_items.append(s);
}
}
}
if (move_items.size() > 0) {
MediaMove* mm = new MediaMove();
mm->to = m;
mm->items = move_items;
undo_stack.push(mm);
}
}
}
// dragging files within project
// if we dragged to the root OR dragged to a folder
if (!drop_item.isValid() || (drop_item.isValid() && m->get_type() == MEDIA_TYPE_FOLDER)) {
QVector<Media*> move_items;
for (int i=0;i<items.size();i++) {
const QModelIndex& item = items.at(i);
const QModelIndex& parent = item.parent();
Media* s = project_parent->item_to_media(item);
if (parent != drop_item && item != drop_item) {
bool ignore = false;
if (parent.isValid()) {
// if child belongs to a selected parent, assume the user is just moving the parent and ignore the child
QModelIndex par = parent;
while (par.isValid() && !ignore) {
for (int j=0;j<items.size();j++) {
if (par == items.at(j)) {
ignore = true;
break;
}
}
par = par.parent();
}
}
if (!ignore) {
move_items.append(s);
}
}
}
if (move_items.size() > 0) {
MediaMove* mm = new MediaMove();
mm->to = m;
mm->items = move_items;
undo_stack.push(mm);
}
}
}
}
void SourcesCommon::reveal_in_browser() {
Media* media = project_parent->item_to_media(selected_items.at(0));
Footage* m = media->to_footage();
Media* media = project_parent->item_to_media(selected_items.at(0));
Footage* m = media->to_footage();
#if defined(Q_OS_WIN)
QStringList args;
args << "/select," << QDir::toNativeSeparators(m->url);
QProcess::startDetached("explorer", args);
QStringList args;
args << "/select," << QDir::toNativeSeparators(m->url);
QProcess::startDetached("explorer", args);
#elif defined(Q_OS_MAC)
QStringList args;
args << "-e";
args << "tell application \"Finder\"";
args << "-e";
args << "activate";
args << "-e";
args << "select POSIX file \""+m->url+"\"";
args << "-e";
args << "end tell";
QProcess::startDetached("osascript", args);
QStringList args;
args << "-e";
args << "tell application \"Finder\"";
args << "-e";
args << "activate";
args << "-e";
args << "select POSIX file \""+m->url+"\"";
args << "-e";
args << "end tell";
QProcess::startDetached("osascript", args);
#else
QDesktopServices::openUrl(QUrl::fromLocalFile(m->url.left(m->url.lastIndexOf('/'))));
QDesktopServices::openUrl(QUrl::fromLocalFile(m->url.left(m->url.lastIndexOf('/'))));
#endif
}
void SourcesCommon::stop_rename_timer() {
rename_timer.stop();
rename_timer.stop();
}
void SourcesCommon::rename_interval() {
stop_rename_timer();
if (view->hasFocus() && editing_item != NULL) {
view->edit(editing_index);
}
stop_rename_timer();
if (view->hasFocus() && editing_item != NULL) {
view->edit(editing_index);
}
}
void SourcesCommon::item_renamed(Media* item) {
if (editing_item == item) {
MediaRename* mr = new MediaRename(item, "idk");
undo_stack.push(mr);
editing_item = NULL;
}
if (editing_item == item) {
MediaRename* mr = new MediaRename(item, "idk");
undo_stack.push(mr);
editing_item = NULL;
}
}
+36 -35
View File
@@ -9,60 +9,61 @@
SourceIconView::SourceIconView(QWidget *parent) : QListView(parent) {
setSelectionMode(QAbstractItemView::ExtendedSelection);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(item_click(const QModelIndex&)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu()));
setResizeMode(QListView::Adjust);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(item_click(const QModelIndex&)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu()));
}
void SourceIconView::show_context_menu() {
project_parent->sources_common->show_context_menu(this, selectedIndexes());
project_parent->sources_common->show_context_menu(this, selectedIndexes());
}
void SourceIconView::item_click(const QModelIndex& index) {
if (selectionModel()->selectedRows().size() == 1 && index.column() == 0) {
project_parent->sources_common->item_click(project_parent->item_to_media(index), index);
}
if (selectedIndexes().size() == 1 && index.column() == 0) {
project_parent->sources_common->item_click(project_parent->item_to_media(index), index);
}
}
void SourceIconView::mousePressEvent(QMouseEvent* event) {
project_parent->sources_common->mousePressEvent(event);
if (!indexAt(event->pos()).isValid()) selectionModel()->clear();
QListView::mousePressEvent(event);
project_parent->sources_common->mousePressEvent(event);
if (!indexAt(event->pos()).isValid()) selectionModel()->clear();
QListView::mousePressEvent(event);
}
void SourceIconView::dragEnterEvent(QDragEnterEvent *event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
} else {
QListView::dragEnterEvent(event);
}
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
} else {
QListView::dragEnterEvent(event);
}
}
void SourceIconView::dragMoveEvent(QDragMoveEvent *event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
} else {
QListView::dragMoveEvent(event);
}
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
} else {
QListView::dragMoveEvent(event);
}
}
void SourceIconView::dropEvent(QDropEvent* event) {
QModelIndex drop_item = indexAt(event->pos());
if (!drop_item.isValid()) drop_item = rootIndex();
project_parent->sources_common->dropEvent(this, event, drop_item, selectedIndexes());
QModelIndex drop_item = indexAt(event->pos());
if (!drop_item.isValid()) drop_item = rootIndex();
project_parent->sources_common->dropEvent(this, event, drop_item, selectedIndexes());
}
void SourceIconView::mouseDoubleClickEvent(QMouseEvent *event) {
bool default_behavior = true;
if (selectedIndexes().size() == 1) {
Media* m = project_parent->item_to_media(selectedIndexes().at(0));
if (m->get_type() == MEDIA_TYPE_FOLDER) {
default_behavior = false;
setRootIndex(selectedIndexes().at(0));
emit changed_root();
}
}
if (default_behavior) {
project_parent->sources_common->mouseDoubleClickEvent(event, selectedIndexes());
}
bool default_behavior = true;
if (selectedIndexes().size() == 1) {
Media* m = project_parent->item_to_media(selectedIndexes().at(0));
if (m->get_type() == MEDIA_TYPE_FOLDER) {
default_behavior = false;
setRootIndex(selectedIndexes().at(0));
emit changed_root();
}
}
if (default_behavior) {
project_parent->sources_common->mouseDoubleClickEvent(event, selectedIndexes());
}
}
+25 -21
View File
@@ -27,47 +27,51 @@
SourceTable::SourceTable(QWidget* parent) : QTreeView(parent) {
setSortingEnabled(true);
sortByColumn(0, Qt::AscendingOrder);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(item_click(const QModelIndex&)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu()));
setAcceptDrops(true);
sortByColumn(0, Qt::AscendingOrder);
setContextMenuPolicy(Qt::CustomContextMenu);
setEditTriggers(QAbstractItemView::NoEditTriggers);
setDragDropMode(QAbstractItemView::DragDrop);
setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(item_click(const QModelIndex&)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu()));
}
void SourceTable::show_context_menu() {
project_parent->sources_common->show_context_menu(this, selectionModel()->selectedRows());
project_parent->sources_common->show_context_menu(this, selectionModel()->selectedRows());
}
void SourceTable::item_click(const QModelIndex& index) {
if (selectionModel()->selectedRows().size() == 1 && index.column() == 0) {
project_parent->sources_common->item_click(project_parent->item_to_media(index), index);
}
if (selectionModel()->selectedRows().size() == 1 && index.column() == 0) {
project_parent->sources_common->item_click(project_parent->item_to_media(index), index);
}
}
void SourceTable::mousePressEvent(QMouseEvent* event) {
project_parent->sources_common->mousePressEvent(event);
QTreeView::mousePressEvent(event);
project_parent->sources_common->mousePressEvent(event);
QTreeView::mousePressEvent(event);
}
void SourceTable::mouseDoubleClickEvent(QMouseEvent* event) {
project_parent->sources_common->mouseDoubleClickEvent(event, selectionModel()->selectedRows());
project_parent->sources_common->mouseDoubleClickEvent(event, selectionModel()->selectedRows());
}
void SourceTable::dragEnterEvent(QDragEnterEvent *event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
} else {
QTreeView::dragEnterEvent(event);
}
event->acceptProposedAction();
} else {
QTreeView::dragEnterEvent(event);
}
}
void SourceTable::dragMoveEvent(QDragMoveEvent *event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
} else {
QTreeView::dragMoveEvent(event);
}
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
} else {
QTreeView::dragMoveEvent(event);
}
}
void SourceTable::dropEvent(QDropEvent* event) {
project_parent->sources_common->dropEvent(this, event, indexAt(event->pos()), selectionModel()->selectedRows());
project_parent->sources_common->dropEvent(this, event, indexAt(event->pos()), selectionModel()->selectedRows());
}
+1257 -1259
View File
File diff suppressed because it is too large Load Diff