Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording: fix table refresh issues #4648

Merged
merged 8 commits into from
Feb 2, 2022
6 changes: 3 additions & 3 deletions src/library/browse/browsetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ void BrowseTableModel::addSearchColumn(int index) {
}

void BrowseTableModel::setPath(mixxx::FileAccess path) {
if (path.info().hasLocation()) {
m_currentDirectory = path.info().locationPath();
if (path.info().hasLocation() && path.info().isDir()) {
m_currentDirectory = path.info().location();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that location() does not strip a trailing slash. Is this new behaviour desired?
I have hacked up a test to verify this:
https://github.com/daschuer/mixxx/blob/2114f3e34122b195bde868e2a3355f9626324bf6/src/test/fileinfo_test.cpp#L62

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, intended:

Since locationPath() was chosen only to remove the trailing / from the paths passed by the BrowseFeature to have a 'clean' model key, and working around the sideeffect caused by the Rec path (no trailing /)...
I changed setPath() to use the entire path location (with /) for the model key and avoid the Rec issue in the first place:

} else {
m_currentDirectory = QString();
}
Expand Down Expand Up @@ -364,8 +364,8 @@ void BrowseTableModel::slotInsert(const QList<QList<QStandardItem*>>& rows,
for (int i = 0; i < rows.size(); ++i) {
appendRow(rows.at(i));
}
emit restoreModelState();
}
emit restoreModelState();
}

TrackModel::Capabilities BrowseTableModel::getCapabilities() const {
Expand Down
7 changes: 4 additions & 3 deletions src/library/browse/browsethread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,13 @@ void BrowseThread::populateModel() {
if (row % 10 == 0) {
// this is a blocking operation
emit rowsAppended(rows, thisModelObserver);
qDebug() << "Append " << rows.count() << " from " << fileAccess.info();
qDebug() << "Append" << rows.count() << "tracks from "
<< thisPath.info().locationPath();
rows.clear();
}
// Sleep additionally for 10ms which prevents us from GUI freezes
// Sleep additionally for 20ms which prevents us from GUI freezes
msleep(20);
}
emit rowsAppended(rows, thisModelObserver);
qDebug() << "Append last " << rows.count();
qDebug() << "Append last" << rows.count() << "tracks from" << thisPath.info().locationPath();
}
15 changes: 5 additions & 10 deletions src/library/recording/dlgrecording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ DlgRecording::DlgRecording(
box->insertWidget(1, m_pTrackTableView);
}

m_recordingDir = m_pRecordingManager->getRecordingDir();

m_proxyModel.setFilterCaseSensitivity(Qt::CaseInsensitive);
m_proxyModel.setSortCaseSensitivity(Qt::CaseInsensitive);

m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo(m_recordingDir)));
refreshBrowseModel();
m_pTrackTableView->loadTrackModel(&m_proxyModel);

connect(pushButtonRecording,
Expand All @@ -106,11 +104,6 @@ DlgRecording::DlgRecording(
DlgRecording::~DlgRecording() {
}

void DlgRecording::onShow() {
m_recordingDir = m_pRecordingManager->getRecordingDir();
m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo(m_recordingDir)));
}

bool DlgRecording::hasFocus() const {
return m_pTrackTableView->hasFocus();
}
Expand All @@ -120,7 +113,9 @@ void DlgRecording::setFocus() {
}

void DlgRecording::refreshBrowseModel() {
m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo(m_recordingDir)));
saveCurrentViewState();
QString recordingDir = m_pRecordingManager->getRecordingDir();
m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo(recordingDir)));
}

void DlgRecording::onSearch(const QString& text) {
Expand Down Expand Up @@ -175,7 +170,7 @@ void DlgRecording::slotRecordingStateChanged(bool isRecording) {
labelRecStatistics->hide();
}
//This will update the recorded track table view
m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo(m_recordingDir)));
refreshBrowseModel();
}

// gets number of recorded bytes and update label
Expand Down
3 changes: 1 addition & 2 deletions src/library/recording/dlgrecording.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DlgRecording : public QWidget, public Ui::DlgRecording, public virtual Lib
~DlgRecording() override;

void onSearch(const QString& text) override;
void onShow() override;
void onShow() override{};
bool hasFocus() const override;
void setFocus() override;
void loadSelectedTrack() override;
Expand Down Expand Up @@ -55,7 +55,6 @@ class DlgRecording : public QWidget, public Ui::DlgRecording, public virtual Lib
WTrackTableView* m_pTrackTableView;
BrowseTableModel m_browseModel;
ProxyTrackModel m_proxyModel;
QString m_recordingDir;

