예제 #1
0
/** This signal is called to indicate that a selection has been made. */
void PointListView::slot_Select()
{
  Waypoint *_wp = m_listw->getCurrentWaypoint();

  if ( _wp )
    {
      emit newWaypoint( _wp, true );
      slot_Close();
    }
}
예제 #2
0
PointListView::PointListView( ListWidgetParent* lwParent, QWidget *parent ) :
  QWidget( parent ),
  m_listw( lwParent ),
  m_homeChanged( false )
{
  setObjectName("PointListView");

  QBoxLayout *topLayout = new QVBoxLayout( this );
  topLayout->addWidget(m_listw, 10);

  QBoxLayout *buttonrow=new QHBoxLayout;
  topLayout->addLayout(buttonrow);

  QPushButton *cmdClose = new QPushButton(tr("Close"), this);

  buttonrow->addWidget(cmdClose);

  QPushButton *cmdInfo = new QPushButton(tr("Info"), this);
  buttonrow->addWidget(cmdInfo);

  m_cmdHome = new QPushButton(tr("Home"), this);
  buttonrow->addWidget(m_cmdHome);

  m_cmdSelect = new QPushButton(tr("Select"), this);
  buttonrow->addWidget(m_cmdSelect);

  connect(m_cmdSelect, SIGNAL(clicked()),
          this, SLOT(slot_Select()));
  connect(cmdInfo, SIGNAL(clicked()),
          this, SLOT(slot_Info()));
  connect(cmdClose, SIGNAL(clicked()),
          this, SLOT(slot_Close()));
  connect(m_cmdHome, SIGNAL(clicked()),
          this, SLOT(slot_Home()));
  connect(m_listw, SIGNAL(wpSelectionChanged()),
          this, SLOT(slot_Selected()));
  connect(this, SIGNAL(done()),
          m_listw, SLOT(slot_Done()));

  // activate keyboard shortcut Return as select
  QShortcut* scSelect = new QShortcut( this );
  scSelect->setKey( Qt::Key_Return );
  connect( scSelect, SIGNAL(activated()), this, SLOT( slot_Select() ));
}
예제 #3
0
/**
 * Constructor
 */
