Port to new connect syntax
ClosedPublic

Authored by ngraham on May 22 2019, 8:11 PM.

Details

Test Plan
  • It compiles
  • Tested all functionality; everything works (well... at least everything that was working before is still working now :) )

Diff Detail

Repository
R432 File Sharing (Samba) integration
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ngraham requested review of this revision.May 22 2019, 8:11 PM
ngraham created this revision.
ngraham updated this revision to Diff 58513.May 22 2019, 8:13 PM

Remove extra space

aacid added a subscriber: aacid.May 22 2019, 9:04 PM
aacid added inline comments.
samba/filepropertiesplugin/delegate.h
41

why add the int if you're not going to use it?

bruns added a subscriber: bruns.May 22 2019, 10:18 PM
bruns added inline comments.
samba/filepropertiesplugin/delegate.cpp
46

use a lambda here:

  • avoids the single-use emitCommitData wrapper
  • avoids the need for qobject_cast<QWidget*>(sender()), which is the combobox (just capture it).
bruns added inline comments.May 22 2019, 10:30 PM
samba/filepropertiesplugin/sambausershareplugin.cpp
136

I think instead of emiting KFilePropertiesPlugin::changed() it would be better to call setDirty() in the slots.

See https://api.kde.org/frameworks/kio/html/classKPropertiesDialogPlugin.html#af25f4b84d915dcc005a203a637ad0511

ngraham added inline comments.May 22 2019, 10:45 PM
samba/filepropertiesplugin/delegate.cpp
46

I'd love to, and I tried, but this stuff is pretty new to me and I kept getting error: cannot define member function What's wrong with this?

connect(comboBox, &QComboBox::activated,
        [comboBox]() { emit commitData(comboBox); });
samba/filepropertiesplugin/delegate.h
41

QComboBox::activated passes an int argument along that as far as I can tell (I could be wrong) needs to be handled by the function it's connected to

bruns added inline comments.May 22 2019, 11:06 PM
samba/filepropertiesplugin/delegate.cpp
46

commitData is an inherited member function from QItemDelegate, i.e. you have to also capture this

aacid added inline comments.May 22 2019, 11:15 PM
samba/filepropertiesplugin/delegate.cpp
46

without having tried it, you probably still need the QOverload to say which activated version you want, so

connect(comboBox, QOverload<int>::of(&QComboBox::activated), this, [this, comboBox] { emit commitData(comboBox); });

samba/filepropertiesplugin/delegate.h
41

nah, the right hand side needs to be a subset of the left hand side (or be able to convert from one to another)

ngraham added inline comments.May 23 2019, 4:58 PM
samba/filepropertiesplugin/delegate.cpp
46

Nope, same issue I'm afraid.

bruns added inline comments.May 23 2019, 7:08 PM
samba/filepropertiesplugin/delegate.cpp
46

GCC 8.3.1 gives me a helpful error message:

...samba/filepropertiesplugin/delegate.cpp: In lambda function:
...samba/filepropertiesplugin/delegate.cpp:48:58: error: passing ‘const UserPermissionDelegate’ as ‘this’ argument discards qualifiers [-fpermissive]
         [this, comboBox] (int) { emit commitData(comboBox); }

this is const as createEditor(...) is const. Apparently connect discards the constness of this.

But reading through https://doc.qt.io/qt-5/qtwidgets-itemviews-spinboxdelegate-example.html , it seems like the connect is not needed at all. The selected value is propagated via setModelData.

Can you test if it still works when you remove the whole connect(...) here?

ngraham updated this revision to Diff 58568.May 24 2019, 4:05 AM

Address review comments

ngraham marked 10 inline comments as done.May 24 2019, 4:06 AM

Yep, totally works without that connect().

bruns added inline comments.May 24 2019, 8:02 AM
samba/filepropertiesplugin/sambausershareplugin.cpp
140

I meant - do setDirty() in e.g. checkShareName(), i.e. only one connection per signal.

ngraham updated this revision to Diff 58605.May 24 2019, 3:15 PM
ngraham marked an inline comment as done.

Don't double-connect

bruns added a comment.May 24 2019, 3:36 PM

LGTM

currently, GCC thows some "0 for nullptr" and "missing override" warnings, are you going to address these (new SR)?

Also, Qt recommends deriving from QStyledItemDelegate

LGTM

currently, GCC thows some "0 for nullptr" and "missing override" warnings, are you going to address these (new SR)?

Also, Qt recommends deriving from QStyledItemDelegate

Yeah there are a lot of warnings and more code cleanup needed, this is just the first of many. :)

This revision was not accepted when it landed; it landed in state Needs Review.May 24 2019, 3:42 PM
This revision was automatically updated to reflect the committed changes.