[import] Update file content overview after file type change
ClosedPublic

Authored by croick on Jul 31 2018, 7:12 PM.

Details

Summary
  • just like in fileNameChanged() call updateContent() in fileTypeChanged() if necessary
  • put those calls in an extra function
Test Plan
  • select an HDF5, NETCDF or ROOT file in the file importer
  • choose a different file type
  • switch back to the right file type

Diff Detail

Repository
R262 LabPlot
Branch
updateafterfiletype
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 1415
Build 1433: arc lint + arc unit
croick created this revision.Jul 31 2018, 7:12 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptJul 31 2018, 7:12 PM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
croick requested review of this revision.Jul 31 2018, 7:12 PM
asemke added a subscriber: asemke.Jul 31 2018, 7:28 PM
asemke added inline comments.
src/kdefrontend/datasources/ImportFileWidget.cpp
624

const QString& fileName

773

const QString& fileName

843

const QString& name

src/kdefrontend/datasources/ImportFileWidget.h
111

should this really be a slot?

croick updated this revision to Diff 38875.Jul 31 2018, 8:10 PM
croick edited the summary of this revision. (Show Details)
  • fix reference and constness
croick updated this revision to Diff 38876.Jul 31 2018, 8:13 PM
  • one more const
croick marked 3 inline comments as done.Jul 31 2018, 8:15 PM
croick added inline comments.
src/kdefrontend/datasources/ImportFileWidget.cpp
624

You meant const QString fileName, right?

773

You meant const QString fileName, right?

843

Cannot make it const, it's modified later on.

src/kdefrontend/datasources/ImportFileWidget.h
111

No, but there were only slots so far (also unconnected).

fkristof added inline comments.
src/kdefrontend/datasources/ImportFileWidget.cpp
612

Remove space

( !fileName.isEmpty()
612

I'd say it would be safer to have 2 separate ifs, even if we know that the order is left to right, if somebody changes/adds here something and the fileName.at(0) will be before the isEmpty() then there will be a crash.

if (!fileName.isEmpty()) {
       if (fileName.at(0) != QDir::separator()) {
1106

AbstractFileFilter::FileType fileType

asemke added inline comments.Aug 1 2018, 5:10 PM
src/kdefrontend/datasources/ImportFileWidget.cpp
612

This part Christoph copied simply from another place... This logic we have in many places in the code where we striclty rely on the fixed ordering of the evaluation which has also to be guaranteed by the compiler. Many people are used to this and I think this is ok...

624

I meant const reference. Though the difference with respect to the performance between copying an object and creating a reference to it might be very small for implicitly shared Qt classes (QString is implicitely shared), it's still matter of convention and of code styly. With const QString& you _explicitly_ say I do not want to copy and I'm not going to change the reference - this is what we try to consistenly use throughout the code.

843

ok.

src/kdefrontend/datasources/ImportFileWidget.h
111

Ok. We should clean up here a bit maybe later and make private functions. Thanks for the pointer.

croick updated this revision to Diff 38919.Aug 1 2018, 8:49 PM
croick marked 3 inline comments as done.
  • remove leading whitespace
croick marked an inline comment as done.Aug 1 2018, 9:06 PM
croick added inline comments.
src/kdefrontend/datasources/ImportFileWidget.cpp
612

I agree with Alexander. What's actually bothering me here, is the assumption that a relative path is supposed to be relative to the home folder. Maybe there is some reason for this, but it seems weird at least.

624

I agree that arguments should be passed by reference, not by value, but I cannot have a const reference to a temporary object. The object it is referring to (fileName in absolutePath() or just the temporary return value) would be deleted once the function returns.

1106

fileTypeChanged() gets the fileType as int. I would have to explicitly cast this to AbstractFileFilter::FileType for the call of updateContent(). I thought I should stick to the current code, but I can change it, if you think that it is important.

asemke added inline comments.
src/kdefrontend/datasources/ImportFileWidget.cpp
612

Let's decouple this problem from your patch that is fixing another problem. Let's finalize your patch and submitt it. Maybe @sgerlach can have another look at this piece of code where already another FIXME is placed.

624

Ok. This is a valid point. I forgot that we are having here a new function.

1106

Let's cast this to the enum value like we do this in ImportFileWidget::fileNameChanged() already and in all other widgets where we cast from integers coming from the comboboxes to the internal enum values, also in order to benefit from the compiler checks for the missing switch-cases. The current code in fileTypeChanged() is not good in this respect, yes. So, if it's not a big issue for you, let's clean up here in your patch.

croick updated this revision to Diff 38974.Aug 2 2018, 7:38 PM
  • explicitly use AbstractFileFilter::FileType
croick marked 2 inline comments as done.Aug 2 2018, 7:41 PM
croick added inline comments.
src/kdefrontend/datasources/ImportFileWidget.cpp
612

Actually it was me putting the FIXME there.

asemke accepted this revision.Aug 3 2018, 12:03 PM
This revision is now accepted and ready to land.Aug 3 2018, 12:03 PM
This revision was automatically updated to reflect the committed changes.