NumberInputPad::NumberInputPad( QString number, QWidget *parent ) :
  QFrame( parent ),
  m_autoSip(true),
  m_setNumber(number),
  m_intMaximum(false, INT_MAX),
  m_intMinimum(false, INT_MIN),
  m_doubleMaximum(false, 0.0),
  m_doubleMinimum(false, 0.0),
  m_pressedButton( 0 )
{
#ifdef ANDROID
  setFrameStyle(QFrame::Box | QFrame::Plain);
#else
  setFrameStyle( QFrame::StyledPanel | QFrame::Plain );
#endif

  setLineWidth( 3 * Layout::getIntScaledDensity() );

  QPalette palette;
  palette.setColor(QPalette::WindowText, Qt::darkBlue);
  setPalette(palette);

  setObjectName("NumberInputPad");
  setWindowFlags(Qt::Tool);
  setWindowModality( Qt::WindowModal );
  setAttribute(Qt::WA_DeleteOnClose);

  // Save the current state of the software input panel
  m_autoSip = qApp->autoSipEnabled();

  // Disable software input panel
  qApp->setAutoSipEnabled( false );

  int row = 0;
  QGridLayout* gl = new QGridLayout (this);
  gl->setMargin( 5 * Layout::getIntScaledDensity() );
  gl->setSpacing( 10 * Layout::getIntScaledDensity() );

  m_tipLabel = new QLabel (this);
  m_tipLabel->setAlignment(Qt::AlignCenter);
  gl->addWidget( m_tipLabel, row, 0, 1, 5 );

  gl->setRowStretch(row, 5 * Layout::getIntScaledDensity() );
  row++;

  m_editor = new QLineEdit (this);

  connect( m_editor, SIGNAL(textChanged(const QString&)),
           this, SLOT(slot_TextChanged(const QString&)) );

  setNumber( number );
  gl->addWidget( m_editor, row, 0, 1, 5 );

  int iconSize = Layout::iconSize( font() );
  QSize qis( iconSize, iconSize );

  int minBW = QFontMetrics(font()).width("MMM");

  m_cancel = new QPushButton( " ", this );
  m_cancel->setIcon( QIcon(GeneralConfig::instance()->loadPixmap("cancel.png")) );
  m_cancel->setIconSize( qis );
  m_cancel->setMinimumWidth( minBW );
  gl->addWidget( m_cancel, row, 6 );
  row++;

  gl->setRowMinimumHeight( row, 5 * Layout::getIntScaledDensity() );
  gl->setColumnMinimumWidth( 5, 5 * Layout::getIntScaledDensity());
  row++;

  m_num1 = new QPushButton( " 1 ", this );
  m_num1->setMinimumWidth( minBW );
  gl->addWidget( m_num1, row, 0 );

  m_num2 = new QPushButton( " 2 ", this );
  m_num2->setMinimumWidth( minBW );
  gl->addWidget( m_num2, row, 1 );

  m_num3 = new QPushButton( " 3 ", this );
  m_num3->setMinimumWidth( minBW );
  gl->addWidget( m_num3, row, 2 );

  m_num4 = new QPushButton( " 4 ", this );
  m_num4->setMinimumWidth( minBW );
  gl->addWidget( m_num4, row, 3 );

  m_num5 = new QPushButton( " 5 ", this );
  m_num5->setMinimumWidth( minBW );
  gl->addWidget( m_num5, row, 4 );

  m_home = new QPushButton( " ", this );
  m_home->setMinimumWidth( minBW );
  m_home->setIcon( QIcon(GeneralConfig::instance()->loadPixmap("home_new.png")) );
  m_home->setIconSize( qis );
  gl->addWidget( m_home, row, 6 );
  row++;

  m_num6 = new QPushButton( " 6 ", this );
  m_num6->setMinimumWidth( minBW );
  gl->addWidget( m_num6, row, 0 );

  m_num7 = new QPushButton( " 7 ", this );
  m_num7->setMinimumWidth( minBW );
  gl->addWidget( m_num7, row, 1 );

  m_num8 = new QPushButton( " 8 ", this );
  m_num8->setMinimumWidth( minBW );
  gl->addWidget( m_num8, row, 2 );

  m_num9 = new QPushButton( " 9 ", this );
  m_num9->setMinimumWidth( minBW );
  gl->addWidget( m_num9, row, 3 );

  m_num0 = new QPushButton( " 0 ", this );
  m_num0->setMinimumWidth( minBW );
  gl->addWidget( m_num0, row, 4 );

  m_pm = new QPushButton( "+ -", this );
  m_pm->setMinimumWidth( minBW );
  gl->addWidget( m_pm, row, 6 );

  row++;

  m_decimal = new QPushButton( " . ", this );
  m_decimal->setMinimumWidth( minBW );
  gl->addWidget( m_decimal, row, 0 );

  QStyle* style = QApplication::style();

  m_left = new QPushButton( " ", this);
  m_left->setMinimumWidth( minBW );
  //m_left->setIcon(style->standardIcon(QStyle::SP_ArrowLeft));
  m_left->setIcon( QIcon(GeneralConfig::instance()->loadPixmap("left-32.png")) );
  m_left->setIconSize( qis );
  gl->addWidget( m_left, row, 1 );

  m_right = new QPushButton( " ", this );
  m_right->setMinimumWidth( minBW );
  //m_right->setIcon(style->standardIcon(QStyle::SP_ArrowRight));
  m_right->setIcon( QIcon(GeneralConfig::instance()->loadPixmap("right-32.png")) );
  m_right->setIconSize( qis );
  gl->addWidget( m_right, row, 2 );

  m_delLeft = new QPushButton( " ", this );
  m_delLeft->setMinimumWidth( minBW );
  //m_delLeft->setIcon(style->standardIcon(QStyle::SP_MediaSkipBackward));
  m_delLeft->setIcon( QIcon(GeneralConfig::instance()->loadPixmap("media-skip-backward-32.png")) );
  m_delLeft->setIconSize( qis );
  gl->addWidget( m_delLeft, row, 3 );

  m_delRight = new QPushButton( " ", this );
  m_delRight->setMinimumWidth( minBW );
  //m_delRight->setIcon (style->standardIcon(QStyle::SP_MediaSkipForward));
  m_delRight->setIcon( QIcon(GeneralConfig::instance()->loadPixmap("media-skip-forward-32.png")) );
  m_delRight->setIconSize( qis );
  gl->addWidget( m_delRight, row, 4 );

  m_ok = new QPushButton( " ", this );
  m_ok->setMinimumWidth( minBW );
  m_ok->setIcon( QIcon(GeneralConfig::instance()->loadPixmap("ok.png")) );
  m_ok->setIconSize( qis );
  gl->addWidget( m_ok, row, 6 );

  m_ok->setFocusPolicy( Qt::NoFocus );
  m_cancel->setFocusPolicy( Qt::NoFocus );
  m_delLeft->setFocusPolicy( Qt::NoFocus );
  m_delRight->setFocusPolicy( Qt::NoFocus );
  m_left->setFocusPolicy( Qt::NoFocus );
  m_right->setFocusPolicy( Qt::NoFocus );
  m_decimal->setFocusPolicy( Qt::NoFocus );
  m_pm->setFocusPolicy( Qt::NoFocus );
  m_home->setFocusPolicy( Qt::NoFocus );
  m_num0->setFocusPolicy( Qt::NoFocus );
  m_num1->setFocusPolicy( Qt::NoFocus );
  m_num2->setFocusPolicy( Qt::NoFocus );
  m_num3->setFocusPolicy( Qt::NoFocus );
  m_num4->setFocusPolicy( Qt::NoFocus );
  m_num5->setFocusPolicy( Qt::NoFocus );
  m_num6->setFocusPolicy( Qt::NoFocus );
  m_num7->setFocusPolicy( Qt::NoFocus );
  m_num8->setFocusPolicy( Qt::NoFocus );
  m_num9->setFocusPolicy( Qt::NoFocus );

  m_digitSignalMapper = new QSignalMapper(this);
  m_buttonSignalMapper = new QSignalMapper(this);

  connect(m_num1, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_num2, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_num3, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_num4, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_num5, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_num6, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_num7, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_num8, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_num9, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_num0, SIGNAL(pressed()), m_digitSignalMapper, SLOT(map()));
  connect(m_decimal, SIGNAL(pressed()), m_buttonSignalMapper, SLOT(map()));
  connect(m_left, SIGNAL(pressed()), m_buttonSignalMapper, SLOT(map()));
  connect(m_right, SIGNAL(pressed()), m_buttonSignalMapper, SLOT(map()));
  connect(m_delLeft, SIGNAL(pressed()), m_buttonSignalMapper, SLOT(map()));
  connect(m_delRight, SIGNAL(pressed()), m_buttonSignalMapper, SLOT(map()));
  connect(m_home, SIGNAL(pressed()), m_buttonSignalMapper, SLOT(map()));

  m_digitSignalMapper->setMapping(m_num1, m_num1);
  m_digitSignalMapper->setMapping(m_num2, m_num2);
  m_digitSignalMapper->setMapping(m_num3, m_num3);
  m_digitSignalMapper->setMapping(m_num4, m_num4);
  m_digitSignalMapper->setMapping(m_num5, m_num5);
  m_digitSignalMapper->setMapping(m_num6, m_num6);
  m_digitSignalMapper->setMapping(m_num7, m_num7);
  m_digitSignalMapper->setMapping(m_num8, m_num8);
  m_digitSignalMapper->setMapping(m_num9, m_num9);
  m_digitSignalMapper->setMapping(m_num0, m_num0);
  m_buttonSignalMapper->setMapping(m_decimal, m_decimal);
  m_buttonSignalMapper->setMapping(m_left, m_left);
  m_buttonSignalMapper->setMapping(m_right, m_right);
  m_buttonSignalMapper->setMapping(m_delLeft, m_delLeft);
  m_buttonSignalMapper->setMapping(m_delRight, m_delRight);
  m_buttonSignalMapper->setMapping(m_home, m_home);

  connect( m_digitSignalMapper, SIGNAL(mapped(QWidget *)),
           this, SLOT(slot_DigitPressed(QWidget *)));
  connect( m_buttonSignalMapper, SIGNAL(mapped(QWidget *)),
           this, SLOT(slot_ButtonPressed(QWidget *)));

  connect( m_pm, SIGNAL(pressed() ), this, SLOT(slot_Pm()) );
  connect( m_ok, SIGNAL(pressed() ), this, SLOT(slot_Ok()) );
  connect( m_cancel, SIGNAL(pressed() ), this, SLOT(slot_Close()) );

  m_timerButton = new QTimer( this );
  m_timerButton->setSingleShot( true );
  m_timerDigit = new QTimer( this );
  m_timerDigit->setSingleShot( true );

  connect( m_timerButton, SIGNAL(timeout()), this, SLOT(slot_RepeatButton()));
  connect( m_timerDigit, SIGNAL(timeout()), this, SLOT(slot_RepeatDigit()));
}
예제 #4
0
/**
 * Constructor
 */
