Author: cazfi
Date: Sun Jun 26 09:50:28 2016
New Revision: 33034

URL: http://svn.gna.org/viewcvs/freeciv?rev=33034&view=rev
Log:
Added initial version of req_edit dialog to the ruledit.

See patch #7319

Added:
    trunk/tools/ruledit/req_edit.cpp
    trunk/tools/ruledit/req_edit.h
Modified:
    trunk/tools/ruledit/Makefile.am
    trunk/tools/ruledit/tab_good.cpp
    trunk/tools/ruledit/tab_good.h

Modified: trunk/tools/ruledit/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/Makefile.am?rev=33034&r1=33033&r2=33034&view=diff
==============================================================================
--- trunk/tools/ruledit/Makefile.am     (original)
+++ trunk/tools/ruledit/Makefile.am     Sun Jun 26 09:50:28 2016
@@ -25,6 +25,7 @@
 
 MOC_FILES = \
             meta_edit_utype.cpp \
+           meta_req_edit.cpp   \
             meta_requirers_dlg.cpp \
             meta_ruledit_qt.cpp \
             meta_tab_misc.cpp  \
@@ -49,6 +50,8 @@
                tab_tech.h      \
                 tab_unit.cpp   \
                tab_unit.h      \
+               req_edit.cpp    \
+               req_edit.h      \
                requirers_dlg.cpp \
                requirers_dlg.h \
                ruledit.cpp     \

Added: trunk/tools/ruledit/req_edit.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/req_edit.cpp?rev=33034&view=auto
==============================================================================
--- trunk/tools/ruledit/req_edit.cpp    (added)
+++ trunk/tools/ruledit/req_edit.cpp    Sun Jun 26 09:50:28 2016
@@ -0,0 +1,89 @@
+/***********************************************************************
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   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; either version 2, or (at your option)
+   any later version.
+
+   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.
+***********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <fc_config.h>
+#endif
+
+// Qt
+#include <QGridLayout>
+#include <QPushButton>
+
+// utility
+#include "fcintl.h"
+
+// common
+#include "requirements.h"
+
+#include "req_edit.h"
+
+/**************************************************************************
+  Setup req_edit object
+**************************************************************************/
+req_edit::req_edit(ruledit_gui *ui_in, QString target,
+                   const struct requirement_vector *preqs) : QDialog()
+{
+  QGridLayout *main_layout = new QGridLayout(this);
+  QPushButton *close_button;
+  int row = 0;
+
+  ui = ui_in;
+
+  area = new QTextEdit();
+  area->setParent(this);
+  area->setReadOnly(true);
+  main_layout->addWidget(area, row++, 0);
+
+  close_button = new QPushButton(QString::fromUtf8(R__("Close")), this);
+  connect(close_button, SIGNAL(pressed()), this, SLOT(close_now()));
+  main_layout->addWidget(close_button, row++, 0);
+
+  setLayout(main_layout);
+  setWindowTitle(target);
+
+  requirement_vector_iterate(preqs, preq) {
+    char buf[512];
+
+    if (!preq->present) {
+      continue;
+    }
+
+    universal_name_translation(&preq->source,
+                               buf, sizeof(buf));
+    add(buf);
+  } requirement_vector_iterate_end;
+}
+
+/**************************************************************************
+  Clear text area
+**************************************************************************/
+void req_edit::clear(const char *title)
+{
+  area->clear();
+}
+
+/**************************************************************************
+  Add req entry
+**************************************************************************/
+void req_edit::add(const char *msg)
+{
+  area->append(QString::fromUtf8(msg));
+}
+
+/**************************************************************************
+  User pushed close button
+**************************************************************************/
+void req_edit::close_now()
+{
+  done(0);
+}

Added: trunk/tools/ruledit/req_edit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/req_edit.h?rev=33034&view=auto
==============================================================================
--- trunk/tools/ruledit/req_edit.h      (added)
+++ trunk/tools/ruledit/req_edit.h      Sun Jun 26 09:50:28 2016
@@ -0,0 +1,47 @@
+/***********************************************************************
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   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; either version 2, or (at your option)
+   any later version.
+
+   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.
+***********************************************************************/
+
+#ifndef FC__REQ_EDIT_H
+#define FC__REQ_EDIT_H
+
+#ifdef HAVE_CONFIG_H
+#include <fc_config.h>
+#endif
+
+// Qt
+#include <QDialog>
+#include <QTextEdit>
+
+class ruledit_gui;
+
+class req_edit : public QDialog
+{
+  Q_OBJECT
+
+  public:
+  explicit req_edit(ruledit_gui *ui_in, QString target,
+                    const struct requirement_vector *preqs);
+    void clear(const char *title);
+    void add(const char *msg);
+
+  private:
+    ruledit_gui *ui;
+
+    QTextEdit *area;
+
+  private slots:
+    void close_now();
+};
+
+
+#endif // FC__REQ_EDIT_H

Modified: trunk/tools/ruledit/tab_good.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/tab_good.cpp?rev=33034&r1=33033&r2=33034&view=diff
==============================================================================
--- trunk/tools/ruledit/tab_good.cpp    (original)
+++ trunk/tools/ruledit/tab_good.cpp    Sun Jun 26 09:50:28 2016
@@ -33,6 +33,7 @@
 #include "improvement.h"
 
 // ruledit
+#include "req_edit.h"
 #include "ruledit.h"
 #include "ruledit_qt.h"
 #include "validity.h"
@@ -49,6 +50,7 @@
   QLabel *label;
   QPushButton *add_button;
   QPushButton *delete_button;
+  QPushButton *reqs_button;
 
   ui = ui_in;
   selected = 0;
@@ -79,6 +81,11 @@
   good_layout->addWidget(same_name, 1, 1);
   good_layout->addWidget(name, 1, 2);
 
+  reqs_button = new QPushButton(QString::fromUtf8(R__("Requirements")), this);
+  connect(reqs_button, SIGNAL(pressed()), this, SLOT(edit_reqs()));
+  good_layout->addWidget(reqs_button, 2, 2);
+  show_experimental(reqs_button);
+
   add_button = new QPushButton(QString::fromUtf8(R__("Add Good")), this);
   connect(add_button, SIGNAL(pressed()), this, SLOT(add_now()));
   good_layout->addWidget(add_button, 5, 0);
@@ -259,3 +266,16 @@
     name->setText(rname->text());
   }
 }
+
+/**************************************************************************
+  User wants to edit reqs
+**************************************************************************/
+void tab_good::edit_reqs()
+{
+  if (selected != nullptr) {
+    req_edit *redit = new req_edit(ui, goods_rule_name(selected),
+                                   &selected->reqs);
+
+    redit->show();
+  }
+}

Modified: trunk/tools/ruledit/tab_good.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/tab_good.h?rev=33034&r1=33033&r2=33034&view=diff
==============================================================================
--- trunk/tools/ruledit/tab_good.h      (original)
+++ trunk/tools/ruledit/tab_good.h      Sun Jun 26 09:50:28 2016
@@ -53,6 +53,7 @@
     void add_now();
     void delete_now();
     void same_name_toggle(bool checked);
+    void edit_reqs();
 };
 
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to