Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes
FileView Class Reference

Brief description of class still missing. More...

#include <FileView.h>

List of all members.

Public Slots

void getSelection (SubSignalPool &sel)
void newGraphicWindow ()
void newMapWindow ()
void newTableWindow ()
void newTool ()
void remove ()
void setSignalWindow (GeopsyMainWindow *sw)

Public Member Functions

 FileView (QWidget *parent=0)
SignalFileItemmodel () const
void refresh ()
virtual QSize sizeHint () const

Protected Member Functions

virtual void contextMenuEvent (QContextMenuEvent *e)
virtual void mouseDoubleClickEvent (QMouseEvent *e)

Protected Attributes

QAction * _graphicAction
QAction * _mapAction
QMenu * _menu
GeopsyMainWindow_sw
QAction * _tableAction

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

FileView::FileView ( QWidget *  parent = 0)

Description of constructor still missing

References _menu, _sw, getSelection(), model(), SigSelectionDnD::setDropEnabled(), and TRACE.

    : QTreeView(parent)
{
  TRACE;
  SigSelectionDnD * sigDnD=new SigSelectionDnD(this);
  viewport() ->installEventFilter(sigDnD);
  sigDnD->setDropEnabled(false);
  connect(sigDnD, SIGNAL(getSelection( SubSignalPool& )),
           this, SLOT(getSelection( SubSignalPool& )) );

  _sw=0;
  _menu=new QMenu(this);
  setContextMenuPolicy(Qt::DefaultContextMenu);

  SignalFileItem * model=new SignalFileItem(this);
  header()->hide();
  setRootIsDecorated(false);
  setModel(model);
  setSelectionBehavior(QAbstractItemView::SelectRows);
  setSelectionMode(QAbstractItemView::ExtendedSelection);
  setEditTriggers(QAbstractItemView::NoEditTriggers);
  setColumnWidth(0,250);
}

Member Function Documentation

void FileView::contextMenuEvent ( QContextMenuEvent *  e) [protected, virtual]

References _graphicAction, _mapAction, _menu, _sw, _tableAction, ToolFactory::addPopularActions(), newTool(), GeopsyMainWindow::toolFactory(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  _menu->clear();

  QModelIndex index=indexAt(e->pos());
  if(index.isValid()) {
    QItemSelectionModel& sm=*selectionModel();
    if(!sm.isSelected(index)) {
      sm.select(index, QItemSelectionModel::ClearAndSelect);
    }
    _menu->addAction(_tableAction);
    _menu->addAction(_graphicAction);
    _menu->addAction(_mapAction);
    _menu->addSeparator();
    if(_sw->toolFactory() ->addPopularActions(_menu, this, SLOT(newTool())) ) {
      _menu->addSeparator();
    }
    _menu->addAction(tr("Remove"), this, SLOT(remove()) );
    _menu->popup(mapToGlobal( e->pos()) );
  }
}
void FileView::getSelection ( SubSignalPool sel) [slot]

References TRACE.

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

{
  TRACE;
  return static_cast<SignalFileItem *>(QTreeView::model());
}
void FileView::mouseDoubleClickEvent ( QMouseEvent *  e) [protected, virtual]

References newGraphicWindow(), and TRACE.

{
  TRACE;
  QModelIndex index=indexAt(e->pos());
  if(index.isValid()) newGraphicWindow();
}
void FileView::newGraphicWindow ( ) [slot]
void FileView::newMapWindow ( ) [slot]
void FileView::newTableWindow ( ) [slot]
void FileView::newTool ( ) [slot]

References _sw, newGraphicWindow(), ToolFactory::showTool(), GeopsyMainWindow::toolFactory(), and TRACE.

Referenced by contextMenuEvent().

{
  TRACE;
  QAction * a=(QAction * ) sender();
  if(a || a->inherits( "QAction" )) {
    QAction * original=*((QAction **) a->data().toByteArray().data());
    newGraphicWindow();
    _sw->toolFactory() ->showTool(original);
  }
}
void FileView::remove ( ) [slot]

References _sw, GeopsyMainWindow::closeAllWindows(), GeopsyMainWindow::filesRemoved(), GeopsyGui::SignalFileItem::getSelection(), model(), MSG_ID, GeopsyGui::SignalFileItem::remove(), QGpCoreTools::tr(), TRACE, and GeopsyMainWindow::workspace().

{
  TRACE;
  static const QString title=tr( "Removing files from database" );
  QList<SignalFile *> fList;
  model()->getSelection(fList, *selectionModel());
  if(fList.isEmpty()) {
    Message::warning(MSG_ID, title, tr( "No file selected for removal." ), Message::ok());
    return;
  }
  QString fileListStr;
  for(QList<SignalFile *>::Iterator it=fList.begin();it!=fList.end();++it) {
    fileListStr+=((*it)->isOriginalFile() ? "\nO " : "\n  ")+(*it)->name();
  }
  if(Message::warning(MSG_ID, title,
                            tr( "List of file(s) to remove:\n%1\n\n"
                                "Original files (marked with 'O') will not be erased from disk. "
                                "All other files automatically produced by Geopsy will be erased "
                                "from the disk.\n\nDo you really want to remove these files?" ).arg(fileListStr),
                            Message::no(), Message::yes())==Message::Answer0) return ;
  if(!_sw->workspace()->windowList().isEmpty()) {
    if(Message::warning(MSG_ID, title,
                        tr("Closing all opened window is mandatory before removing "
                           "a file. Do you want to close all windows?"),
                        Message::no(), Message::yes())==Message::Answer0) return;
    _sw->closeAllWindows();
    qApp->processEvents(QEventLoop::DeferredDeletion); // wait for all windows to be closed
  }
  _sw->filesRemoved(fList);
  model()->remove(fList);
}
QSize FileView::sizeHint ( ) const [virtual]

References TRACE.

{
  TRACE;
  return QSize(200, -1);
}

Member Data Documentation

QAction* FileView::_graphicAction [protected]
QAction* FileView::_mapAction [protected]
QMenu* FileView::_menu [protected]

Referenced by contextMenuEvent(), and FileView().

QAction* FileView::_tableAction [protected]

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