- Some work on drawMap widget and scene to allow undo, clear, save and load operations
authorunc0rr
Sat, 18 Dec 2010 23:02:39 +0300
changeset 4560 5d6c7f88db73
parent 4559 194d5a7a3fd4
child 4561 da9d27bc6ea6
- Some work on drawMap widget and scene to allow undo, clear, save and load operations - Fix tons of "parameter not used" warnings
QTfrontend/SquareLabel.cpp
QTfrontend/ammoSchemeModel.cpp
QTfrontend/bgwidget.cpp
QTfrontend/chatwidget.cpp
QTfrontend/drawmapscene.cpp
QTfrontend/drawmapscene.h
QTfrontend/drawmapwidget.cpp
QTfrontend/drawmapwidget.h
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
QTfrontend/hats.cpp
QTfrontend/hwform.cpp
QTfrontend/igbox.cpp
QTfrontend/itemNum.cpp
QTfrontend/mapContainer.cpp
QTfrontend/netregister.cpp
QTfrontend/pages.h
QTfrontend/statsPage.cpp
QTfrontend/togglebutton.cpp
--- a/QTfrontend/SquareLabel.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/SquareLabel.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -29,6 +29,8 @@
 
 void SquareLabel::paintEvent(QPaintEvent * event)
 {
+    Q_UNUSED(event);
+
     QPainter painter(this);
     int pixsize;
     if (width() > height()) {
--- a/QTfrontend/ammoSchemeModel.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/ammoSchemeModel.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -577,6 +577,10 @@
 
 QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
 {
+    Q_UNUSED(section);
+    Q_UNUSED(orientation);
+    Q_UNUSED(role);
+
     return QVariant();
 }
 
@@ -598,6 +602,8 @@
 
 Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
 {
+    Q_UNUSED(index);
+
     return
         Qt::ItemIsEnabled
         | Qt::ItemIsSelectable
@@ -620,6 +626,8 @@
 
 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
 {
+    Q_UNUSED(count);
+
     beginInsertRows(parent, row, row);
 
     QList<QVariant> newScheme = defaultScheme;
@@ -684,6 +692,10 @@
 
 QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
 {
+    Q_UNUSED(section);
+    Q_UNUSED(orientation);
+    Q_UNUSED(role);
+
     return QVariant();
 }
 
--- a/QTfrontend/bgwidget.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/bgwidget.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -103,6 +103,8 @@
 
 void BGWidget::paintEvent(QPaintEvent *event)
 {
+    Q_UNUSED(event);
+
     QPainter p;
     p.begin(this);
     //p.setRenderHint(QPainter::Antialiasing);
--- a/QTfrontend/chatwidget.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/chatwidget.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -341,6 +341,8 @@
 
 void HWChatWidget::chatNickSelected(int index)
 {
+    Q_UNUSED(index);
+
     QListWidgetItem* item = chatNicks->currentItem();
     if (!item)
         return;
--- a/QTfrontend/drawmapscene.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/drawmapscene.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -57,6 +57,8 @@
 
 void DrawMapScene::mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent)
 {
+    Q_UNUSED(mouseEvent);
+
     simplifyLast();
 
     m_currPath = 0;
@@ -73,6 +75,14 @@
     }
 }
 
+void DrawMapScene::clearMap()
+{
+    clear();
+    paths.clear();
+
+    emit pathChanged();
+}
+
 QByteArray DrawMapScene::encode()
 {
     QByteArray b;
@@ -128,11 +138,15 @@
 
         points.append(QPoint(px, py));
     }
+
+    emit pathChanged();
 }
 
 void DrawMapScene::simplifyLast()
 {
-    QList<QPoint> points = paths[0];
+    if(!paths.size()) return;
+
+    QList<QPoint> points = paths.at(0);
 
     QPoint prevPoint = points.first();
     int i = 1;
--- a/QTfrontend/drawmapscene.h	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/drawmapscene.h	Sat Dec 18 23:02:39 2010 +0300
@@ -22,6 +22,7 @@
 
 public slots:
     void undo();
+    void clearMap();
     void simplifyLast();
 
 private:
--- a/QTfrontend/drawmapwidget.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/drawmapwidget.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -1,3 +1,5 @@
+#include <QFile>
+
 #include "drawmapwidget.h"
 
 DrawMapWidget::DrawMapWidget(QWidget *parent) :
@@ -5,6 +7,8 @@
     ui(new Ui::DrawMapWidget)
 {
     ui->setupUi(this);
+
+    m_scene = 0;
 }
 
 DrawMapWidget::~DrawMapWidget()
@@ -43,3 +47,23 @@
 
     resizeEvent(0);
 }
+
+void DrawMapWidget::undo()
+{
+    if(m_scene) m_scene->undo();
+}
+
+void DrawMapWidget::clear()
+{
+    if(m_scene) m_scene->clear();
+}
+
+void DrawMapWidget::save(const QString & fileName)
+{
+    Q_UNUSED(fileName);
+}
+
+void DrawMapWidget::load(const QString & fileName)
+{
+    Q_UNUSED(fileName);
+}
--- a/QTfrontend/drawmapwidget.h	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/drawmapwidget.h	Sat Dec 18 23:02:39 2010 +0300
@@ -15,7 +15,6 @@
     {
     public:
         QGraphicsView *graphicsView;
-        QPushButton *pbUndo;
 
         void setupUi(QWidget *drawMapWidget)
         {
@@ -50,6 +49,12 @@
 
     void setScene(DrawMapScene * scene);
 
+public slots:
+    void undo();
+    void clear();
+    void save(const QString & fileName);
+    void load(const QString & fileName);
+
 protected:
     void changeEvent(QEvent *e);
     virtual void resizeEvent(QResizeEvent * event);
@@ -57,6 +62,8 @@
 
 private:
     Ui::DrawMapWidget *ui;
+
+    DrawMapScene * m_scene;
 };
 
 #endif // DRAWMAPWIDGET_H
--- a/QTfrontend/gamecfgwidget.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/gamecfgwidget.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -32,7 +32,7 @@
 #include "ammoSchemeModel.h"
 #include "proto.h"
 
-GameCFGWidget::GameCFGWidget(QWidget* parent, bool externalControl) :
+GameCFGWidget::GameCFGWidget(QWidget* parent) :
   QGroupBox(parent), mainLayout(this)
 {
     mainLayout.setMargin(0);
--- a/QTfrontend/gamecfgwidget.h	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/gamecfgwidget.h	Sat Dec 18 23:02:39 2010 +0300
@@ -36,7 +36,7 @@
     Q_OBJECT
 
 public:
-    GameCFGWidget(QWidget* parent, bool externalControl=false);
+    GameCFGWidget(QWidget* parent);
     quint32 getGameFlags() const;
     quint32 getInitHealth() const;
     QByteArray getFullConfig() const;
--- a/QTfrontend/hats.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/hats.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -77,6 +77,10 @@
 QVariant HatsModel::headerData(int section,
             Qt::Orientation orientation, int role) const
 {
+    Q_UNUSED(section);
+    Q_UNUSED(orientation);
+    Q_UNUSED(role);
+
     return QVariant();
 }
 
--- a/QTfrontend/hwform.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/hwform.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -1157,6 +1157,8 @@
 
 void HWForm::UpdateCampaignPage(int index)
 {
+    Q_UNUSED(index);
+
     HWTeam team(ui.pageCampaign->CBTeam->currentText());
     ui.pageCampaign->CBSelect->clear();
 
--- a/QTfrontend/igbox.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/igbox.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -24,6 +24,7 @@
 #include "igbox.h"
 
 IconedGroupBox::IconedGroupBox(QWidget * parent)
+    : QGroupBox(parent)
 {
 // Has issues with border-radius on children
 //    setAttribute(Qt::WA_PaintOnScreen, true);
@@ -56,6 +57,8 @@
 
 void IconedGroupBox::paintEvent(QPaintEvent * event)
 {
+    Q_UNUSED(event);
+
     QStylePainter painter(this);
 
     QStyleOptionGroupBox option;
--- a/QTfrontend/itemNum.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/itemNum.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -68,6 +68,8 @@
 
 void ItemNum::paintEvent(QPaintEvent* event)
 {
+  Q_UNUSED(event);
+
   QPainter painter(this);
 
   if (numItems==maxItems+1) {
--- a/QTfrontend/mapContainer.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/mapContainer.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -426,6 +426,7 @@
 
 void HWMapContainer::resizeEvent ( QResizeEvent * event )
 {
+    Q_UNUSED(event);
   //imageButt->setIconSize(imageButt->size());
 }
 
--- a/QTfrontend/netregister.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/netregister.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -21,7 +21,8 @@
 HWNetRegisterServer::HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port) :
   QObject(parent)
 {
-
+    Q_UNUSED(descr);
+    Q_UNUSED(port);
 }
 
 void HWNetRegisterServer::unregister()
--- a/QTfrontend/pages.h	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/pages.h	Sat Dec 18 23:02:39 2010 +0300
@@ -71,6 +71,8 @@
 
  protected:
   AbstractPage(QWidget* parent = 0) {
+    Q_UNUSED(parent);
+
     font14 = new QFont("MS Shell Dlg", 14);
     setFocusPolicy(Qt::StrongFocus);
   }
--- a/QTfrontend/statsPage.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/statsPage.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -31,6 +31,8 @@
 
 void FitGraphicsView::resizeEvent(QResizeEvent * event)
 {
+    Q_UNUSED(event);
+
     fitInView(sceneRect());
 }
 
--- a/QTfrontend/togglebutton.cpp	Sat Dec 18 21:19:26 2010 +0300
+++ b/QTfrontend/togglebutton.cpp	Sat Dec 18 23:02:39 2010 +0300
@@ -19,6 +19,7 @@
 #include "togglebutton.h"
 
 ToggleButtonWidget::ToggleButtonWidget(QWidget * parent, QString img)
+    : QPushButton(parent)
 {
     setCheckable(true);