some refactoring work
This commit is contained in:
+12
-12
@@ -432,10 +432,10 @@ void Project::new_folder() {
|
||||
|
||||
QModelIndex index = olive::project_model.create_index(m->row(), 0, m);
|
||||
switch (olive::CurrentConfig.project_view_type) {
|
||||
case PROJECT_VIEW_TREE:
|
||||
case olive::PROJECT_VIEW_TREE:
|
||||
tree_view->edit(sorter->mapFromSource(index));
|
||||
break;
|
||||
case PROJECT_VIEW_ICON:
|
||||
case olive::PROJECT_VIEW_ICON:
|
||||
icon_view->edit(sorter->mapFromSource(index));
|
||||
break;
|
||||
}
|
||||
@@ -871,7 +871,7 @@ bool Project::reveal_media(Media *media, QModelIndex parent) {
|
||||
// retrieve its parent item
|
||||
QModelIndex hierarchy = sorted_index.parent();
|
||||
|
||||
if (olive::CurrentConfig.project_view_type == PROJECT_VIEW_TREE) {
|
||||
if (olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_TREE) {
|
||||
|
||||
// if we're in tree view, expand every folder in the hierarchy containing the media
|
||||
while (hierarchy.isValid()) {
|
||||
@@ -886,7 +886,7 @@ bool Project::reveal_media(Media *media, QModelIndex parent) {
|
||||
);
|
||||
|
||||
tree_view->selectionModel()->select(row_select, QItemSelectionModel::Select);
|
||||
} else if (olive::CurrentConfig.project_view_type == PROJECT_VIEW_ICON) {
|
||||
} else if (olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_ICON) {
|
||||
|
||||
// if we're in icon view, we just "browse" to the parent folder
|
||||
icon_view->setRootIndex(hierarchy);
|
||||
@@ -1206,7 +1206,7 @@ void Project::save_project(bool autorecovery) {
|
||||
|
||||
stream.writeStartElement("project"); // project
|
||||
|
||||
stream.writeTextElement("version", QString::number(SAVE_VERSION));
|
||||
stream.writeTextElement("version", QString::number(olive::kSaveVersion));
|
||||
|
||||
stream.writeTextElement("url", olive::ActiveProjectFilename);
|
||||
proj_dir = QFileInfo(olive::ActiveProjectFilename).absoluteDir();
|
||||
@@ -1240,26 +1240,26 @@ void Project::save_project(bool autorecovery) {
|
||||
}
|
||||
|
||||
void Project::update_view_type() {
|
||||
tree_view->setVisible(olive::CurrentConfig.project_view_type == PROJECT_VIEW_TREE);
|
||||
icon_view_container->setVisible(olive::CurrentConfig.project_view_type == PROJECT_VIEW_ICON);
|
||||
tree_view->setVisible(olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_TREE);
|
||||
icon_view_container->setVisible(olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_ICON);
|
||||
|
||||
switch (olive::CurrentConfig.project_view_type) {
|
||||
case PROJECT_VIEW_TREE:
|
||||
case olive::PROJECT_VIEW_TREE:
|
||||
sources_common->view = tree_view;
|
||||
break;
|
||||
case PROJECT_VIEW_ICON:
|
||||
case olive::PROJECT_VIEW_ICON:
|
||||
sources_common->view = icon_view;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Project::set_icon_view() {
|
||||
olive::CurrentConfig.project_view_type = PROJECT_VIEW_ICON;
|
||||
olive::CurrentConfig.project_view_type = olive::PROJECT_VIEW_ICON;
|
||||
update_view_type();
|
||||
}
|
||||
|
||||
void Project::set_tree_view() {
|
||||
olive::CurrentConfig.project_view_type = PROJECT_VIEW_TREE;
|
||||
olive::CurrentConfig.project_view_type = olive::PROJECT_VIEW_TREE;
|
||||
update_view_type();
|
||||
}
|
||||
|
||||
@@ -1343,7 +1343,7 @@ QVector<Media*> Project::list_all_project_sequences() {
|
||||
}
|
||||
|
||||
QModelIndexList Project::get_current_selected() {
|
||||
if (olive::CurrentConfig.project_view_type == PROJECT_VIEW_TREE) {
|
||||
if (olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_TREE) {
|
||||
return tree_view->selectionModel()->selectedRows();
|
||||
}
|
||||
return icon_view->selectionModel()->selectedIndexes();
|
||||
|
||||
+2
-2
@@ -502,13 +502,13 @@ void Timeline::repaint_timeline() {
|
||||
&& panel_sequence_viewer->playing
|
||||
&& !zoom_just_changed) {
|
||||
// auto scroll
|
||||
if (olive::CurrentConfig.autoscroll == AUTOSCROLL_PAGE_SCROLL) {
|
||||
if (olive::CurrentConfig.autoscroll == olive::AUTOSCROLL_PAGE_SCROLL) {
|
||||
int playhead_x = getTimelineScreenPointFromFrame(olive::ActiveSequence->playhead);
|
||||
if (playhead_x < 0 || playhead_x > (editAreas->width() - videoScrollbar->width())) {
|
||||
horizontalScrollBar->setValue(getScreenPointFromFrame(zoom, olive::ActiveSequence->playhead));
|
||||
draw = false;
|
||||
}
|
||||
} else if (olive::CurrentConfig.autoscroll == AUTOSCROLL_SMOOTH_SCROLL) {
|
||||
} else if (olive::CurrentConfig.autoscroll == olive::AUTOSCROLL_SMOOTH_SCROLL) {
|
||||
if (center_scroll_to_playhead(horizontalScrollBar, zoom, olive::ActiveSequence->playhead)) {
|
||||
draw = false;
|
||||
}
|
||||
|
||||
+16
-16
@@ -144,14 +144,14 @@ void Viewer::reset_all_audio() {
|
||||
long timecode_to_frame(const QString& s, int view, double frame_rate) {
|
||||
QList<QString> list = s.split(QRegExp("[:;]"));
|
||||
|
||||
if (view == TIMECODE_FRAMES || (list.size() == 1 && view != TIMECODE_MILLISECONDS)) {
|
||||
if (view == olive::kTimecodeFrames || (list.size() == 1 && view != olive::kTimecodeMilliseconds)) {
|
||||
return s.toLong();
|
||||
}
|
||||
|
||||
int frRound = qRound(frame_rate);
|
||||
int hours, minutes, seconds, frames;
|
||||
|
||||
if (view == TIMECODE_MILLISECONDS) {
|
||||
if (view == olive::kTimecodeMilliseconds) {
|
||||
long milliseconds = s.toLong();
|
||||
|
||||
hours = milliseconds/3600000;
|
||||
@@ -174,14 +174,14 @@ long timecode_to_frame(const QString& s, int view, double frame_rate) {
|
||||
|
||||
int f = (frames + seconds + minutes + hours);
|
||||
|
||||
if ((view == TIMECODE_DROP || view == TIMECODE_MILLISECONDS) && frame_rate_is_droppable(frame_rate)) {
|
||||
if ((view == olive::kTimecodeDrop || view == olive::kTimecodeMilliseconds) && frame_rate_is_droppable(frame_rate)) {
|
||||
// return drop
|
||||
int d;
|
||||
int m;
|
||||
|
||||
int dropFrames = round(frame_rate * .066666); //Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
|
||||
int framesPer10Minutes = round(frame_rate * 60 * 10); //Number of frames per ten minutes
|
||||
int framesPerMinute = (round(frame_rate)*60)- dropFrames; //Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
|
||||
int dropFrames = qRound(frame_rate * .066666); //Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
|
||||
int framesPer10Minutes = qRound(frame_rate * 60 * 10); //Number of frames per ten minutes
|
||||
int framesPerMinute = (qRound(frame_rate)*60)- dropFrames; //Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
|
||||
|
||||
d = f / framesPer10Minutes;
|
||||
f -= dropFrames*9*d;
|
||||
@@ -198,7 +198,7 @@ long timecode_to_frame(const QString& s, int view, double frame_rate) {
|
||||
}
|
||||
|
||||
QString frame_to_timecode(long f, int view, double frame_rate) {
|
||||
if (view == TIMECODE_FRAMES) {
|
||||
if (view == olive::kTimecodeFrames) {
|
||||
return QString::number(f);
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ QString frame_to_timecode(long f, int view, double frame_rate) {
|
||||
int frames = 0;
|
||||
QString token = ":";
|
||||
|
||||
if ((view == TIMECODE_DROP || view == TIMECODE_MILLISECONDS) && frame_rate_is_droppable(frame_rate)) {
|
||||
if ((view == olive::kTimecodeDrop || view == olive::kTimecodeMilliseconds) && frame_rate_is_droppable(frame_rate)) {
|
||||
//CONVERT A FRAME NUMBER TO DROP FRAME TIMECODE
|
||||
//Code by David Heidelberger, adapted from Andrew Duncan, further adapted for Olive by Olive Team
|
||||
//Given an int called framenumber and a double called framerate
|
||||
@@ -218,11 +218,11 @@ QString frame_to_timecode(long f, int view, double frame_rate) {
|
||||
int d;
|
||||
int m;
|
||||
|
||||
int dropFrames = round(frame_rate * .066666); //Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
|
||||
int framesPerHour = round(frame_rate*60*60); //Number of frqRound64ames in an hour
|
||||
int dropFrames = qRound(frame_rate * .066666); //Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
|
||||
int framesPerHour = qRound(frame_rate*60*60); //Number of frqRound64ames in an hour
|
||||
int framesPer24Hours = framesPerHour*24; //Number of frames in a day - timecode rolls over after 24 hours
|
||||
int framesPer10Minutes = round(frame_rate * 60 * 10); //Number of frames per ten minutes
|
||||
int framesPerMinute = (round(frame_rate)*60)- dropFrames; //Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
|
||||
int framesPer10Minutes = qRound(frame_rate * 60 * 10); //Number of frames per ten minutes
|
||||
int framesPerMinute = (qRound(frame_rate)*60)- dropFrames; //Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
|
||||
|
||||
//If framenumber is greater than 24 hrs, next operation will rollover clock
|
||||
f = f % framesPer24Hours; //% is the modulus operator, which returns a remainder. a % b = the remainder of a/b
|
||||
@@ -237,7 +237,7 @@ QString frame_to_timecode(long f, int view, double frame_rate) {
|
||||
f = f + dropFrames*9*d;
|
||||
}
|
||||
|
||||
int frRound = round(frame_rate);
|
||||
int frRound = qRound(frame_rate);
|
||||
frames = f % frRound;
|
||||
secs = (f / frRound) % 60;
|
||||
mins = ((f / frRound) / 60) % 60;
|
||||
@@ -253,7 +253,7 @@ QString frame_to_timecode(long f, int view, double frame_rate) {
|
||||
secs = f/int_fps % 60;
|
||||
frames = f%int_fps;
|
||||
}
|
||||
if (view == TIMECODE_MILLISECONDS) {
|
||||
if (view == olive::kTimecodeMilliseconds) {
|
||||
return QString::number((hours*3600000)+(mins*60000)+(secs*1000)+qCeil(frames*1000/frame_rate));
|
||||
}
|
||||
return QString(QString::number(hours).rightJustified(2, '0') +
|
||||
@@ -263,8 +263,8 @@ QString frame_to_timecode(long f, int view, double frame_rate) {
|
||||
);
|
||||
}
|
||||
|
||||
bool frame_rate_is_droppable(float rate) {
|
||||
return (qFuzzyCompare(rate, 23.976f) || qFuzzyCompare(rate, 29.97f) || qFuzzyCompare(rate, 59.94f));
|
||||
bool frame_rate_is_droppable(double rate) {
|
||||
return (qFuzzyCompare(rate, 23.976) || qFuzzyCompare(rate, 29.97) || qFuzzyCompare(rate, 59.94));
|
||||
}
|
||||
|
||||
void Viewer::seek(long p) {
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
#include "ui/labelslider.h"
|
||||
#include "ui/resizablescrollbar.h"
|
||||
|
||||
bool frame_rate_is_droppable(float rate);
|
||||
bool frame_rate_is_droppable(double rate);
|
||||
long timecode_to_frame(const QString& s, int view, double frame_rate);
|
||||
QString frame_to_timecode(long f, int view, double frame_rate);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user