~ubuntu-branches/debian/jessie/ugene/jessie

« back to all changes in this revision

Viewing changes to src/plugins/dna_export/src/ExportDialogController.cpp

  • Committer: Package Import Robot
  • Author(s): Steffen Moeller
  • Date: 2011-11-02 13:29:07 UTC
  • mfrom: (1.2.1) (3.1.11 natty)
  • Revision ID: package-import@ubuntu.com-20111102132907-o34gwnt0uj5g6hen
Tags: 1.9.8+repack-1
* First release to Debian
  - added README.Debian
  - increased policy version to 3.9.2
  - added URLs for version control system
* Added debug package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************
2
 
* Unipro UGENE - Integrated Bioinformatics Suite
3
 
* Copyright (C) 2008 Unipro, Russia (http://ugene.unipro.ru)
4
 
* All Rights Reserved
5
 
6
 
*     This source code is distributed under the terms of the
7
 
*     GNU General Public License. See the files COPYING and LICENSE
8
 
*     for details.
9
 
*****************************************************************/
10
 
 
11
 
#include "ExportDialogController.h"
12
 
 
13
 
#include <core_api/AppContext.h>
14
 
#include <core_api/Settings.h>
15
 
#include <util_gui/DialogUtils.h>
16
 
#include <util_gui/GUIUtils.h>
17
 
 
18
 
#include <QtGui/QMessageBox>
19
 
#include <QtGui/QFileDialog>
20
 
 
21
 
#define SETTINGS_ROOT QString("dna_export/")
22
 
 
23
 
namespace GB2 {
24
 
 
25
 
ExportDialogController::ExportDialogController(bool m, bool allowComplement, bool allowTranslation, const DocumentFormatId& id) {
26
 
    setupUi(this);    
27
 
 
28
 
    multiMode = m;
29
 
    strand = TriState_Yes;
30
 
    translate = false;
31
 
    translateAllFrames = false;
32
 
    
33
 
    if (!allowComplement) {
34
 
        directStrandButton->setEnabled(false);
35
 
        complementStrandButton->setEnabled(false);
36
 
        bothStrandsButton->setEnabled(false);
37
 
        
38
 
        directStrandButton->setHidden(true);
39
 
        complementStrandButton->setHidden(true);
40
 
        bothStrandsButton->setHidden(true);
41
 
 
42
 
    }
43
 
    if (!allowTranslation) {
44
 
        translateButton->setEnabled(false);
45
 
        translateButton->setHidden(true);
46
 
        allTFramesButton->setHidden(true);
47
 
    }
48
 
 
49
 
    if (!allowTranslation && !allowComplement) {
50
 
         translationBox->setHidden(true);
51
 
    }
52
 
 
53
 
    if (!multiMode) {
54
 
        saveModeBox->setEnabled(false);
55
 
        saveModeBox->setHidden(true);
56
 
    }
57
 
    formatId = id;
58
 
    connect(exportButton, SIGNAL(clicked()), SLOT(sl_exportClicked()));
59
 
    connect(fileButton, SIGNAL(clicked()), SLOT(sl_fileClicked()));
60
 
 
61
 
    int height = layout()->minimumSize().height();
62
 
    setMaximumHeight(height);
63
 
}
64
 
 
65
 
 
66
 
void ExportDialogController::updateModel() {
67
 
    strand = directStrandButton->isChecked() ? TriState_Yes : complementStrandButton->isChecked() ? TriState_No : TriState_Unknown;
68
 
    translate = translateButton->isChecked();
69
 
    translateAllFrames = allTFramesButton->isChecked();
70
 
 
71
 
    merge = mergeButton->isChecked();
72
 
    mergeGap = merge ? mergeSpinBox->value() : 0;
73
 
    file = fileNameEdit->text();
74
 
}
75
 
 
76
 
 
77
 
void ExportDialogController::sl_exportClicked() {
78
 
    if (fileNameEdit->text().isEmpty()) {
79
 
        QMessageBox::warning(this, tr("warning"), tr("file_is_empty"));
80
 
        fileNameEdit->setFocus();
81
 
        return;
82
 
    }
83
 
    updateModel();
84
 
    accept();
85
 
}
86
 
 
87
 
void ExportDialogController::sl_fileClicked() {
88
 
    QString filter = DialogUtils::prepareDocumentsFileFilter(formatId, false);
89
 
    LastOpenDirHelper lod;
90
 
    lod.url = QFileDialog::getSaveFileName(this, tr("select_file_title"), lod, filter);
91
 
    if (lod.url.isEmpty()) {
92
 
        return;
93
 
    }
94
 
    fileNameEdit->setText(lod.url);
95
 
}
96
 
 
97
 
}//namespace