[Konsole-devel] About duplicated enumeration definitions in the code

Kurt Hindenburg kurt.hindenburg at gmail.com
Mon Mar 19 12:33:33 UTC 2012


On Mon, Mar 19, 2012 at 4:28 AM, Jekyll Wu <adaptee at gmail.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 于 2012年03月18日 21:08, Kurt Hindenburg 写道:
> > On Fri, Mar 16, 2012 at 11:52 PM, Jekyll Wu <adaptee at gmail.com>
> > wrote:
> >
> > Such duplication is definitely not good. What is the better way to
> > eliminate those duplication ?
> >
> > a). Make TerminalDisplay, HistorySizeDialog, etc all #inlucde
> > "Profile.h"
> >
> > b). Move those enum definition into another separate small
> > header(like Enumeration.h), and all other related files #include
> > "Enumeration.h"
> >
> > Hi,
> >> Definitely b - also can you look at using Qt QFlags if you find
> >> that useful.
>
> Hi:
>
> I have pushed a few commits for merging those enumeration definitions.
>
> I'm sure the result is still not good enough. Feel free to correct my
> stupid mistakes.
>
> Thanks for the suggestion, but I wonder whether you actually meant to
> say QMetaType.
>
> Hi,
  https://qt-project.org/doc/qt-4.8/QFlags.html

Kurt

There are still other related problems. For example, the following
> code does not look quite good:
>
> void ViewManager::applyProfileToView(...)
> {
>    ...
>    // set scroll-bar position
>    int scrollBarPosition =
> profile->property<int>(Profile::ScrollBarPosition);
>
>    if (scrollBarPosition == Enum::ScrollBarLeft)
>        view->setScrollBarPosition(Enum::ScrollBarLeft);
>    else if (scrollBarPosition == Enum::ScrollBarRight)
>        view->setScrollBarPosition(Enum::ScrollBarRight);
>    else if (scrollBarPosition == Enum::ScrollBarHidden)
>        view->setScrollBarPosition(Enum::ScrollBarHidden);
>
>    ....
> }
>
> problem 1: it is not type safety. if profile->property<int> returns
> a strange value(image use modifies the profile manually and sets a
> invalid number), the result would be strange.
>
> problem 2: I prefer to hide all those "profile->property<xxx>()"
> within class Profile itself.
>
> Regards
> Jekyll
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.18 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQIcBAEBAgAGBQJPZu4cAAoJEOemZ9znWXlAL6IP/2RIYS9hfF+rSPzHBzvaZGng
> tRL9NYSYQLG8zN4q5qTfZ/xKedEHUyuj81MWVVOB17my1KOfKBNwkSO5UG9UUnHI
> KI+fxw5ymBC2EheSQZvjeVcGdkSlCj7Yw7aVl1LaSdRknLFAmAc7Pd+UA2Ni8Qov
> TC5qNeKzxpctQTYEFHam+dRpoxu9cEqrX7Dvns7bet8xgU6rDC9gsFCyY5C7wXfz
> rKcAAMhRsEAxmtzcUaRYC6dyDihUIXn8YQMW5nFGYAfTPXJFKRjeCy6TCgeKU999
> Ooc+IS4qKC4/R0UC2y3TwkCh/cBG9fZ10TYx4uKhM+y/RhbmFlOIviBqx8mp8TNz
> o9s2r9jFMTHJYleQ9VpwKraHJkXieS2Cm8/RceOzmmzyFk2GE+GBZ539Ra7nMohE
> 1iXp85gKCpuZdKFFQp3CnbH0QVsmxrvDwBudYU4iwBvyFHvupBdijpJljTysBJ3A
> SG6epvJR6Fj+09MihhsPIIdcHhj6C6y2qzrSS8uBK+0eiJLoozMLWvUPUmmfR0ve
> /2d7hpRrSS406rJB1I6j7t+kPaU4rbFoHlhXHnO4q6GZ+vmGueXH4HqoflWIwtZB
> w9vFrLrketrhAeN39td+57zfo3ojuD8bXJTSKaB5U0xw0N52SPxYFVXRy+i9p1H6
> Vjgv81TD0R7LfiugTfG1
> =rqJd
> -----END PGP SIGNATURE-----
> _______________________________________________
> konsole-devel mailing list
> konsole-devel at kde.org
> https://mail.kde.org/mailman/listinfo/konsole-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/konsole-devel/attachments/20120319/2d46241f/attachment.html>


More information about the konsole-devel mailing list