vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://localhost/vvregister/write.php"));
- registerForm->show();
+ if(registerForm->canPush()){
+ registerForm->show();
+ registerForm->acquitPushed();//too bad if there is not internet connection anymore.
+ }
}
//------------------------------------------------------------------------------
#include "vvRegisterForm.h"
#include <QNetworkRequest>
+#include <QSettings>
+#include <QDir>
#include <iostream>
#include "common/globals.h"
#include "vvCommon.h"
+#include "vvUtils.h"
vvRegisterForm::vvRegisterForm(QUrl url):url(url) {
manager = new QNetworkAccessManager(this);
}
void vvRegisterForm::sendData(){
- if(canPush()){
QUrl url2(url);
url2.addQueryItem("name", firstName->text().toUtf8());
url2.addQueryItem("lastName", lastName->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();
- }
+ manager->get(QNetworkRequest(url2));
}
void vvRegisterForm::accept(){
- sendData();
- QDialog::accept();
+ sendData();
+ QDialog::accept();
}
bool vvRegisterForm::canPush(){
- return true;
+ QSettings settings(getVVSettingsPath(), getSettingsOptionFormat());
+ return settings.value("vvVersion").toString().toStdString()<VV_VERSION;
}
void vvRegisterForm::acquitPushed(){
-
+ QSettings settings(getVVSettingsPath(), getSettingsOptionFormat());
+ settings.setValue("vvVersion", VV_VERSION);
}
\ No newline at end of file
#include <sstream>
#include <algorithm>
#include <QDir>
-#include <QSettings>
#include "clitkCommon.h"
#include "vvUtils.h"
const std::string vv_user_file=".vv_settings.txt";
+const std::string recentFileList="recentFiles";
typedef std::list<std::string> FileListType;
-static QSettings settings(QDir::homePath()+QString::fromStdString("/"+vv_user_file), QSettings::NativeFormat);
+QString getVVSettingsPath(){
+ return QDir::homePath()+QString::fromStdString("/"+vv_user_file);
+}
+
+QSettings::Format getSettingsOptionFormat(){
+ return QSettings::NativeFormat;
+}
+
///Returns the last images opened by the user
FileListType GetRecentlyOpenedImages()
{
+ QSettings settings(getVVSettingsPath(), getSettingsOptionFormat());
FileListType result;
- settings.beginGroup("recentFiles");
+ settings.beginGroup(QString::fromStdString(recentFileList));
QStringList keys = settings.childKeys();
for(int i=0; i<keys.size(); i++){
std::string value=settings.value(QString::fromStdString (keys[i].toStdString())).toString().toStdString();
///Adds an image to the list of recently opened images
void AddToRecentlyOpenedImages(std::string filename)
{
+ QSettings settings(getVVSettingsPath(), getSettingsOptionFormat());
FileListType file_list = GetRecentlyOpenedImages();
FileListType::iterator i = std::find(file_list.begin(),file_list.end(),filename);
file_list.pop_back();
file_list.push_front(filename);
- 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.beginGroup(QString::fromStdString(recentFileList));
+ 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();
}
+
#define vvXXX_h
#include <list>
#include <string>
+#include <QSettings>
///Returns the last images opened by the user
std::list<std::string> GetRecentlyOpenedImages();
///Adds an image to the list of recently opened images
void AddToRecentlyOpenedImages(std::string filename);
+///path to user settings
+QString getVVSettingsPath();
+
+///by default nativeFormat
+QSettings::Format getSettingsOptionFormat();
+
#endif