First version with http communications

This commit is contained in:
Paolo Cignoni cignoni 2006-11-08 01:04:48 +00:00
parent aa8ff3dae6
commit 69ec743346
5 changed files with 71 additions and 9 deletions

View File

@ -23,6 +23,9 @@
/****************************************************************************
History
$Log$
Revision 1.5 2006/11/08 01:04:48 cignoni
First version with http communications
Revision 1.4 2006/02/01 12:45:29 glvertex
- Solved openig bug when running by command line
@ -40,8 +43,10 @@ Added copyright info
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow window;
window.showMaximized();
QCoreApplication::setOrganizationName("VCG");
QCoreApplication::setApplicationName("MeshLab");
MainWindow window;
window.showMaximized();
if(argc>1) window.open(argv[1]);
else window.open();

View File

@ -23,6 +23,9 @@
/****************************************************************************
History
$Log$
Revision 1.70 2006/11/08 01:04:48 cignoni
First version with http communications
Revision 1.69 2006/10/26 12:07:12 corsini
add lighting properties option
@ -91,6 +94,7 @@ class QMenu;
class QScrollArea;
class QSignalMapper;
class QProgressDialog;
class QHttp;
class MainWindow : public QMainWindow
{
@ -99,7 +103,7 @@ class MainWindow : public QMainWindow
public:
MainWindow();
static bool QCallBack(const int pos, const char * str);
const QString appName() const {return tr("MeshLab v0.7"); }
const QString appName() const {return tr("MeshLab v0.8"); }
// MaskObj maskobj;
public slots:
@ -157,8 +161,11 @@ private slots:
void about();
void aboutPlugins();
///////////Slot General Purpose ////////////////////////
void dropEvent ( QDropEvent * event );
void dragEnterEvent(QDragEnterEvent *);
void connectionFinished(int id, bool status);
private:
void createActions();
@ -172,11 +179,15 @@ private:
//void LoadKnownFilters(QStringList &filters, QHash<QString, int> &allKnownFormats, int type);
QHttp *httpReq;
QBuffer *myLocalBuf;
int idHost;
int idGet;
static QProgressBar *qb;
QWorkspace *workspace;
QSignalMapper *windowMapper;
QDir pluginsDir;
QDir pluginsDir;
QStringList pluginFileNames;
std::vector<MeshIOInterface*> meshIOPlugins;
QByteArray toolbarState; //stato delle toolbar e dockwidgets

View File

@ -24,6 +24,9 @@
History
$Log$
Revision 1.60 2006/11/08 01:04:48 cignoni
First version with http communications
Revision 1.59 2006/10/26 12:07:30 corsini
add lighting properties option
@ -80,7 +83,7 @@ Added short key lastFilter
#include <QtGui>
#include <QToolBar>
#include <QProgressBar>
#include <QHttp>
#include "meshmodel.h"
#include "interfaces.h"
@ -103,6 +106,9 @@ MainWindow::MainWindow()
connect(workspace, SIGNAL(windowActivated(QWidget *)),this, SLOT(updateMenus()));
connect(workspace, SIGNAL(windowActivated(QWidget *)),this, SLOT(updateWindowMenu()));
httpReq=new QHttp(this);
connect(httpReq, SIGNAL(requestFinished(int,bool)), this, SLOT(connectionFinished(int,bool)));
createActions();
createMenus();
createToolBars();
@ -526,9 +532,11 @@ void MainWindow::addToMenu(QList<QAction *> actionList, QMenu *menu, const char
}
}
// this function update the app settings with the current recent file list
// and update the loaded mesh counter
void MainWindow::setCurrentFile(const QString &fileName)
{
QSettings settings("Recent Files");
QSettings settings;
QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(fileName);
files.prepend(fileName);
@ -541,5 +549,39 @@ void MainWindow::setCurrentFile(const QString &fileName)
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
if (mainWin) mainWin->updateRecentFileActions();
}
int loadedMeshCounter=settings.value("loadedMeshCounter",0).toInt();
settings.setValue("loadedMeshCounter",loadedMeshCounter+1);
int lastComunicatedValue=settings.value("lastComunicatedValue",0).toInt();
QString UID=settings.value("UID",QString("")).toString();
if(UID.isEmpty())
{
UID=QUuid::createUuid ().toString();
settings.setValue("UID",UID);
}
if(loadedMeshCounter-lastComunicatedValue>20)
{
QString message= QString("/~cignoni/meshlab.php?code=%1&count=%2").arg(UID).arg(loadedMeshCounter);
idHost=httpReq->setHost("vcg.isti.cnr.it"); // id == 1
myLocalBuf = new QBuffer();
bool ret=myLocalBuf->open(QBuffer::WriteOnly);
if(!ret) QMessageBox::information(this,"Meshlab",QString("Failed opening of internal buffer"));
idGet=httpReq->get(message,myLocalBuf); // id == 2
}
}
void MainWindow::connectionFinished(int id, bool status)
{
if(id==idGet && status == false)
{
httpReq->close();
if(myLocalBuf->isOpen())
{
myLocalBuf->close();
QMessageBox::information(this,"Remote Counter",QString("Updated!"));
QSettings settings;
int loadedMeshCounter=settings.value("loadedMeshCounter",0).toInt();
settings.setValue("lastComunicatedValue",loadedMeshCounter);
}
}
}

View File

@ -24,6 +24,9 @@
History
$Log$
Revision 1.109 2006/11/08 01:04:48 cignoni
First version with http communications
Revision 1.108 2006/11/07 09:15:27 cignoni
Added Drag n drog opening of files (thanks to Valentino Fiorin)
@ -100,7 +103,7 @@ Minor edits.
#include <QtGui>
#include <QToolBar>
#include <QProgressBar>
#include <QHttp>
#include "meshmodel.h"
#include "interfaces.h"
@ -122,7 +125,7 @@ Minor edits.
void MainWindow::updateRecentFileActions()
{
QSettings settings("Recent Files");
QSettings settings;
QStringList files = settings.value("recentFileList").toStringList();
int numRecentFiles = qMin(files.size(), (int)MAXRECENTFILES);
for (int i = 0; i < numRecentFiles; ++i) {

View File

@ -53,6 +53,7 @@ RC_FILE = meshlab.rc
QT += opengl
QT += xml
QT += network
# the following line is needed to avoid mismatch between
# the awful min/max macros of windows and the limits max