--- a/QTfrontend/itemNum.cpp Fri Oct 26 18:55:27 2007 +0000
+++ b/QTfrontend/itemNum.cpp Fri Nov 30 18:31:41 2007 +0000
@@ -21,8 +21,8 @@
#include <QMouseEvent>
#include <QPainter>
-ItemNum::ItemNum(const QImage& im, QWidget * parent) :
- m_im(im), QWidget(parent), nonInteractive(false)
+ItemNum::ItemNum(const QImage& im, QWidget * parent, unsigned char min, unsigned char max) :
+ m_im(im), QWidget(parent), nonInteractive(false), minItems(min), maxItems(max), numItems(min)
{
}
@@ -35,10 +35,14 @@
if(nonInteractive) return;
if(event->button()==Qt::LeftButton) {
event->accept();
- incItems();
+ if(numItems < maxItems) {
+ incItems();
+ }
} else if (event->button()==Qt::RightButton) {
event->accept();
- decItems();
+ if(numItems > minItems) {
+ decItems();
+ }
} else {
event->ignore();
return;
@@ -55,3 +59,13 @@
painter.drawImage(target, m_im);
}
}
+
+unsigned char ItemNum::getItemsNum() const
+{
+ return numItems;
+}
+
+void ItemNum::setItemsNum(const unsigned char num)
+{
+ numItems=num;
+}