FlarmAliasList::FlarmAliasList( QWidget *parent ) :
  QWidget( parent ),
  list(0),
  m_enableScroller(0)
{
  setAttribute( Qt::WA_DeleteOnClose );

  QHBoxLayout *topLayout = new QHBoxLayout( this );
  topLayout->setSpacing(5);

  list = new QTableWidget( 0, 2, this );
  list->setSelectionBehavior( QAbstractItemView::SelectRows );
  // list->setSelectionMode( QAbstractItemView::SingleSelection );
  list->setAlternatingRowColors( true );
  list->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
  list->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel );

#ifdef ANDROID
  QScrollBar* lvsb = list->verticalScrollBar();
  lvsb->setStyleSheet( Layout::getCbSbStyle() );
#endif

#ifdef QSCROLLER
  QScroller::grabGesture( list->viewport(), QScroller::LeftMouseButtonGesture );
#endif

#ifdef QTSCROLLER
  QtScroller::grabGesture( list->viewport(), QtScroller::LeftMouseButtonGesture );
#endif

  QString style = "QTableView QTableCornerButton::section { background: gray }";
  list->setStyleSheet( style );
  QHeaderView *vHeader = list->verticalHeader();
  style = "QHeaderView::section { width: 2em }";
  vHeader->setStyleSheet( style );

  // set new row height from configuration
  int afMargin = GeneralConfig::instance()->getListDisplayAFMargin();
  rowDelegate = new RowDelegate( list, afMargin );
  list->setItemDelegate( rowDelegate );

  // hide vertical headers
  // QHeaderView *vHeader = list->verticalHeader();
  // vHeader->setVisible(false);

  QHeaderView* hHeader = list->horizontalHeader();
  hHeader->setStretchLastSection( true );
