1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2017 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #ifndef _HI_GT_LINEEDIT_H_
23 #define _HI_GT_LINEEDIT_H_
24 
25 #include <QLineEdit>
26 
27 #include "GTGlobals.h"
28 
29 namespace HI {
30 /*!
31  * \brief The class for working with QLineEdit primitive
32  */
33 class HI_EXPORT GTLineEdit {
34 public:
35     enum PasteMethod { Shortcut,
36                        Mouse };
37 
38     // fails if lineEdit is NULL, GTLineEdit::clear fails
39     // or a set text differs from a given string
40 #ifdef Q_OS_DARWIN
41     static void setText(GUITestOpStatus &os, QLineEdit *lineEdit, const QString &str, bool noCheck = false, bool useCopyPaste = true);
42     static void setText(GUITestOpStatus &os, const QString &lineEditName, const QString &text, const QWidget *const parent, bool noCheck = false, bool useCopyPaste = true);
43 #else
44     static void setText(GUITestOpStatus &os, QLineEdit *lineEdit, const QString &str, bool noCheck = false, bool useCopyPaste = false);
45     static void setText(GUITestOpStatus &os, const QString &lineEditName, const QString &text, QWidget const *const parent, bool noCheck = false, bool useCopyPaste = false);
46 #endif
47     static QString getText(GUITestOpStatus &os, QLineEdit *lineEdit);
48     static QString getText(GUITestOpStatus &os, const QString &lineEditName, QWidget *parent = NULL);
49 
50     // fails if lineEdit is NULL, or lineEdit's text wasn't cleared
51     static void clear(GUITestOpStatus &os, QLineEdit *lineEdit);
52 
53     // fails if GTLineEdit::clear fails
54     static void pasteClipboard(GUITestOpStatus &os, QLineEdit *lineEdit, PasteMethod pasteMethod = Shortcut);
55 
56     // fails if lineEdit is NULL or lineEdit text is not in lineEdit's rect
57     // considering lineEdit's fontMetrics and textMargins
58     static void checkTextSize(GUITestOpStatus &os, QLineEdit *lineEdit);
59     static void checkText(GUITestOpStatus &os, QLineEdit *lineEdit, const QString &expectedText);
60     static void checkText(GUITestOpStatus &os, const QString &lineEditName, QWidget const *const parent, const QString &expectedText);
61 
62     static QString copyText(GUITestOpStatus &os, QLineEdit *lineEdit);
63 
64     // fails if lineEdit is NULL
65     // checks if str can be pasted in lineEdit
66     static bool tryToSetText(GUITestOpStatus &os, QLineEdit *lineEdit, const QString &str);
67 };
68 
69 }  // namespace HI
70 
71 #endif  // _HI_GT_LINEEDIT_H_
72