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_DOCUMENT_FORMAT_SELECTOR_CONTROLLER_
23 #define _U2_DOCUMENT_FORMAT_SELECTOR_CONTROLLER_
24 
25 #include <ui_DocumentFormatSelectorDialog.h>
26 
27 #include <QComboBox>
28 #include <QRadioButton>
29 #include <QToolButton>
30 
31 #include <U2Core/AppContext.h>
32 #include <U2Core/DocumentUtils.h>
33 
34 namespace U2 {
35 
36 class LabelClickProvider : public QObject {
37     Q_OBJECT
38 public:
39     LabelClickProvider(QLabel *label, QRadioButton *rb);
40 
41 private:
42     bool eventFilter(QObject *object, QEvent *event);
43 
44     QLabel *label;
45     QRadioButton *rb;
46 };
47 
48 class DocumentFormatSelectorController : public QDialog, public Ui_DocumentFormatSelectorDialog {
49     Q_OBJECT
50 
51     DocumentFormatSelectorController(QList<FormatDetectionResult> &results, QWidget *p);
52 
53 public:
54     static int selectResult(const GUrl &url, const QString &rawDataPreview, QList<FormatDetectionResult> &results);
55     static QString score2Text(int score);
56 
57 private slots:
58     void sl_moreFormatInfo();
59 
60 private:
61     int getSelectedFormatIdx() const;
62 
63     QList<QRadioButton *> radioButtons;
64     QList<QToolButton *> moreButtons;
65     QComboBox *userSelectedFormat;
66     const QList<FormatDetectionResult> &formatDetectionResults;
67 };
68 
69 }  // namespace U2
70 
71 #endif
72