#if QT_VERSION >= 0x050000
  hHeader->setSectionsClickable( true );
#else
  hHeader->setClickable( true );
#endif

  connect( hHeader, SIGNAL(sectionClicked(int)),
           this, SLOT(slot_HeaderClicked(int)) );

  QTableWidgetItem *item = new QTableWidgetItem( tr(" Flarm ID ") );
  list->setHorizontalHeaderItem( 0, item );

  item = new QTableWidgetItem( tr(" Alias (15) ") );
  list->setHorizontalHeaderItem( 1, item );

  connect( list, SIGNAL(cellChanged( int, int )),
           this, SLOT(slot_CellChanged( int, int )) );

  connect( list, SIGNAL(cellClicked( int, int )),
           this, SLOT(slot_CellClicked( int, int )) );

  connect( list, SIGNAL(itemSelectionChanged()),
           this, SLOT(slot_ItemSelectionChanged()) );

  topLayout->addWidget( list, 2 );

  QGroupBox* buttonBox = new QGroupBox( this );

  int buttonSize = Layout::getButtonSize();
  int iconSize   = buttonSize - 5;

  QPushButton *addButton  = new QPushButton;
  addButton->setIcon( QIcon( GeneralConfig::instance()->loadPixmap( "add.png" ) ) );
  addButton->setIconSize(QSize(iconSize, iconSize));
  // addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);
  addButton->setMinimumSize(buttonSize, buttonSize);
  addButton->setMaximumSize(buttonSize, buttonSize);

  deleteButton  = new QPushButton;
  deleteButton->setIcon( QIcon( GeneralConfig::instance()->loadPixmap( "delete.png" ) ) );
  deleteButton->setIconSize(QSize(iconSize, iconSize));
  // deleteButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);
  deleteButton->setMinimumSize(buttonSize, buttonSize);
  deleteButton->setMaximumSize(buttonSize, buttonSize);
  deleteButton->setEnabled(false);

#if defined(QSCROLLER) || defined(QTSCROLLER)

  m_enableScroller = new QCheckBox("][");
  m_enableScroller->setCheckState( Qt::Checked );
  m_enableScroller->setMinimumHeight( Layout::getButtonSize(12) );

  connect( m_enableScroller, SIGNAL(stateChanged(int)),
	   this, SLOT(slot_scrollerBoxToggled(int)) );

