coriolis/crlcore/src/LibraryManager/CellsWidget.cpp

112 lines
3.6 KiB
C++
Raw Normal View History

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
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2015-2018, All Rights Reserved
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
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | Alliance / Hurricane Interface |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./CellsWidget.cpp" |
// +-----------------------------------------------------------------+
#include <QFontMetrics>
#include <QLabel>
#include <QLineEdit>
#include <QHeaderView>
#include <QKeyEvent>
#include <QVBoxLayout>
#include <QAction>
#include <QModelIndex>
#include "hurricane/viewer/Graphics.h"
#include "crlcore/CellsModel.h"
#include "crlcore/CellsWidget.h"
#include "crlcore/LibraryManager.h"
namespace CRL {
using Hurricane::Graphics;
CellsWidget::CellsWidget ( QWidget* parent )
: QWidget (parent)
, _baseModel (new CellsModel(this))
, _view (new QTableView(this))
, _rowHeight (20)
, _selected ()
{
setAttribute( Qt::WA_DeleteOnClose );
setAttribute( Qt::WA_QuitOnClose, false );
setContextMenuPolicy( Qt::ActionsContextMenu );
_rowHeight = QFontMetrics( Graphics::getFixedFont() ).height() + 4;
_view->setShowGrid ( false );
_view->setAlternatingRowColors( true );
_view->setSelectionMode ( QAbstractItemView::SingleSelection );
_view->setSelectionBehavior ( QAbstractItemView::SelectRows );
_view->setSortingEnabled ( true );
_view->setModel ( _baseModel );
//_view->resizeColumnToContents ( 1 );
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
QHeaderView* horizontalHeader = _view->horizontalHeader();
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
horizontalHeader->setSectionResizeMode ( 0, QHeaderView::Stretch );
horizontalHeader->setSectionResizeMode ( 1, QHeaderView::ResizeToContents );
#else
horizontalHeader->setResizeMode ( 0, QHeaderView::Stretch );
horizontalHeader->setResizeMode ( 1, QHeaderView::ResizeToContents );
#endif
//horizontalHeader->setStretchLastSection( false );
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
QHeaderView* verticalHeader = _view->verticalHeader();
verticalHeader->setVisible( false );
verticalHeader->setDefaultSectionSize( _rowHeight );
QLabel* title = new QLabel( "Cells" );
title->setFont( Graphics::getFixedFont(QFont::Bold,false,false,+1) );
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->addWidget( title, 0, Qt::AlignHCenter );
vLayout->addWidget( _view );
setLayout( vLayout );
connect( _view->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&))
, this , SLOT (selectCurrent (const QModelIndex&,const QModelIndex&)) );
}
void CellsWidget::setLibrary ( const AllianceLibrary* library )
{
_baseModel->setLibrary( library );
_view->resizeColumnToContents ( 0 );
_view->selectRow( 0 );
emit selectCurrent( _view->currentIndex(), _view->currentIndex() );
}
void CellsWidget::updateLibrary ()
{ _baseModel->updateLibrary(); }
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
void CellsWidget::updateSelected ()
{ if (_selected.isValid()) _baseModel->emitDataChanged(_selected); }
void CellsWidget::selectCurrent ( const QModelIndex& index, const QModelIndex& )
{
if (index.isValid()) {
_selected = index;
emit selectedCell( _baseModel->getCellDatas(index.row()) );
}
}
} // CRL namespace.