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

« back to all changes in this revision

Viewing changes to src/corelibs/U2Gui/src/util_gui/ProjectTreeItemSelectorDialog.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
 * UGENE - Integrated Bioinformatics Tools.
 
3
 * Copyright (C) 2008-2011 UniPro <ugene@unipro.ru>
 
4
 * http://ugene.unipro.ru
 
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
#include "ProjectTreeItemSelectorDialog.h"
 
23
#include "ProjectTreeItemSelectorDialogImpl.h"
 
24
#include "ProjectTreeController.h"
 
25
 
 
26
#include <U2Core/DocumentModel.h>
 
27
 
 
28
#include <QtGui/QTreeWidget>
 
29
#include <QtGui/QVBoxLayout>
 
30
#include <QtGui/QHBoxLayout>
 
31
#include <QtGui/QSpacerItem>
 
32
#include <QtGui/QPushButton>
 
33
 
 
34
namespace U2 {
 
35
 
 
36
ProjectTreeItemSelectorDialogImpl::ProjectTreeItemSelectorDialogImpl(QWidget* p, const ProjectTreeControllerModeSettings& s) 
 
37
: QDialog(p)
 
38
{
 
39
    setupUi(this);
 
40
    controller = new ProjectTreeController(this, treeWidget, s);
 
41
    //TODO: fix bug with double clicking on gobject
 
42
    //connect(controller, SIGNAL(si_doubleClicked(GObject*)), SLOT(sl_objectClicked(GObject*)));
 
43
    acceptByDoubleClick = true;
 
44
}
 
45
 
 
46
void ProjectTreeItemSelectorDialogImpl::sl_objectClicked(GObject* obj) {
 
47
 
 
48
    Document* d = obj->getDocument();
 
49
    assert(d != NULL);
 
50
    if (!d->isLoaded()) { 
 
51
        QAction* loadSelectedDocumentsAction = controller->getLoadSeletectedDocumentsAction();
 
52
        assert(loadSelectedDocumentsAction->isEnabled());
 
53
        loadSelectedDocumentsAction->trigger();
 
54
        return;
 
55
    }
 
56
   
 
57
    if (acceptByDoubleClick) {
 
58
         accept();
 
59
    }
 
60
}
 
61
 
 
62
ProjectTreeItemSelectorDialogImpl::~ProjectTreeItemSelectorDialogImpl() {
 
63
    delete controller;
 
64
}
 
65
 
 
66
QList<Document*> ProjectTreeItemSelectorDialog::selectDocuments(const ProjectTreeControllerModeSettings& s, QWidget* p) {
 
67
    QList<Document*> res;
 
68
    ProjectTreeItemSelectorDialogImpl d(p, s);
 
69
    int rc = d.exec();
 
70
    if (rc == QDialog::Accepted) {
 
71
        const DocumentSelection* ds = d.controller->getDocumentSelection();
 
72
        res << ds->getSelectedDocuments();
 
73
    }
 
74
    return res;    
 
75
}
 
76
 
 
77
QList<GObject*> ProjectTreeItemSelectorDialog::selectObjects(const ProjectTreeControllerModeSettings& s, QWidget* p) {
 
78
    QList<GObject*> res;
 
79
    ProjectTreeItemSelectorDialogImpl d(p, s);
 
80
    int rc = d.exec();
 
81
    if (rc == QDialog::Accepted) {
 
82
        const GObjectSelection* os = d.controller->getGObjectSelection();
 
83
        res << os->getSelectedObjects();
 
84
    }
 
85
    return res;
 
86
}
 
87
 
 
88
}//namespace