1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 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 _U2_GUI_ANNOTATIONS_TREE_VIEW_UTILS_H_
23 #define _U2_GUI_ANNOTATIONS_TREE_VIEW_UTILS_H_
24 
25 #include "GTGlobals.h"
26 
27 class QTreeWidget;
28 class QTreeWidgetItem;
29 
30 namespace U2 {
31 using namespace HI;
32 
33 class AVItem;
34 class U2Region;
35 
36 class GTUtilsAnnotationsTreeView {
37 public:
38     static QTreeWidget *getTreeWidget(HI::GUITestOpStatus &os);
39 
40     static void addAnnotationsTableFromProject(HI::GUITestOpStatus &os, const QString &tableName);
41 
42     // returns center or item's rect
43     // fails if the item wasn't found
44     static QPoint getItemCenter(HI::GUITestOpStatus &os, const QString &itemName);
45 
46     static QTreeWidgetItem *findFirstAnnotation(HI::GUITestOpStatus &os, const GTGlobals::FindOptions &options = GTGlobals::FindOptions());
47     static QTreeWidgetItem *findItem(HI::GUITestOpStatus &os, const QString &itemName, const GTGlobals::FindOptions & = GTGlobals::FindOptions());
48     static QTreeWidgetItem *findItem(HI::GUITestOpStatus &os, const QString &itemName, QTreeWidgetItem *parentItem, const GTGlobals::FindOptions & = GTGlobals::FindOptions());
49     static QTreeWidgetItem *findItemWithIndex(HI::GUITestOpStatus &os, const QString &itemName, const int index);
50     static QList<QTreeWidgetItem *> findItems(HI::GUITestOpStatus &os, const QString &itemName, const GTGlobals::FindOptions & = GTGlobals::FindOptions());
51 
52     static QStringList getGroupNames(HI::GUITestOpStatus &os, const QString &annotationTableName = "");
53 
54     static QStringList getAnnotationNamesOfGroup(HI::GUITestOpStatus &os, const QString &groupName);
55     static QList<U2Region> getAnnotatedRegionsOfGroup(HI::GUITestOpStatus &os, const QString &groupName);
56     static QList<U2Region> getAnnotatedRegionsOfGroup(HI::GUITestOpStatus &os, const QString &groupName, const QString &parentName);
57 
58     // finds given region in annotation with a given name. U2Region: visible {begin, end} positions.
59     static bool findRegion(HI::GUITestOpStatus &os, const QString &itemName, const U2Region &region);
60 
61     static QString getSelectedItem(HI::GUITestOpStatus &os);
62     static QList<QTreeWidgetItem *> getAllSelectedItems(HI::GUITestOpStatus &os);
63     static QString getAVItemName(HI::GUITestOpStatus &os, AVItem *avItem);
64     static QString getQualifierValue(HI::GUITestOpStatus &os, const QString &qualifierName, QTreeWidgetItem *parentItem);
65     static QString getQualifierValue(HI::GUITestOpStatus &os, const QString &qualName, const QString &parentName);
66     static QList<U2Region> getAnnotatedRegions(HI::GUITestOpStatus &os);
67     static QList<U2Region> getSelectedAnnotatedRegions(HI::GUITestOpStatus &os);
68     static QString getAnnotationRegionString(HI::GUITestOpStatus &os, const QString &annotationName);
69     static QString getAnnotationType(HI::GUITestOpStatus &os, const QString &annotationName);
70 
71     static void createQualifier(HI::GUITestOpStatus &os, const QString &qualName, const QString &qualValue, const QString &parentName);
72 
73     static void selectItems(HI::GUITestOpStatus &os, const QStringList &items);
74     static void selectItems(HI::GUITestOpStatus &os, const QList<QTreeWidgetItem *> &items);
75 
76     static void clickItem(HI::GUITestOpStatus &os, const QString &item, const int numOfItem, bool isDoubleClick);
77 
78     // location string format: 1..51
79     static void createAnnotation(HI::GUITestOpStatus &os, const QString &groupName, const QString &annotationName, const QString &location, bool createNewTable = true, const QString &saveTo = "");
80 
81     static void deleteItem(HI::GUITestOpStatus &os, const QString &itemName);
82     static void deleteItem(HI::GUITestOpStatus &os, QTreeWidgetItem *item);
83 
84     static void callContextMenuOnItem(HI::GUITestOpStatus &os, QTreeWidgetItem *item);
85     static void callContextMenuOnItem(HI::GUITestOpStatus &os, const QString &itemName);
86     static void callContextMenuOnQualifier(HI::GUITestOpStatus &os, const QString &parentName, const QString &qualifierName);
87 
88     /** Checks that there are no annotations in the annotations view. */
89     static void checkNoAnnotations(HI::GUITestOpStatus &os);
90 
91     static const QString widgetName;
92 };
93 
94 }  // namespace U2
95 
96 #endif
97