1 | /* $Id: UISearchLineEdit.h 78459 2019-05-10 07:31:41Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISearchLineEdit class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef FEQT_INCLUDED_SRC_widgets_UISearchLineEdit_h
|
---|
19 | #define FEQT_INCLUDED_SRC_widgets_UISearchLineEdit_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 |
|
---|
25 | /* Qt includes */
|
---|
26 | #include <QLineEdit>
|
---|
27 |
|
---|
28 | /* GUI includes: */
|
---|
29 | #include "UILibraryDefs.h"
|
---|
30 |
|
---|
31 | /** A QLineEdit extension with an overlay label drawn on the right hand side of it.
|
---|
32 | * mostly used for entering a search term and then label show total number of matched items
|
---|
33 | * and currently selected, scrolled item. */
|
---|
34 | class SHARED_LIBRARY_STUFF UISearchLineEdit : public QLineEdit
|
---|
35 | {
|
---|
36 |
|
---|
37 | Q_OBJECT;
|
---|
38 |
|
---|
39 | public:
|
---|
40 |
|
---|
41 | UISearchLineEdit(QWidget *pParent = 0);
|
---|
42 | void setMatchCount(int iMatchCount);
|
---|
43 | void setScroolToIndex(int iScrollToIndex);
|
---|
44 | void reset();
|
---|
45 |
|
---|
46 | protected:
|
---|
47 |
|
---|
48 | virtual void paintEvent(QPaintEvent *pEvent) /* override */;
|
---|
49 |
|
---|
50 | private:
|
---|
51 |
|
---|
52 | void colorBackground(bool fWarning);
|
---|
53 |
|
---|
54 | /** Stores the total number of matched items. */
|
---|
55 | int m_iMatchCount;
|
---|
56 | /** Stores the index of the currently scrolled/made-visible item withing the list of search results.
|
---|
57 | * Must be smaller that or equal to m_iMatchCount. */
|
---|
58 | int m_iScrollToIndex;
|
---|
59 | /** When true we color line edit background with a more reddish color. */
|
---|
60 | bool m_fMark;
|
---|
61 | QColor m_unmarkColor;
|
---|
62 | QColor m_markColor;
|
---|
63 | };
|
---|
64 |
|
---|
65 | #endif /* !FEQT_INCLUDED_SRC_widgets_UISearchLineEdit_h */
|
---|