~ubuntu-branches/ubuntu/karmic/ugene/karmic

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2009-06-16 13:20:00 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090616132000-a0eezpre9uvx91a5
Tags: 1.4.2+repack-0ubuntu1
New upstream release

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
 
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