コード例 #1
0
void TabPage::forward() {
  // remember current scroll position
  BrowseHistoryItem& item = history_.currentItem();
  QAbstractItemView* childView = folderView_->childView();
  item.setScrollPos(childView->verticalScrollBar()->value());

  history_.forward();
  chdir(history_.currentPath(), false);
}
コード例 #2
0
void TabPage::jumpToHistory(int index)
{
  if(index >=0 && index < history_.size()) {
    // remember current scroll position
    BrowseHistoryItem& item = history_.currentItem();
    QAbstractItemView* childView = folderView_->childView();
    item.setScrollPos(childView->verticalScrollBar()->value());

    history_.setCurrentIndex(index);
    chdir(history_.currentPath(), false);
  }
}
コード例 #3
0
void TabPage::chdir(FmPath* newPath, bool addHistory) {
  if(folder_) {
    // we're already in the specified dir
    if(fm_path_equal(newPath, fm_folder_get_path(folder_)))
      return;

    // remember the previous folder path that we have browsed.
    lastFolderPath_ = fm_folder_get_path(folder_);

    if(addHistory) {
      // store current scroll pos in the browse history
      BrowseHistoryItem& item = history_.currentItem();
      QAbstractItemView* childView = folderView_->childView();
      item.setScrollPos(childView->verticalScrollBar()->value());
    }

    // free the previous model
    if(folderModel_) {
      proxyModel_->setSourceModel(NULL);
      folderModel_->unref(); // unref the cached model
      folderModel_ = NULL;
    }

    freeFolder();
  }

  char* disp_name = fm_path_display_basename(newPath);
  title_ = QString::fromUtf8(disp_name);
  Q_EMIT titleChanged(title_);
  g_free(disp_name);

  folder_ = fm_folder_from_path(newPath);
  proxyFilter_->setVirtHidden(folder_);
  if(addHistory) {
    // add current path to browse history
    history_.add(path());
  }
  g_signal_connect(folder_, "start-loading", G_CALLBACK(onFolderStartLoading), this);
  g_signal_connect(folder_, "finish-loading", G_CALLBACK(onFolderFinishLoading), this);
  g_signal_connect(folder_, "error", G_CALLBACK(onFolderError), this);
  g_signal_connect(folder_, "fs-info", G_CALLBACK(onFolderFsInfo), this);
  /* destroy the page when the folder is unmounted or deleted. */
  g_signal_connect(folder_, "removed", G_CALLBACK(onFolderRemoved), this);
  g_signal_connect(folder_, "unmount", G_CALLBACK(onFolderUnmount), this);
  g_signal_connect(folder_, "content-changed", G_CALLBACK(onFolderContentChanged), this);

  folderModel_ = CachedFolderModel::modelFromFolder(folder_);
  proxyModel_->setSourceModel(folderModel_);
  proxyModel_->sort(proxyModel_->sortColumn(), proxyModel_->sortOrder());
  Settings& settings = static_cast<Application*>(qApp)->settings();
  proxyModel_->setFolderFirst(settings.sortFolderFirst());
  proxyModel_->sort(settings.sortColumn(), settings.sortOrder());

  if(fm_folder_is_loaded(folder_)) {
    onFolderStartLoading(folder_, this);
    onFolderFinishLoading(folder_, this);
    onFolderFsInfo(folder_, this);
  }
  else
    onFolderStartLoading(folder_, this);
}
コード例 #4
0
SettingsPageTerrainColors::SettingsPageTerrainColors(QWidget *parent) :
  QWidget(parent),
  colorsChanged(false),
  m_autoSip( true )
{
  setObjectName("SettingsPageTerrainColors");

  setWindowFlags( Qt::Tool );
  setWindowModality( Qt::WindowModal );
  setAttribute(Qt::WA_DeleteOnClose);
  setWindowTitle( tr("Settings - Terrain Colors") );

  if( parent )
    {
      resize( parent->size() );
    }

  // Layout used by scroll area
  QHBoxLayout *sal = new QHBoxLayout;

  // new widget used as container for the dialog layout.
  QWidget* sw = new QWidget;

  // Scroll area
  QScrollArea* sa = new QScrollArea;
  sa->setWidgetResizable( true );
  sa->setFrameStyle( QFrame::NoFrame );
  sa->setWidget( sw );

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

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

  // Add scroll area to its own layout
  sal->addWidget( sa );

  QHBoxLayout *contentLayout = new QHBoxLayout(this);

  // Pass scroll area layout to the content layout.
  contentLayout->addLayout( sal );

  /**
   * Altitude levels in meters to be displayed in color combo box.
   */
  const char *altitudes[51] = {
                 "< 0",
                 "0",
                 "10",
                 "25",
                 "50",
                 "75",
                 "100",
                 "150",
                 "200",
                 "250",
                 "300",
                 "350",
                 "400",
                 "450",
                 "500",
                 "600",
                 "700",
                 "800",
                 "900",
                 "1000",
                 "1250",
                 "1500",
                 "1750",
                 "2000",
                 "2250",
                 "2500",
                 "2750",
                 "3000",
                 "3250",
                 "3500",
                 "3750",
                 "4000",
                 "4250",
                 "4500",
                 "4750",
                 "5000",
                 "5250",
                 "5500",
                 "5750",
                 "6000",
                 "6250",
                 "6500",
                 "6750",
                 "7000",
                 "7250",
                 "7500",
                 "7750",
                 "8000",
                 "8250",
                 "8500",
                 "8750"
  };

  // Determine pixmap size to be used for icons in dependency of the used font
  int size = QFontMetrics(font()).boundingRect("XM").height() - 2;
  pixmapSize = QSize( size, size );
  QPixmap pixmap(pixmapSize);

  // load stored terrain colors into working list
  for( int i = 0; i < SIZEOF_TERRAIN_COLORS; i++ )
    {
      QColor color = GeneralConfig::instance()->getTerrainColor(i);
      terrainColor[i] = color;
    }

  // load ground color
  groundColor = GeneralConfig::instance()->getGroundColor();

  // put all widgets in a HBox layout
  QHBoxLayout *topLayout = new QHBoxLayout(sw);

  // create elevation color bar as image
  elevationImage = new ElevationColorImage( &terrainColor[0], this );
  topLayout->addWidget( elevationImage );

  // all editor widgets will be put into a group box to get a better view
  QGroupBox *editBox = new QGroupBox( tr("Color Selection"), this );

  // put group box in an extra VBox layout to center it vertically
  QVBoxLayout *editAll = new QVBoxLayout;
  editAll->addStretch( 10 );
  editAll->addWidget( editBox );
  editAll->addStretch( 10 );

  topLayout->addLayout( editAll );

  // put all edit widgets (combo box and buttons) in a separate VBox layout
  QVBoxLayout *editLayout = new QVBoxLayout;
  editLayout->setSpacing( editLayout->spacing() * Layout::getIntScaledDensity() );

  QLabel *label = new QLabel( tr("Terrain Level") );
  editLayout->addWidget( label );

  //--------------------------------------------------------------------------
  // The users altitude unit (meters/feed) must be considered during
  // elevation display in the combo box.
  QString unit;

  elevationBox = new QComboBox( this );

#ifdef ANDROID
  QAbstractItemView* listView = elevationBox->view();
  QScrollBar* lvsb = listView->verticalScrollBar();
  lvsb->setStyleSheet( Layout::getCbSbStyle() );
#endif

#ifdef QSCROLLER
  elevationBox->view()->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
  QScroller::grabGesture( elevationBox->view()->viewport(), QScroller::LeftMouseButtonGesture );
#endif

#ifdef QTSCROLLER
  elevationBox->view()->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
  QtScroller::grabGesture( elevationBox->view()->viewport(), QtScroller::LeftMouseButtonGesture );
#endif

  if( Altitude::getUnit() == Altitude::meters )
    {
      // use unit meter
       unit = "m";

       for( int i = SIZEOF_TERRAIN_COLORS-1; i > 1; i-- )
        {
          pixmap.fill( terrainColor[i] );
          elevationBox->addItem( QIcon( pixmap ), QString(altitudes[i]) + unit );
        }
    }
  else
    {
      // use unit feed
      unit = "ft";

      for( int i = SIZEOF_TERRAIN_COLORS-1; i > 1; i-- )
        {
          int altFeed = static_cast<int>(QString(altitudes[i]).toDouble() * 3.28095);
          pixmap.fill( terrainColor[i] );
          elevationBox->addItem( QIcon( pixmap ), QString::number(altFeed) + unit );
        }
    }

  pixmap.fill( terrainColor[1] );
  elevationBox->addItem( QIcon( pixmap ), QString(altitudes[1]) );

  pixmap.fill( terrainColor[0] );
  elevationBox->addItem( QIcon( pixmap ), QString(altitudes[0]) );

  // set index to level 0
  elevationBox->setCurrentIndex( SIZEOF_TERRAIN_COLORS-2 );

  editLayout->addWidget( elevationBox );

  //--------------------------------------------------------------------------
  // add push button for elevation color chooser dialog
  editColorButton = new QPushButton( tr("Terrain Color") );

  // on click the color chooser dialog will be opened
  connect( editColorButton, SIGNAL(clicked()), this, SLOT(slot_editColor()) );

  editLayout->addWidget( editColorButton );

  //--------------------------------------------------------------------------
  // add push button for ground color chooser dialog
  groundColorButton = new QPushButton( tr("Ground Color") );

  pixmap.fill( groundColor );
  groundColorButton->setIcon( QIcon(pixmap) );

  // on click the color chooser dialog will be opened
  connect( groundColorButton, SIGNAL(clicked()), this, SLOT(slot_editGroundColor()) );

  editLayout->addSpacing( 10 * Layout::getIntScaledDensity() );
  editLayout->addWidget( groundColorButton );
  editLayout->addSpacing( 20 * Layout::getIntScaledDensity() );

  //--------------------------------------------------------------------------
  // add button for assigning of default colors
  defaultColorButton = new QPushButton( tr("Color Defaults") );

  // on click all colors are reset to the defaults
  connect( defaultColorButton, SIGNAL(clicked()), this, SLOT(slot_setColorDefaults()) );

  editLayout->addWidget( defaultColorButton );

  // add stretch items to posit editor widgets in the center of the VBox layout
  editLayout->insertStretch(0, 10 );
  editLayout->addStretch( 10 );

  editBox->setLayout(editLayout);

  //--------------------------------------------------------------------------
  // add spin box for moving elevation zero line
  QGroupBox *setOffsetBox = new QGroupBox( tr("Elevation Offset"), this );

  // put group box in an extra VBox layout to center it vertically
  QVBoxLayout *offsetLayout = new QVBoxLayout;
  offsetLayout->addStretch( 10 );
  offsetLayout->addWidget( setOffsetBox );
  offsetLayout->addStretch( 10 );

  QVBoxLayout *spinboxLayout = new QVBoxLayout;

  elevationOffset = new QSpinBox;
  elevationOffset->setSingleStep(1);
  elevationOffset->setRange(-50, 50);

  connect( elevationOffset, SIGNAL(editingFinished()),
           MainWindow::mainWindow(), SLOT(slotCloseSip()) );

  VarSpinBox* hspin = new VarSpinBox( elevationOffset );
  spinboxLayout->addWidget(hspin);
  setOffsetBox->setLayout(spinboxLayout);

  topLayout->addLayout( offsetLayout );
  topLayout->insertSpacing(1, 60 );
  topLayout->addStretch( 10 );

  QPushButton *cancel = new QPushButton(this);
  cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png")));
  cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12)));
  cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);

  QPushButton *ok = new QPushButton(this);
  ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png")));
  ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12)));
  ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);

  QLabel *titlePix = new QLabel(this);
  titlePix->setAlignment( Qt::AlignCenter );
  titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("setup.png"));

  connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept()));
  connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject()));

  QVBoxLayout *buttonBox = new QVBoxLayout;
  buttonBox->setSpacing(0);
  buttonBox->addStretch(2);
  buttonBox->addWidget(cancel, 1);
  buttonBox->addSpacing(30);
  buttonBox->addWidget(ok, 1);
  buttonBox->addStretch(2);
  buttonBox->addWidget(titlePix);
  contentLayout->addLayout(buttonBox);

  load();
}