Changeset View
Standalone View
krusader/GUI/krhistorcombobox.h
- This file was added.
1 | /***************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2018 Shie Erlich <krusader@users.sourceforge.net> * | ||||
3 | * Copyright (C) 2018 Rafi Yanai <krusader@users.sourceforge.net> * | ||||
4 | * Copyright (C) 2018 Krusader Krew [https://krusader.org] * | ||||
5 | * * | ||||
6 | * This file is part of Krusader [https://krusader.org]. * | ||||
7 | * * | ||||
8 | * Krusader is free software: you can redistribute it and/or modify * | ||||
9 | * it under the terms of the GNU General Public License as published by * | ||||
10 | * the Free Software Foundation, either version 2 of the License, or * | ||||
11 | * (at your option) any later version. * | ||||
12 | * * | ||||
13 | * Krusader is distributed in the hope that it will be useful, * | ||||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
16 | * GNU General Public License for more details. * | ||||
17 | * * | ||||
18 | * You should have received a copy of the GNU General Public License * | ||||
19 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||||
20 | *****************************************************************************/ | ||||
21 | | ||||
22 | #ifndef KRHISTORCOMBOBOX_H | ||||
23 | #define KRHISTORCOMBOBOX_H | ||||
24 | | ||||
25 | #include <KCompletion/KHistoryComboBox> | ||||
26 | | ||||
27 | /*! A KrHistorComboBox event filter that e.g. deletes the current item when the user presses Shift+Del | ||||
28 | | ||||
abika: Please use
```
/**
* ...
*/
```
comments everywhere like e.g. in the KF5 libraries. No text… | |||||
I didn't find it in https://phabricator.kde.org/w/krusader/ -> https://techbase.kde.org/Policies/Frameworks_Coding_Style
I found that they use "/*!" in the source code of Qt: https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qcoreapplication.cpp asensi: I didn't find it in https://phabricator.kde.org/w/krusader/ -> https://techbase.kde. | |||||
I just think we should try to stick to one kind of comments and "/** ... */" is imho best for most cases. abika: I just think we should try to stick to one kind of comments and "/** ... */" is imho best for… | |||||
29 | There was more information in http://doc.qt.io/qt-5/qobject.html#installEventFilter, https://forum.qt.io/post/160618 | ||||
30 | and https://stackoverflow.com/questions/17820947/remove-items-from-qcombobox-from-ui/52459337#52459337 | ||||
31 | */ | ||||
Stackoverflow has shorter "Share" links - https://stackoverflow.com/a/52459337/6286694 abika: Stackoverflow has shorter "Share" links - https://stackoverflow.com/a/52459337/6286694 | |||||
That type of address helps me to avoid confusions (e.g. writing the address of another answer, that mistake would be immediately seen because the subject is visible in the address). asensi: That type of address helps me to avoid confusions (e.g. writing the address of another answer… | |||||
This is also about link stability: The share links are less likely to change over time and point to unreachable pages. abika: This is also about link stability: The share links are less likely to change over time and… | |||||
32 | class KHBoxEventFilter : public QObject | ||||
33 | { | ||||
abika: Please move the class to the cpp file. | |||||
In that case this message is seen when compiling: error: ‘KHBoxEventFilter’ does not name a type KHBoxEventFilter boxEventFilter; ^~~~~~~~~~~~~~~~ and if, additionally, a class KHBoxEventFilter; line is added to the .h file then field ‘boxEventFilter’ has incomplete type ‘KHBoxEventFilter’ KHBoxEventFilter boxEventFilter; ^~~~~ but perhaps it was meant another thing with "Please move the class to the cpp file" :-? asensi: In that case this message is seen when compiling:
error: ‘KHBoxEventFilter’ does not name a… | |||||
abika: true. But it should be possible when removing these fields. See below. | |||||
34 | Q_OBJECT | ||||
35 | | ||||
36 | public: | ||||
37 | explicit KHBoxEventFilter(QObject *parent = nullptr) : QObject(parent) {} | ||||
38 | | ||||
39 | protected: | ||||
40 | bool eventFilter(QObject *obj, QEvent *event) override; | ||||
41 | }; | ||||
42 | | ||||
43 | //! An event filter for the popup list of a KrHistorComboBox, e.g. it deletes the current item when the user presses Shift+Del | ||||
44 | class KHBoxListEventFilter : public QObject | ||||
45 | { | ||||
abika: Please move the class to the cpp file. | |||||
46 | Q_OBJECT | ||||
47 | | ||||
48 | public: | ||||
49 | explicit KHBoxListEventFilter(QObject *parent = nullptr) : QObject(parent) {} | ||||
50 | | ||||
51 | protected: | ||||
52 | bool eventFilter(QObject *obj, QEvent *event) override; | ||||
53 | }; | ||||
54 | | ||||
55 | | ||||
56 | //! A specialized version of a KHistoryComboBox, e.g. it deletes the current item when the user presses Shift+Del | ||||
57 | class KrHistorComboBox : public KHistoryComboBox | ||||
58 | { | ||||
abika: Typo: KrHistor**y**ComboBox | |||||
I find that if the names of two classes are different only by one letter then misplacements (e.g. using one class instead of another) are more common. When two differences exist then those mistakes are caught much more frequently. And if the differences exist at the beginning (instead of at the end) then they are more clearly seen. asensi: I find that if the names of two classes are different only by one letter then misplacements (e. | |||||
Then please find a different name instead of leaving out characters. I mean when you write an essay you wouldn't omit characters in words only because the reader could mistake them for other, similar words. abika: Then please find a different name instead of leaving out characters.
I mean when you write an… | |||||
59 | Q_OBJECT | ||||
60 | | ||||
61 | public: | ||||
62 | explicit KrHistorComboBox(bool useCompletion, QWidget *parent = nullptr); | ||||
63 | | ||||
64 | protected: | ||||
65 | KHBoxEventFilter boxEF; | ||||
66 | KHBoxListEventFilter listEF; | ||||
abika: Full variable name:
`KHBoxEventFilter boxEventFilter;` | |||||
asensi: That's OK for me :-) | |||||
67 | }; | ||||
Full variable name here, too. abika: Full variable name here, too.
Wait, and why are these even fields? You can create the filters… | |||||
Event filters are needed after an object is constructed, e.g. in order to process what the user is typing. asensi: Event filters are needed after an object is constructed, e.g. in order to process what the user… | |||||
abika: create them as new objects. See below | |||||
68 | | ||||
69 | #endif // KRHISTORCOMBOBOX_H |
Please use
comments everywhere like e.g. in the KF5 libraries. No text on the first /** line.
And line break after 100 or 120 chars.