Changeset View
Standalone View
plugins/standardoutputview/outputwidget.h
Show All 18 Lines | |||||
19 | * 02110-1301, USA. | 19 | * 02110-1301, USA. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #ifndef KDEVPLATFORM_PLUGIN_OUTPUTWIDGET_H | 22 | #ifndef KDEVPLATFORM_PLUGIN_OUTPUTWIDGET_H | ||
23 | #define KDEVPLATFORM_PLUGIN_OUTPUTWIDGET_H | 23 | #define KDEVPLATFORM_PLUGIN_OUTPUTWIDGET_H | ||
24 | 24 | | |||
25 | #include <QMap> | 25 | #include <QMap> | ||
26 | #include <QWidget> | 26 | #include <QWidget> | ||
27 | #include <QSharedPointer> | ||||
27 | 28 | | |||
28 | #include <interfaces/itoolviewactionlistener.h> | 29 | #include <interfaces/itoolviewactionlistener.h> | ||
29 | #include <outputview/ioutputviewmodel.h> | 30 | #include <outputview/ioutputviewmodel.h> | ||
30 | #include <outputview/ioutputview.h> | 31 | #include <outputview/ioutputview.h> | ||
31 | 32 | | |||
32 | class KExpandableLineEdit; | 33 | class KExpandableLineEdit; | ||
33 | class KToggleAction; | 34 | class KToggleAction; | ||
34 | class StandardOutputViewTest; | 35 | class StandardOutputViewTest; | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 86 | private: | |||
96 | QWidget* currentWidget() const; | 97 | QWidget* currentWidget() const; | ||
97 | void enableActions(); | 98 | void enableActions(); | ||
98 | KDevelop::IOutputViewModel* outputViewModel() const; | 99 | KDevelop::IOutputViewModel* outputViewModel() const; | ||
99 | QAbstractItemView* outputView() const; | 100 | QAbstractItemView* outputView() const; | ||
100 | void activateIndex(const QModelIndex& index, QAbstractItemView* view, KDevelop::IOutputViewModel* iface); | 101 | void activateIndex(const QModelIndex& index, QAbstractItemView* view, KDevelop::IOutputViewModel* iface); | ||
101 | void eventuallyDoFocus(); | 102 | void eventuallyDoFocus(); | ||
102 | int currentOutputIndex(); | 103 | int currentOutputIndex(); | ||
103 | 104 | | |||
104 | QMap<int, QTreeView*> m_views; | 105 | struct FilteredView { | ||
105 | QMap<int, QSortFilterProxyModel*> m_proxyModels; | 106 | QSharedPointer<QTreeView> view; | ||
106 | QMap<int, QString> m_filters; | 107 | QSharedPointer<QSortFilterProxyModel> proxyModel; | ||
108 | QString filter; | ||||
109 | }; | ||||
kfunk: If I'm not mistaken you could omit the `destroy()` function (and probably a few other… | |||||
Well, frankly speaking, I'm not sure that this will make the code cleaner. A lot of lines in the code use the raw pointer to QTreeView objects, so I'll need to take out the raw pointer from QSharedPointer, which is not quite clean. vkorneev: Well, frankly speaking, I'm not sure that this will make the code cleaner. A lot of lines in… | |||||
110 | QHash<int, FilteredView>::iterator findFilteredView(QAbstractItemView *view); | ||||
111 | | ||||
Please remove the "get" prefix, name the method simply filteredView(QAbstractItemView *view); kossebau: Please remove the "get" prefix, name the method simply `filteredView(QAbstractItemView *view);` | |||||
I'd personally name it findFilteredView(), and make it const, and return a const_iterator. At least from a quick glance, it seems like the iterator returned is always not changed/removed. pino: I'd personally name it `findFilteredView()`, and make it `const`, and return a `const_iterator`. | |||||
I was thinking about returning the const_iterator, but the returned value is changed at least in OutputWidget::outputFilter() (lines 658 and 663). vkorneev: I was thinking about returning the const_iterator, but the returned value is changed at least… | |||||
112 | QHash<int, FilteredView> m_views; | ||||
107 | QTabWidget* m_tabwidget; | 113 | QTabWidget* m_tabwidget; | ||
Unless you need the values sorted by the key (which is QMap does), I suggest to switch also to QHash. pino: Unless you need the values sorted by the key (which is QMap does), I suggest to switch also to… | |||||
108 | QStackedWidget* m_stackwidget; | 114 | QStackedWidget* m_stackwidget; | ||
109 | const ToolViewData* data; | 115 | const ToolViewData* data; | ||
110 | QToolButton* m_closeButton; | 116 | QToolButton* m_closeButton; | ||
111 | QAction* m_closeOthersAction; | 117 | QAction* m_closeOthersAction; | ||
112 | QAction* m_nextAction; | 118 | QAction* m_nextAction; | ||
113 | QAction* m_previousAction; | 119 | QAction* m_previousAction; | ||
114 | KToggleAction* m_activateOnSelect; | 120 | KToggleAction* m_activateOnSelect; | ||
115 | KToggleAction* m_focusOnSelect; | 121 | KToggleAction* m_focusOnSelect; | ||
116 | KExpandableLineEdit* m_filterInput; | 122 | KExpandableLineEdit* m_filterInput; | ||
117 | QWidgetAction* m_filterAction; | 123 | QWidgetAction* m_filterAction; | ||
118 | }; | 124 | }; | ||
119 | 125 | | |||
120 | #endif | 126 | #endif | ||
121 | 127 | |
If I'm not mistaken you could omit the destroy() function (and probably a few other deletes) completely by making the two pointers in the struct a QSharedPointer. I think this would make the code a little bit more clean.
What do you think?