All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Member Functions
GeopsyGui::SignalFileItem Class Reference

Brief description of class still missing. More...

#include <SignalFileItem.h>

List of all members.

Public Member Functions

virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
virtual QVariant data (const QModelIndex &index, int role) const
virtual Qt::ItemFlags flags (const QModelIndex &) const
void getSelection (SubSignalPool &sel, const QItemSelectionModel &sm)
void getSelection (QList< SignalFile * > &sel, const QItemSelectionModel &sm)
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
QModelIndex index (SignalFile *f)
virtual QModelIndex parent (const QModelIndex &index) const
void remove (const QList< SignalFile * > &sel)
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
void setDatabase (SignalDB *db)
 SignalFileItem (QObject *parent=0)
 ~SignalFileItem ()

Static Public Member Functions

static SignalFilefile (const QModelIndex &index)

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

GeopsyGui::SignalFileItem::SignalFileItem ( QObject *  parent = 0)

Description of constructor still missing

References GeopsyCore::GeopsyCoreEngine::currentDB(), GeopsyCore::geopsyCore, and TRACE.

    : QAbstractItemModel(parent)
{
  TRACE;
  _db=geopsyCore->currentDB();
}

Description of destructor still missing

{}

Member Function Documentation

int GeopsyGui::SignalFileItem::columnCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

Currently return only 1 but may evolve in the future

References TRACE.

{
  TRACE;
  return 2;
}
QVariant GeopsyGui::SignalFileItem::data ( const QModelIndex &  index,
int  role 
) const [virtual]

References file(), GeopsyCore::SignalFile::name(), GeopsyCore::SignalFile::shortName(), and TRACE.

{
  TRACE;
  if( !index.isValid()) return QVariant();
  SignalFile * f=file(index);
  switch (role) {
  case Qt::DisplayRole:
    if(index.column()==0) {
      return f->shortName();
    } else {
      return f->name();
    }
  case Qt::ToolTipRole:
    return f->name();
  default:
    return QVariant();
  }
}
SignalFile * GeopsyGui::SignalFileItem::file ( const QModelIndex &  index) [static]

References TRACE.

Referenced by data().

{
  TRACE;
  return static_cast<SignalFile *>(index.internalPointer());
}
virtual Qt::ItemFlags GeopsyGui::SignalFileItem::flags ( const QModelIndex &  ) const [inline, virtual]
{return Qt::ItemIsSelectable | Qt::ItemIsEnabled;}
void GeopsyGui::SignalFileItem::getSelection ( SubSignalPool sel,
const QItemSelectionModel &  sm 
)

Loop over all files to provide a sub pool with files sorted in the same way as displayed in the file list. Using QItemSelectionModel::selectedRows() leads to random order (probably a QHash somewhere).

References GeopsyCore::SubSignalPool::addFile(), GeopsyCore::SignalFilePool::at(), GeopsyCore::SignalFilePool::count(), GeopsyCore::SignalDB::filePool(), parent(), and TRACE.

Referenced by FileView::getSelection(), and FileView::remove().

{
  TRACE;
  static const QModelIndex parent;
  int nFiles=_db->filePool().count();
  for(int i=0;i<nFiles;i++) {
    if(sm.isRowSelected(i, parent)) {
      sel.addFile(_db->filePool().at(i));
    }
  }
}
void GeopsyGui::SignalFileItem::getSelection ( QList< SignalFile * > &  sel,
const QItemSelectionModel &  sm 
)

References GeopsyCore::SignalFilePool::at(), GeopsyCore::SignalDB::filePool(), and TRACE.

{
  TRACE;
  QModelIndexList l=sm.selectedRows();
  for(QModelIndexList::iterator it=l.begin(); it !=l.end(); it++) {
    sel << _db->filePool().at(it->row());
  }
}
QModelIndex GeopsyGui::SignalFileItem::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const [virtual]

References GeopsyCore::SignalFilePool::at(), GeopsyCore::SignalDB::filePool(), and TRACE.

Referenced by remove().

{
  TRACE;
  return createIndex(row, column, _db->filePool().at(row));
}

References GeopsyCore::SignalDB::filePool(), GeopsyCore::SignalFilePool::indexOf(), and TRACE.

{
  TRACE;
  if(f) {
    int i=_db->filePool().indexOf(f);
    if(i>-1) return createIndex(i, 0, f);
  }
  return QModelIndex();
}
QModelIndex GeopsyGui::SignalFileItem::parent ( const QModelIndex &  index) const [virtual]

References TRACE.

Referenced by getSelection().

{
  TRACE;
  return QModelIndex();
}
void GeopsyGui::SignalFileItem::remove ( const QList< SignalFile * > &  sel)

References GeopsyCore::GeopsyCoreEngine::currentDB(), GeopsyCore::geopsyCore, index(), GeopsyCore::SignalDB::removeFile(), and TRACE.

Referenced by FileView::remove().

{
  TRACE;
  for(QList<SignalFile *>::const_iterator it=sel.begin();it!=sel.end();++it) {
    QModelIndex i=index(*it);
    beginRemoveRows(QModelIndex(), i.row(), i.row());
    geopsyCore->currentDB()->removeFile( *it);
    endRemoveRows();
  }
}
int GeopsyGui::SignalFileItem::rowCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

References GeopsyCore::SignalFilePool::count(), GeopsyCore::SignalDB::filePool(), and TRACE.

{
  TRACE;
  if(!parent.isValid()) {
    return _db->filePool().count();
  } else {
    return 0;
  }
}

References TRACE.

Referenced by FileView::refresh().

{
  TRACE;
  _db=db;
  reset();
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines