Changeset View
Changeset View
Standalone View
Standalone View
src/mode/katemodemenulist.h
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | 74 | public: | |||
---|---|---|---|---|---|
137 | { | 137 | { | ||
138 | init(Bottom); | 138 | init(Bottom); | ||
139 | } | 139 | } | ||
140 | ~KateModeMenuList() | 140 | ~KateModeMenuList() | ||
141 | { | 141 | { | ||
142 | } | 142 | } | ||
143 | 143 | | |||
144 | /** | 144 | /** | ||
145 | * Reload all items. | ||||
146 | * @see KateModeManager::update() | ||||
147 | */ | ||||
148 | void reloadItems(); | ||||
149 | | ||||
150 | /** | ||||
145 | * Update the selected item in the list widget, but without changing | 151 | * Update the selected item in the list widget, but without changing | ||
146 | * the syntax highlighting in the document. | 152 | * the syntax highlighting in the document. | ||
147 | * This is useful for updating this menu, when changing the syntax highlighting | 153 | * This is useful for updating this menu, when changing the syntax highlighting | ||
148 | * from another menu, or from an external one. This doesn't hide or show the menu. | 154 | * from another menu, or from an external one. This doesn't hide or show the menu. | ||
149 | * @param nameMode Raw name of the syntax highlight definition. If it's empty, | 155 | * @param nameMode Raw name of the syntax highlight definition. If it's empty, | ||
150 | * the "Normal" mode will be used. | 156 | * the "Normal" mode will be used. | ||
157 | * @return True if @p nameMode exists and is selected. | ||||
151 | */ | 158 | */ | ||
152 | void selectHighlightingFromExternal(const QString &nameMode); | 159 | bool selectHighlightingFromExternal(const QString &nameMode); | ||
153 | /** | 160 | /** | ||
154 | * Update the selected item in the list widget, but without changing | 161 | * Update the selected item in the list widget, but without changing | ||
155 | * the syntax highlighting in the document. This doesn't hide or show the menu. | 162 | * the syntax highlighting in the document. This doesn't hide or show the menu. | ||
156 | * The menu is kept updated according to the active syntax highlighting, | 163 | * The menu is kept updated according to the active syntax highlighting, | ||
157 | * obtained from the KTextEditor::DocumentPrivate class. | 164 | * obtained from the KTextEditor::DocumentPrivate class. | ||
165 | * @return True if the item is selected correctly. | ||||
158 | * @see KTextEditor::DocumentPrivate::fileType() | 166 | * @see KTextEditor::DocumentPrivate::fileType() | ||
159 | */ | 167 | */ | ||
160 | void selectHighlightingFromExternal(); | 168 | bool selectHighlightingFromExternal(); | ||
161 | 169 | | |||
162 | /** | 170 | /** | ||
163 | * Set the button that shows this menu. It allows to update the label | 171 | * Set the button that shows this menu. It allows to update the label | ||
164 | * of the button and define the alignment of the menu with respect to it. | 172 | * of the button and define the alignment of the menu with respect to it. | ||
165 | * This function doesn't call QPushButton::setMenu(). | 173 | * This function doesn't call QPushButton::setMenu(). | ||
166 | * @param button Trigger button. | 174 | * @param button Trigger button. | ||
167 | * @param positionX Horizontal position of the menu with respect to the trigger button. | 175 | * @param positionX Horizontal position of the menu with respect to the trigger button. | ||
168 | * @param positionY Vertical position of the menu with respect to the trigger button. | 176 | * @param positionY Vertical position of the menu with respect to the trigger button. | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 211 | private: | |||
254 | * less than zero, the section is added to the end of the list/model. | 262 | * less than zero, the section is added to the end of the list/model. | ||
255 | * @return A pointer to the item created with the section title. | 263 | * @return A pointer to the item created with the section title. | ||
256 | */ | 264 | */ | ||
257 | KateModeMenuListData::ListItem *createSectionList(const QString §ionName, const QBrush &background, bool bSeparator = true, int modelPosition = -1); | 265 | KateModeMenuListData::ListItem *createSectionList(const QString §ionName, const QBrush &background, bool bSeparator = true, int modelPosition = -1); | ||
258 | 266 | | |||
259 | /** | 267 | /** | ||
260 | * Load message when the list is empty in the search. | 268 | * Load message when the list is empty in the search. | ||
261 | */ | 269 | */ | ||
262 | inline void loadEmptyMsg(); | 270 | void loadEmptyMsg(); | ||
263 | 271 | | |||
264 | AutoScroll m_autoScroll = ScrollToSelectedItem; | 272 | AutoScroll m_autoScroll = ScrollToSelectedItem; | ||
265 | AlignmentHButton m_positionX; | 273 | AlignmentHButton m_positionX; | ||
266 | AlignmentVButton m_positionY; | 274 | AlignmentVButton m_positionY; | ||
267 | AutoUpdateTextButton m_autoUpdateTextButton; | 275 | AutoUpdateTextButton m_autoUpdateTextButton; | ||
268 | 276 | | |||
269 | QPushButton *m_pushButton = nullptr; | 277 | QPointer<QPushButton> m_pushButton = nullptr; | ||
270 | QLabel *m_emptyListMsg = nullptr; | 278 | QLabel *m_emptyListMsg = nullptr; | ||
271 | QGridLayout *m_layoutList = nullptr; | 279 | QGridLayout *m_layoutList = nullptr; | ||
272 | QScrollBar *m_scroll = nullptr; | 280 | QScrollBar *m_scroll = nullptr; | ||
273 | 281 | | |||
274 | KateModeMenuListData::SearchLine *m_searchBar = nullptr; | 282 | KateModeMenuListData::SearchLine *m_searchBar = nullptr; | ||
275 | KateModeMenuListData::ListView *m_list = nullptr; | 283 | KateModeMenuListData::ListView *m_list = nullptr; | ||
276 | QStandardItemModel *m_model = nullptr; | 284 | QStandardItemModel *m_model = nullptr; | ||
277 | 285 | | |||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 331 | public: | |||
353 | * @param classicScrollbarMargin Additional margin for the scroll bar, if fixed in the list. | 361 | * @param classicScrollbarMargin Additional margin for the scroll bar, if fixed in the list. | ||
354 | */ | 362 | */ | ||
355 | inline int getContentWidth(const int overlayScrollbarMargin, const int classicScrollbarMargin) const; | 363 | inline int getContentWidth(const int overlayScrollbarMargin, const int classicScrollbarMargin) const; | ||
356 | 364 | | |||
357 | inline void setCurrentItem(const int rowItem) | 365 | inline void setCurrentItem(const int rowItem) | ||
358 | { | 366 | { | ||
359 | selectionModel()->setCurrentIndex(m_parentMenu->m_model->index(rowItem, 0), QItemSelectionModel::ClearAndSelect); | 367 | selectionModel()->setCurrentIndex(m_parentMenu->m_model->index(rowItem, 0), QItemSelectionModel::ClearAndSelect); | ||
360 | } | 368 | } | ||
369 | | ||||
361 | inline QStandardItem *currentItem() const | 370 | inline QStandardItem *currentItem() const | ||
362 | { | 371 | { | ||
363 | return m_parentMenu->m_model->item(currentIndex().row(), 0); | 372 | return m_parentMenu->m_model->item(currentIndex().row(), 0); | ||
364 | } | 373 | } | ||
365 | 374 | | |||
366 | inline void scrollToItem(const int rowItem, QAbstractItemView::ScrollHint hint = QAbstractItemView::PositionAtCenter) | 375 | inline void scrollToItem(const int rowItem, QAbstractItemView::ScrollHint hint = QAbstractItemView::PositionAtCenter) | ||
367 | { | 376 | { | ||
368 | scrollTo(m_parentMenu->m_model->index(rowItem, 0), hint); | 377 | scrollTo(m_parentMenu->m_model->index(rowItem, 0), hint); | ||
369 | } | 378 | } | ||
370 | 379 | | |||
380 | inline void scrollToFirstItem() | ||||
381 | { | ||||
382 | setCurrentItem(1); | ||||
383 | scrollToTop(); | ||||
384 | } | ||||
385 | | ||||
371 | protected: | 386 | protected: | ||
372 | /** | 387 | /** | ||
373 | * Override from QListView. | 388 | * Override from QListView. | ||
374 | */ | 389 | */ | ||
375 | void keyPressEvent(QKeyEvent *event) override; | 390 | void keyPressEvent(QKeyEvent *event) override; | ||
376 | 391 | | |||
377 | private: | 392 | private: | ||
378 | KateModeMenuList *m_parentMenu = nullptr; | 393 | KateModeMenuList *m_parentMenu = nullptr; | ||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 475 | private: | |||
474 | void setSearchResult(const int rowItem, bool &bEmptySection, int &lastSection, int &firstSection, int &lastItem); | 489 | void setSearchResult(const int rowItem, bool &bEmptySection, int &lastSection, int &firstSection, int &lastItem); | ||
475 | 490 | | |||
476 | /** | 491 | /** | ||
477 | * Delay in search results after typing, in milliseconds. | 492 | * Delay in search results after typing, in milliseconds. | ||
478 | * Default value: 200 | 493 | * Default value: 200 | ||
479 | */ | 494 | */ | ||
480 | static const int m_searchDelay = 170; | 495 | static const int m_searchDelay = 170; | ||
481 | 496 | | |||
497 | /** | ||||
498 | * This prevents auto-scrolling when the search is kept clean. | ||||
499 | */ | ||||
482 | bool m_bSearchStateAutoScroll = false; | 500 | bool m_bSearchStateAutoScroll = false; | ||
501 | | ||||
483 | QString m_search = QString(); | 502 | QString m_search = QString(); | ||
484 | int m_queuedSearches = 0; | 503 | int m_queuedSearches = 0; | ||
485 | Qt::CaseSensitivity m_caseSensitivity = Qt::CaseInsensitive; | 504 | Qt::CaseSensitivity m_caseSensitivity = Qt::CaseInsensitive; | ||
486 | 505 | | |||
487 | /** | 506 | /** | ||
488 | * List of items to display in the "Best Search Matches" section. The integer value | 507 | * List of items to display in the "Best Search Matches" section. The integer value | ||
489 | * corresponds to the original position of the item in the model. The purpose of this | 508 | * corresponds to the original position of the item in the model. The purpose of this | ||
490 | * is to restore the position of the items when starting or cleaning a search. | 509 | * is to restore the position of the items when starting or cleaning a search. | ||
491 | */ | 510 | */ | ||
492 | QList<QPair<ListItem *, int>> m_bestResults; | 511 | QList<QPair<ListItem *, int>> m_bestResults; | ||
493 | 512 | | |||
494 | KateModeMenuList *m_parentMenu = nullptr; | 513 | KateModeMenuList *m_parentMenu = nullptr; | ||
495 | friend Factory; | 514 | friend Factory; | ||
515 | friend void KateModeMenuList::reloadItems(); | ||||
496 | 516 | | |||
497 | protected: | 517 | protected: | ||
498 | /** | 518 | /** | ||
499 | * Override from QLineEdit. This allows you to navigate through | 519 | * Override from QLineEdit. This allows you to navigate through | ||
500 | * the menu and write in the search bar simultaneously with the keyboard. | 520 | * the menu and write in the search bar simultaneously with the keyboard. | ||
501 | */ | 521 | */ | ||
502 | void keyPressEvent(QKeyEvent *event) override; | 522 | void keyPressEvent(QKeyEvent *event) override; | ||
503 | 523 | | |||
Show All 30 Lines |