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_DASHBOARD_WIDGET_H_
23 #define _U2_DASHBOARD_WIDGET_H_
24 
25 #include <QFileInfo>
26 #include <QGridLayout>
27 #include <QMenu>
28 #include <QToolButton>
29 #include <QWidget>
30 
31 #include <U2Core/global.h>
32 
33 #include <U2Lang/WorkflowMonitor.h>
34 
35 namespace U2 {
36 
37 /**
38  * Container class for all Dashboard widgets.
39  *
40  * Adds title and bounding box around widget content.
41  */
42 class U2DESIGNER_EXPORT DashboardWidget : public QWidget {
43     Q_OBJECT
44 public:
45     DashboardWidget(const QString &title, QWidget *contentWidget);
46 };
47 
48 class U2DESIGNER_EXPORT DashboardFileButton : public QToolButton {
49     Q_OBJECT
50 public:
51     DashboardFileButton(const QStringList &urlList, const QString &dashboardDir, const WorkflowMonitor *monitor, bool isFolderMode = false);
52 
53 private slots:
54     void sl_openFileClicked();
55     void sl_dashboardDirChanged(const QString &dashboardDir);
56 
57 private:
58     void addUrlActionsToMenu(QMenu *menu, const QString &url, bool addOpenByUgeneAction = false);
59 
60     /** List of urls to open. */
61     QStringList urlList;
62 
63     /** Path to dashboard dir. */
64     QFileInfo dashboardDirInfo;
65 
66     /** The must process the URL as a folder. */
67     bool isFolderMode;
68 };
69 
70 /** Styled dashboard menu used with file buttons. */
71 class U2DESIGNER_EXPORT DashboardPopupMenu : public QMenu {
72     Q_OBJECT
73 public:
74     explicit DashboardPopupMenu(QAbstractButton *button, QWidget *parent = 0);
75     void showEvent(QShowEvent *event);
76 
77 private:
78     QAbstractButton *button;
79 };
80 
81 /** Various Dashboard widget helpers. */
82 class U2DESIGNER_EXPORT DashboardWidgetUtils {
83 public:
84     static void addTableHeadersRow(QGridLayout *gridLayout, const QStringList &headerNameList);
85 
86     static void addTableRow(QGridLayout *gridLayout, const QString &rowId, const QStringList &valueList);
87 
88     static void addTableCell(QGridLayout *gridLayout, const QString &rowId, QWidget *widget, int row, int column, bool isLastRow, bool isLastColumn);
89 
90     static void addTableCell(QGridLayout *gridLayout, const QString &rowId, const QString &text, int row, int column, bool isLastRow, bool isLastColumn);
91 
92     /**
93      * Adds new row or updates existing row in the table. Uses rowId to compare rows.
94      * Returns true if a new row was added.
95      */
96     static bool addOrUpdateTableRow(QGridLayout *gridLayout, const QString &rowId, const QStringList &valueList);
97 
98     static QString parseOpenUrlValueFromOnClick(const QString &onclickValue);
99 };
100 
101 }  // namespace U2
102 #endif
103