From: Maxime Date: Fri, 6 May 2011 12:55:52 +0000 (+0200) Subject: - version of vv in vvCommon.h X-Git-Tag: v1.2.1~39 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=8e0671d3fff58c9232517f0b91cc0d1d3d3821ed;p=clitk.git - version of vv in vvCommon.h - register form being launched at every application launch - calling a local server if the user agrees to send the register form - writing qtSettings instead of a plain file. if a non QtSettings saved file is present at the same location, it is written over. --- diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index ca6152b..25cac3d 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -7,6 +7,7 @@ if(COMMAND cmake_policy) endif(COMMAND cmake_policy) #========================================================= + #========================================================= #List of vv tools to compile SET(vv_TOOLS @@ -62,6 +63,7 @@ SET(vv_COMMON_WITH_UI vvToolSimpleInputSelectorWidget vvToolInputSelectorWidget vvToolStructureSetManager + vvRegisterForm ) # All others sources @@ -113,10 +115,12 @@ QT4_WRAP_CPP(vv_SRCS vvStructureSetActor.h vvROIActor.h vvToolCreatorBase.h + vvRegisterForm.h ) QT4_WRAP_UI(vv_UI_CXX qt_ui/vvHelpDialog.ui + qt_ui/vvRegisterForm.ui qt_ui/vvDocumentation.ui qt_ui/vvDicomSeriesSelector.ui qt_ui/vvDummyWindow.ui #For testing @@ -256,3 +260,9 @@ ELSE(WIN32) ENDIF(WIN32) INCLUDE(CPack) #========================================================= +#========================================================= +configure_file ( + vvCommon.h.in + vvCommon.h +) +#========================================================= \ No newline at end of file diff --git a/vv/qt_ui/vvRegisterForm.ui b/vv/qt_ui/vvRegisterForm.ui new file mode 100644 index 0000000..59f7764 --- /dev/null +++ b/vv/qt_ui/vvRegisterForm.ui @@ -0,0 +1,160 @@ + + + vvRegisterForm + + + + 0 + 0 + 389 + 300 + + + + Dialog + + + + + 40 + 260 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 160 + 120 + 201 + 21 + + + + + + + 100 + 120 + 61 + 20 + + + + First name + + + + + + 100 + 140 + 61 + 20 + + + + Last name + + + + + + 160 + 140 + 201 + 21 + + + + + + + 160 + 160 + 201 + 21 + + + + + + + 160 + 180 + 201 + 21 + + + + + + + 100 + 160 + 61 + 20 + + + + Email + + + + + + 100 + 180 + 61 + 20 + + + + Institute + + + + + + + buttonBox + accepted() + vvRegisterForm + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + vvRegisterForm + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/vv/vvCommon.h.in b/vv/vvCommon.h.in new file mode 100644 index 0000000..7ad04e6 --- /dev/null +++ b/vv/vvCommon.h.in @@ -0,0 +1,2 @@ +#define VV_VERSION "v@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@" + \ No newline at end of file diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 18020b1..3a11afe 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -21,10 +21,12 @@ #include #include #include "QTreePushButton.h" +#include // VV include #include "vvMainWindow.h" #include "vvHelpDialog.h" +#include "vvRegisterForm.h" #include "vvDocumentation.h" #include "vvProgressDialog.h" #include "vvQDicomSeriesSelector.h" @@ -331,6 +333,10 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage())); timerMemory->start(2000); + + vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://localhost/vvregister/write.php")); + registerForm->show(); + } //------------------------------------------------------------------------------ diff --git a/vv/vvRegisterForm.cxx b/vv/vvRegisterForm.cxx new file mode 100644 index 0000000..3903796 --- /dev/null +++ b/vv/vvRegisterForm.cxx @@ -0,0 +1,53 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ +#include + +#include "vvRegisterForm.h" +#include +#include +#include "common/globals.h" +#include "vvCommon.h" + +vvRegisterForm::vvRegisterForm(QUrl url):url(url) { + manager = new QNetworkAccessManager(this); + setupUi(this); +} + +void vvRegisterForm::sendData(){ + if(canPush()){ + QUrl url2(url); + url2.addQueryItem("name", firstName->text().toUtf8()); + url2.addQueryItem("lastName", lastName->text().toUtf8()); + url2.addQueryItem("email", email->text().toUtf8()); + url2.addQueryItem("group", group->text().toUtf8()); + url2.addQueryItem("os", QString::fromUtf8(OS_NAME)); + url2.addQueryItem("vvVersion", QString::fromUtf8(VV_VERSION)); + manager->get(QNetworkRequest(url2));//make pushed in callback? + acquitPushed(); + } +} +void vvRegisterForm::accept(){ + sendData(); + QDialog::accept(); +} +bool vvRegisterForm::canPush(){ + return true; +} +void vvRegisterForm::acquitPushed(){ + +} \ No newline at end of file diff --git a/vv/vvRegisterForm.h b/vv/vvRegisterForm.h new file mode 100644 index 0000000..10c5770 --- /dev/null +++ b/vv/vvRegisterForm.h @@ -0,0 +1,42 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ +#ifndef vvRegisterForm_h +#define vvRegisterForm_h + +#include "ui_vvRegisterForm.h" +#include +#include +class vvRegisterForm : public QDialog, private Ui::vvRegisterForm +{ + Q_OBJECT + +public: + vvRegisterForm(QUrl url); + void sendData(); + ~vvRegisterForm() {} + //return true only if first time + virtual bool canPush(); + virtual void acquitPushed(); +public slots: + virtual void accept(); +protected: + QUrl url; + QNetworkAccessManager* manager; +}; + +#endif diff --git a/vv/vvUtils.cxx b/vv/vvUtils.cxx index 441b4b3..361c780 100644 --- a/vv/vvUtils.cxx +++ b/vv/vvUtils.cxx @@ -15,28 +15,28 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ===========================================================================**/ -#include +#include #include #include - +#include #include "clitkCommon.h" #include "vvUtils.h" const std::string vv_user_file=".vv_settings.txt"; typedef std::list FileListType; +static QSettings settings(QDir::homePath()+QString::fromStdString("/"+vv_user_file), QSettings::NativeFormat); ///Returns the last images opened by the user FileListType GetRecentlyOpenedImages() { - std::ifstream in((QDir::homePath().toStdString() + "/" + vv_user_file).c_str()); - std::string current_file; FileListType result; - in >> current_file; - while (in.good()) { - result.push_back(current_file); - in >> current_file; - } - in.close(); + settings.beginGroup("recentFiles"); + QStringList keys = settings.childKeys(); + for(int i=0; i= 6) //keep list to a reasonable size file_list.pop_back(); file_list.push_front(filename); - std::ofstream out((QDir::homePath().toStdString() + "/" + vv_user_file).c_str(),std::ios_base::out | std::ios_base::trunc); - for (FileListType::iterator j = file_list.begin() ; j != file_list.end() ; j++) - out << (*j) << std::endl; - out.close(); + + settings.beginGroup("recentFiles"); + int index=0; + for (FileListType::iterator j = file_list.begin() ; j != file_list.end() ; j++){ + QString s=QString(index++); + settings.setValue(s, QString::fromStdString ( *j )); + } + settings.endGroup(); }