Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) TestQtRoundedEditRectItem

 

TestQtRoundedEditRectItem is a tool to test the QtRoundedEditRectItem class.

 

 

 

 

 

Downloads

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolTestQtRoundedEditRectItem/ToolTestQtRoundedEditRectItemDesktop.pro

 

include(../../DesktopApplication.pri)

include(../../Libraries/Apfloat.pri)
include(../../Libraries/Boost.pri)
include(../../Libraries/GeneralConsole.pri)
include(../../Libraries/GeneralDesktop.pri)

include(../../Classes/CppContainer/CppContainer.pri)
include(../../Classes/CppCounter/CppCounter.pri)
include(../../Classes/CppGeometry/CppGeometry.pri)
include(../../Classes/CppPlane/CppPlane.pri)
include(../../Classes/CppQtKeyboardFriendlyGraphicsView/CppQtKeyboardFriendlyGraphicsView.pri)
include(../../Classes/CppQtRoundedRectItem/CppQtRoundedRectItem.pri)
include(../../Classes/CppQtRoundedEditRectItem/CppQtRoundedEditRectItem.pri)
include(../../Classes/CppRibiRegex/CppRibiRegex.pri)

include(ToolTestQtRoundedEditRectItemDesktop.pri)

SOURCES += qtmain.cpp

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/ToolTestQtRoundedEditRectItemConsole.pri

 

INCLUDEPATH += \
    ../../Tools/ToolTestQtRoundedEditRectItem

SOURCES += \
    ../../Tools/ToolTestQtRoundedEditRectItem/testqtroundededitrectitemmenudialog.cpp

HEADERS += \
    ../../Tools/ToolTestQtRoundedEditRectItem/testqtroundededitrectitemmenudialog.h

OTHER_FILES += \
    ../../Tools/ToolTestQtRoundedEditRectItem/Licence.txt

RESOURCES += \
    ../../Tools/ToolTestQtRoundedEditRectItem/ToolTestQtRoundedEditRectItem.qrc

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/ToolTestQtRoundedEditRectItemDesktop.pri

 

include(../../Tools/ToolTestQtRoundedEditRectItem/ToolTestQtRoundedEditRectItemConsole.pri)

HEADERS += \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemwidget.h \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmenudialog.h \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemcomparedialog.h \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmodifydialog.h

SOURCES += \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemwidget.cpp \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmenudialog.cpp \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemcomparedialog.cpp \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmodifydialog.cpp

FORMS += \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmenudialog.ui \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemcomparedialog.ui \
    ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmodifydialog.ui

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/ToolTestQtRoundedEditRectItemWebsite.pri

 

include(../../Tools/ToolTestQtRoundedEditRectItem/ToolTestQtRoundedEditRectItemConsole.pri)

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/qtmain.cpp

 

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#include <QApplication>
#include <QDesktopWidget>
#include "qttestqtroundededitrectitemmenudialog.h"
#pragma GCC diagnostic pop

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  ribi::QtTestQtRoundedEditRectItemMenuDialog d;
  d.show();
  return a.exec();
}

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemcomparedialog.h

 

