Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) TestSelectFileDialog

 

TestSelectFileDialog is a tool to test the WtSelectFileDialog class.

 

 

 

 

 

Downloads

 

 

 

 

 

 

Older downloads

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolTestSelectFileDialog/ToolTestSelectFileDialogWebsite.pro

 

#Don't enable Effective C++ warnings when using Qwt
include(../../WebApplication.pri)
include(../../Libraries/BoostAll.pri)
include(../../Libraries/Fparser.pri)
include(../../Libraries/GeneralConsole.pri)
include(../../Libraries/GeneralWeb.pri)
include(../../Libraries/Wt.pri)

include(../../Classes/CppWtSelectFileDialog/CppWtSelectFileDialog.pri)


SOURCES += \
    wtmain.cpp \
    wttestselectfiledialogmenudialog.cpp \
    wttestselectfiledialogmaindialog.cpp

HEADERS += \
    wttestselectfiledialogmenudialog.h \
    wttestselectfiledialogmaindialog.h

RESOURCES += \
    ToolTestSelectFileDialog.qrc

 

 

 

 

 

./ToolTestSelectFileDialog/ToolTestSelectFileDialogConsole.pri

 

INCLUDEPATH += \
    ../../Tools/ToolTestSelectFileDialog

SOURCES +=

HEADERS +=

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

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

 

 

 

 

 

./ToolTestSelectFileDialog/ToolTestSelectFileDialogDesktop.pri

 

INCLUDEPATH += \
    ../../Tools/ToolTestSelectFileDialog

SOURCES +=

HEADERS +=

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

 

 

 

 

 

./ToolTestSelectFileDialog/ToolTestSelectFileDialogWebsite.pri

 

include(../../Tools/ToolTestSelectFileDialog/ToolTestSelectFileDialogConsole.pri)

SOURCES += \
    ../../Tools/ToolTestSelectFileDialog/wttestselectfiledialogmaindialog.cpp \
    ../../Tools/ToolTestSelectFileDialog/wttestselectfiledialogmenudialog.cpp
HEADERS += \
    ../../Tools/ToolTestSelectFileDialog/wttestselectfiledialogmaindialog.h \
    ../../Tools/ToolTestSelectFileDialog/wttestselectfiledialogmenudialog.h

 

 

 

 

 

./ToolTestSelectFileDialog/wtmain.cpp

 

