예제 #1
0
QgsGrassRegion::QgsGrassRegion( QgisInterface *iface,
                                QWidget * parent, Qt::WindowFlags f )
    : QWidget( parent, f )
    , QgsGrassRegionBase()
    , mInterface( 0 )
    , mCanvas( 0 )
    , mRadioGroup( 0 )
    , mX( 0 )
    , mY( 0 )
    , mUpdatingGui( false )
    , mRegionEdit( 0 )
{
  QgsDebugMsg( "QgsGrassRegion()" );
  QgsGrass::initRegion( &mWindow );

  setupUi( this );
  setAttribute( Qt::WA_DeleteOnClose );

  connect( mButtonBox, SIGNAL( clicked( QAbstractButton * ) ), SLOT( buttonClicked( QAbstractButton * ) ) );

  //mPlugin = plugin;
  mInterface = iface;
  mCanvas = mInterface->mapCanvas();
  mUpdatingGui = false;

  // Set input validators
  QDoubleValidator *dv = new QDoubleValidator( 0 );
  QIntValidator *iv = new QIntValidator( 0 );

  mNorth->setValidator( dv );
  mSouth->setValidator( dv );
  mEast->setValidator( dv );
  mWest->setValidator( dv );
  mNSRes->setValidator( dv );
  mEWRes->setValidator( dv );
  mRows->setValidator( iv );
  mCols->setValidator( iv );

  // Group radio buttons
  mRadioGroup = new QButtonGroup();
  mRadioGroup->addButton( mResRadio );
  mRadioGroup->addButton( mRowsColsRadio );
  mResRadio->setChecked( true );
  radioChanged();

  connect( mRadioGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( radioChanged() ) );

  // Connect entries
  connect( mNorth, SIGNAL( editingFinished() ), this, SLOT( northChanged() ) );
  connect( mSouth, SIGNAL( editingFinished() ), this, SLOT( southChanged() ) );
  connect( mEast, SIGNAL( editingFinished() ), this, SLOT( eastChanged() ) );
  connect( mWest, SIGNAL( editingFinished() ), this, SLOT( westChanged() ) );
  connect( mNSRes, SIGNAL( editingFinished() ), this, SLOT( NSResChanged() ) );
  connect( mEWRes, SIGNAL( editingFinished() ), this, SLOT( EWResChanged() ) );
  connect( mRows, SIGNAL( editingFinished() ), this, SLOT( rowsChanged() ) );
  connect( mCols, SIGNAL( editingFinished() ), this, SLOT( colsChanged() ) );

  connect( QgsGrass::instance(), SIGNAL( regionChanged() ), SLOT( reloadRegion() ) );
  connect( mCanvas, SIGNAL( mapToolSet( QgsMapTool * ) ), SLOT( canvasMapToolSet( QgsMapTool * ) ) );
}
예제 #2
0
void HexView::setContentLength(int contentLength)
{
    if (contentLength != contentLength_) {
        contentLength_ = contentLength;
        rowsChanged();
    }
}
예제 #3
0
// after changes are made
void Editor::indexChanged(int index)
{
	if (activeStack_ != activeStack() || index > activeStack()->count()) {
		return;
	}

	int s, e;
	bool redo;
	if (lastIndex_ < index) {
		// Redo
		redo = true;
		s = lastIndex_ + 1;
		e = index;
	} else if (lastIndex_ > index) {
		// Undo
		redo = false;
		s = index + 1;
		e = lastIndex_;
	} else {
		// Merge
		redo = true;
		s = index;
		e = index;
	}

	for (int i = s; i <= e; ++i) {
		const CommandBase *cmd = dynamic_cast<const CommandBase *>(activeStack_->command(i - 1));
		if (cmd->needRepaint()) {
			emit needRepaint();
			break;
		}
	}
	
	for (int i = s; i <= e; ++i) {
		const CommandBase *cmd = dynamic_cast<const CommandBase *>(activeStack_->command(i - 1));
		if (cmd->needUpdateDimension()) {
			const_cast<CommandBase *>(cmd)->model()->update_custom_data<ldraw::metrics>();
			break;
		}
	}

	for (int i = s; i <= e; ++i) {
		const CommandBase *cmd = dynamic_cast<const CommandBase *>(activeStack_->command(i - 1));
		QPair<CommandBase::AffectedRow, QSet<int> > affected = cmd->affectedRows();
		if (affected.second.size()) {
			if (!redo) {
				// flip
				if (affected.first == CommandBase::Inserted)
					affected.first = CommandBase::Removed;
				else
					affected.first = CommandBase::Inserted;
			}
			
			emit rowsChanged(affected);
		}
	}

	lastIndex_ = index;
}
예제 #4
0
void QDeclarativeGrid::setRows(const int rows)
{
    if (rows == m_rows)
        return;
    m_rows = rows;
    prePositioning();
    emit rowsChanged();
}
void WorkspacesInfo::updateWorkspaceGeometry()
{
    int workspaceCount;
    int rows;
    int columns;
    Orientation orientation;
    Corner startingCorner;
    unsigned long *result;

    /* First obtain the number of workspaces, that will be needed to
       also calculate some properties of the layout which could be missing
       from the property we will retrieve after this one */
    result = getX11IntProperty(_NET_NUMBER_OF_DESKTOPS, 1);
    if (result == NULL) {
        workspaceCount = 4;
    } else {
        workspaceCount = result[0];
    }
    XFree(result);

    /* Then ask X11 the layout of the workspaces. */
    result = getX11IntProperty(_NET_DESKTOP_LAYOUT, 4);
    if (result != NULL) {
        /* If we read the values correctly (some pager or the user set them)
           then just use them. */
        orientation = (Orientation) result[0];
        columns = result[1];
        rows = result[2];
        startingCorner = (Corner) result[3];

        /* Perform some sanity checks, since it's possible according to
           the spec for rows or colums to be zero, and we are supposed to
           calculate these values ourselves by using the total count
        */
        if (rows == 0 && columns == 0) {
            rows = 2;
            columns = workspaceCount;
        } else {
            if (rows == 0) {
                rows = ceil((float) workspaceCount / (float) columns);
            } else if (columns == 0) {
                columns = ceil((float) workspaceCount / (float) rows);
            }
        }

        XFree(result);
    } else {
        /* In this property does not exist (as is the case if you
           don't login into the regular gnome session before unity-2d),
           just fallback on reasonable defaults. */
        rows = 2;
        columns = ceil((float) workspaceCount / (float) rows);
        orientation = WorkspacesInfo::OrientationHorizontal;
        startingCorner = WorkspacesInfo::CornerTopLeft;
    }

    /* Notify of changes, if any */
    if (m_count != workspaceCount) {
        m_count = workspaceCount;
        Q_EMIT countChanged(m_count);
    }
    if (m_rows != rows) {
        m_rows = rows;
        Q_EMIT rowsChanged(m_rows);
    }
    if (m_columns != columns) {
        m_columns = columns;
        Q_EMIT columnsChanged(m_columns);
    }
    if (m_orientation != orientation) {
        m_orientation = orientation;
        Q_EMIT orientationChanged(m_orientation);
    }
    if (m_startingCorner != startingCorner) {
        m_startingCorner = startingCorner;
        Q_EMIT startingCornerChanged(m_startingCorner);
    }
}
예제 #6
0
QgsGrassRegion::QgsGrassRegion( QgsGrassPlugin *plugin,  QgisInterface *iface,
                                QWidget * parent, Qt::WFlags f )
    : QDialog( parent, f ), QgsGrassRegionBase( )
{
  QgsDebugMsg( "QgsGrassRegion()" );

  setupUi( this );
  setAttribute( Qt::WA_DeleteOnClose );

  connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
  connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );

  mPlugin = plugin;
  mInterface = iface;
  mCanvas = mInterface->mapCanvas();
  restorePosition();
  mUpdatingGui = false;

  // Set input validators
  QDoubleValidator *dv = new QDoubleValidator( 0 );
  QIntValidator *iv = new QIntValidator( 0 );

  mNorth->setValidator( dv );
  mSouth->setValidator( dv );
  mEast->setValidator( dv );
  mWest->setValidator( dv );
  mNSRes->setValidator( dv );
  mEWRes->setValidator( dv );
  mRows->setValidator( iv );
  mCols->setValidator( iv );

  // Group radio buttons
  mRadioGroup = new QButtonGroup();
  mRadioGroup->addButton( mCellResRadio );
  mRadioGroup->addButton( mRowsColsRadio );
  mCellResRadio->setChecked( true );
  radioChanged();

  connect( mRadioGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( radioChanged() ) );

  // Set values to current region
  QString gisdbase = QgsGrass::getDefaultGisdbase();
  QString location = QgsGrass::getDefaultLocation();
  QString mapset   = QgsGrass::getDefaultMapset();

  if ( gisdbase.isEmpty() || location.isEmpty() || mapset.isEmpty() )
  {
    QMessageBox::warning( 0, tr( "Warning" ),
                          tr( "GISDBASE, LOCATION_NAME or MAPSET is not set, cannot display current region." ) );
  }

  QgsGrass::setLocation( gisdbase, location );
  char *err = G__get_window( &mWindow, ( char * ) "", ( char * ) "WIND", mapset.toLatin1().data() );

  if ( err )
  {
    QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot read current region: %1" ).arg( QString::fromUtf8( err ) ) );
    return;
  }

  mRegionEdit = new QgsGrassRegionEdit( mCanvas );
  connect( mRegionEdit, SIGNAL( captureStarted() ), this, SLOT( hide() ) );
  connect( mRegionEdit, SIGNAL( captureEnded() ), this, SLOT( onCaptureFinished() ) );
  mCanvas->setMapTool( mRegionEdit );

  refreshGui();

  connect( mCanvas, SIGNAL( renderComplete( QPainter * ) ), this, SLOT( postRender( QPainter * ) ) );

  // Connect entries
  connect( mNorth, SIGNAL( editingFinished() ), this, SLOT( northChanged() ) );
  connect( mSouth, SIGNAL( editingFinished() ), this, SLOT( southChanged() ) );
  connect( mEast, SIGNAL( editingFinished() ), this, SLOT( eastChanged() ) );
  connect( mWest, SIGNAL( editingFinished() ), this, SLOT( westChanged() ) );
  connect( mNSRes, SIGNAL( editingFinished() ), this, SLOT( NSResChanged() ) );
  connect( mEWRes, SIGNAL( editingFinished() ), this, SLOT( EWResChanged() ) );
  connect( mRows, SIGNAL( editingFinished() ), this, SLOT( rowsChanged() ) );
  connect( mCols, SIGNAL( editingFinished() ), this, SLOT( colsChanged() ) );

  // Symbology
  QPen pen = mPlugin->regionPen();
  mColorButton->setColor( pen.color() );
  connect( mColorButton, SIGNAL( clicked() ), this, SLOT( changeColor() ) );

  mWidthSpinBox->setValue( pen.width() );
  connect( mWidthSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeWidth() ) );
}
void QMLBoardTile::setRows(int rows)
{
    mRows = rows;
    emit rowsChanged();
}