//---------------------------------------------------------------------------
/*
TestQtRoundedEditRectItem, tool to test QtRoundedEditRectItem
Copyright (C) 2012-2015 Richel Bilderbeek

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 3 of the License, 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.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQtRoundedEditRectItem.htm
//---------------------------------------------------------------------------
#ifndef QTTESTQTROUNDEDEDITRECTITEMCOMPAREDIALOG_H
#define QTTESTQTROUNDEDEDITRECTITEMCOMPAREDIALOG_H

#include "qthideandshowdialog.h"

namespace Ui {
class QtTestQtRoundedEditRectItemCompareDialog;
}

namespace ribi {

class QtTestQtRoundedEditRectItemCompareDialog : public ribi::QtHideAndShowDialog
{
  Q_OBJECT
    
public:

  explicit QtTestQtRoundedEditRectItemCompareDialog(QWidget *parent = 0);
  QtTestQtRoundedEditRectItemCompareDialog(const QtTestQtRoundedEditRectItemCompareDialog&) = delete;
  QtTestQtRoundedEditRectItemCompareDialog& operator=(const QtTestQtRoundedEditRectItemCompareDialog&) = delete;
  ~QtTestQtRoundedEditRectItemCompareDialog() noexcept;
protected:
  void keyPressEvent(QKeyEvent * event);

private:
  Ui::QtTestQtRoundedEditRectItemCompareDialog *ui;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // QTTESTQTROUNDEDEDITRECTITEMCOMPAREDIALOG_H

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemcomparedialog.cpp

 

//---------------------------------------------------------------------------
/*
TestQtRoundedEditRectItem, tool to test QtRoundedEditRectItem
Copyright (C) 2012-2015 Richel Bilderbeek

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 3 of the License, 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.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQtRoundedEditRectItem.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "qttestqtroundededitrectitemcomparedialog.h"
#include <QKeyEvent>

#include "testtimer.h"
#include "trace.h"
#include "ui_qttestqtroundededitrectitemcomparedialog.h"
#pragma GCC diagnostic pop

ribi::QtTestQtRoundedEditRectItemCompareDialog::QtTestQtRoundedEditRectItemCompareDialog(QWidget *parent) :
    QtHideAndShowDialog(parent),
    ui(new Ui::QtTestQtRoundedEditRectItemCompareDialog)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);
}

ribi::QtTestQtRoundedEditRectItemCompareDialog::~QtTestQtRoundedEditRectItemCompareDialog() noexcept
{
  delete ui;
}

void ribi::QtTestQtRoundedEditRectItemCompareDialog::keyPressEvent(QKeyEvent * event)
{
  if (event->key() == Qt::Key_Escape) { close(); return; }
}

#ifndef NDEBUG
void ribi::QtTestQtRoundedEditRectItemCompareDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmenudialog.h

 


//---------------------------------------------------------------------------
/*
TestQtRoundedEditRectItem, tool to test QtRoundedEditRectItem
Copyright (C) 2012-2015 Richel Bilderbeek

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 3 of the License, 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.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQtRoundedEditRectItem.htm
//---------------------------------------------------------------------------
#ifndef QTTESTQTROUNDEDEDITRECTITEMMENUDIALOG_H
#define QTTESTQTROUNDEDEDITRECTITEMMENUDIALOG_H

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#include "qthideandshowdialog.h"
#pragma GCC diagnostic pop

namespace Ui {
  class QtTestQtRoundedEditRectItemMenuDialog;
}

namespace ribi {

class QtTestQtRoundedEditRectItemMenuDialog : public ribi::QtHideAndShowDialog
{
  Q_OBJECT

public:
  explicit QtTestQtRoundedEditRectItemMenuDialog(QWidget *parent = 0);
  QtTestQtRoundedEditRectItemMenuDialog(const QtTestQtRoundedEditRectItemMenuDialog&) = delete;
  QtTestQtRoundedEditRectItemMenuDialog& operator=(const QtTestQtRoundedEditRectItemMenuDialog&) = delete;
  ~QtTestQtRoundedEditRectItemMenuDialog() noexcept;

protected:
  
  void keyPressEvent(QKeyEvent * event);

private:
  Ui::QtTestQtRoundedEditRectItemMenuDialog *ui;

private slots:
  void on_button_about_clicked();
  void on_button_quit_clicked();
  void on_button_compare_clicked();
  void on_button_modify_clicked();

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // QTTESTQTROUNDEDEDITRECTITEMMENUDIALOG_H

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestQtRoundedEditRectItem, tool to test QtRoundedEditRectItem
Copyright (C) 2012-2015 Richel Bilderbeek

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 3 of the License, 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.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQtRoundedEditRectItem.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#include "qttestqtroundededitrectitemmenudialog.h"

#include <QDesktopWidget>
#include <QKeyEvent>

#include "qtkeyboardfriendlygraphicsview.h"
#include "qtroundedrectitem.h"
#include "qtroundededitrectitem.h"
#include "testqtroundededitrectitemmenudialog.h"
#include "qtaboutdialog.h"
#include "qttestqtroundededitrectitemcomparedialog.h"
#include "qttestqtroundededitrectitemmodifydialog.h"
#include "trace.h"
#include "testtimer.h"
#include "ui_qttestqtroundededitrectitemmenudialog.h"
#pragma GCC diagnostic pop

ribi::QtTestQtRoundedEditRectItemMenuDialog::QtTestQtRoundedEditRectItemMenuDialog(QWidget *parent) :
    QtHideAndShowDialog(parent),
    ui(new Ui::QtTestQtRoundedEditRectItemMenuDialog)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);
}

ribi::QtTestQtRoundedEditRectItemMenuDialog::~QtTestQtRoundedEditRectItemMenuDialog() noexcept
{
  delete ui;
}

void ribi::QtTestQtRoundedEditRectItemMenuDialog::keyPressEvent(QKeyEvent * event)
{
  if (event->key() == Qt::Key_Escape) { close(); return; }
}

void ribi::QtTestQtRoundedEditRectItemMenuDialog::on_button_about_clicked()
{
  About a = TestQtRoundedEditRectItemMenuDialog().GetAbout();
  a.AddLibrary("QtHideAndShowDialog version: " + QtHideAndShowDialog::GetVersion());
  a.AddLibrary("QtKeyboardFriendlyGraphicsView version: " + QtKeyboardFriendlyGraphicsView::GetVersion());
  a.AddLibrary("QtRoundedRectItem version: " + QtRoundedRectItem::GetVersion());
  a.AddLibrary("QtRoundedEditRectItem version: " + QtRoundedEditRectItem::GetVersion());
  QtAboutDialog d(a);
  d.setWindowIcon(this->windowIcon());
  d.setStyleSheet(this->styleSheet());
  this->ShowChild(&d);
}

void ribi::QtTestQtRoundedEditRectItemMenuDialog::on_button_compare_clicked()
{
  QtTestQtRoundedEditRectItemCompareDialog d;
  d.setWindowIcon(this->windowIcon());
  //d.setStyleSheet(this->styleSheet());
  ShowChild(&d);
}

void ribi::QtTestQtRoundedEditRectItemMenuDialog::on_button_modify_clicked()
{
  QtTestQtRoundedEditRectItemModifyDialog d;
  d.setWindowIcon(this->windowIcon());
  //d.setStyleSheet(this->styleSheet());
  ShowChild(&d);
}

void ribi::QtTestQtRoundedEditRectItemMenuDialog::on_button_quit_clicked()
{
  close();
}

#ifndef NDEBUG
void ribi::QtTestQtRoundedEditRectItemMenuDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  QtRoundedRectItem();
  QtRoundedEditRectItem();
  QtTestQtRoundedEditRectItemCompareDialog();
  QtTestQtRoundedEditRectItemModifyDialog();
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmodifydialog.h

 

//---------------------------------------------------------------------------
/*
TestQtRoundedEditRectItem, tool to test QtRoundedRectItem
Copyright (C) 2012-2015 Richel Bilderbeek

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 3 of the License, 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.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQtRoundedEditRectItem.htm
//---------------------------------------------------------------------------
#ifndef QTTESTQTROUNDEDEDITRECTITEMMODIFYDIALOG_H
#define QTTESTQTROUNDEDEDITRECTITEMMODIFYDIALOG_H

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#include <boost/shared_ptr.hpp>
#include "qthideandshowdialog.h"
#pragma GCC diagnostic pop

struct QGraphicsView;

namespace Ui {
class QtTestQtRoundedEditRectItemModifyDialog;
}


namespace ribi {

//struct QtRoundedRectItem;
struct QtRoundedEditRectItem;
struct QtRoundedEditRectItemDialog;

class QtTestQtRoundedEditRectItemModifyDialog : public QtHideAndShowDialog
{
  Q_OBJECT
    
public:

  explicit QtTestQtRoundedEditRectItemModifyDialog(QWidget *parent = 0);
  QtTestQtRoundedEditRectItemModifyDialog(const QtTestQtRoundedEditRectItemModifyDialog&) = delete;
  QtTestQtRoundedEditRectItemModifyDialog& operator=(const QtTestQtRoundedEditRectItemModifyDialog&) = delete;
  ~QtTestQtRoundedEditRectItemModifyDialog() noexcept;

protected:
  void keyPressEvent(QKeyEvent * event);

private slots:

private:
  Ui::QtTestQtRoundedEditRectItemModifyDialog *ui;

  boost::shared_ptr<QtRoundedEditRectItemDialog> m_dialog_left;
  boost::shared_ptr<QtRoundedEditRectItemDialog> m_dialog_right;
  boost::shared_ptr<QGraphicsView> m_view_left;
  boost::shared_ptr<QGraphicsView> m_view_right;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // QTTESTQTROUNDEDEDITRECTITEMMODIFYDIALOG_H

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemmodifydialog.cpp

 

//---------------------------------------------------------------------------
/*
TestQtRoundedEditRectItem, tool to test QtRoundedRectItem
Copyright (C) 2012-2015 Richel Bilderbeek

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 3 of the License, 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.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestQtRoundedEditRectItem.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#include "qttestqtroundededitrectitemmodifydialog.h"

#include <boost/make_shared.hpp>
#include <boost/lambda/lambda.hpp>

#include <QHBoxLayout>
#include <QKeyEvent>
#include <QGraphicsView>

#include "container.h"
#include "qtroundededitrectitem.h"
#include "qtroundededitrectitemdialog.h"
#include "testtimer.h"
#include "trace.h"
#include "ui_qttestqtroundededitrectitemmodifydialog.h"
#pragma GCC diagnostic pop

ribi::QtTestQtRoundedEditRectItemModifyDialog::QtTestQtRoundedEditRectItemModifyDialog(QWidget *parent) :
    QtHideAndShowDialog(parent),
    ui(new Ui::QtTestQtRoundedEditRectItemModifyDialog),
    m_dialog_left(boost::make_shared<QtRoundedEditRectItemDialog>()),
    m_dialog_right(boost::make_shared<QtRoundedEditRectItemDialog>()),
    m_view_left(boost::make_shared<QGraphicsView>()),
    m_view_right(boost::make_shared<QGraphicsView>())

{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);

  const auto item = boost::make_shared<QtRoundedEditRectItem>();

  //Add item to both dialogs
  m_dialog_left->SetItem(item);
  m_dialog_right->SetItem(item);

  //Create scene and add item to it
  {
    assert(!m_view_left->scene());
    assert(!m_view_right->scene());
    QGraphicsScene * const scene = new QGraphicsScene;
    m_view_left->setScene(scene);
    m_view_right->setScene(scene);
    assert(m_view_left->scene());
    assert(m_view_right->scene());
    scene->addItem(item.get());
  }

  //Put dialogs and view on dialog
  {
    assert(!this->layout());
    QHBoxLayout * const my_layout = new QHBoxLayout;
    this->setLayout(my_layout);
    assert(this->layout());

    my_layout->addWidget(m_view_left.get());
    my_layout->addWidget(m_view_right.get());
    my_layout->addWidget(m_dialog_left.get());
    my_layout->addWidget(m_dialog_right.get());
  }
}

ribi::QtTestQtRoundedEditRectItemModifyDialog::~QtTestQtRoundedEditRectItemModifyDialog() noexcept
{
  delete ui;
}

void ribi::QtTestQtRoundedEditRectItemModifyDialog::keyPressEvent(QKeyEvent * event)
{
  if (event->key() == Qt::Key_Escape) { close(); return; }
}

#ifndef NDEBUG
void ribi::QtTestQtRoundedEditRectItemModifyDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemwidget.h

 

#ifndef QTTESTQTROUNDEDEDITRECTITEMWIDGETWIDGET_H
#define QTTESTQTROUNDEDEDITRECTITEMWIDGETWIDGET_H

#include "qtkeyboardfriendlygraphicsview.h"

struct QFont;

namespace ribi {

///The widget holding the items
struct QtTestQtRoundedEditRectItemWidget : public QtKeyboardFriendlyGraphicsView
{
  QtTestQtRoundedEditRectItemWidget(QWidget *parent = 0);

  void keyPressEvent(QKeyEvent *event) noexcept;

private:
  ///Display a font
  void Display(const QFont& font);

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // QTTESTQTROUNDEDEDITRECTITEMWIDGETWIDGET_H

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemwidget.cpp

 

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include "qttestqtroundededitrectitemwidget.h"

#include <cassert>
#include <cmath>
#include <iostream>

#include <boost/lexical_cast.hpp>

#include <QFontDialog>
#include <QGraphicsScene>
#include <QGraphicsSimpleTextItem>
#include <QIcon>
#include <QKeyEvent>
#include <QGraphicsSimpleTextItem>
#include <QPen>
#include "about.h"
#include "qtaboutdialog.h"
#include "qtroundededitrectitem.h"
#include "testqtroundededitrectitemmenudialog.h"
#include "trace.h"
#include "testtimer.h"
#pragma GCC diagnostic pop

ribi::QtTestQtRoundedEditRectItemWidget::QtTestQtRoundedEditRectItemWidget(QWidget *parent)
  : QtKeyboardFriendlyGraphicsView(parent)
{
  #ifndef NDEBUG
  Test();
  #endif
  //Display with default font
  this->Display(QtRoundedEditRectItem().GetFont());
}

void ribi::QtTestQtRoundedEditRectItemWidget::Display(const QFont& font)
{
  scene()->clear();

  //Add texts
  {
    const std::vector<std::string> v
      =
      {
        "F1: change font",
        "Space: set focus to random item",
        "Arrow keys: move focus",
        "Shift + arrow keys: move item"
        //"F2: edit item"
      };
    const int sz = boost::numeric_cast<int>(v.size());
    for (int i=0; i!=sz; ++i)
    {
      QGraphicsSimpleTextItem * const item = new QGraphicsSimpleTextItem(v[i].c_str());
      const double w = item->boundingRect().width();
      const double h = item->boundingRect().height();
      const double y = -100.0 + (static_cast<double>(i - (sz/2)) * 20.0);
      item->setPos(-0.5 * w,(-0.5 * h) + y);
      assert(!item->scene());
      scene()->addItem(item);
    }
  }
  const int n_cols = 10;
  const int n_rows = 26 * 2; //Twice the number of chars in the alphabet
  double x = 0.0;
  for (int col=0; col!=n_cols; ++col)
  {
    double y = 0.0;
    double max_width = 0.0;
    for (int row=0; row!=n_rows; ++row)
    {
      QtRoundedEditRectItem * const item = new QtRoundedEditRectItem;
      item->SetFont(font);
      const char c = (row / 26 ? 'A' : 'a') + (row % 26);
      const std::string s
        = std::string(1 + col,c)
        + " "
        + boost::lexical_cast<std::string>(c);

      item->SetText( std::vector<std::string>(1 + col,s) );
      item->SetCenterPos(x,y);
      item->SetFocusPen(QPen(QColor(255,0,0),3.0));
      assert(!item->scene());
      scene()->addItem(item);

      y += item->boundingRect().height() + 2.0;
      max_width = std::max(max_width,item->boundingRect().width());
    }
    x += max_width + 6.0;
  }

}

void ribi::QtTestQtRoundedEditRectItemWidget::keyPressEvent(QKeyEvent *event) noexcept
{

  switch (event->key())
  {
    case Qt::Key_F1:
    {
      bool ok;
      static QFont font = QtRoundedEditRectItem().GetFont();
      const QFont new_font = QFontDialog::getFont(&ok, font, this);
      if (ok) { font = new_font; Display(font); }
    }
    return;
  }
  QtKeyboardFriendlyGraphicsView::keyPressEvent(event);
}

#ifndef NDEBUG
void ribi::QtTestQtRoundedEditRectItemWidget::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/testqtroundededitrectitemmenudialog.h

 

#ifndef TESTQTROUNDEDEDITRECTITEMWIDGETMENUDIALOG_H
#define TESTQTROUNDEDEDITRECTITEMWIDGETMENUDIALOG_H

#include "menudialog.h"

namespace ribi {

struct TestQtRoundedEditRectItemMenuDialog final : public MenuDialog
{
  About GetAbout() const noexcept override;
  Help GetHelp() const noexcept override;
  boost::shared_ptr<const Program> GetProgram() const noexcept override;
  std::string GetVersion() const noexcept override;
  std::vector<std::string> GetVersionHistory() const noexcept override;

  private:
  int ExecuteSpecific(const std::vector<std::string>& argv) noexcept override;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // TESTQTROUNDEDEDITRECTITEMWIDGETMENUDIALOG_H

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/testqtroundededitrectitemmenudialog.cpp

 

#include "testqtroundededitrectitemmenudialog.h"

#include <cassert>
#include <iostream>

#include "container.h"
#include "fileio.h"
#include "plane.h"
#include "testtimer.h"
#include "ribi_regex.h"
#include "richelbilderbeekprogram.h"
#include "trace.h"

int ribi::TestQtRoundedEditRectItemMenuDialog::ExecuteSpecific(const std::vector<std::string>& argv) noexcept
{
  #ifndef NDEBUG
  Test();
  #endif
  const int argc = static_cast<int>(argv.size());
  if (argc == 1)
  {
    std::cout << GetHelp() << '\n';
    return 1;
  }
  assert(!"TODO");
  return 1;
}

ribi::About ribi::TestQtRoundedEditRectItemMenuDialog::GetAbout() const noexcept
{
  About a(
    "Richel Bilderbeek",
    "TestQtRoundedEditRectItemWidget",
    "tests QtRoundedEditRectItemWidget",
    "the 9th of August 2014",
    "2012-2015",
    "http://www.richelbilderbeek.nl/ToolTestQtRoundedEditRectItemWidget.htm",
    GetVersion(),
    GetVersionHistory());
  a.AddLibrary("Container version: " + Container().GetVersion());
  a.AddLibrary("FileIo version: " + fileio::FileIo().GetVersion());
  a.AddLibrary("Plane version: " + Plane::GetVersion());
  a.AddLibrary("ribi::Regex version: " + Regex::GetVersion());
  a.AddLibrary("Trace version: " + Trace::GetVersion());
  return a;
}

ribi::Help ribi::TestQtRoundedEditRectItemMenuDialog::GetHelp() const noexcept
{
  return Help(
    this->GetAbout().GetFileTitle(),
    this->GetAbout().GetFileDescription(),
    {

    },
    {

    }
  );
}

boost::shared_ptr<const ribi::Program> ribi::TestQtRoundedEditRectItemMenuDialog::GetProgram() const noexcept
{
  const boost::shared_ptr<const Program> p {
    new ProgramTestQtRoundedEditRectItem
  };
  assert(p);
  return p;
}

std::string ribi::TestQtRoundedEditRectItemMenuDialog::GetVersion() const noexcept
{
  return "1.6";
}

std::vector<std::string> ribi::TestQtRoundedEditRectItemMenuDialog::GetVersionHistory() const noexcept
{
  return {
    "2012-12-21: version 1.0: initial version",
    "2012-12-31: version 1.1: added menu",
    "2013-11-05: version 1.2: conformized for ProjectRichelBilderbeekConsole",
    "2014-06-15: version 1.3: added Modify dialog in desktop version",
    "2014-06-23: version 1.4: use of QtRoundedEditRectItemDialog",
    "2014-08-07: version 1.5: increased use of Tdd",
    "2014-08-09: version 1.6: some bugfixes in the classes used"

  };
}

#ifndef NDEBUG
void ribi::TestQtRoundedEditRectItemMenuDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  {
    Container();
    fileio::FileIo();
    const boost::shared_ptr<Plane> p{
      new Plane(
        Plane::Coordinat3D(1.0,0.0,0.0),
        Plane::Coordinat3D(0.0,1.0,0.0),
        Plane::Coordinat3D(0.0,0.0,1.0)
      )
    };
    ::ribi::Regex();
  }

  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/crosscompiletowindows.sh

 

#!/bin/sh
#From http://richelbilderbeek.nl/CppQtCrosscompileToWindowsExample15.htm

echo "Cross compiling to Windows"

echo "1/2: Creating Windows makefile"
i686-pc-mingw32-qmake ToolTestQtRoundedEditRectItem.pro

echo "2/2: making makefile"

make

echo "Done cross compiling, running Windows executable with Wine"

cd release

wine ToolTestQtRoundedEditRectItem.exe

 

 

 

 

 

./ToolTestQtRoundedEditRectItem/zip.sh

 

#!/bin/sh

echo "Removing user information"
rm *.user

echo "Removing possible temp file"
rm copy.txt
rm tmp.txt


echo "Creating of all main folders"

mkdir temp_zip
mkdir temp_zip/Classes
mkdir temp_zip/Tools

echo "Creating of all subfolders"

mkdir temp_zip/Classes/CppAbout
mkdir temp_zip/Classes/CppQtAboutDialog
mkdir temp_zip/Classes/CppQtKeyboardFriendlyGraphicsView
mkdir temp_zip/Classes/CppQtRoundedEditRectItem
mkdir temp_zip/Classes/CppQtRoundedRectItem
mkdir temp_zip/Classes/CppQtRoundedTextRectItem
mkdir temp_zip/Classes/CppTrace
mkdir temp_zip/Tools/ToolTestQtRoundedEditRectItem

echo "Copying files"

cp ../../Classes/CppAbout/Licence.txt temp_zip/Classes/CppAbout/Licence.txt
cp ../../Classes/CppAbout/about.cpp temp_zip/Classes/CppAbout/about.cpp
cp ../../Classes/CppAbout/about.h temp_zip/Classes/CppAbout/about.h
cp ../../Classes/CppQtAboutDialog/Licence.txt temp_zip/Classes/CppQtAboutDialog/Licence.txt
cp ../../Classes/CppQtAboutDialog/qtaboutdialog.cpp temp_zip/Classes/CppQtAboutDialog/qtaboutdialog.cpp
cp ../../Classes/CppQtAboutDialog/qtaboutdialog.h temp_zip/Classes/CppQtAboutDialog/qtaboutdialog.h
cp ../../Classes/CppQtAboutDialog/qtaboutdialog.ui temp_zip/Classes/CppQtAboutDialog/qtaboutdialog.ui
cp ../../Classes/CppQtKeyboardFriendlyGraphicsView/Licence.txt temp_zip/Classes/CppQtKeyboardFriendlyGraphicsView/Licence.txt
cp ../../Classes/CppQtKeyboardFriendlyGraphicsView/qtkeyboardfriendlygraphicsview.cpp temp_zip/Classes/CppQtKeyboardFriendlyGraphicsView/qtkeyboardfriendlygraphicsview.cpp
cp ../../Classes/CppQtKeyboardFriendlyGraphicsView/qtkeyboardfriendlygraphicsview.h temp_zip/Classes/CppQtKeyboardFriendlyGraphicsView/qtkeyboardfriendlygraphicsview.h
cp ../../Classes/CppQtRoundedEditRectItem/Licence.txt temp_zip/Classes/CppQtRoundedEditRectItem/Licence.txt
cp ../../Classes/CppQtRoundedEditRectItem/qtroundededitrectitem.cpp temp_zip/Classes/CppQtRoundedEditRectItem/qtroundededitrectitem.cpp
cp ../../Classes/CppQtRoundedEditRectItem/qtroundededitrectitem.h temp_zip/Classes/CppQtRoundedEditRectItem/qtroundededitrectitem.h
cp ../../Classes/CppQtRoundedRectItem/Licence.txt temp_zip/Classes/CppQtRoundedRectItem/Licence.txt
cp ../../Classes/CppQtRoundedRectItem/qtroundedrectitem.cpp temp_zip/Classes/CppQtRoundedRectItem/qtroundedrectitem.cpp
cp ../../Classes/CppQtRoundedRectItem/qtroundedrectitem.h temp_zip/Classes/CppQtRoundedRectItem/qtroundedrectitem.h
cp ../../Classes/CppQtRoundedTextRectItem/Licence.txt temp_zip/Classes/CppQtRoundedTextRectItem/Licence.txt
cp ../../Classes/CppQtRoundedTextRectItem/qtroundedtextrectitem.cpp temp_zip/Classes/CppQtRoundedTextRectItem/qtroundedtextrectitem.cpp
cp ../../Classes/CppQtRoundedTextRectItem/qtroundedtextrectitem.h temp_zip/Classes/CppQtRoundedTextRectItem/qtroundedtextrectitem.h
cp ../../Classes/CppTrace/Licence.txt temp_zip/Classes/CppTrace/Licence.txt
cp ../../Classes/CppTrace/trace.h temp_zip/Classes/CppTrace/trace.h
cp ../../Tools/ToolTestQtRoundedEditRectItem/Licence.txt temp_zip/Tools/ToolTestQtRoundedEditRectItem/Licence.txt
cp ../../Tools/ToolTestQtRoundedEditRectItem/ToolTestQtRoundedEditRectItem.pro temp_zip/Tools/ToolTestQtRoundedEditRectItem/ToolTestQtRoundedEditRectItem.pro
cp ../../Tools/ToolTestQtRoundedEditRectItem/crosscompiletowindows.sh temp_zip/Tools/ToolTestQtRoundedEditRectItem/crosscompiletowindows.sh
cp ../../Tools/ToolTestQtRoundedEditRectItem/qtmain.cpp temp_zip/Tools/ToolTestQtRoundedEditRectItem/qtmain.cpp
cp ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemwidget.cpp temp_zip/Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemwidget.cpp
cp ../../Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemwidget.h temp_zip/Tools/ToolTestQtRoundedEditRectItem/qttestqtroundededitrectitemwidget.h
cp ../../Tools/ToolTestQtRoundedEditRectItem/testqtroundededitrectitemmenudialog.cpp temp_zip/Tools/ToolTestQtRoundedEditRectItem/testqtroundededitrectitemmenudialog.cpp
cp ../../Tools/ToolTestQtRoundedEditRectItem/testqtroundededitrectitemmenudialog.h temp_zip/Tools/ToolTestQtRoundedEditRectItem/testqtroundededitrectitemmenudialog.h
cp ../../Tools/ToolTestQtRoundedEditRectItem/zip.sh temp_zip/Tools/ToolTestQtRoundedEditRectItem/zip.sh

FILENAME="ToolTestQtRoundedEditRectItemSource"
ZIP_FILENAME=$FILENAME".zip"

echo "Compressing files"

cd temp_zip
zip -r $FILENAME Classes
zip -r $FILENAME Tools
cd ..
cp "temp_zip/"$ZIP_FILENAME $ZIP_FILENAME

echo "Cleaning up"

echo "Emptying subfolders"

rm temp_zip/Classes/CppAbout/*.*
rm temp_zip/Classes/CppQtAboutDialog/*.*
rm temp_zip/Classes/CppQtKeyboardFriendlyGraphicsView/*.*
rm temp_zip/Classes/CppQtRoundedEditRectItem/*.*
rm temp_zip/Classes/CppQtRoundedRectItem/*.*
rm temp_zip/Classes/CppQtRoundedTextRectItem/*.*
rm temp_zip/Classes/CppTrace/*.*
rm temp_zip/Tools/ToolTestQtRoundedEditRectItem/*.*

echo "Removing subfolders"

rmdir temp_zip/Classes/CppAbout
rmdir temp_zip/Classes/CppQtAboutDialog
rmdir temp_zip/Classes/CppQtKeyboardFriendlyGraphicsView
rmdir temp_zip/Classes/CppQtRoundedEditRectItem
rmdir temp_zip/Classes/CppQtRoundedRectItem
rmdir temp_zip/Classes/CppQtRoundedTextRectItem
rmdir temp_zip/Classes/CppTrace
rmdir temp_zip/Tools/ToolTestQtRoundedEditRectItem

echo "Removing main folders"

rmdir temp_zip/Classes
rmdir temp_zip/Tools

echo "Removing temporary folder"

rm temp_zip/*.*
rmdir temp_zip

echo "Done"

# CreateQtProjectZipFile, version 1.3
# Copyright (C) 2012 Richel Bilderbeek
# Programmed on the 10th of June 2012
# by Richel Bilderbeek
#
# CreateQtProjectZipFile can be downloaded from http://www.richelbilderbeek.nl/ToolCreateQtProjectZipFile.htm
# Licenced under GPL 3.0

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml