DBManager.qt.H

00001 #ifndef NEOVISIONII_NEOANNOTATE_DBMANAGER_QT_H
00002 #define NEOVISIONII_NEOANNOTATE_DBMANAGER_QT_H
00003 
00004 #include <Qt/QtCore>
00005 
00006 #include <Qt/qdialog.h>
00007 #include <Qt/qlineedit.h>
00008 #include <Qt/qcombobox.h>
00009 #include <Qt/qformlayout.h>
00010 #include <Qt/qpushbutton.h>
00011 #include <Qt/qmessagebox.h>
00012 #include <Qt/qdatetimeedit.h>
00013 #include <Qt/qtreewidget.h>
00014 
00015 #include <QtSql/QSqlDatabase>
00016 #include <QtSql/QSqlError>
00017 #include <QtSql/QSqlQuery>
00018 #include <Qt3Support/q3networkprotocol.h>
00019 
00020 #define VIDEO_ARCHIVE_LOCATION "/lab/raid2/neo2/neo2data/archive/" 
00021 #define VIDEO_WORKING_LOCATION "/lab/neo2data/archive/"
00022 #define VIDEO_INCOMING_LOCATION "/lab/neo2data/incoming/"
00023 
00024 class DBManager;
00025 
00026 class ConnectionDialog : public QDialog
00027 {
00028   Q_OBJECT
00029 
00030   public:
00031     ConnectionDialog(QWidget* parent);
00032 
00033     QLineEdit* serverNameEdit; 
00034     QLineEdit* dbNameEdit; 
00035     QLineEdit* userNameEdit; 
00036     QLineEdit* passwordEdit; 
00037 };
00038 
00039 class NewDBEntryDialog : public QDialog
00040 {
00041   Q_OBJECT 
00042 
00043   public:
00044     NewDBEntryDialog(QWidget* parent, DBManager* mgr, QSqlDatabase* _db);
00045 
00046     void showEvent(QShowEvent* event);
00047 
00048     QString getMgzJFileName() { return itsMgzJFileName; }
00049     QString getSceneUid()     { return itsSceneUid; }
00050 
00051   public slots:
00052     void fillInCameraOperator(int labComboBoxRow);
00053     void commitNewScene();
00054     void browse();
00055     void copyFinished(int exitCode, QProcess::ExitStatus exitStatus);
00056 
00057   signals:
00058     void closeProgressDialog();
00059 
00060 
00061   private:
00062     DBManager *itsDBManager;
00063 
00064     QLabel* filenameLabel;
00065     QComboBox* labComboBox;
00066     QComboBox* cameraComboBox;
00067     QComboBox* operatorComboBox;
00068     QComboBox* weatherComboBox;
00069     QLineEdit* startFrameEdit;
00070     QLineEdit* numFramesEdit;
00071     QLineEdit* frameRateEdit;
00072     QLineEdit* sceneNameEdit;
00073     QLabel* fileNameLabel;
00074     QDateTimeEdit* startDateTimeEdit;
00075     QDateTimeEdit* endDateTimeEdit;
00076     QComboBox* timeZoneBox;
00077 
00078     QString itsMgzJFileName;
00079 
00080     QSqlDatabase* db;
00081 
00082     QString itsSceneUid;
00083 
00084 };
00085 
00086 class OpenDBEntryDialog : public QDialog
00087 {
00088   Q_OBJECT
00089 
00090   public:
00091     OpenDBEntryDialog(QWidget* parent, DBManager *mgr, QSqlDatabase* _db);
00092 
00093     QString getMgzJFileName() { return itsMgzJFileName; }
00094     QString getSceneUid()     { return itsSceneUid; }
00095 
00096     void showEvent(QShowEvent* event);
00097 
00098 
00099   public slots:
00100     void openEntry();
00101 
00102   private:
00103     DBManager *itsDBManager;
00104     QTreeWidget* itsSceneTree;
00105     QString itsMgzJFileName;
00106     QString itsSceneUid;
00107     QSqlDatabase* db;
00108 };
00109 
00110 class SelectAnnotationSourceDialog: public QDialog
00111 {
00112   Q_OBJECT
00113   public:
00114     SelectAnnotationSourceDialog(QWidget* parent, QSqlDatabase* _db);
00115 
00116     QString getSourceUid() { return itsSourceUid; }
00117 
00118     void showEvent(QShowEvent* event);
00119 
00120   public slots:
00121     void selectSource();
00122 
00123   private:
00124   QTreeWidget* itsSourceTree;
00125   QString itsSourceUid;
00126   QSqlDatabase* db;
00127 };
00128 
00129 class DBManager : public QWidget
00130 {
00131   Q_OBJECT;
00132   public:
00133     DBManager(QWidget* parent) :
00134       QWidget(parent),
00135       itsSelectAnnotationSourceDialog(parent, &db),
00136       itsNewDBEntryDialog(parent, this, &db),
00137       itsOpenDBEntryDialog(parent, this, &db),
00138       itsConnDialog(parent),
00139       connected(false),
00140       itsSceneUid("-1")
00141     { 
00142       itsArchiveLoc  = "/lab/raid2/neo2/neo2data/archive/";
00143       itsWorkingLoc  = "/lab/neo2data/archive/";
00144       itsIncomingLoc = "/lab/neo2data/incoming/";
00145     }
00146 
00147     void saveAnnotation();
00148 
00149     void createDBEntry()
00150     {
00151       if(!connected) connectToDb();
00152       if(!connected) return;
00153 
00154       if(itsNewDBEntryDialog.exec())
00155       {
00156         itsSceneUid = itsNewDBEntryDialog.getSceneUid();
00157         emit openVideo(itsNewDBEntryDialog.getMgzJFileName());
00158       }
00159     }
00160 
00161 
00162     void openAnnotation();
00163 
00164     bool isConnected() { return connected; }
00165 
00166     QMap<int, QString> getObjCategories();
00167 
00168 
00169     void updateSettings(QSettings *settings);
00170     QString itsArchiveLoc;
00171     QString itsWorkingLoc;
00172     QString itsIncomingLoc;
00173   signals:
00174     void openVideo(QString fileName);
00175 
00176   public slots:
00177     void connectToDb();
00178     void chooseAnnotationSource();
00179 
00180 
00181   private:
00182     QSqlDatabase db;
00183     SelectAnnotationSourceDialog itsSelectAnnotationSourceDialog;
00184     NewDBEntryDialog itsNewDBEntryDialog;
00185     OpenDBEntryDialog itsOpenDBEntryDialog;
00186     ConnectionDialog itsConnDialog;
00187     bool connected;
00188     QString itsSceneUid;
00189 
00190 };
00191 
00192 #endif // NEOVISIONII_NEOANNOTATE_DBMANAGER_QT_H
00193 
Generated on Sun May 8 08:41:02 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3