示例#1
0
void SelectProjectScreen::openProjectGui()
{
  Gui::label(Rect(centerPanel.x + PADDING,
                  centerPanel.y + PADDING, 300, 30),
                  "Select project to open:");

  if(Gui::button(Rect(centerPanel.x + centerPanel.width - 100 - PADDING,
                      centerPanel.y + centerPanel.height - 25 - PADDING,
                      100, 25), "Open") == true)
  {
    openButtonClicked();
  }

  int yPad = 50;
  Rect selectRect(centerPanel.x + PADDING, centerPanel.y + yPad, centerPanel.width - (PADDING * 2), centerPanel.height - (yPad * 2));
  Gui::box(selectRect, "");

  for(int i = 0; i < projects.size(); i++)
  {
    Rect itemRect(selectRect.x, selectRect.y + (20 * i), selectRect.width, 20);
    if(projects.at(i) == selectedProject)
    {
      Gui::box(itemRect, projects.at(i));
    }
    else
    {
      Gui::label(itemRect, projects.at(i));
    }

    if(Input::getMouseButtonDown(0) == true && itemRect.contains(Input::getMousePosition()) == true)
    {
      selectedProject = projects.at(i);
    }
  }
}
示例#2
0
CloudRoutesDialog::CloudRoutesDialog( CloudRouteModel *model, QWidget *parent ) : QDialog( parent ),
    d( new Private( model ) )
{
    d->setupUi( this );
    
    RouteItemDelegate *delegate = new RouteItemDelegate( d->listView, d->m_model );
    connect( delegate, SIGNAL(downloadButtonClicked(QString)), this, SIGNAL(downloadButtonClicked(QString)) );
    connect( delegate, SIGNAL(openButtonClicked(QString)), this, SIGNAL(openButtonClicked(QString)) );
    connect( delegate, SIGNAL(deleteButtonClicked(QString)), this, SIGNAL(deleteButtonClicked(QString)) );
    connect( delegate, SIGNAL(removeFromCacheButtonClicked(QString)), this, SIGNAL(removeFromCacheButtonClicked(QString)) );
    connect( delegate, SIGNAL(uploadToCloudButtonClicked(QString)), this, SIGNAL(uploadToCloudButtonClicked(QString)) );
    connect( d->m_model, SIGNAL(modelReset()), this, SLOT(updateNoRouteLabel()) );

    d->progressBar->setHidden( true );
    d->labelNoRoute->setHidden( true );

    d->listView->setItemDelegate( delegate );
    d->listView->setModel( d->m_model );
}
示例#3
0
bool RouteItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( model );

    if ( ( event->type() == QEvent::MouseButtonRelease ) ) {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>( event );
        QPoint pos = mouseEvent->pos();
        
        bool cached = index.data( CloudRouteModel::IsCached ).toBool();
        bool onCloud = index.data( CloudRouteModel::IsOnCloud ).toBool();

        if( cached && !onCloud ) {
            QRect uploadRect = position( UploadToCloudButton, option );

            if ( uploadRect.contains( pos ) ) {
                QString timestamp = index.data( CloudRouteModel::Timestamp ).toString();
                emit uploadToCloudButtonClicked( timestamp );
                return true;
            }
        }

        if ( cached ) {
            QRect openRect = position( OpenButton, option );
            QRect cacheRemoveRect = position( RemoveFromCacheButton, option );

            if ( openRect.contains( pos ) ) {
                QString timestamp = index.data( CloudRouteModel::Timestamp ).toString();
                emit openButtonClicked( timestamp );
                return true;
            } else if ( cacheRemoveRect.contains( pos ) ) {
                QString timestamp = index.data( CloudRouteModel::Timestamp ).toString();
                emit removeFromCacheButtonClicked( timestamp );
                return true;
            }
        } else {
            QRect downloadRect = position( DownloadButton, option );
            QRect cloudRemoveRect = position( RemoveFromCloudButton, option );
            
            if ( downloadRect.contains( pos ) ) {
                QString timestamp = index.data( CloudRouteModel::Timestamp ).toString();
                m_model->setDownloadingItem( index );
                emit downloadButtonClicked( timestamp );
                return true;
            }
            
            if ( cloudRemoveRect.contains( pos ) ) {
                QString timestamp = index.data( CloudRouteModel::Timestamp ).toString();
                emit deleteButtonClicked( timestamp );
                return true;
            }
        }
    }
    
    return false;
}