#endif

  QPushButton *okButton = new QPushButton;
  okButton->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png")));
  okButton->setIconSize(QSize(iconSize, iconSize));
  // okButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);
  okButton->setMinimumSize(buttonSize, buttonSize);
  okButton->setMaximumSize(buttonSize, buttonSize);

  QPushButton *closeButton = new QPushButton;
  closeButton->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png")));
  closeButton->setIconSize(QSize(iconSize, iconSize));
  // closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);
  closeButton->setMinimumSize(buttonSize, buttonSize);
  closeButton->setMaximumSize(buttonSize, buttonSize);

  connect( addButton, SIGNAL(clicked() ), this, SLOT(slot_AddRow()) );
  connect( deleteButton, SIGNAL(clicked() ), this, SLOT(slot_DeleteRows()) );
  connect( okButton, SIGNAL(clicked() ), this, SLOT(slot_Ok()) );
  connect( closeButton, SIGNAL(clicked() ), this, SLOT(slot_Close()) );

  // vertical box with operator buttons
  QVBoxLayout *vbox = new QVBoxLayout;

  vbox->setSpacing(0);
  vbox->addWidget( addButton );
  vbox->addSpacing(32);
  vbox->addWidget( deleteButton );
  vbox->addStretch(2);

#if defined(QSCROLLER) || defined(QTSCROLLER)

  vbox->addWidget( m_enableScroller, 0, Qt::AlignCenter );
  vbox->addStretch(2);