void refreshLabels();
void slotRecButtonClicked(bool checked);
Expand Down
2 changes: 1 addition & 1 deletion src/library/recording/recordingfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ QVariant RecordingFeature::title() {
TreeItemModel* RecordingFeature::sidebarModel() const {
return m_pSidebarModel;
}

void RecordingFeature::bindLibraryWidget(WLibrary* pLibraryWidget,
KeyboardEventFilter *keyboard) {
//The view will be deleted by LibraryWidget
Expand Down Expand Up @@ -67,7 +68,6 @@ void RecordingFeature::bindLibraryWidget(WLibrary* pLibraryWidget,
&RecordingFeature::restoreModelState);
}


void RecordingFeature::activate() {
emit refreshBrowseModel();
emit switchToView(kViewName);
Expand Down
73 changes: 33 additions & 40 deletions src/recording/recordingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ qint64 RecordingManager::getFreeSpace() {
// returns the free space on the recording location in bytes
// return -1 if the free space could not be determined
qint64 rv = -1;
QStorageInfo storage(getRecordingDir());
QStorageInfo storage(m_recordingDir);
if (storage.isValid()) {
rv = storage.bytesAvailable();
}
Expand Down Expand Up @@ -168,8 +168,7 @@ void RecordingManager::splitContinueRecording()
m_recReady->set(RECORD_SPLIT_CONTINUE);
}

void RecordingManager::stopRecording()
{
void RecordingManager::stopRecording() {
qDebug() << "Recording stopped";
m_recReady->set(RECORD_OFF);
m_recordingFile = "";
Expand Down Expand Up @@ -201,20 +200,18 @@ QString& RecordingManager::getRecordingDir() {
}

// Only called when recording is active.
void RecordingManager::slotDurationRecorded(quint64 duration)
{
if(m_secondsRecordedSplit != duration)
{
void RecordingManager::slotDurationRecorded(quint64 duration) {
if (m_secondsRecordedSplit != duration) {
m_secondsRecordedSplit = duration;
if(duration >= m_split_time)
{
if (duration >= m_split_time) {
qDebug() << "Splitting after " << duration << " seconds";
// This will reuse the previous filename but append a suffix.
splitContinueRecording();
}
emit durationRecorded(getRecordedDurationStr(m_secondsRecorded+m_secondsRecordedSplit));
}
}

// Copy from the implementation in enginerecord.cpp
QString RecordingManager::getRecordedDurationStr(unsigned int duration) {
return QString("%1:%2")
Expand All @@ -223,17 +220,15 @@ QString RecordingManager::getRecordedDurationStr(unsigned int duration) {
}

// Only called when recording is active.
void RecordingManager::slotBytesRecorded(int bytes)
{
void RecordingManager::slotBytesRecorded(int bytes) {
// auto conversion to quint64
m_iNumberOfBytesRecorded += bytes;
m_iNumberOfBytesRecordedSplit += bytes;

//Split before reaching the max size. m_split_size has some headroom, as
//seen in the constant definitions in defs_recording.h. Also, note that
//bytes are increased in the order of 10s of KBs each call.
if(m_iNumberOfBytesRecordedSplit >= m_split_size)
{
if (m_iNumberOfBytesRecordedSplit >= m_split_size) {
qDebug() << "Splitting after " << m_iNumberOfBytesRecorded << " bytes written";
// This will reuse the previous filename but append a suffix.
splitContinueRecording();
Expand Down Expand Up @@ -314,34 +309,32 @@ const QString& RecordingManager::getRecordingLocation() const {
return m_recordingLocation;
}


quint64 RecordingManager::getFileSplitSize()
{
QString fileSizeStr = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "FileSize"));
if (fileSizeStr == SPLIT_650MB) {
return SIZE_650MB;
} else if (fileSizeStr == SPLIT_700MB) {
return SIZE_700MB;
} else if (fileSizeStr == SPLIT_1024MB) {
return SIZE_1GB;
} else if (fileSizeStr == SPLIT_2048MB) {
return SIZE_2GB;
} else if (fileSizeStr == SPLIT_4096MB) {
return SIZE_4GB;
} else if (fileSizeStr == SPLIT_60MIN) {
return SIZE_4GB; //Ignore size limit. use time limit
} else if (fileSizeStr == SPLIT_74MIN) {
return SIZE_4GB; //Ignore size limit. use time limit
} else if (fileSizeStr == SPLIT_80MIN) {
return SIZE_4GB; //Ignore size limit. use time limit
} else if (fileSizeStr == SPLIT_120MIN) {
return SIZE_4GB; //Ignore size limit. use time limit
} else {
return SIZE_650MB;
}
quint64 RecordingManager::getFileSplitSize() {
QString fileSizeStr = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "FileSize"));
if (fileSizeStr == SPLIT_650MB) {
return SIZE_650MB;
} else if (fileSizeStr == SPLIT_700MB) {
return SIZE_700MB;
} else if (fileSizeStr == SPLIT_1024MB) {
return SIZE_1GB;
} else if (fileSizeStr == SPLIT_2048MB) {
return SIZE_2GB;
} else if (fileSizeStr == SPLIT_4096MB) {
return SIZE_4GB;
} else if (fileSizeStr == SPLIT_60MIN) {
return SIZE_4GB; //Ignore size limit. use time limit
} else if (fileSizeStr == SPLIT_74MIN) {
return SIZE_4GB; //Ignore size limit. use time limit
} else if (fileSizeStr == SPLIT_80MIN) {
return SIZE_4GB; //Ignore size limit. use time limit
} else if (fileSizeStr == SPLIT_120MIN) {
return SIZE_4GB; //Ignore size limit. use time limit
} else {
return SIZE_650MB;
}
}
unsigned int RecordingManager::getFileSplitSeconds()
{

unsigned int RecordingManager::getFileSplitSeconds() {
QString fileSizeStr = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "FileSize"));
if (fileSizeStr == SPLIT_60MIN) {
return 60*60;
Expand Down