coriolis/unicorn/src/OpenCellDialog.cpp

165 lines
4.8 KiB
C++
Raw Normal View History

// -*- C++ -*-
//
// This file is part of the Coriolis Software.
New Library Manager Widget. Access with Tools menu or CTRL+M. * New: In CRL Core, created a LibraryManager widget. It provides a composite information based on what is present, for each Alliance library: 1. - A Cell in memory, without Catalog::State. 2. - A Catalog::State, with or whithout the Cell in memory. 3. - The files of the Cell in the librariy's directory. 4. - A file with a format referenced for one of the importers. File type recognition is based *only* on the file extension, so it may easily confused. Be careful about what you put in the library's directory. One of the big limitation is that it will not display Hurricane libraries that do not have the AllianceLibrary extension. This widget is put in a separate library <libmanager>, included in the default CRLCORE_LIBRARIES. * Change: In CRL Core, in State (through the loader), now sets the InMemory flag (event if nobody uses it yet...). Display it in the state _getString(). In AllianceFramework, new getAllianceLibraries() method. In CatalogExtension, make the static method "get()" publicly accessible, for sometimes we want the whole State. * Bug: In vlsisapd, in Path, the pathcache was not rebuild when it should, leading to incorrect results. * New: In vlsisapd, in Path, added a listdir() method to access the contents of a directory and a stat() method to poll the status of a file/directory. Rename the ".string()" method in ".toString()" to avoid tricky name resolution with std::string, refactor in all the other tools. * Change: In Hurricane, in Controller, no longer oversize the fonts of the table's headers. * New: In Unicorn, in UnicornGui, integrate LibraryManager.
2015-05-09 10:03:17 -05:00
// Copyright (c) UPMC 2008-2015, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | U n i c o r n - M a i n G U I |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./OpenCellDialog.cpp" |
// +-----------------------------------------------------------------+
New Library Manager Widget. Access with Tools menu or CTRL+M. * New: In CRL Core, created a LibraryManager widget. It provides a composite information based on what is present, for each Alliance library: 1. - A Cell in memory, without Catalog::State. 2. - A Catalog::State, with or whithout the Cell in memory. 3. - The files of the Cell in the librariy's directory. 4. - A file with a format referenced for one of the importers. File type recognition is based *only* on the file extension, so it may easily confused. Be careful about what you put in the library's directory. One of the big limitation is that it will not display Hurricane libraries that do not have the AllianceLibrary extension. This widget is put in a separate library <libmanager>, included in the default CRLCORE_LIBRARIES. * Change: In CRL Core, in State (through the loader), now sets the InMemory flag (event if nobody uses it yet...). Display it in the state _getString(). In AllianceFramework, new getAllianceLibraries() method. In CatalogExtension, make the static method "get()" publicly accessible, for sometimes we want the whole State. * Bug: In vlsisapd, in Path, the pathcache was not rebuild when it should, leading to incorrect results. * New: In vlsisapd, in Path, added a listdir() method to access the contents of a directory and a stat() method to poll the status of a file/directory. Rename the ".string()" method in ".toString()" to avoid tricky name resolution with std::string, refactor in all the other tools. * Change: In Hurricane, in Controller, no longer oversize the fonts of the table's headers. * New: In Unicorn, in UnicornGui, integrate LibraryManager.
2015-05-09 10:03:17 -05:00
#include <iostream>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QRadioButton>
#include <QButtonGroup>
#include <QCheckBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "hurricane/Warning.h"
#include "hurricane/viewer/Graphics.h"
#include "crlcore/Environment.h"
#include "crlcore/AllianceFramework.h"
#include "unicorn/OpenCellDialog.h"
namespace Unicorn {
New Library Manager Widget. Access with Tools menu or CTRL+M. * New: In CRL Core, created a LibraryManager widget. It provides a composite information based on what is present, for each Alliance library: 1. - A Cell in memory, without Catalog::State. 2. - A Catalog::State, with or whithout the Cell in memory. 3. - The files of the Cell in the librariy's directory. 4. - A file with a format referenced for one of the importers. File type recognition is based *only* on the file extension, so it may easily confused. Be careful about what you put in the library's directory. One of the big limitation is that it will not display Hurricane libraries that do not have the AllianceLibrary extension. This widget is put in a separate library <libmanager>, included in the default CRLCORE_LIBRARIES. * Change: In CRL Core, in State (through the loader), now sets the InMemory flag (event if nobody uses it yet...). Display it in the state _getString(). In AllianceFramework, new getAllianceLibraries() method. In CatalogExtension, make the static method "get()" publicly accessible, for sometimes we want the whole State. * Bug: In vlsisapd, in Path, the pathcache was not rebuild when it should, leading to incorrect results. * New: In vlsisapd, in Path, added a listdir() method to access the contents of a directory and a stat() method to poll the status of a file/directory. Rename the ".string()" method in ".toString()" to avoid tricky name resolution with std::string, refactor in all the other tools. * Change: In Hurricane, in Controller, no longer oversize the fonts of the table's headers. * New: In Unicorn, in UnicornGui, integrate LibraryManager.
2015-05-09 10:03:17 -05:00
using namespace std;
using Hurricane::Warning;
using Hurricane::Graphics;
using CRL::Environment;
using CRL::AllianceFramework;
// -------------------------------------------------------------------
// Class : "OpenCellDialog".
OpenCellDialog::OpenCellDialog ( QWidget* parent )
: QDialog (parent)
, _lineEdit (NULL)
, _viewerCheckBox(NULL)
{
setWindowTitle ( tr("Open Cell") );
QLabel* label = new QLabel ();
label->setText ( tr("Enter Cell name (without extention)") );
label->setFont ( Graphics::getNormalFont(true) );
_lineEdit = new QLineEdit ();
_lineEdit->setMinimumWidth ( 400 );
_viewerCheckBox = new QCheckBox ();
_viewerCheckBox->setText ( tr("Open in new Viewer") );
QPushButton* okButton = new QPushButton ();
okButton->setText ( "OK" );
okButton->setDefault ( true );
QPushButton* cancelButton = new QPushButton ();
cancelButton->setText ( "Cancel" );
QHBoxLayout* hLayout1 = new QHBoxLayout ();
hLayout1->addStretch ();
hLayout1->addWidget ( okButton );
hLayout1->addStretch ();
hLayout1->addWidget ( cancelButton );
hLayout1->addStretch ();
#if DEPRECATED
QFrame* separator = new QFrame ();
separator->setFrameShape ( QFrame::HLine );
separator->setFrameShadow ( QFrame::Sunken );
QHBoxLayout* hLayout2 = new QHBoxLayout ();
QButtonGroup* formatGroup = new QButtonGroup ();
QRadioButton* formatButton = new QRadioButton ();
formatButton->setText ( tr("vst/ap") );
formatButton->setChecked ( true );
formatGroup->setId ( formatButton, 0 );
formatGroup->addButton ( formatButton );
hLayout2->addWidget ( formatButton );
formatButton = new QRadioButton ();
formatButton->setText ( tr("DEF") );
formatButton->setChecked ( false );
formatGroup->setId ( formatButton, 1 );
formatGroup->addButton ( formatButton );
hLayout2->addWidget ( formatButton );
#endif // DEPRECATED
QVBoxLayout* vLayout = new QVBoxLayout ();
vLayout->setSizeConstraint ( QLayout::SetFixedSize );
vLayout->addWidget ( label );
vLayout->addWidget ( _lineEdit );
vLayout->addWidget ( _viewerCheckBox );
vLayout->addLayout ( hLayout1 );
//vLayout->addWidget ( separator );
//vLayout->addLayout ( hLayout2 );
setLayout ( vLayout );
//setModal ( true );
connect ( okButton, SIGNAL(clicked()) , this, SLOT(accept()) );
connect ( cancelButton, SIGNAL(clicked()) , this, SLOT(reject()) );
//connect ( formatGroup , SIGNAL(buttonClicked(int)), this, SLOT(formatChanged(int)) );
}
const QString OpenCellDialog::getCellName () const
{
return _lineEdit->text();
}
bool OpenCellDialog::newViewerRequest () const
{
return _viewerCheckBox->isChecked();
}
bool OpenCellDialog::runDialog ( QWidget* parent, QString& name, bool& newViewerRequest )
{
OpenCellDialog* dialog = new OpenCellDialog ( parent );
bool dialogResult = (dialog->exec() == Accepted);
name = dialog->getCellName ();
newViewerRequest = dialog->newViewerRequest ();
delete dialog;
return dialogResult;
}
#if DEPRECATED
void OpenCellDialog::formatChanged ( int index )
{
Environment* environment = AllianceFramework::get()->getEnvironment();
switch ( index ) {
case 0:
environment->setIN_LO ( "vst" );
environment->setIN_PH ( "ap" );
break;
case 1:
environment->setIN_LO ( "def" );
environment->setIN_PH ( "def" );
break;
default:
cerr << Warning("Unknown input format: %d.",index) << endl;
}
}
#endif
} // End of Unicorn namespace.