#endif

  vbox->addWidget( okButton );
  vbox->addSpacing(32);
  vbox->addWidget( closeButton );
  buttonBox->setLayout( vbox );

  topLayout->addWidget( buttonBox );

  // load alias data into table
  if( ! aliasHash.isEmpty() )
    {
      QMutableHashIterator<QString, QString> it(aliasHash);

      while( it.hasNext() )
        {
          it.next();
          slot_AddRow( it.key(), it.value() );
        }

      list->sortByColumn( 1, Qt::AscendingOrder );
    }
}
예제 #5
0
void FlarmAliasList::slot_Ok()
{
  if( list->rowCount() != 0 )
    {
      // Check data for consistency. Empty entries are not accepted.
      for( int i = 0; i < list->rowCount(); i++ )
        {
          for( int j = 0; j < 2; j++ )
            {
              if( list->item( i, j )->text().trimmed().isEmpty() )
                {
                  QMessageBox mb( QMessageBox::Warning,
                                  tr( "Missing Entry" ),
                                  tr( "Please fill out all fields!" ),
                                  QMessageBox::Ok,
                                  this );
#ifdef ANDROID
                  mb.show();
                  QPoint pos = mapToGlobal(QPoint( width()/2 - mb.width()/2,
                                                   height()/2 - mb.height()/2 ));
                  mb.move( pos );
#endif
                  mb.exec();
                  return;
                }
            }
        }
    }

  aliasHash.clear(); // Clear alias hash

  // Save all to alias hash
  for( int i = 0; i < list->rowCount(); i++ )
    {
      // Alias names are limited to MaxAliasLength characters
      aliasHash.insert( list->item( i, 0 )->text().trimmed(),
                        list->item( i, 1 )->text().trimmed().left(MaxAliasLength) );
    }

  saveAliasData(); // Save data into file

  // Check, if only one row is selected. In this case this item is set as
  // the selected Flarm identifier. No row selection will reset the current
  // selected Flarm identifier.
  QList<QTableWidgetItem *> items = list->selectedItems();

  if( items.size() >= 0 && items.size() <= 2 )
    {
      QString selectedObject = "";

      if( items.size() > 0 )
        {
          QTableWidgetItem *item = items.at(0);
          selectedObject = item->text().trimmed();
        }

      // Report new selection to FlarmListView and FlarmDisplay
      emit newObjectSelection( selectedObject );
    }

  slot_Close();
}
예제 #6
0
GpsStatusDialog::GpsStatusDialog(QWidget * parent) :
  QWidget( parent ),
  showNmeaData( true ),
  nmeaLines( 0 ),
  cntSIVSentence( 1 )
{
  noOfInstances++;

  setWindowTitle(tr("GPS Status"));
  setWindowFlags( Qt::Tool );
  setWindowModality( Qt::WindowModal );
  setAttribute(Qt::WA_DeleteOnClose);

  if( _globalMainWindow )
    {
      // Resize the window to the same size as the main window has. That will
      // completely hide the parent window.
      resize( _globalMainWindow->size() );
    }

  uTimer = new QTimer( this );
  uTimer->setSingleShot( true );

  connect( uTimer, SIGNAL(timeout()), this,
           SLOT(slot_updateGpsMessageDisplay()) );

  elevAziDisplay = new GpsElevationAzimuthDisplay(this);
  snrDisplay     = new GpsSnrDisplay(this);

  nmeaBox = new QLabel;
  nmeaBox->setObjectName("NmeaBox");
  nmeaBox->setTextFormat(Qt::PlainText);
  nmeaBox->setBackgroundRole( QPalette::Light );
  nmeaBox->setAutoFillBackground( true );
  nmeaBox->setMargin(5);

  QFont f = font();

#if defined MAEMO
  f.setPixelSize(16);
#elif ANDROID
  f.setPointSize(6);
#else
  f.setPixelSize(14);
#endif

  nmeaBox->setFont(f);

  QScrollArea *nmeaScrollArea = new QScrollArea;
  nmeaScrollArea->setWidgetResizable( true );
  nmeaScrollArea->setWidget(nmeaBox);

#ifdef ANDROID
  // Make the vertical scrollbar bigger for Android
  QScrollBar* vsb = nmeaScrollArea->verticalScrollBar();
  vsb->setStyleSheet( Layout::getCbSbStyle() );
#endif

#ifdef QSCROLLER
  QScroller::grabGesture( nmeaScrollArea->viewport(), QScroller::LeftMouseButtonGesture );
#endif

#ifdef QTSCROLLER
  QtScroller::grabGesture( nmeaScrollArea->viewport(), QtScroller::LeftMouseButtonGesture );
#endif

  QVBoxLayout* nmeaBoxLayout = new QVBoxLayout;
  nmeaBoxLayout->setSpacing( 0 );
  nmeaBoxLayout->addWidget( nmeaScrollArea );

  satSource = new QComboBox;
  satSource->setToolTip( tr("GPS source filter") );
  satSource->addItem( "$GP" );
  satSource->addItem( "$BD" );
  satSource->addItem( "$GA" );
  satSource->addItem( "$GL" );
  satSource->addItem( "$GN" );
  satSource->addItem( "ALL" );

  startStop = new QPushButton( tr("Stop"), this );
  save      = new QPushButton( tr("Save"), this );

  QPushButton* close = new QPushButton( tr("Close"), this );

  QVBoxLayout* buttonBox = new QVBoxLayout;
  buttonBox->addWidget( satSource );
  buttonBox->addStretch( 5 );
  buttonBox->addWidget( startStop );
  buttonBox->addSpacing( 5 );
  buttonBox->addWidget( save );
  buttonBox->addSpacing( 5 );
  buttonBox->addWidget( close );

  QHBoxLayout* hBox = new QHBoxLayout;
  hBox->addWidget(elevAziDisplay, 1);
  hBox->addWidget(snrDisplay, 2);
  hBox->addLayout( buttonBox );

  QVBoxLayout* topLayout = new QVBoxLayout( this );
  topLayout->addLayout( hBox );
  topLayout->addLayout( nmeaBoxLayout );

  connect( satSource, SIGNAL(currentIndexChanged(int)),
                      SLOT(slot_GpsSourceChanged(int)) );

  connect( GpsNmea::gps, SIGNAL(newSentence(const QString&)),
           this, SLOT(slot_Sentence(const QString&)) );

  connect( startStop, SIGNAL(clicked()), this, SLOT(slot_ToggleStartStop()) );

  connect( save, SIGNAL(clicked()), this, SLOT(slot_SaveNmeaData()) );

  connect( close, SIGNAL(clicked()), this, SLOT(slot_Close()) );
}
예제 #7
0
/**
 * Constructor
 */
Logbook::Logbook( QWidget *parent ) :
  QWidget( parent ),
  m_tableModified(false)
{
  setObjectName("Logbook");
  setWindowFlags(Qt::Tool);
  setWindowTitle( tr("Logbook"));
  setWindowModality( Qt::WindowModal );
  setAttribute(Qt::WA_DeleteOnClose);

  // Resize the window to the same size as the main window has. That will
  // completely hide the parent window.
  resize( MainWindow::mainWindow()->size() );

  QHBoxLayout *topLayout = new QHBoxLayout( this );
  topLayout->setSpacing(5);

  m_table = new QTableWidget( 0, 8, this );

  m_table->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
  m_table->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel );

