14bbbdcb |
1 | // Created on: 2017-06-16 |
2 | // Created by: Natalia ERMOLAEVA |
3 | // Copyright (c) 2017 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef DFBrowser_SearchLine_H |
17 | #define DFBrowser_SearchLine_H |
18 | |
0cb512c0 |
19 | #include <inspector/DFBrowser_SearchLineModel.hxx> // to include DFBrowser_SearchItemInfo |
20 | |
14bbbdcb |
21 | #include <Standard.hxx> |
22 | #include <TDocStd_Application.hxx> |
23 | #include <TDF_Label.hxx> |
24 | |
130eb114 |
25 | #include <Standard_WarningsDisable.hxx> |
14bbbdcb |
26 | #include <QCompleter> |
27 | #include <QFrame> |
28 | #include <QLineEdit> |
130eb114 |
29 | #include <Standard_WarningsRestore.hxx> |
14bbbdcb |
30 | |
31 | class DFBrowser_Module; |
32 | class DFBrowser_SearchLineModel; |
33 | |
34 | class QAbstractItemModel; |
35 | class QLineEdit; |
36 | class QToolButton; |
37 | class QStringList; |
38 | |
39 | //! \class DFBrowser_SearchLine |
40 | //! It contains a line edit control with auto completion and search button |
41 | class DFBrowser_SearchLine : public QFrame |
42 | { |
43 | Q_OBJECT |
44 | public: |
45 | |
46 | //! Constructor |
47 | Standard_EXPORT DFBrowser_SearchLine (QWidget* theParent); |
48 | |
49 | //! Destructor |
7e1c1e48 |
50 | virtual ~DFBrowser_SearchLine() {} |
14bbbdcb |
51 | |
52 | //! Creates search line model filled by the module. It is necessary for auto completion of line edit |
53 | //! \param theModule a current module |
54 | Standard_EXPORT void SetModule (DFBrowser_Module* theModule); |
55 | |
56 | //! Returns the current module |
57 | Standard_EXPORT DFBrowser_Module* GetModule(); |
58 | |
59 | //! Fills the search line model by OCAF document values |
60 | //! \param theDocumentValues container of document index to container of entry/attribute name to item information |
61 | //! \param theDocumentInfoValues container of a document index to entry/attribute name |
62 | Standard_EXPORT void SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues, |
63 | const QMap<int, QStringList>& theDocumentInfoValues); |
64 | |
65 | //! Clears cache of values in search line model |
66 | Standard_EXPORT void ClearValues(); |
67 | |
68 | //! Returns completer model |
7e1c1e48 |
69 | QAbstractItemModel* GetModel() { return myLineControl->completer()->model(); } |
14bbbdcb |
70 | |
71 | //! Returns completion completer model |
7e1c1e48 |
72 | QAbstractItemModel* GetCompletionModel() { return myLineControl->completer()->completionModel(); } |
14bbbdcb |
73 | |
74 | //! Returns the current line edit text |
75 | QString Text() const { return myLineControl->text(); } |
76 | |
77 | //! Sets the current text value |
78 | //! \param theValue a string value |
79 | void SetText (const QString& theValue) { myLineControl->setText (theValue); } |
80 | |
81 | signals: |
82 | |
83 | //! Signals that is emitted by text changed in line edit control |
84 | void searchActivated(); |
85 | |
86 | private slots: |
87 | |
88 | //! Updates icon of search button depending on text is empty and emits searchActivated signal |
89 | void onTextChanged (const QString& theText); |
7e1c1e48 |
90 | |
91 | //! Sets completion prefix in completer model |
14bbbdcb |
92 | void onReturnPressed() { myLineControl->completer()->setCompletionPrefix (myLineControl->text()); } |
7e1c1e48 |
93 | |
94 | //! Sets empty text if the current text is not empty: new search is started |
14bbbdcb |
95 | void onSearchButtonClicked(); |
96 | |
97 | private: |
98 | |
99 | QLineEdit* myLineControl; //!< line editor control |
7e1c1e48 |
100 | QToolButton* mySearchButton; //!< search button |
14bbbdcb |
101 | }; |
102 | |
103 | #endif |