From 2a441ecbea378da1a2cdea969c48bb7d9e547135 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 8 Oct 2008 19:22:25 +0200 Subject: Import new upstream release 0.42 --- offsetConstraint.cpp | 98 ---------------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 offsetConstraint.cpp (limited to 'offsetConstraint.cpp') diff --git a/offsetConstraint.cpp b/offsetConstraint.cpp deleted file mode 100644 index 3369bf9..0000000 --- a/offsetConstraint.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* $Id: offsetConstraint.cpp,v 1.7 2006/11/05 04:42:43 ganzhorn Exp $ - * This file is part of lfhex. - * Copyright (C) 2006 Salem Ganzhorn - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include // for min<>() - -#include "local.h" -#include "offsetConstraint.hpp" -#include "box.hpp" - -OffsetConstraint::OffsetConstraint( QWidget * parent ) - : QGroupBox(parent) -{ - QLayout* l = new QHBoxLayout(this); - this->setLayout(l); - hbox * h = new hbox(this); - l->addWidget(h); - new QLabel("X =",h); - stride = new QSpinBox(h); - stride->setRange(1,16); - stride->setValue(1); - connect(stride,SIGNAL(valueChanged(int)), - this,SLOT(setStride(int))); - - h = new hbox(this); - l->addWidget(h); - new QLabel("Y =",h); - offset = new QSpinBox(h); - offset->setRange(1,16); - offset->setValue(1); - - setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); -} - -// public interface - -int OffsetConstraint::getStride(void) const -{ - return stride->text().toInt(); -} - -int OffsetConstraint::getOffset(void) const -{ - return offset->text().toInt(); -} - -off_t OffsetConstraint::next(off_t off) const -{ - return( ((off-getOffset())/getStride()+1)*getStride()+getOffset() ); -} - -off_t OffsetConstraint::prev(off_t off) const -{ - return( ((off-getOffset())/getStride() - 1)*getStride()+getOffset() ); -} - -// public slots -void OffsetConstraint::setOffset(int x) -{ - offset->setValue( min(x,getStride()-1) ); -} - -void OffsetConstraint::setStride(int x) -{ - // constrain x to (0,MAXINT) - if( x < 1 ) { - stride->setValue(1); - return; - } - - // constrain offset to [0,x) - - // setRange() does not seem to work as the documentation says, so - // we have to manually change the value - if( offset->text().toInt() >= x ) - offset->setValue(x-1); - offset->setRange(0,x-1); - return; -} - -- cgit v1.2.3-54-g00ecf