//---------------------------------------------------------------------------
/*
TestSelectFileDialog, tool to test the SelectFileDialog class
Copyright (C) 2011 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/ToolTestSelectFileDialog.htm
//---------------------------------------------------------------------------
#include <boost/filesystem.hpp>

#include <Wt/WApplication>
#include <Wt/WEnvironment>

#include "wtautoconfig.h"
#include "wtselectfiledialog.h"
#include "wttestselectfiledialogmenudialog.h"

struct WtApplication : public Wt::WApplication
{
  WtApplication(const Wt::WEnvironment& env)
    : Wt::WApplication(env)
  {
    this->setTitle("TestSelectFileDialog");
    this->useStyleSheet("wt.css");
    root()->addWidget(new ribi::WtTestSelectFileDialogMenuDialog);
  }
};

Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
  return new WtApplication(env);
}

int main(int argc, char **argv)
{
  ribi::WtSelectFileDialog::SetPath(boost::filesystem::path(argv[0]).parent_path().string());
  ribi::WtAutoConfig a(argc,argv,createApplication);
  ribi::WtAutoConfig::SaveDefaultStylesheet();
  return a.Run();
}

 

 

 

 

 

./ToolTestSelectFileDialog/wttestselectfiledialogmaindialog.h

 

//---------------------------------------------------------------------------
/*
TestSelectFileDialog, tool to test the SelectFileDialog class
Copyright (C) 2011-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/ToolTestSelectFileDialog.htm
//---------------------------------------------------------------------------
#ifndef WTTESTSELECTFILEDIALOGMAINDIALOG_H
#define WTTESTSELECTFILEDIALOGMAINDIALOG_H

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#include <vector>
#include <boost/shared_ptr.hpp>

#include <Wt/WContainerWidget>
#pragma GCC diagnostic pop

namespace Wt { struct WAnchor; }

namespace ribi {

struct WtSelectFileDialog;
//---------------------------------------------------------------------------
struct WtTestSelectFileDialogMainDialog : public Wt::WContainerWidget
{
  WtTestSelectFileDialogMainDialog();

  private:

  ///OnSelect is called when a user selects a file
  void OnSelect();

  ///Show is called at startup
  void Show();

  ///The user interface of this class
  struct Ui
  {
    Ui() : m_anchor(0), m_dialog(0) {}
    Wt::WAnchor * m_anchor;
    WtSelectFileDialog * m_dialog;
  } ui;
};

} //~namespace ribi

#endif // WTTESTSELECTFILEDIALOGMAINDIALOG_H

 

 

 

 

 

./ToolTestSelectFileDialog/wttestselectfiledialogmaindialog.cpp

 

//---------------------------------------------------------------------------
/*
TestSelectFileDialog, tool to test the SelectFileDialog class
Copyright (C) 2011-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/ToolTestSelectFileDialog.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#include <boost/lexical_cast.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/signals2.hpp>

#include <Wt/WAnchor>
#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WEnvironment>
#include <Wt/WGroupBox>
#include <Wt/WLabel>
#include <Wt/WPushButton>
#include <Wt/WFileResource>

#include "fileio.h"
#include "wtaboutdialog.h"
#include "wttestselectfiledialogmaindialog.h"
#include "wtselectfiledialog.h"

#include <QFile>
#pragma GCC diagnostic pop

ribi::WtTestSelectFileDialogMainDialog::WtTestSelectFileDialogMainDialog()
  : ui{}
{
  {
    std::vector<std::string> v;
    v.push_back("ToolTestSelectFileDialogWelcome.png");
    for(const std::string& s: v)
    {
      if (!(QFile::exists(s.c_str())))
      {
        QFile f( (std::string(":/ToolTestSelectFileDialog/images/") + s).c_str() );
        f.copy(s.c_str());
      }
      if (!(QFile::exists(s.c_str())))
      {
        std::cerr << "Missing file " << s << std::endl;
      }
      assert(QFile::exists(s.c_str()));
    }
  }

  Show();
}

void ribi::WtTestSelectFileDialogMainDialog::OnSelect()
{
  ui.m_anchor->setText((std::string("Download ") + ui.m_dialog->GetSelectedFile()).c_str() );
  ui.m_anchor->setResource(new Wt::WFileResource(ui.m_dialog->GetSelectedFile(),ui.m_dialog->GetSelectedFile()));
}

void ribi::WtTestSelectFileDialogMainDialog::Show()
{
  clear();
  setContentAlignment(Wt::AlignCenter);

  ui.m_anchor = new Wt::WAnchor;
  ui.m_dialog = new WtSelectFileDialog;

  this->addWidget(ui.m_dialog);
  this->addWidget(new Wt::WBreak);
  this->addWidget(ui.m_anchor);

  ui.m_dialog->m_signal_selected.connect(
    boost::bind(&ribi::WtTestSelectFileDialogMainDialog::OnSelect,this));
}

 

 

 

 

 

./ToolTestSelectFileDialog/wttestselectfiledialogmenudialog.h

 

//---------------------------------------------------------------------------
/*
TestSelectFileDialog, tool to test the SelectFileDialog class
Copyright (C) 2011-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/ToolTestSelectFileDialog.htm
//---------------------------------------------------------------------------
#ifndef WTTESTSELECTFILEDIALOGMENUDIALOG_H
#define WTTESTSELECTFILEDIALOGMENUDIALOG_H

#include <string>
#include <vector>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#include <Wt/WContainerWidget>
#pragma GCC diagnostic pop

namespace ribi {

struct WtTestSelectFileDialogMenuDialog : public Wt::WContainerWidget
{
  WtTestSelectFileDialogMenuDialog();

  static std::string GetVersion();
  static std::vector<std::string> GetVersionHistory();

  private:
  Wt::WWidget * CreateNewAboutDialog() const;
  Wt::WWidget * CreateNewMainDialog() const;
  Wt::WWidget * CreateNewWelcomeDialog() const;
};

} //~namespace ribi

#endif // WTTESTSELECTFILEDIALOGMENUDIALOG_H

 

 

 

 

 

./ToolTestSelectFileDialog/wttestselectfiledialogmenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestSelectFileDialog, tool to test the SelectFileDialog class
Copyright (C) 2011-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/ToolTestSelectFileDialog.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WGroupBox>
#include <Wt/WImage>
#include <Wt/WLabel>
#include <Wt/WStackedWidget>
#include <Wt/WMenu>
#include <Wt/WMenuItem>

#include "trace.h"
#include "wtaboutdialog.h"
#include "wtautoconfig.h"
#include "wtselectfiledialog.h"
#include "wttestselectfiledialogmaindialog.h"
#include "wttestselectfiledialogmenudialog.h"

#pragma GCC diagnostic pop

ribi::WtTestSelectFileDialogMenuDialog::WtTestSelectFileDialogMenuDialog()
{
  this->setContentAlignment(Wt::AlignCenter);
  {
    Wt::WLabel * const title = new Wt::WLabel("TestSelectFileDialog");
    title->setStyleClass("title");
    this->addWidget(title);
  }
  //Menu
  {
    Wt::WStackedWidget * const contents = new Wt::WStackedWidget;
    Wt::WMenu * const menu = new Wt::WMenu(contents,Wt::Horizontal);
    //Using CSS styleclass is the best (only?) way to display the menu well
    menu->setStyleClass("menu");
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Welcome",
        CreateNewWelcomeDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Start",
        CreateNewMainDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "About",
        CreateNewAboutDialog());
      menu->addItem(item);
    }
    //Display menu on top
    this->addWidget(menu);
    this->addWidget(new Wt::WBreak);
    //Display contents below menu
    this->addWidget(contents);
  }
}

Wt::WWidget * ribi::WtTestSelectFileDialogMenuDialog::CreateNewAboutDialog() const
{
   About a(
    "Richel Bilderbeek",
    "TestSelectFileDialog",
    "tool to test the SelectFileDialog class",
    "the 15th of July 2011",
    "2011-2015",
    "http://www.richelbilderbeek.nl/ToolTestSelectFileDialog.htm",
    GetVersion(),
    GetVersionHistory());

  a.AddLibrary("Trace version: " + Trace::GetVersion());
  a.AddLibrary("WtAutoConfig version: " + WtAutoConfig::GetVersion());
  a.AddLibrary("WtSelectFileDialog version: " + WtSelectFileDialog::GetVersion());
  WtAboutDialog * const d = new WtAboutDialog(a,false);
  assert(d);
  return d;
}

Wt::WWidget * ribi::WtTestSelectFileDialogMenuDialog::CreateNewMainDialog() const
{
  WtTestSelectFileDialogMainDialog * const d
    = new WtTestSelectFileDialogMainDialog;
  assert(d);
  return d;
}

Wt::WWidget * ribi::WtTestSelectFileDialogMenuDialog::CreateNewWelcomeDialog() const
{
  Wt::WContainerWidget * dialog = new Wt::WContainerWidget;
  dialog->setContentAlignment(Wt::AlignCenter);
  dialog->addWidget(new Wt::WBreak);
  new Wt::WLabel("Welcome to TestSelectFileDialog",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("TestSelectFileDialog tests the WtSelectFileDialog class:",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  Wt::WGroupBox * const box = new Wt::WGroupBox("Explanation",dialog);
  Wt::WImage * const image = new Wt::WImage("ToolTestSelectFileDialogWelcome.png");
  box->addWidget(image);
  return dialog;
}

std::string ribi::WtTestSelectFileDialogMenuDialog::GetVersion()
{
  return "1.1";
}

std::vector<std::string> ribi::WtTestSelectFileDialogMenuDialog::GetVersionHistory()
{
  return {
    "2011-07-01: Version 1.0: initial version",
    "2011-07-15: Version 1.1: added downloading of selected files"
  };
}

 

 

 

 

 

./ToolTestSelectFileDialog/zip.sh

 

#!/bin/sh
#zip packs all the files to port into a single .zip file,
#minicking the same folder structure
#Folder structure
# *
#   * Classes
#     * CppAbout
#     * CppCopy_if
#     * CppTrace
#     * CppWtAboutDialog
#     * CppWtAutoConfig
#     * CppWtSelectFileDialog
#   * Tools
#    * ToolTestSelectFileDialog

echo "Converting DIA to PNG"
dia --filter=png ToolTestSelectFileDialogArchitecture.dia

echo "Removing previous user's information"
rm ToolTestSelectFileDialogDesktop.pro.user
rm ToolTestSelectFileDialogWebsite.pro.user

echo "Mimicking file structure"
mkdir temp_zip
mkdir temp_zip/Classes
mkdir temp_zip/Classes/CppAbout
mkdir temp_zip/Classes/CppCopy_if
mkdir temp_zip/Classes/CppTrace
mkdir temp_zip/Classes/CppWtAboutDialog
mkdir temp_zip/Classes/CppWtAutoConfig
mkdir temp_zip/Classes/CppWtSelectFileDialog
mkdir temp_zip/Tools
mkdir temp_zip/Tools/ToolTestSelectFileDialog

echo "Copying files"
cp ../../Classes/CppAbout/*.* temp_zip/Classes/CppAbout
cp ../../Classes/CppCopy_if/*.* temp_zip/Classes/CppCopy_if
cp ../../Classes/CppTrace/*.* temp_zip/Classes/CppTrace
cp ../../Classes/CppWtAboutDialog/*.* temp_zip/Classes/CppWtAboutDialog
cp ../../Classes/CppWtAutoConfig/*.* temp_zip/Classes/CppWtAutoConfig
cp ../../Classes/CppWtSelectFileDialog/*.* temp_zip/Classes/CppWtSelectFileDialog
cp ../../Tools/ToolTestSelectFileDialog/*.* temp_zip/Tools/ToolTestSelectFileDialog

FILENAME=ToolTestSelectFileDialogSource_1_1
ZIP_FILENAME=$FILENAME".zip"

echo "Remove previous zip"
rm $ZIP_FILENAME

#echo "Compressing files"
cd temp_zip
zip -r $FILENAME Classes
#zip -r $FILENAME Libraries
#zip -r $FILENAME Projects
zip -r $FILENAME Tools
cd ..
cp "temp_zip/"$ZIP_FILENAME $ZIP_FILENAME

echo "Cleaning up"

#Classes
rm temp_zip/Classes/CppAbout/*.*
rm temp_zip/Classes/CppCopy_if/*.*
rm temp_zip/Classes/CppTrace/*.*
rm temp_zip/Classes/CppWtAboutDialog/*.*
rm temp_zip/Classes/CppWtAutoConfig/*.*
rm temp_zip/Classes/CppWtSelectFileDialog/*.*
rmdir temp_zip/Classes/CppAbout
rmdir temp_zip/Classes/CppCopy_if
rmdir temp_zip/Classes/CppTrace
rmdir temp_zip/Classes/CppWtAboutDialog
rmdir temp_zip/Classes/CppWtAutoConfig
rmdir temp_zip/Classes/CppWtSelectFileDialog
rmdir temp_zip/Classes

#Tools
rm temp_zip/Tools/ToolTestSelectFileDialog/*.*
rmdir temp_zip/Tools/ToolTestSelectFileDialog
rmdir temp_zip/Tools
rm temp_zip/*.*
rmdir temp_zip
echo "Done"

 

 

 

 

 

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