#ifdef ANDROID
  QScrollBar* lvsb = m_table->verticalScrollBar();
  lvsb->setStyleSheet( Layout::getCbSbStyle() );
#endif

#ifdef QSCROLLER
  QScroller::grabGesture( m_table->viewport(), QScroller::LeftMouseButtonGesture );
#endif

#ifdef QTSCROLLER
  QtScroller::grabGesture( m_table->viewport(), QtScroller::LeftMouseButtonGesture );
#endif

  m_table->setSelectionBehavior( QAbstractItemView::SelectRows );
  m_table->setAlternatingRowColors( true );

  QHeaderView* hHeader = m_table->horizontalHeader();

  // that makes trouble on N810
  // hHeader->setStretchLastSection( true );
#if QT_VERSION >= 0x050000
  hHeader->setSectionsClickable( true );
#else
  hHeader->setClickable( true );
#endif

  connect( hHeader, SIGNAL(sectionClicked(int)),
           this, SLOT(slot_HeaderClicked(int)) );

  setTableHeader();
  topLayout->addWidget( m_table, 2 );

  QGroupBox* buttonBox = new QGroupBox( this );

  int buttonSize = Layout::getButtonSize();
  int iconSize   = buttonSize - 5;

  m_deleteAllButton  = new QPushButton;
  m_deleteAllButton->setIcon( QIcon( GeneralConfig::instance()->loadPixmap( "clear.png" ) ) );
  m_deleteAllButton->setIconSize(QSize(iconSize, iconSize));
  m_deleteAllButton->setMinimumSize(buttonSize, buttonSize);
  m_deleteAllButton->setMaximumSize(buttonSize, buttonSize);

  m_deleteButton  = new QPushButton;
  m_deleteButton->setIcon( QIcon( GeneralConfig::instance()->loadPixmap( "delete.png" ) ) );
  m_deleteButton->setIconSize(QSize(iconSize, iconSize));
  m_deleteButton->setMinimumSize(buttonSize, buttonSize);
  m_deleteButton->setMaximumSize(buttonSize, buttonSize);
  m_deleteButton->setEnabled(false);

  m_okButton = new QPushButton;
  m_okButton->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png")));
  m_okButton->setIconSize(QSize(iconSize, iconSize));
  m_okButton->setMinimumSize(buttonSize, buttonSize);
  m_okButton->setMaximumSize(buttonSize, buttonSize);

  QPushButton *closeButton = new QPushButton;
  closeButton->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png")));
  closeButton->setIconSize(QSize(iconSize, iconSize));
  closeButton->setMinimumSize(buttonSize, buttonSize);
  closeButton->setMaximumSize(buttonSize, buttonSize);

  connect( m_deleteAllButton, SIGNAL(clicked() ), this, SLOT(slot_DeleteAllRows()) );
  connect( m_deleteButton, SIGNAL(clicked() ), this, SLOT(slot_DeleteRows()) );
  connect( m_okButton, SIGNAL(clicked() ), this, SLOT(slot_Ok()) );
  connect( closeButton, SIGNAL(clicked() ), this, SLOT(slot_Close()) );

  // vertical box with operator buttons
  QVBoxLayout *vbox = new QVBoxLayout;

  vbox->setSpacing(0);
  vbox->addWidget( m_deleteAllButton );
  vbox->addSpacing(32);
  vbox->addWidget( m_deleteButton );
  vbox->addStretch(2);
  vbox->addWidget( m_okButton );
  vbox->addSpacing(32);
  vbox->addWidget( closeButton );
  buttonBox->setLayout( vbox );

  topLayout->addWidget( buttonBox );

  QString style = "QTableView QTableCornerButton::section { background: gray }";
  m_table->setStyleSheet( style );

  QHeaderView *vHeader = m_table->verticalHeader();
  style = "QHeaderView::section { width: 2em }";
  vHeader->setStyleSheet( style );

  // set new row height from configuration
  int afMargin = GeneralConfig::instance()->getListDisplayAFMargin();
  rowDelegate = new RowDelegate( m_table, afMargin );
  m_table->setItemDelegate( rowDelegate );

  loadLogbookData();
}