Browse Source

Première passe de nettoyage du code :

nom_de_variable
NomDeFonction
class_objet* objet
dialogue* fenetre_dialogue
master
Maxime Wack 11 years ago
parent
commit
c684d61e47
28 changed files with 840 additions and 782 deletions
  1. +4
    -0
      CosMoS/CosMoS.project
  2. +149
    -145
      CosMoS/bdd.cpp
  3. +21
    -21
      CosMoS/bdd.h
  4. +89
    -89
      CosMoS/config.cpp
  5. +35
    -35
      CosMoS/config.h
  6. +19
    -19
      CosMoS/correc.cpp
  7. +1
    -1
      CosMoS/correc.fbp
  8. +1
    -1
      CosMoS/correc.h
  9. +25
    -25
      CosMoS/correcGUI.cpp
  10. +1
    -1
      CosMoS/correcGUI.h
  11. +22
    -22
      CosMoS/cosmos.cpp
  12. +1
    -1
      CosMoS/cosmos.fbp
  13. +1
    -1
      CosMoS/cosmos.h
  14. +59
    -59
      CosMoS/cosmosGUI.cpp
  15. +1
    -1
      CosMoS/cosmosGUI.h
  16. +24
    -24
      CosMoS/options.cpp
  17. +3
    -3
      CosMoS/options.h
  18. +71
    -71
      CosMoS/optionsRche.cpp
  19. +10
    -10
      CosMoS/optionsRche.fbp
  20. +3
    -3
      CosMoS/optionsRche.h
  21. +12
    -12
      CosMoS/optionsRcheGUI.cpp
  22. +1
    -1
      CosMoS/optionsRcheGUI.h
  23. +135
    -135
      CosMoS/recherche.cpp
  24. +17
    -17
      CosMoS/recherche.h
  25. +71
    -71
      CosMoS/resultats.cpp
  26. +12
    -12
      CosMoS/resultats.h
  27. +1
    -0
      Sante_Pub.workspace
  28. +51
    -2
      Sante_Pub.workspace.session

+ 4
- 0
CosMoS/CosMoS.project View File

@@ -33,6 +33,7 @@
<![CDATA[
]]>
</Environment>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
@@ -75,6 +76,7 @@
<![CDATA[
]]>
</Environment>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
@@ -114,6 +116,7 @@
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[
]]>
</Environment>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
@@ -156,6 +159,7 @@
<![CDATA[
]]>
</Environment>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">


+ 149
- 145
CosMoS/bdd.cpp View File

@@ -1,6 +1,6 @@
#include "bdd.h"

class_bdd::class_bdd(const wxString& path_in, wxGrid* grid)
class_bdd::class_bdd(const wxString& path_in, wxGrid* grid_consults)
{
this->path_in = path_in;
if (wxFileExists(path_in + slash + "db.lck"))
@@ -8,17 +8,17 @@ class_bdd::class_bdd(const wxString& path_in, wxGrid* grid)
wxMessageBox(_T("La base est actuellement en cours d'utilisation.\nSi vous êtes certains que ce n'est pas le cas,\n(comme par exemple après un crash)\nsupprimez le fichier db.lck situé dans le même répertoire"));
exit(0);
}
this->grid = grid;
this->grid_consults = grid_consults;
wxString path = path_in + slash + "cosmos.db";
if (!wxFileExists(path))
createEmpty(path);
CreateEmpty(path);
else if ((rc=sqlite3_open_v2(_C(path), &db, SQLITE_OPEN_READWRITE, NULL)) != SQLITE_OK)
{
wxMessageBox(_T("Erreur lors de l'ouverture de la base de données"), "Erreur", wxICON_ERROR | wxOK);
exit(0);
}
wxFile* lock = new wxFile(path_in + slash + "db.lck", wxFile::write);
lock->Close();
wxFile* file_lock = new wxFile(path_in + slash + "db.lck", wxFile::write);
file_lock->Close();
}

class_bdd::~class_bdd()
@@ -27,7 +27,7 @@ class_bdd::~class_bdd()
wxRemoveFile(path_in + slash + "db.lck");
}

void class_bdd::createEmpty(const wxString& path)
void class_bdd::CreateEmpty(const wxString& path)
{
rc = 0;
rc += sqlite3_open_v2(_C(path), &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
@@ -42,28 +42,28 @@ void class_bdd::createEmpty(const wxString& path)
}
}

void class_bdd::importer(const wxString& filename)
void class_bdd::Importer(const wxString& filename)
{
rc = 0;
int size = 0;
int progress = 0; //indicateurs de progression
wxUniChar c;
wxString fichier;
wxString content;
bool inquote = false; //guillemets
bool firstline = true;
bool is_first_line = true;
wxString item[23];
wxFFile* importfile = new wxFFile();
importfile->Open(filename);
wxFFile* file_import = new wxFFile();
file_import->Open(filename);
#ifdef __WXMSW__
importfile->ReadAll(&fichier, wxConvAuto(wxFONTENCODING_SYSTEM));
file_import->ReadAll(&content, wxConvAuto(wxFONTENCODING_SYSTEM));
#elif defined(__WXGTK__)
importfile->ReadAll(&fichier);
file_import->ReadAll(&content);
#endif
size = fichier.length() + 1;
size = content.length() + 1;
sqlite3_exec(db, "SAVEPOINT before_import;", NULL, NULL, NULL);
wxProgressDialog progress_dialog("Import", "Import de la base...", size, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME | wxPD_CAN_ABORT);
wxProgressDialog dialog_progress("Import", "Import de la base...", size, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME | wxPD_CAN_ABORT);
do
{
@@ -72,7 +72,7 @@ void class_bdd::importer(const wxString& filename)
item[i]="";
do
{
c = fichier[progress];
c = content[progress];
progress++;
if (c == '"')
{
@@ -86,13 +86,13 @@ void class_bdd::importer(const wxString& filename)
item[22]="";
do
{
c = fichier[progress];
c = content[progress];
progress++;
if ((c != '\n') && (c != '\0'))
item[22] << c;
}while ((c != '\n') && (c != '\0')); //dernier item de la ligne, se finit si retour ou EOF
if (!firstline)
if (!is_first_line)
{
//Insertion dans la table de consults
wxString requete = "INSERT OR REPLACE INTO Consult (id, n_dossier, nom, prenom, responsable, consultant, theme, etablissement, travail, date_cs, publi_prevue, service) VALUES (";
@@ -123,61 +123,61 @@ void class_bdd::importer(const wxString& filename)
<< ");";
rc += sqlite3_exec(db, requete, NULL, NULL, NULL);
}
firstline = false;
is_first_line = false;
//Annulation de l'import
if (!progress_dialog.Update(progress))
if (!dialog_progress.Update(progress))
{
wxMessageBox(_T("Aucune nouvelle donnée n'a été ajoutée"), "Attention !");
sqlite3_exec(db, "ROLLBACK TO before_import;", NULL, NULL, NULL);
break;
}
if (fichier[progress] == '\0')
if (content[progress] == '\0')
break;
}while (c != '\0');
importfile->Close();
progress_dialog.Update(size);
file_import->Close();
dialog_progress.Update(size);
sqlite3_exec(db, "RELEASE before_import;", NULL, NULL, NULL);
if (rc)
wxMessageBox("Erreur lors de l'import", "Erreur", wxOK | wxICON_ERROR);
updategrid();
GenerateGrid();
}

void class_bdd::exporter(const wxString& filename)
void class_bdd::Exporter(const wxString& filename)
{
/*#ifdef __WXMSW__
importfile->ReadAll(&fichier, wxConvAuto(wxFONTENCODING_SYSTEM));
file_import->ReadAll(&fichier, wxConvAuto(wxFONTENCODING_SYSTEM));
#elif defined(__WXGTK__)
importfile->ReadAll(&fichier);
file_import->ReadAll(&fichier);
#endif*/
wxProgressDialog progress_dialog("Export", "Export de la base...", grid->GetNumberRows(), NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
wxFFile* exportfile = new wxFFile(filename, "w");
wxString ligne;
ligne = "Travail numéro;Dossier numéro;Nom demandeur;Prénom demandeur;Service libellé;Etablissement libellé;Type travail libellé;Thème;Nom responsable;Consultant responsable;Date dernier RDV eff;Publi;Publi CHU;Consultant associé;Date de publication 1;Lien 1;Date de publication 2;Lien 2\n";
exportfile->Write(ligne);
for (int i=0; i < grid->GetNumberRows(); i++)
wxProgressDialog dialog_progress("Export", "Export de la base...", grid_consults->GetNumberRows(), NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
wxFFile* file_export = new wxFFile(filename, "w");
wxString line;
line = "Travail numéro;Dossier numéro;Nom demandeur;Prénom demandeur;Service libellé;Etablissement libellé;Type travail libellé;Thème;Nom responsable;Consultant responsable;Date dernier RDV eff;Publi;Publi CHU;Consultant associé;Date de publication 1;Lien 1;Date de publication 2;Lien 2\n";
file_export->Write(line);
for (int i=0; i < grid_consults->GetNumberRows(); i++)
{
wxString id = grid->GetCellValue(i,13);
ligne="";
wxString id = grid_consults->GetCellValue(i,13);
line="";
wxString requete = "SELECT service FROM Consult WHERE id=" + id + ";";
sqlite3_prepare_v2(db, requete, -1, &stmt, NULL);
sqlite3_step(stmt);
wxString service = sqlite3_column_text(stmt,0);
ligne << grid->GetCellValue(i,13) << ";"
<< grid->GetCellValue(i,4) << ";"
<< "\"" << grid->GetCellValue(i,5) << "\";"
<< "\"" << grid->GetCellValue(i,6) << "\";"
line << grid_consults->GetCellValue(i,13) << ";"
<< grid_consults->GetCellValue(i,4) << ";"
<< "\"" << grid_consults->GetCellValue(i,5) << "\";"
<< "\"" << grid_consults->GetCellValue(i,6) << "\";"
<< "\"" << service << "\";"
<< "\"" << grid->GetCellValue(i,10) << "\";"
<< "\"" << grid->GetCellValue(i,11) << "\";"
<< "\"" << grid->GetCellValue(i,9) << "\";"
<< "\"" << grid->GetCellValue(i,7) << "\";"
<< "\"" << grid->GetCellValue(i,8) << "\";"
<< grid->GetCellValue(i,12) << ";"
<< grid->GetCellValue(i,1) << ";"
<< grid->GetCellValue(i,2) << ";"
<< grid->GetCellValue(i,3) << ";";
wxArrayString list_publi = getidresult(id);
<< "\"" << grid_consults->GetCellValue(i,10) << "\";"
<< "\"" << grid_consults->GetCellValue(i,11) << "\";"
<< "\"" << grid_consults->GetCellValue(i,9) << "\";"
<< "\"" << grid_consults->GetCellValue(i,7) << "\";"
<< "\"" << grid_consults->GetCellValue(i,8) << "\";"
<< grid_consults->GetCellValue(i,12) << ";"
<< grid_consults->GetCellValue(i,1) << ";"
<< grid_consults->GetCellValue(i,2) << ";"
<< grid_consults->GetCellValue(i,3) << ";";
wxArrayString list_publi = GetIdResult(id);
for (unsigned int j=0; j < list_publi.GetCount(); j++)
{
if (list_publi[j].Left(1) == '@')
@@ -185,25 +185,27 @@ void class_bdd::exporter(const wxString& filename)
requete = "SELECT date_publi,lien FROM Publi WHERE id=" + list_publi[j].AfterLast('@') + ";";
sqlite3_prepare_v2(db, requete, -1, &stmt, NULL);
sqlite3_step(stmt);
ligne << sqlite3_column_text(stmt,0) << ";" << sqlite3_column_text(stmt,1) << ";";
line << sqlite3_column_text(stmt,0) << ";" << sqlite3_column_text(stmt,1) << ";";
}
}
ligne << "\n";
exportfile->Write(ligne);
progress_dialog.Update(i);
line << "\n";
file_export->Write(line);
dialog_progress.Update(i);
}
exportfile->Close();
file_export->Close();
}

void class_bdd::updategrid()
void class_bdd::GenerateGrid()
{
wxBeginBusyCursor();
int line_nb = 0;
rc = 0;
int nligne = 0;
stmt = NULL;
if (grid->GetNumberRows() != 0)
grid->DeleteRows(0, grid->GetNumberRows()); //reset de la grille
if (grid_consults->GetNumberRows() != 0)
grid_consults->DeleteRows(0, grid_consults->GetNumberRows()); //reset de la grille
rc = sqlite3_prepare_v2(db, "SELECT * FROM Consult;", -1, &stmt, NULL); //import depuis Consult
if (sqlite3_step(stmt) == SQLITE_DONE) //Si la bdd est vide
{
@@ -213,104 +215,106 @@ void class_bdd::updategrid()
}
else
sqlite3_reset(stmt); //retour à la première ligne, celle-ci étant lue juste avant pour vérifier la non vacuité
while (sqlite3_step(stmt) == SQLITE_ROW)
{
grid->AppendRows();
grid->SetCellValue(nligne, 4, _itoW(sqlite3_column_int(stmt, 1))); //n_dossier
grid_consults->AppendRows();
grid_consults->SetCellValue(line_nb, 4, _itoW(sqlite3_column_int(stmt, 1))); //n_dossier
for (int i=2; i<10; i++) //nom, prénom, responsable, consultant, theme, etablissement, travail, date
{
wxString orig = sqlite3_column_text(stmt, i);
// corrections
rc = sqlite3_prepare_v2(db, "SELECT dest FROM Correc WHERE orig=\"" + orig + "\";", -1, &stmt_correc, NULL);
if (sqlite3_step(stmt_correc) == SQLITE_DONE)
grid->SetCellValue(nligne, i+3, orig);
grid_consults->SetCellValue(line_nb, i+3, orig);
else
{
grid->SetCellValue(nligne, i+3, sqlite3_column_text(stmt_correc, 0));
//grid->SetCellBackgroundColour(nligne, i+3, *wxYELLOW);
grid_consults->SetCellValue(line_nb, i+3, sqlite3_column_text(stmt_correc, 0));
//grid->SetCellBackgroundColour(line_nb, i+3, *wxYELLOW);
}
sqlite3_finalize(stmt_correc);
}
// autocorrection prenoms
wxString prenom = grid->GetCellValue(nligne, 6);
wxString prenom = grid_consults->GetCellValue(line_nb, 6);
if (prenom.IsSameAs("xxx", false) || prenom.IsSameAs("xx", false) || prenom.IsSameAs("zzz", false) || prenom.IsSameAs("zz", false) || prenom.IsSameAs("yy", false) || prenom.IsSameAs("xy", false))
grid->SetCellValue(nligne, 6, "");
grid_consults->SetCellValue(line_nb, 6, "");
// autocorrection responsables
wxString resp = grid->GetCellValue(nligne, 7);
resp.Replace("Mr. Le Pr. ", "", true);
resp.Replace("Mme Le Dr. ", "", true);
resp.Replace("Mme Le Pr. ", "", true);
resp.Replace("Mr. ", "", true);
resp.Replace("Dr. ", "", true);
resp.Replace("Dr ", "", true);
resp.Replace("Pr. ", "", true);
resp.Replace("Pr ", "", true);
resp.Replace("Mme ", "", true);
resp.Replace("Melle ", "", true);
grid->SetCellValue(nligne, 7, resp);
wxString responsable = grid_consults->GetCellValue(line_nb, 7);
responsable.Replace("Mr. Le Pr. ", "", true);
responsable.Replace("Mme Le Dr. ", "", true);
responsable.Replace("Mme Le Pr. ", "", true);
responsable.Replace("Mr. ", "", true);
responsable.Replace("Dr. ", "", true);
responsable.Replace("Dr ", "", true);
responsable.Replace("Pr. ", "", true);
responsable.Replace("Pr ", "", true);
responsable.Replace("Mme ", "", true);
responsable.Replace("Melle ", "", true);
grid_consults->SetCellValue(line_nb, 7, responsable);
grid->SetCellValue(nligne, 13, _itoW(sqlite3_column_int(stmt, 0))); //id, caché
grid_consults->SetCellValue(line_nb, 13, _itoW(sqlite3_column_int(stmt, 0))); //id, caché
/*wxColour lightgreen(230, 255, 230); //TODO: gestion des couleurs dans la config ?
if (sqlite3_column_int(stmt, 10))
for (int j=0; j<13; j++)
grid->SetCellBackgroundColour(nligne, j, lightgreen); //coloration des publis prévues*/
nligne++;
grid->SetCellBackgroundColour(line_nb, j, lightgreen); //coloration des publis prévues*/
line_nb++;
}
sqlite3_finalize(stmt);
nligne = 0;
line_nb = 0;
sqlite3_prepare_v2(db, "SELECT * FROM Result;", -1, &stmt, NULL); //import depuis Result
while (sqlite3_step(stmt) == SQLITE_ROW)
{
grid->SetCellValue(nligne, 0, _itoW(sqlite3_column_int(stmt, 4))); //nb_results
grid_consults->SetCellValue(line_nb, 0, _itoW(sqlite3_column_int(stmt, 4))); //nb_results
for (int i=1; i<4; i++)
grid->SetCellValue(nligne, i, _itoW(sqlite3_column_int(stmt, i))); //publi, publi_CHU, cs_associe
grid_consults->SetCellValue(line_nb, i, _itoW(sqlite3_column_int(stmt, i))); //publi, publi_CHU, cs_associe
if (sqlite3_column_int(stmt, 1))
for (int i=0; i<13; i++)
grid->SetCellBackgroundColour(nligne, i, *wxGREEN); //coloration des consults trouvées
nligne++;
grid_consults->SetCellBackgroundColour(line_nb, i, *wxGREEN); //coloration des consults trouvées
line_nb++;
}
sqlite3_finalize(stmt);
grid->AutoSizeColumns(false);
grid->AutoSizeRows(false);
grid->HideCol(13);
grid_consults->AutoSizeColumns(false);
grid_consults->AutoSizeRows(false);
grid_consults->HideCol(13);
wxEndBusyCursor();
}

void class_bdd::modresultpubli(int row, unsigned int bitfield)
void class_bdd::SetResultPubli(int row, unsigned int bitfield)
{
wxString id = grid->GetCellValue(row,13);
wxString id = grid_consults->GetCellValue(row,13);
wxString val[3] = {"0","0","0"};
//Actualisation de la grille
for (int i=1; i<= 3; i++)
grid->SetCellValue(row,i,"0");
grid_consults->SetCellValue(row,i,"0");
if (bitfield & 1<<1)
{
grid->SetCellValue(row,1,"1");
grid_consults->SetCellValue(row,1,"1");
val[0] = "1";
}
if (bitfield & 1<<2)
{
grid->SetCellValue(row,2,"1");
grid_consults->SetCellValue(row,2,"1");
val[1] = "1";
}
if (bitfield & 1<<3)
{
grid->SetCellValue(row,3,"1");
grid_consults->SetCellValue(row,3,"1");
val[2] = "1";
}
for (int i=0; i<13; i++)
{
if (bitfield & 1<<1)
grid->SetCellBackgroundColour(row, i, *wxGREEN);
grid_consults->SetCellBackgroundColour(row, i, *wxGREEN);
else
grid->SetCellBackgroundColour(row, i, grid->GetDefaultCellBackgroundColour());
grid_consults->SetCellBackgroundColour(row, i, grid_consults->GetDefaultCellBackgroundColour());
}
grid->ForceRefresh();
grid_consults->ForceRefresh();

rc = 0;
wxString requete = "UPDATE Result SET";
@@ -324,7 +328,7 @@ void class_bdd::modresultpubli(int row, unsigned int bitfield)
wxMessageBox("Erreur lors de la mise à jour de la valeur", "Erreur", wxOK | wxICON_ERROR);
}

int class_bdd::nbcorrections()
int class_bdd::GetNbCorrecs()
{
int count = 0;
sqlite3_prepare_v2(db, "SELECT * FROM Correc;", -1, &stmt, NULL);
@@ -334,27 +338,27 @@ int class_bdd::nbcorrections()
return count;
}

wxString* class_bdd::getcorrecorig()
wxString* class_bdd::GetCorrecOrig()
{
wxString* retour = new wxString[nbcorrections()];
wxString* out = new wxString[GetNbCorrecs()];
sqlite3_prepare_v2(db, "SELECT * FROM Correc;", -1, &stmt, NULL);
for (int i=0; sqlite3_step(stmt) == SQLITE_ROW; i++)
retour[i] = sqlite3_column_text(stmt, 0);
out[i] = sqlite3_column_text(stmt, 0);
sqlite3_finalize(stmt);
return retour;
return out;
}

wxString* class_bdd::getcorrecdest()
wxString* class_bdd::GetCorrecDest()
{
wxString* retour = new wxString[nbcorrections()];
wxString* out = new wxString[GetNbCorrecs()];
sqlite3_prepare_v2(db, "SELECT * FROM Correc;", -1, &stmt, NULL);
for (int i=0; sqlite3_step(stmt) == SQLITE_ROW; i++)
retour[i] = sqlite3_column_text(stmt, 1);
out[i] = sqlite3_column_text(stmt, 1);
sqlite3_finalize(stmt);
return retour;
return out;
}

void class_bdd::addcorrection(const wxString& id, int col, const wxString& dest)
void class_bdd::AddCorrec(const wxString& id, int col, const wxString& dest)
{
rc = 0;
wxString requete = "SELECT * FROM Consult WHERE id=" + id + ";";
@@ -362,40 +366,40 @@ void class_bdd::addcorrection(const wxString& id, int col, const wxString& dest)
sqlite3_step(stmt);
wxString orig = sqlite3_column_text(stmt, col-3);
sqlite3_finalize(stmt);
modcorrection(orig, dest);
SetCorrec(orig, dest);
}

void class_bdd::modcorrection(const wxString& orig, const wxString& dest)
void class_bdd::SetCorrec(const wxString& orig, const wxString& dest)
{
wxString requete = "INSERT OR REPLACE INTO Correc VALUES (\"" + orig + "\",\"" + dest + "\");";
sqlite3_exec(db, requete, NULL, NULL, NULL);
// Mise à jour de la grille
for (int i=0; i<grid->GetNumberRows(); i++)
for (int i=0; i<grid_consults->GetNumberRows(); i++)
{
requete = "SELECT * FROM Consult WHERE id=" + grid->GetCellValue(i, 13) + ";";
requete = "SELECT * FROM Consult WHERE id=" + grid_consults->GetCellValue(i, 13) + ";";
sqlite3_prepare_v2(db, requete, -1, &stmt, NULL);
sqlite3_step(stmt);
for (int j=5; j<11; j++)
{
wxString table_orig = sqlite3_column_text(stmt, j - 3);
if (table_orig == orig)
grid->SetCellValue(i, j, dest);
grid_consults->SetCellValue(i, j, dest);
}
sqlite3_finalize(stmt);
}
// Suppression d'une correction si on revient à l'original
if (dest == orig)
delcorrection(orig);
DelCorrec(orig);
}

void class_bdd::delcorrection(const wxString& orig)
void class_bdd::DelCorrec(const wxString& orig)
{
sqlite3_exec(db, "DELETE FROM Correc WHERE orig=\"" + orig + "\";", NULL, NULL, NULL);
}

int class_bdd::nbresult(const wxString& id)
int class_bdd::GetNbResults(const wxString& id)
{
sqlite3_prepare_v2(db, "SELECT nb_result FROM Result WHERE id=" + id + ";" , -1, &stmt, NULL);
sqlite3_step(stmt);
@@ -405,61 +409,61 @@ int class_bdd::nbresult(const wxString& id)
return out;
}

void class_bdd::modnbresult(const wxString& id, int nbresults)
void class_bdd::SetNbResults(const wxString& id, int nb_results)
{
sqlite3_exec(db, "UPDATE Result SET nb_result=" + _itoW(nbresults) + " WHERE id=" + id + ";", NULL, NULL, NULL);
sqlite3_exec(db, "UPDATE Result SET nb_result=" + _itoW(nb_results) + " WHERE id=" + id + ";", NULL, NULL, NULL);
}

wxArrayString class_bdd::getidresult(const wxString& id, bool stripped)
wxArrayString class_bdd::GetIdResult(const wxString& id, bool stripped)
{
sqlite3_prepare_v2(db, "SELECT id_result FROM Result WHERE id=" + id + ";", -1, &stmt, NULL);
sqlite3_step(stmt);
wxString list = sqlite3_column_text(stmt, 0);
wxString list_id = sqlite3_column_text(stmt, 0);
sqlite3_finalize(stmt);
wxArrayString out;
while (list.Length() > 0)
while (list_id.Length() > 0)
{
if (stripped)
out.Add(list.BeforeFirst(',').AfterLast('!'));
out.Add(list_id.BeforeFirst(',').AfterLast('!'));
else
out.Add(list.BeforeFirst(','));
list = list.AfterFirst(',');
out.Add(list_id.BeforeFirst(','));
list_id = list_id.AfterFirst(',');
}
return out;
}

void class_bdd::setidresult(const wxString& id, wxArrayString idresult)
void class_bdd::SetIdResult(const wxString& id, wxArrayString id_results)
{
wxString list = "";
wxString list_id = "";
int count = 0;
for (unsigned int i=0; i<idresult.GetCount(); i++)
for (unsigned int i=0; i<id_results.GetCount(); i++)
{
list += idresult[i] + ",";
if (idresult[i].Left(1) != '!')
list_id += id_results[i] + ",";
if (id_results[i].Left(1) != '!')
count++;
}
list = list.BeforeLast(',');
sqlite3_exec(db, "UPDATE Result SET id_result=\"" + list + "\" WHERE id=" + id + ";", NULL, NULL, NULL);
modnbresult(id, count);
list_id = list_id.BeforeLast(',');
sqlite3_exec(db, "UPDATE Result SET id_result=\"" + list_id + "\" WHERE id=" + id + ";", NULL, NULL, NULL);
SetNbResults(id, count);
}

void class_bdd::addidresult(const wxString& id, const wxString& idresult)
void class_bdd::AddIdResult(const wxString& id, const wxString& id_result)
{
sqlite3_prepare_v2(db, "SELECT id_result FROM Result WHERE id=" + id + ";", -1, &stmt, NULL);
sqlite3_step(stmt);
wxString list = sqlite3_column_text(stmt, 0);
wxString list_id = sqlite3_column_text(stmt, 0);
sqlite3_finalize(stmt);
if (list.Length() > 0)
list = idresult + "," + list;
if (list_id.Length() > 0)
list_id = id_result + "," + list_id;
else
list = idresult;
list_id = id_result;
sqlite3_exec(db, "UPDATE Result SET id_result=\"" + list + "\" WHERE id=" + id + ";", NULL, NULL, NULL);
sqlite3_exec(db, "UPDATE Result SET id_result=\"" + list_id + "\" WHERE id=" + id + ";", NULL, NULL, NULL);
}

bool class_bdd::publiexists(const wxString& id)
bool class_bdd::IsPubli(const wxString& id)
{
sqlite3_prepare_v2(db, "SELECT * FROM Publi WHERE id=" + id + ";", -1, &stmt, NULL);
if (sqlite3_step(stmt) == SQLITE_DONE)
@@ -468,24 +472,24 @@ bool class_bdd::publiexists(const wxString& id)
return true;
}

void class_bdd::addpubli(wxString id, wxString titre, wxString auteurs, wxString abstract, wxString revue, wxString lien, wxString date)
void class_bdd::AddPubli(wxString id, wxString title, wxString authors, wxString abstract, wxString journal, wxString link, wxString date)
{
titre.Replace("\"", "_");
title.Replace("\"", "_");
abstract.Replace("\"", "_");
wxString requete = "INSERT OR REPLACE INTO Publi (id, titre, auteurs, abstract, revue, lien, date_publi) VALUES (";
requete << id << ", "
<< "\"" << titre << "\", "
<< "\"" << auteurs << "\", "
<< "\"" << title << "\", "
<< "\"" << authors << "\", "
<< "\"" << abstract << "\", "
<< "\"" << revue << "\", "
<< "\"" << lien << "\", "
<< "\"" << journal << "\", "
<< "\"" << link << "\", "
<< "\"" << date << "\");";
rc = sqlite3_exec(db, requete, NULL, NULL, NULL);
if (rc)
wxMessageBox(_itoW(rc) + "\n" + requete);
}

wxArrayString class_bdd::getpubli(wxString id)
wxArrayString class_bdd::GetPublis(wxString id)
{
wxArrayString out;
sqlite3_prepare_v2(db, "SELECT * FROM Publi WHERE id=" + id + ";", -1, &stmt, NULL);


+ 21
- 21
CosMoS/bdd.h View File

@@ -17,43 +17,43 @@ class class_bdd
sqlite3* db;
sqlite3_stmt* stmt, *stmt_correc;
int rc;
wxGrid* grid;
wxGrid* grid_consults;
wxString path_in;
void createEmpty(const wxString& path);
void CreateEmpty(const wxString& path);
public:
class_bdd(const wxString& path_in, wxGrid* grid);
class_bdd(const wxString& path_in, wxGrid* grid_consults);
~class_bdd();
// import/export
void importer(const wxString& filename);
void exporter(const wxString& filename);
void Importer(const wxString& filename);
void Exporter(const wxString& filename);
// mise à jour de la grille
void updategrid();
void GenerateGrid();
// modification des booléens de publi
void modresultpubli(int row, unsigned int bitfield); //modifie le statut de publi dans la bdd et la grille (publi(1<<1)/publichu(1<<2)/cs_associe(1<<3)
void SetResultPubli(int row, unsigned int bitfield); //modifie le statut de publi dans la bdd et la grille (publi(1<<1)/publichu(1<<2)/cs_associe(1<<3)
// gestion des corrections
int nbcorrections();
wxString* getcorrecorig();
wxString* getcorrecdest();
void addcorrection(const wxString& id, int col, const wxString& dest);
void modcorrection(const wxString& orig, const wxString& dest);
void delcorrection(const wxString& orig);
int GetNbCorrecs();
wxString* GetCorrecOrig();
wxString* GetCorrecDest();
void AddCorrec(const wxString& id, int col, const wxString& dest);
void SetCorrec(const wxString& orig, const wxString& dest);
void DelCorrec(const wxString& orig);
// gestion des résultats
int nbresult(const wxString& id);
void modnbresult(const wxString& id, int nbresults);
wxArrayString getidresult(const wxString& id, bool stripped=false);
void setidresult(const wxString& id, wxArrayString idresult);
void addidresult(const wxString& id, const wxString& idresult);
int GetNbResults(const wxString& id);
void SetNbResults(const wxString& id, int nb_results);
wxArrayString GetIdResult(const wxString& id, bool stripped=false);
void SetIdResult(const wxString& id, wxArrayString id_results);
void AddIdResult(const wxString& id, const wxString& id_result);
// gestion des publis
bool publiexists(const wxString& id);
void addpubli(wxString id, wxString titre, wxString auteurs, wxString abstract, wxString revue, wxString lien, wxString date);
wxArrayString getpubli(wxString id);
bool IsPubli(const wxString& id);
void AddPubli(wxString id, wxString title, wxString authors, wxString abstract, wxString journal, wxString link, wxString date);
wxArrayString GetPublis(wxString id);
};

#endif //__bdd__

+ 89
- 89
CosMoS/config.cpp View File

@@ -1,179 +1,179 @@
#include "config.h"

config::config()
class_config::class_config()
{
if (!wxFileExists("cosmos.cfg"))
createDefault();
CreateDefault();
else
load();
Load();
}

void config::createDefault()
void class_config::CreateDefault()
{
dbpath = wxGetCwd();
useproxy = true;
proxyurl = "www-proxy.chu-nancy.fr";
proxyport = 8080;
path_db = wxGetCwd();
use_proxy = true;
proxy_url = "www-proxy.chu-nancy.fr";
proxy_port = 8080;
rule defaultrule = {"defaut", true, true, true, true, AND, AND, AND, true, true, 2, 5, true, "Nancy", false, "", 20};
ruleset.push_back(defaultrule);
rule default_rule = {"defaut", true, true, true, true, AND, AND, AND, true, true, 2, 5, true, "Nancy", false, "", 20};
list_rules.push_back(default_rule);
first_time = true;
is_first_time = true;
}

config::~config()
class_config::~class_config()
{
ruleset.clear();
list_rules.clear();
}


void config::save()
void class_config::Save()
{
wxXmlDocument* fichier_config = new wxXmlDocument();
wxXmlDocument* file_config = new wxXmlDocument();
wxXmlNode* rootnode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "CosMoS_config"); //root
wxXmlNode* dbpathnode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "dbpath"); // dbpath
dbpathnode->AddAttribute("value", dbpath); // dbpath_value
dbpathnode->AddAttribute("value", path_db); // dbpath_value
rootnode->AddChild(dbpathnode);
wxXmlNode* proxynode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "proxy"); // proxy
proxynode->AddAttribute("set", bool2W(useproxy)); // proxy_set
proxynode->AddAttribute("url", proxyurl); // proxy_url
proxynode->AddAttribute("port", _itoW(proxyport)); // proxy_port
proxynode->AddAttribute("set", bool2W(use_proxy)); // proxy_set
proxynode->AddAttribute("url", proxy_url); // proxy_url
proxynode->AddAttribute("port", _itoW(proxy_port)); // proxy_port
rootnode->AddChild(proxynode);
wxXmlNode* rulesetnode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "ruleset"); // ruleset
for (vector<rule>::iterator i = ruleset.begin(); i < ruleset.end(); i++)
addsettoxml(rulesetnode, *i); // rule(s)
for (vector<rule>::iterator i = list_rules.begin(); i < list_rules.end(); i++)
AddRulesToXML(rulesetnode, *i); // rule(s)
rootnode->AddChild(rulesetnode);
fichier_config->SetRoot(rootnode);
file_config->SetRoot(rootnode);
fichier_config->Save("cosmos.cfg");
delete fichier_config;
file_config->Save("cosmos.cfg");
delete file_config;
}

void config::addsettoxml(wxXmlNode* setlistnode, rule toadd)
void class_config::AddRulesToXML(wxXmlNode* setlistnode, rule to_add)
{
wxXmlNode* setnode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "rule"); // rule
setnode->AddAttribute("name", toadd.name); // rule_name
setnode->AddAttribute("inuse", bool2W(toadd.inuse)); // rule_inuse
setnode->AddAttribute("name", to_add.name); // rule_name
setnode->AddAttribute("inuse", bool2W(to_add.in_use)); // rule_inuse
wxXmlNode* nomsnode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "noms"); // noms
nomsnode->AddAttribute("demandeur", bool2W(toadd.usedemandeur)); // noms_demandeur
nomsnode->AddAttribute("responsable", bool2W(toadd.useresponsable)); // noms_responsable
nomsnode->AddAttribute("consultant", bool2W(toadd.useconsultant)); // noms_consultant
nomsnode->AddAttribute("demandeur", bool2W(to_add.use_demandeur)); // noms_demandeur
nomsnode->AddAttribute("responsable", bool2W(to_add.use_responsable)); // noms_responsable
nomsnode->AddAttribute("consultant", bool2W(to_add.use_consultant)); // noms_consultant
setnode->AddChild(nomsnode);
wxXmlNode* opsnode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "ops"); // ops
opsnode->AddAttribute("demandeur", op2W(toadd.opdemandeur)); // ops_demandeur
opsnode->AddAttribute("both", op2W(toadd.opboth)); // ops_both
opsnode->AddAttribute("responsable", op2W(toadd.opresponsable)); // ops_responsable
opsnode->AddAttribute("demandeur", op2W(to_add.op_demandeur)); // ops_demandeur
opsnode->AddAttribute("both", op2W(to_add.op_both)); // ops_both
opsnode->AddAttribute("responsable", op2W(to_add.op_responsable)); // ops_responsable
setnode->AddChild(opsnode);
wxXmlNode* datesnode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "dates");// dates
datesnode->AddAttribute("usedebut", bool2W(toadd.usedebut)); // dates_usedebut
datesnode->AddAttribute("debut", _itoW(toadd.debut)); // dates_debut
datesnode->AddAttribute("usefin", bool2W(toadd.usefin)); // dates_usefin
datesnode->AddAttribute("fin", _itoW(toadd.fin)); // dates_fin
datesnode->AddAttribute("usedebut", bool2W(to_add.use_debut)); // dates_usedebut
datesnode->AddAttribute("debut", _itoW(to_add.debut)); // dates_debut
datesnode->AddAttribute("usefin", bool2W(to_add.use_fin)); // dates_usefin
datesnode->AddAttribute("fin", _itoW(to_add.fin)); // dates_fin
setnode->AddChild(datesnode);
wxXmlNode* villenode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "ville");// ville
villenode->AddAttribute("set", bool2W(toadd.useville)); // ville_set
villenode->AddAttribute("value", toadd.ville); // ville_value
villenode->AddAttribute("set", bool2W(to_add.use_ville)); // ville_set
villenode->AddAttribute("value", to_add.ville); // ville_value
setnode->AddChild(villenode);
wxXmlNode* supplnode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "suppl");// suppl
supplnode->AddAttribute("set", bool2W(toadd.usesuppl)); // suppl_set
supplnode->AddAttribute("value", toadd.suppl); // suppl_value
supplnode->AddAttribute("set", bool2W(to_add.use_suppl)); // suppl_set
supplnode->AddAttribute("value", to_add.suppl); // suppl_value
setnode->AddChild(supplnode);
wxXmlNode* retmaxnode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "retmax");// retmax
retmaxnode->AddAttribute("value", _itoW(toadd.retmax)); // retmax_value
retmaxnode->AddAttribute("value", _itoW(to_add.retmax)); // retmax_value
setnode->AddChild(retmaxnode);
setlistnode->AddChild(setnode);
}

void config::load()
void class_config::Load()
{
rule currentrule;
wxXmlDocument* fichier_config = new wxXmlDocument("cosmos.cfg"); //root
wxXmlNode* parcours = fichier_config->GetRoot()->GetChildren(); // dbpath
dbpath = parcours->GetAttribute("value"); // dbpath_value
rule current_rule;
wxXmlDocument* file_config = new wxXmlDocument("cosmos.cfg"); //root
wxXmlNode* parcours = file_config->GetRoot()->GetChildren(); // dbpath
path_db = parcours->GetAttribute("value"); // dbpath_value
parcours = parcours->GetNext(); // proxy
useproxy = W2bool(parcours->GetAttribute("set")); // proxy_set
proxyurl = parcours->GetAttribute("url"); // proxy_url
proxyport = wxAtoi(parcours->GetAttribute("port")); // proxy_port
use_proxy = W2bool(parcours->GetAttribute("set")); // proxy_set
proxy_url = parcours->GetAttribute("url"); // proxy_url
proxy_port = wxAtoi(parcours->GetAttribute("port")); // proxy_port
parcours = parcours->GetNext(); // ruleset
if (parcours->GetChildren())
{
parcours = parcours->GetChildren(); // rule
do
{
currentrule.name = parcours->GetAttribute("name"); // rule_name
currentrule.inuse = W2bool(parcours->GetAttribute("inuse")); // rule_inuse
current_rule.name = parcours->GetAttribute("name"); // rule_name
current_rule.in_use = W2bool(parcours->GetAttribute("inuse")); // rule_inuse
parcours = parcours->GetChildren(); // noms
currentrule.usedemandeur = W2bool(parcours->GetAttribute("demandeur")); // noms_demandeur
currentrule.useresponsable = W2bool(parcours->GetAttribute("responsable"));// noms_responsable
currentrule.useconsultant = W2bool(parcours->GetAttribute("consultant"));// noms_consultant
current_rule.use_demandeur = W2bool(parcours->GetAttribute("demandeur")); // noms_demandeur
current_rule.use_responsable = W2bool(parcours->GetAttribute("responsable"));// noms_responsable
current_rule.use_consultant = W2bool(parcours->GetAttribute("consultant"));// noms_consultant
parcours = parcours->GetNext(); // ops
currentrule.opdemandeur = W2op(parcours->GetAttribute("demandeur")); // ops_demandeur
currentrule.opboth = W2op(parcours->GetAttribute("both")); // ops_both
currentrule.opresponsable = W2op(parcours->GetAttribute("responsable"));// ops_responsable
current_rule.op_demandeur = W2op(parcours->GetAttribute("demandeur")); // ops_demandeur
current_rule.op_both = W2op(parcours->GetAttribute("both")); // ops_both
current_rule.op_responsable = W2op(parcours->GetAttribute("responsable"));// ops_responsable
parcours = parcours->GetNext(); // dates
currentrule.usedebut = W2bool(parcours->GetAttribute("usedebut")); // dates_usedebut
currentrule.debut = wxAtoi(parcours->GetAttribute("debut")); // dates_debut
currentrule.usefin = W2bool(parcours->GetAttribute("usefin")); // dates_usefin
currentrule.fin = wxAtoi(parcours->GetAttribute("fin")); // dates_fin
current_rule.use_debut = W2bool(parcours->GetAttribute("usedebut")); // dates_usedebut
current_rule.debut = wxAtoi(parcours->GetAttribute("debut")); // dates_debut
current_rule.use_fin = W2bool(parcours->GetAttribute("usefin")); // dates_usefin
current_rule.fin = wxAtoi(parcours->GetAttribute("fin")); // dates_fin
parcours = parcours->GetNext(); // ville
currentrule.useville = W2bool(parcours->GetAttribute("set")); // ville_set
currentrule.ville = parcours->GetAttribute("value"); // ville_value
current_rule.use_ville = W2bool(parcours->GetAttribute("set")); // ville_set
current_rule.ville = parcours->GetAttribute("value"); // ville_value
parcours = parcours->GetNext(); // suppl
currentrule.usesuppl = W2bool(parcours->GetAttribute("set")); // suppl_set
currentrule.suppl = parcours->GetAttribute("value"); // suppl_value
current_rule.use_suppl = W2bool(parcours->GetAttribute("set")); // suppl_set
current_rule.suppl = parcours->GetAttribute("value"); // suppl_value
parcours = parcours->GetNext(); // retmax
currentrule.retmax = wxAtoi(parcours->GetAttribute("value")); // retmax_value
current_rule.retmax = wxAtoi(parcours->GetAttribute("value")); // retmax_value
parcours = parcours->GetParent()->GetNext();
ruleset.push_back(currentrule);
list_rules.push_back(current_rule);
}while (parcours);
}
delete fichier_config;
delete file_config;
first_time = false;
is_first_time = false;
}

void config::addrule(rule toadd)
void class_config::AddRule(rule to_add)
{
ruleset.push_back(toadd);
list_rules.push_back(to_add);
}

void config::delrule(int index)
void class_config::DelRule(int index)
{
ruleset.erase(ruleset.begin()+index);
list_rules.erase(list_rules.begin()+index);
}

int config::getnbrule()
int class_config::GetNbRules()
{
return ruleset.size();
return list_rules.size();
}

rule config::getrule(int index)
rule class_config::GetRule(int index)
{
return ruleset[index];
return list_rules[index];
}

void config::modrule(int index, rule temp)
void class_config::SetRule(int index, rule temp)
{
ruleset[index] = temp;
list_rules[index] = temp;
}

void config::uprule(int index)
void class_config::MoveRuleUp(int index)
{
if (index > 0)
{
rule temp = ruleset[index-1];
ruleset[index-1] = ruleset[index];
ruleset[index] = temp;
rule temp = list_rules[index-1];
list_rules[index-1] = list_rules[index];
list_rules[index] = temp;
}
}

void config::downrule(int index)
void class_config::MoveRuleDown(int index)
{
if (index < (int)ruleset.size() - 1)
if (index < (int)list_rules.size() - 1)
{
rule temp = ruleset[index+1];
ruleset[index+1] = ruleset[index];
ruleset[index] = temp;
rule temp = list_rules[index+1];
list_rules[index+1] = list_rules[index];
list_rules[index] = temp;
}
}

+ 35
- 35
CosMoS/config.h View File

@@ -12,55 +12,55 @@ using namespace std;
typedef struct trule
{
wxString name;
bool inuse;
bool usedemandeur, useresponsable, useconsultant;
int opdemandeur, opboth, opresponsable;
bool usedebut, usefin;
bool in_use;
bool use_demandeur, use_responsable, use_consultant;
int op_demandeur, op_both, op_responsable;
bool use_debut, use_fin;
int debut, fin;
bool useville;
bool use_ville;
wxString ville;
bool usesuppl;
bool use_suppl;
wxString suppl;
int retmax;
}rule;

class config
class class_config
{
protected:
bool first_time;
wxString dbpath;
bool useproxy;
wxString proxyurl;
int proxyport;
vector<rule> ruleset;
bool is_first_time;
wxString path_db;
bool use_proxy;
wxString proxy_url;
int proxy_port;
vector<rule> list_rules;
void createDefault();
void load();
void addsettoxml(wxXmlNode* xmldoc, rule toadd);
void CreateDefault();
void Load();
void AddRulesToXML(wxXmlNode* setlistnode, rule to_add);
public:
config();
~config();
class_config();
~class_config();
void save();
void addrule(rule toadd);
void delrule(int index);
int getnbrule();
rule getrule(int index);
void modrule(int index, rule temp);
void uprule(int index);
void downrule(int index);
void Save();
void AddRule(rule to_add);
void DelRule(int index);
int GetNbRules();
rule GetRule(int index);
void SetRule(int index, rule temp);
void MoveRuleUp(int index);
void MoveRuleDown(int index);
// GETters et SETters
void SetDbpath(const wxString& dbpath) {this->dbpath = dbpath;}
void SetProxyport(int proxyport) {this->proxyport = proxyport;}
void SetProxyurl(const wxString& proxyurl) {this->proxyurl = proxyurl;}
void SetUseproxy(bool useproxy) {this->useproxy = useproxy;}
const wxString& GetDbpath() const {return dbpath;}
int GetProxyport() const {return proxyport;}
const wxString& GetProxyurl() const {return proxyurl;}
bool IsUseproxy() const {return useproxy;}
bool IsFirstTime() const {return first_time;}
void SetPathDb(const wxString& path_db) {this->path_db = path_db;}
void SetProxyPort(int proxy_port) {this->proxy_port = proxy_port;}
void SetProxyUrl(const wxString& proxy_url) {this->proxy_url = proxy_url;}
void SetUseProxy(bool use_proxy) {this->use_proxy = use_proxy;}
const wxString& GetPathDb() const {return path_db;}
int GetProxyPort() const {return proxy_port;}
const wxString& GetProxyUrl() const {return proxy_url;}
bool IsUseProxy() const {return use_proxy;}
bool IsFirstTime() const {return is_first_time;}
};




+ 19
- 19
CosMoS/correc.cpp View File

@@ -7,40 +7,40 @@ dialog_correc( parent )
this->bdd = bdd;
}

void correc::update()
void correc::Update()
{
int nbcorrec = bdd->nbcorrections();
if (grid_Correcs->GetNumberRows() != 0)
grid_Correcs->DeleteRows(0, grid_Correcs->GetNumberRows()); //reset de la grille
grid_Correcs->AppendRows(nbcorrec);
wxString* correcorig = bdd->getcorrecorig();
wxString* correcdest = bdd->getcorrecdest();
for (int i=0; i<nbcorrec; i++)
int nb_correc = bdd->GetNbCorrecs();
if (grid_correcs->GetNumberRows() != 0)
grid_correcs->DeleteRows(0, grid_correcs->GetNumberRows()); //reset de la grille
grid_correcs->AppendRows(nb_correc);
wxString* correc_orig = bdd->GetCorrecOrig();
wxString* correc_dest = bdd->GetCorrecDest();
for (int i=0; i<nb_correc; i++)
{
grid_Correcs->SetRowLabelValue(i, "X");
grid_Correcs->SetCellValue(i, 0, correcorig[i]);
grid_Correcs->SetCellValue(i, 1, correcdest[i]);
grid_correcs->SetRowLabelValue(i, "X");
grid_correcs->SetCellValue(i, 0, correc_orig[i]);
grid_correcs->SetCellValue(i, 1, correc_dest[i]);
}
grid_Correcs->AutoSizeRows(false);
grid_Correcs->AutoSizeColumns(false);
grid_correcs->AutoSizeRows(false);
grid_correcs->AutoSizeColumns(false);
Fit();
delete[] correcorig;
delete[] correcdest;
delete[] correc_orig;
delete[] correc_dest;
}

void correc::OnCellChange( wxGridEvent& event )
{
int row = event.GetRow();
bdd->modcorrection(grid_Correcs->GetCellValue(row, 0), grid_Correcs->GetCellValue(row, 1));
bdd->SetCorrec(grid_correcs->GetCellValue(row, 0), grid_correcs->GetCellValue(row, 1));
}

void correc::OnLabelLeftClick( wxGridEvent& event )
{
if (event.GetRow() != -1)
{
wxString orig = grid_Correcs->GetCellValue(event.GetRow(), 0);
bdd->modcorrection(orig, orig);
grid_Correcs->DeleteRows(event.GetRow(), 1, false);
wxString orig = grid_correcs->GetCellValue(event.GetRow(), 0);
bdd->SetCorrec(orig, orig);
grid_correcs->DeleteRows(event.GetRow(), 1, false);
}
}



+ 1
- 1
CosMoS/correc.fbp View File

@@ -124,7 +124,7 @@
<property name="margin_width">0</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">grid_Correcs</property>
<property name="name">grid_correcs</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="row_label_horiz_alignment">wxALIGN_CENTRE</property>


+ 1
- 1
CosMoS/correc.h View File

@@ -23,7 +23,7 @@ protected:
public:
/** Constructor */
correc( wxWindow* parent, class_bdd* bdd );
void update();
void Update();
//// end generated class members
};


+ 25
- 25
CosMoS/correcGUI.cpp View File

@@ -16,44 +16,44 @@ dialog_correc::dialog_correc( wxWindow* parent, wxWindowID id, const wxString& t
wxBoxSizer* verticalsizer;
verticalsizer = new wxBoxSizer( wxVERTICAL );
grid_Correcs = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
grid_correcs = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
grid_Correcs->CreateGrid( 0, 2 );
grid_Correcs->EnableEditing( true );
grid_Correcs->EnableGridLines( true );
grid_Correcs->EnableDragGridSize( true );
grid_Correcs->SetMargins( 0, 0 );
grid_correcs->CreateGrid( 0, 2 );
grid_correcs->EnableEditing( true );
grid_correcs->EnableGridLines( true );
grid_correcs->EnableDragGridSize( true );
grid_correcs->SetMargins( 0, 0 );
// Columns
grid_Correcs->SetColSize( 0, 114 );
grid_Correcs->SetColSize( 1, 82 );
grid_Correcs->EnableDragColMove( false );
grid_Correcs->EnableDragColSize( true );
grid_Correcs->SetColLabelSize( 30 );
grid_Correcs->SetColLabelValue( 0, wxT("Texte d'origine") );
grid_Correcs->SetColLabelValue( 1, wxT("Correction") );
grid_Correcs->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
grid_correcs->SetColSize( 0, 114 );
grid_correcs->SetColSize( 1, 82 );
grid_correcs->EnableDragColMove( false );
grid_correcs->EnableDragColSize( true );
grid_correcs->SetColLabelSize( 30 );
grid_correcs->SetColLabelValue( 0, wxT("Texte d'origine") );
grid_correcs->SetColLabelValue( 1, wxT("Correction") );
grid_correcs->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
grid_Correcs->EnableDragRowSize( true );
grid_Correcs->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
grid_correcs->EnableDragRowSize( true );
grid_correcs->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
grid_Correcs->SetDefaultEditor(new wxGridCellTextEditor);
grid_Correcs->SetDefaultRenderer(new wxGridCellStringRenderer);
grid_correcs->SetDefaultEditor(new wxGridCellTextEditor);
grid_correcs->SetDefaultRenderer(new wxGridCellStringRenderer);
col_orig = new wxGridCellAttr();
col_orig->SetReadOnly();
col_orig->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
col_orig->SetRenderer(new wxGridCellStringRenderer);
grid_Correcs->SetColAttr(0, col_orig);
grid_correcs->SetColAttr(0, col_orig);
// Label Appearance
// Cell Defaults
grid_Correcs->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
verticalsizer->Add( grid_Correcs, 1, wxALL | wxEXPAND, 5 );
grid_correcs->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
verticalsizer->Add( grid_correcs, 1, wxALL | wxEXPAND, 5 );
bouton_ok = new wxButton( this, wxID_ANY, wxT("Ok"), wxDefaultPosition, wxDefaultSize, 0 );
verticalsizer->Add( bouton_ok, 0, wxALL|wxALIGN_RIGHT, 5 );
@@ -64,16 +64,16 @@ dialog_correc::dialog_correc( wxWindow* parent, wxWindowID id, const wxString& t
this->Centre( wxBOTH );
// Connect Events
grid_Correcs->Connect( wxEVT_GRID_CELL_CHANGE, wxGridEventHandler( dialog_correc::OnCellChange ), NULL, this );
grid_Correcs->Connect( wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEventHandler( dialog_correc::OnLabelLeftClick ), NULL, this );
grid_correcs->Connect( wxEVT_GRID_CELL_CHANGE, wxGridEventHandler( dialog_correc::OnCellChange ), NULL, this );
grid_correcs->Connect( wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEventHandler( dialog_correc::OnLabelLeftClick ), NULL, this );
bouton_ok->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_correc::OnOk ), NULL, this );
}

dialog_correc::~dialog_correc()
{
// Disconnect Events
grid_Correcs->Disconnect( wxEVT_GRID_CELL_CHANGE, wxGridEventHandler( dialog_correc::OnCellChange ), NULL, this );
grid_Correcs->Disconnect( wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEventHandler( dialog_correc::OnLabelLeftClick ), NULL, this );
grid_correcs->Disconnect( wxEVT_GRID_CELL_CHANGE, wxGridEventHandler( dialog_correc::OnCellChange ), NULL, this );
grid_correcs->Disconnect( wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEventHandler( dialog_correc::OnLabelLeftClick ), NULL, this );
bouton_ok->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_correc::OnOk ), NULL, this );
}

+ 1
- 1
CosMoS/correcGUI.h View File

@@ -29,7 +29,7 @@ class dialog_correc : public wxDialog
private:
protected:
wxGrid* grid_Correcs;
wxGrid* grid_correcs;
wxButton* bouton_ok;
wxGridCellAttr* col_orig, *col_suppr;


+ 22
- 22
CosMoS/cosmos.cpp View File

@@ -4,11 +4,11 @@ cosmos::cosmos( wxWindow* parent )
:
cosmosGUI( parent )
{
configuration = new config();
fenetre_options = new options(this, configuration);
fenetre_optionsRche = new optionsRche(this, configuration);
config = new class_config();
fenetre_options = new options(this, config);
fenetre_optionsRche = new optionsRche(this, config);
if (configuration->IsFirstTime())
if (config->IsFirstTime())
{
wxMessageBox(_T("Vous lancez CosMoS pour la première fois,\nveuillez configurer le chemin de la base\nainsi que les paramètres de connexion"));
fenetre_options->ShowModal();
@@ -16,35 +16,35 @@ cosmosGUI( parent )
fenetre_optionsRche->ShowModal();
}

bdd = new class_bdd(configuration->GetDbpath(), grid_Consults);
bdd->updategrid();
bdd = new class_bdd(config->GetPathDb(), grid_consults);
bdd->GenerateGrid();
fenetre_corrections = new correc(this, bdd);
recherche = new class_recherche(configuration, bdd, grid_Consults);
fenetre_resultats = new resultats(this, bdd, grid_Consults);
recherche = new class_recherche(config, bdd, grid_consults);
fenetre_resultats = new resultats(this, bdd, grid_consults);
}

void cosmos::OnImport( wxCommandEvent& event )
{
wxFileDialog * opendialog = new wxFileDialog(this, "Importer", "", "", "*.csv", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
wxFileDialog * dialog_open = new wxFileDialog(this, "Importer", "", "", "*.csv", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (opendialog->ShowModal() == wxID_CANCEL)
if (dialog_open->ShowModal() == wxID_CANCEL)
return;
else
bdd->importer(opendialog->GetPath());
bdd->Importer(dialog_open->GetPath());
delete opendialog;
delete dialog_open;
}

void cosmos::OnExport( wxCommandEvent& event )
{
wxFileDialog * savedialog = new wxFileDialog(this, "Exporter", "", "", "*.csv", wxFD_SAVE);
wxFileDialog * dialog_save = new wxFileDialog(this, "Exporter", "", "", "*.csv", wxFD_SAVE);
if (savedialog->ShowModal() == wxID_CANCEL)
if (dialog_save->ShowModal() == wxID_CANCEL)
return;
else
bdd->exporter(savedialog->GetPath());
bdd->Exporter(dialog_save->GetPath());
delete savedialog;
delete dialog_save;
}

void cosmos::OnQuit( wxCommandEvent& event )
@@ -54,7 +54,7 @@ void cosmos::OnQuit( wxCommandEvent& event )
delete fenetre_corrections;
delete bdd;
delete fenetre_options;
delete configuration;
delete config;
exit(0);
}

@@ -65,13 +65,13 @@ void cosmos::OnQuit( wxCloseEvent& event )
delete fenetre_corrections;
delete bdd;
delete fenetre_options;
delete configuration;
delete config;
exit(0);
}

void cosmos::OnStart( wxCommandEvent& event )
{
recherche->start();
recherche->Start();
}

void cosmos::OnOptionsRche( wxCommandEvent& event )
@@ -81,7 +81,7 @@ void cosmos::OnOptionsRche( wxCommandEvent& event )

void cosmos::OnCorrections( wxCommandEvent& event )
{
fenetre_corrections->update();
fenetre_corrections->Update();
fenetre_corrections->ShowModal();
}

@@ -99,12 +99,12 @@ void cosmos::OnCellChange( wxGridEvent& event )
{
int row = event.GetRow();
int col = event.GetCol();
bdd->addcorrection(grid_Consults->GetCellValue(row, 13), col, grid_Consults->GetCellValue(row, col));
bdd->AddCorrec(grid_consults->GetCellValue(row, 13), col, grid_consults->GetCellValue(row, col));
}
void cosmos::OnCellDbClick( wxGridEvent& event )
{
fenetre_resultats->SetCurrentrow(event.GetRow());
fenetre_resultats->update();
fenetre_resultats->Update();
fenetre_resultats->Show();
}

+ 1
- 1
CosMoS/cosmos.fbp View File

@@ -435,7 +435,7 @@
<property name="margin_width">0</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">grid_Consults</property>
<property name="name">grid_consults</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="row_label_horiz_alignment">wxALIGN_CENTRE</property>


+ 1
- 1
CosMoS/cosmos.h View File

@@ -19,7 +19,7 @@ Subclass of cosmosGUI, which is generated by wxFormBuilder.
class cosmos : public cosmosGUI
{
protected:
config* configuration;
class_config* config;
options* fenetre_options;
class_bdd* bdd;
correc* fenetre_corrections;


+ 59
- 59
CosMoS/cosmosGUI.cpp View File

@@ -75,51 +75,51 @@ cosmosGUI::cosmosGUI( wxWindow* parent, wxWindowID id, const wxString& title, co
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxVERTICAL );
grid_Consults = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
grid_consults = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
grid_Consults->CreateGrid( 0, 14, wxGrid::wxGridSelectRowsOrColumns);
grid_Consults->EnableEditing( true );
grid_Consults->EnableGridLines( true );
grid_Consults->EnableDragGridSize( true );
grid_Consults->SetMargins( 0, 0 );
grid_consults->CreateGrid( 0, 14, wxGrid::wxGridSelectRowsOrColumns);
grid_consults->EnableEditing( true );
grid_consults->EnableGridLines( true );
grid_consults->EnableDragGridSize( true );
grid_consults->SetMargins( 0, 0 );
// Columns
grid_Consults->SetColSize( 0, 64 );
grid_Consults->SetColSize( 1, 46 );
grid_Consults->SetColSize( 2, 72 );
grid_Consults->SetColSize( 3, 80 );
grid_Consults->SetColSize( 4, 68 );
grid_Consults->SetColSize( 5, 135 );
grid_Consults->SetColSize( 6, 154 );
grid_Consults->SetColSize( 7, 139 );
grid_Consults->SetColSize( 8, 71 );
grid_Consults->SetColSize( 9, 49 );
grid_Consults->SetColSize( 10, 90 );
grid_Consults->SetColSize( 11, 49 );
grid_Consults->SetColSize( 12, 110 );
grid_Consults->SetColSize( 13, 110 );
grid_Consults->EnableDragColMove( false );
grid_Consults->EnableDragColSize( true );
grid_Consults->SetColLabelSize( 30 );
grid_Consults->SetColLabelValue( 0, wxT("Resultats") );
grid_Consults->SetColLabelValue( 1, wxT("Publi ?") );
grid_Consults->SetColLabelValue( 2, wxT("Publi CHU ?") );
grid_Consults->SetColLabelValue( 3, wxT("Consultant ?") );
grid_Consults->SetColLabelValue( 4, wxT("N° Dossier") );
grid_Consults->SetColLabelValue( 5, wxT("Nom(s) demandeur(s)") );
grid_Consults->SetColLabelValue( 6, wxT("Prénom(s) demandeur(s)") );
grid_Consults->SetColLabelValue( 7, wxT("Nom(s) responsable(s)") );
grid_Consults->SetColLabelValue( 8, wxT("Consultant") );
grid_Consults->SetColLabelValue( 9, wxT("Thème") );
grid_Consults->SetColLabelValue( 10, wxT("Etablissement") );
grid_Consults->SetColLabelValue( 11, wxT("Travail") );
grid_Consults->SetColLabelValue( 12, wxT("Date consultation") );
grid_Consults->SetColLabelValue( 13, wxT("Numéro de travail") );
grid_Consults->HideCol(13);
grid_Consults->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
grid_Consults->SetDefaultEditor(new wxGridCellAutoWrapStringEditor);
grid_Consults->SetDefaultRenderer(new wxGridCellStringRenderer);
grid_consults->SetColSize( 0, 64 );
grid_consults->SetColSize( 1, 46 );
grid_consults->SetColSize( 2, 72 );
grid_consults->SetColSize( 3, 80 );
grid_consults->SetColSize( 4, 68 );
grid_consults->SetColSize( 5, 135 );
grid_consults->SetColSize( 6, 154 );
grid_consults->SetColSize( 7, 139 );
grid_consults->SetColSize( 8, 71 );
grid_consults->SetColSize( 9, 49 );
grid_consults->SetColSize( 10, 90 );
grid_consults->SetColSize( 11, 49 );
grid_consults->SetColSize( 12, 110 );
grid_consults->SetColSize( 13, 110 );
grid_consults->EnableDragColMove( false );
grid_consults->EnableDragColSize( true );
grid_consults->SetColLabelSize( 30 );
grid_consults->SetColLabelValue( 0, wxT("Resultats") );
grid_consults->SetColLabelValue( 1, wxT("Publi ?") );
grid_consults->SetColLabelValue( 2, wxT("Publi CHU ?") );
grid_consults->SetColLabelValue( 3, wxT("Consultant ?") );
grid_consults->SetColLabelValue( 4, wxT("N° Dossier") );
grid_consults->SetColLabelValue( 5, wxT("Nom(s) demandeur(s)") );
grid_consults->SetColLabelValue( 6, wxT("Prénom(s) demandeur(s)") );
grid_consults->SetColLabelValue( 7, wxT("Nom(s) responsable(s)") );
grid_consults->SetColLabelValue( 8, wxT("Consultant") );
grid_consults->SetColLabelValue( 9, wxT("Thème") );
grid_consults->SetColLabelValue( 10, wxT("Etablissement") );
grid_consults->SetColLabelValue( 11, wxT("Travail") );
grid_consults->SetColLabelValue( 12, wxT("Date consultation") );
grid_consults->SetColLabelValue( 13, wxT("Numéro de travail") );
grid_consults->HideCol(13);
grid_consults->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
grid_consults->SetDefaultEditor(new wxGridCellAutoWrapStringEditor);
grid_consults->SetDefaultRenderer(new wxGridCellStringRenderer);
// Editeur pour les cellules à checkbox, avec affectation des valeurs pour vrai et faux
bool_editor = new wxGridCellBoolEditor();
@@ -146,25 +146,25 @@ cosmosGUI::cosmosGUI( wxWindow* parent, wxWindowID id, const wxString& title, co
col_date->SetAlignment(wxALIGN_RIGHT, wxALIGN_CENTER);
// Application des attributs aux colonnes
grid_Consults->SetColAttr(1, col_bool);
grid_Consults->SetColAttr(2, col_bool);
grid_Consults->SetColAttr(3, col_bool);
grid_Consults->SetColAttr(0, col_RO);
grid_Consults->SetColAttr(4, col_RO);
grid_Consults->SetColAttr(11, col_RO);
grid_Consults->SetColAttr(13, col_RO);
grid_Consults->SetColAttr(12, col_date);
grid_consults->SetColAttr(1, col_bool);
grid_consults->SetColAttr(2, col_bool);
grid_consults->SetColAttr(3, col_bool);
grid_consults->SetColAttr(0, col_RO);
grid_consults->SetColAttr(4, col_RO);
grid_consults->SetColAttr(11, col_RO);
grid_consults->SetColAttr(13, col_RO);
grid_consults->SetColAttr(12, col_date);
// Rows
grid_Consults->EnableDragRowSize( true );
grid_Consults->SetRowLabelSize( 80 );
grid_Consults->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
grid_consults->EnableDragRowSize( true );
grid_consults->SetRowLabelSize( 80 );
grid_consults->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
grid_Consults->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTER );
bSizer2->Add( grid_Consults, 1, wxALL|wxEXPAND, 5 );
grid_consults->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTER );
bSizer2->Add( grid_consults, 1, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizer2 );
this->Layout();
@@ -183,13 +183,13 @@ cosmosGUI::cosmosGUI( wxWindow* parent, wxWindowID id, const wxString& title, co
this->Connect( wxID_FIND, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( cosmosGUI::OnOptionsRche ) );
this->Connect( wxID_DUPLICATE, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( cosmosGUI::OnCorrections ) );
searchctrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( cosmosGUI::OnSearch ), NULL, this );
grid_Consults->Connect( wxEVT_GRID_CELL_CHANGE, wxGridEventHandler( cosmosGUI::OnCellChange ), NULL, this );
grid_Consults->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( cosmosGUI::OnCellDbClick ), NULL, this );
grid_consults->Connect( wxEVT_GRID_CELL_CHANGE, wxGridEventHandler( cosmosGUI::OnCellChange ), NULL, this );
grid_consults->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( cosmosGUI::OnCellDbClick ), NULL, this );
}

cosmosGUI::~cosmosGUI()
{
delete grid_Consults;
delete grid_consults;
delete bool_editor;
delete bool_renderer;
// Disconnect Events
@@ -204,7 +204,7 @@ cosmosGUI::~cosmosGUI()
this->Disconnect( wxID_FIND, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( cosmosGUI::OnOptionsRche ) );
this->Disconnect( wxID_DUPLICATE, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( cosmosGUI::OnCorrections ) );
searchctrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( cosmosGUI::OnSearch ), NULL, this );
grid_Consults->Disconnect( wxEVT_GRID_CELL_CHANGE, wxGridEventHandler( cosmosGUI::OnCellChange ), NULL, this );
grid_Consults->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( cosmosGUI::OnCellDbClick ), NULL, this );
grid_consults->Disconnect( wxEVT_GRID_CELL_CHANGE, wxGridEventHandler( cosmosGUI::OnCellChange ), NULL, this );
grid_consults->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( cosmosGUI::OnCellDbClick ), NULL, this );
}

+ 1
- 1
CosMoS/cosmosGUI.h View File

@@ -40,7 +40,7 @@ class cosmosGUI : public wxFrame
wxMenu* menu_Aide;
wxToolBar* toolbar;
wxSearchCtrl* searchctrl;
wxGrid* grid_Consults;
wxGrid* grid_consults;
wxGridCellAttr* col_bool, *col_RO, *col_date;
wxGridCellBoolEditor* bool_editor;
wxGridCellBoolRenderer* bool_renderer;


+ 24
- 24
CosMoS/options.cpp View File

@@ -1,15 +1,15 @@
#include "options.h"

options::options( wxWindow* parent, config* configuration )
options::options( wxWindow* parent, class_config* config )
:
dialog_Options( parent )
{
this->configuration = configuration;
dirpicker_dbpath->SetPath(configuration->GetDbpath());
checkbox_proxy->SetValue(configuration->IsUseproxy());
textctrl_url->SetValue(configuration->GetProxyurl());
spinctrl_port->SetValue(configuration->GetProxyport());
updatefields();
this->config = config;
dirpicker_dbpath->SetPath(config->GetPathDb());
checkbox_proxy->SetValue(config->IsUseProxy());
textctrl_url->SetValue(config->GetProxyUrl());
spinctrl_port->SetValue(config->GetProxyPort());
UpdateUI();
}

options::~options()
@@ -18,40 +18,40 @@ options::~options()

void options::OnCancel( wxCloseEvent& event )
{
dirpicker_dbpath->SetPath(configuration->GetDbpath());
checkbox_proxy->SetValue(configuration->IsUseproxy());
textctrl_url->SetValue(configuration->GetProxyurl());
spinctrl_port->SetValue(configuration->GetProxyport());
dirpicker_dbpath->SetPath(config->GetPathDb());
checkbox_proxy->SetValue(config->IsUseProxy());
textctrl_url->SetValue(config->GetProxyUrl());
spinctrl_port->SetValue(config->GetProxyPort());
this->Hide();
updatefields();
UpdateUI();
}

void options::OnCancel( wxCommandEvent& event )
{
dirpicker_dbpath->SetPath(configuration->GetDbpath());
checkbox_proxy->SetValue(configuration->IsUseproxy());
textctrl_url->SetValue(configuration->GetProxyurl());
spinctrl_port->SetValue(configuration->GetProxyport());
dirpicker_dbpath->SetPath(config->GetPathDb());
checkbox_proxy->SetValue(config->IsUseProxy());
textctrl_url->SetValue(config->GetProxyUrl());
spinctrl_port->SetValue(config->GetProxyPort());
this->Hide();
updatefields();
UpdateUI();
}

void options::OnOk( wxCommandEvent& event )
{
configuration->SetDbpath(dirpicker_dbpath->GetPath());
configuration->SetUseproxy(checkbox_proxy->GetValue());
configuration->SetProxyurl(textctrl_url->GetValue());
configuration->SetProxyport(spinctrl_port->GetValue());
configuration->save();
config->SetPathDb(dirpicker_dbpath->GetPath());
config->SetUseProxy(checkbox_proxy->GetValue());
config->SetProxyUrl(textctrl_url->GetValue());
config->SetProxyPort(spinctrl_port->GetValue());
config->Save();
this->Hide();
}

void options::OnToggleProxy( wxCommandEvent& event )
{
updatefields();
UpdateUI();
}

void options::updatefields()
void options::UpdateUI()
{
if (!checkbox_proxy->GetValue())
{


+ 3
- 3
CosMoS/options.h View File

@@ -15,16 +15,16 @@ Subclass of dialog_Options, which is generated by wxFormBuilder.
class options : public dialog_Options
{
protected:
config* configuration;
class_config* config;
// Handlers for dialog_Options events.
void OnToggleProxy( wxCommandEvent& event );
void OnCancel( wxCloseEvent& event );
void OnCancel( wxCommandEvent& event );
void OnOk( wxCommandEvent& event );
void updatefields();
void UpdateUI();
public:
/** Constructor */
options( wxWindow* parent, config* configuration );
options( wxWindow* parent, class_config* config );
~options();
//// end generated class members



+ 71
- 71
CosMoS/optionsRche.cpp View File

@@ -1,15 +1,15 @@
#include "optionsRche.h"

optionsRche::optionsRche( wxWindow* parent, config* configuration )
optionsRche::optionsRche( wxWindow* parent, class_config* config )
:
dialog_optionsRche( parent )
{
this->configuration = configuration;
int nbrule = configuration->getnbrule();
for (int i=0; i<nbrule; i++)
this->config = config;
int nb_rule = config->GetNbRules();
for (int i=0; i < nb_rule; i++)
{
checklist_ruleset->Append(configuration->getrule(i).name);
if (configuration->getrule(i).inuse)
checklist_ruleset->Append(config->GetRule(i).name);
if (config->GetRule(i).in_use)
checklist_ruleset->Check(i);
}
checklist_ruleset->SetSelection(0);
@@ -20,65 +20,65 @@ dialog_optionsRche( parent )

void optionsRche::OnChecklistSelect( wxCommandEvent& event )
{
rule currentrule = configuration->getrule(event.GetInt());
rule current_rule = config->GetRule(event.GetInt());
textctrl_nomset->SetValue(currentrule.name);
textctrl_nomset->SetValue(current_rule.name);
checkbox_demandeur->SetValue(currentrule.usedemandeur);
checkbox_responsable->SetValue(currentrule.useresponsable);
checkbox_consultant->SetValue(currentrule.useconsultant);
checkbox_demandeur->SetValue(current_rule.use_demandeur);
checkbox_responsable->SetValue(current_rule.use_responsable);
checkbox_consultant->SetValue(current_rule.use_consultant);
radio_demandeur->SetSelection(currentrule.opdemandeur);
radio_both->SetSelection(currentrule.opboth);
radio_responsable->SetSelection(currentrule.opresponsable);
radio_demandeur->SetSelection(current_rule.op_demandeur);
radio_both->SetSelection(current_rule.op_both);
radio_responsable->SetSelection(current_rule.op_responsable);
checkbox_debut->SetValue(currentrule.usedebut);
checkbox_fin->SetValue(currentrule.usefin);
checkbox_debut->SetValue(current_rule.use_debut);
checkbox_fin->SetValue(current_rule.use_fin);
spinctrl_debut->SetValue(currentrule.debut);
spinctrl_fin->SetValue(currentrule.fin);
spinctrl_debut->SetValue(current_rule.debut);
spinctrl_fin->SetValue(current_rule.fin);
checkbox_ville->SetValue(currentrule.useville);
textctrl_ville->SetValue(currentrule.ville);
checkbox_ville->SetValue(current_rule.use_ville);
textctrl_ville->SetValue(current_rule.ville);
checkbox_suppl->SetValue(currentrule.usesuppl);
textctrl_suppl->SetValue(currentrule.suppl);
checkbox_suppl->SetValue(current_rule.use_suppl);
textctrl_suppl->SetValue(current_rule.suppl);
spinctrl_retmax->SetValue(currentrule.retmax);
spinctrl_retmax->SetValue(current_rule.retmax);
wxCommandEvent ev;
updateGUI(ev);
UpdateUI(ev);
}

void optionsRche::OnAdd( wxCommandEvent& event )
{
rule toadd;
toadd.name = textctrl_nomset->GetValue();
toadd.usedemandeur = checkbox_demandeur->GetValue();
toadd.useresponsable = checkbox_responsable->GetValue();
toadd.useconsultant = checkbox_consultant->GetValue();
toadd.opdemandeur = radio_demandeur->GetSelection();
toadd.opboth = radio_both->GetSelection();
toadd.opresponsable = radio_responsable->GetSelection();
toadd.usedebut = checkbox_debut->GetValue();
toadd.usefin = checkbox_fin->GetValue();
toadd.debut = spinctrl_debut->GetValue();
toadd.fin = spinctrl_fin->GetValue();
toadd.useville = checkbox_ville->GetValue();
toadd.ville = textctrl_ville->GetValue();
toadd.usesuppl = checkbox_suppl->GetValue();
toadd.suppl = textctrl_suppl->GetValue();
toadd.retmax = spinctrl_retmax->GetValue();
rule to_add;
to_add.name = textctrl_nomset->GetValue();
to_add.use_demandeur = checkbox_demandeur->GetValue();
to_add.use_responsable = checkbox_responsable->GetValue();
to_add.use_consultant = checkbox_consultant->GetValue();
to_add.op_demandeur = radio_demandeur->GetSelection();
to_add.op_both = radio_both->GetSelection();
to_add.op_responsable = radio_responsable->GetSelection();
to_add.use_debut = checkbox_debut->GetValue();
to_add.use_fin = checkbox_fin->GetValue();
to_add.debut = spinctrl_debut->GetValue();
to_add.fin = spinctrl_fin->GetValue();
to_add.use_ville = checkbox_ville->GetValue();
to_add.ville = textctrl_ville->GetValue();
to_add.use_suppl = checkbox_suppl->GetValue();
to_add.suppl = textctrl_suppl->GetValue();
to_add.retmax = spinctrl_retmax->GetValue();
checklist_ruleset->Append(toadd.name);
checklist_ruleset->Append(to_add.name);
checklist_ruleset->SetSelection(checklist_ruleset->GetCount() - 1);
configuration->addrule(toadd);
config->AddRule(to_add);
}

void optionsRche::OnUp( wxCommandEvent& event )
{
int selected = checklist_ruleset->GetSelection();
configuration->uprule(selected);
config->MoveRuleUp(selected);
if (selected > 0)
{
wxString temp = checklist_ruleset->GetString(selected-1);
@@ -91,7 +91,7 @@ void optionsRche::OnUp( wxCommandEvent& event )
void optionsRche::OnDown( wxCommandEvent& event )
{
int selected = checklist_ruleset->GetSelection();
configuration->downrule(selected);
config->MoveRuleDown(selected);
if (selected < (int)checklist_ruleset->GetCount() - 1)
{
wxString temp = checklist_ruleset->GetString(selected+1);
@@ -103,34 +103,34 @@ void optionsRche::OnDown( wxCommandEvent& event )

void optionsRche::OnDel( wxCommandEvent& event )
{
configuration->delrule(checklist_ruleset->GetSelection());
config->DelRule(checklist_ruleset->GetSelection());
checklist_ruleset->Delete(checklist_ruleset->GetSelection());
}

void optionsRche::OnUpdate( wxCommandEvent& event )
{
rule tomod;
tomod.name = textctrl_nomset->GetValue();
tomod.usedemandeur = checkbox_demandeur->GetValue();
tomod.useresponsable = checkbox_responsable->GetValue();
tomod.useconsultant = checkbox_consultant->GetValue();
tomod.opdemandeur = radio_demandeur->GetSelection();
tomod.opboth = radio_both->GetSelection();
tomod.opresponsable = radio_responsable->GetSelection();
tomod.usedebut = checkbox_debut->GetValue();
tomod.usefin = checkbox_fin->GetValue();
tomod.debut = spinctrl_debut->GetValue();
tomod.fin = spinctrl_fin->GetValue();
tomod.useville = checkbox_ville->GetValue();
tomod.ville = textctrl_ville->GetValue();
tomod.usesuppl = checkbox_suppl->GetValue();
tomod.suppl = textctrl_suppl->GetValue();
tomod.retmax = spinctrl_retmax->GetValue();
rule to_mod;
to_mod.name = textctrl_nomset->GetValue();
to_mod.use_demandeur = checkbox_demandeur->GetValue();
to_mod.use_responsable = checkbox_responsable->GetValue();
to_mod.use_consultant = checkbox_consultant->GetValue();
to_mod.op_demandeur = radio_demandeur->GetSelection();
to_mod.op_both = radio_both->GetSelection();
to_mod.op_responsable = radio_responsable->GetSelection();
to_mod.use_debut = checkbox_debut->GetValue();
to_mod.use_fin = checkbox_fin->GetValue();
to_mod.debut = spinctrl_debut->GetValue();
to_mod.fin = spinctrl_fin->GetValue();
to_mod.use_ville = checkbox_ville->GetValue();
to_mod.ville = textctrl_ville->GetValue();
to_mod.use_suppl = checkbox_suppl->GetValue();
to_mod.suppl = textctrl_suppl->GetValue();
to_mod.retmax = spinctrl_retmax->GetValue();
if (checklist_ruleset->GetSelection() != wxNOT_FOUND)
{
checklist_ruleset->SetString(checklist_ruleset->GetSelection(), tomod.name);
configuration->modrule(checklist_ruleset->GetSelection(), tomod);
checklist_ruleset->SetString(checklist_ruleset->GetSelection(), to_mod.name);
config->SetRule(checklist_ruleset->GetSelection(), to_mod);
}
}

@@ -139,18 +139,18 @@ void optionsRche::OnOk( wxCommandEvent& event )
// Actualisation des sets selectionnés
for (int i=0; i < (int)checklist_ruleset->GetCount(); i++)
{
rule temp = configuration->getrule(i);
rule temp = config->GetRule(i);
if (checklist_ruleset->IsChecked(i))
temp.inuse = true;
temp.in_use = true;
else
temp.inuse = false;
configuration->modrule(i, temp);
temp.in_use = false;
config->SetRule(i, temp);
}
configuration->save();
config->Save();
Close();
}

void optionsRche::updateGUI( wxCommandEvent& event )
void optionsRche::UpdateUI( wxCommandEvent& event )
{
if (checkbox_demandeur->IsChecked())
radio_demandeur->Enable();


+ 10
- 10
CosMoS/optionsRche.fbp View File

@@ -155,7 +155,7 @@
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">sizer_rulesetorder</property>
<property name="orient">wxVERTICAL</property>
@@ -406,7 +406,7 @@
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALIGN_CENTER_HORIZONTAL</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">sizer_nomset</property>
<property name="orient">wxHORIZONTAL</property>
@@ -624,7 +624,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">updateGUI</event>
<event name="OnCheckBox">UpdateUI</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@@ -681,7 +681,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">updateGUI</event>
<event name="OnCheckBox">UpdateUI</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@@ -1055,7 +1055,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">updateGUI</event>
<event name="OnCheckBox">UpdateUI</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@@ -1172,7 +1172,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">updateGUI</event>
<event name="OnCheckBox">UpdateUI</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@@ -1354,7 +1354,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">updateGUI</event>
<event name="OnCheckBox">UpdateUI</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@@ -1536,7 +1536,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">updateGUI</event>
<event name="OnCheckBox">UpdateUI</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@@ -1677,11 +1677,11 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">sizer_retmax</property>
<property name="orient">wxHORIZONTAL</property>


+ 3
- 3
CosMoS/optionsRche.h View File

@@ -15,20 +15,20 @@ Subclass of dialog_optionsRche, which is generated by wxFormBuilder.
class optionsRche : public dialog_optionsRche
{
protected:
config* configuration;
class_config* config;
// Handlers for dialog_optionsRche events.
void OnChecklistSelect( wxCommandEvent& event );
void OnAdd( wxCommandEvent& event );
void OnUp( wxCommandEvent& event );
void OnDown( wxCommandEvent& event );
void OnDel( wxCommandEvent& event );
void updateGUI( wxCommandEvent& event );
void UpdateUI( wxCommandEvent& event );
void OnUpdate( wxCommandEvent& event );
void OnOk( wxCommandEvent& event );
public:
/** Constructor */
optionsRche( wxWindow* parent, config* configuration );
optionsRche( wxWindow* parent, class_config* config );
//// end generated class members
};


+ 12
- 12
CosMoS/optionsRcheGUI.cpp View File

@@ -194,12 +194,12 @@ dialog_optionsRche::dialog_optionsRche( wxWindow* parent, wxWindowID id, const w
bouton_up->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnUp ), NULL, this );
bouton_down->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnDown ), NULL, this );
bouton_del->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnDel ), NULL, this );
checkbox_demandeur->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_responsable->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_debut->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_fin->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_ville->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_suppl->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_demandeur->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_responsable->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_debut->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_fin->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_ville->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_suppl->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
bouton_actualiser->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnUpdate ), NULL, this );
bouton_ok->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnOk ), NULL, this );
}
@@ -212,12 +212,12 @@ dialog_optionsRche::~dialog_optionsRche()
bouton_up->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnUp ), NULL, this );
bouton_down->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnDown ), NULL, this );
bouton_del->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnDel ), NULL, this );
checkbox_demandeur->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_responsable->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_debut->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_fin->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_ville->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_suppl->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::updateGUI ), NULL, this );
checkbox_demandeur->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_responsable->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_debut->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_fin->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_ville->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
checkbox_suppl->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_optionsRche::UpdateUI ), NULL, this );
bouton_actualiser->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnUpdate ), NULL, this );
bouton_ok->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_optionsRche::OnOk ), NULL, this );


+ 1
- 1
CosMoS/optionsRcheGUI.h View File

@@ -74,7 +74,7 @@ class dialog_optionsRche : public wxDialog
virtual void OnUp( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDown( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDel( wxCommandEvent& event ) { event.Skip(); }
virtual void updateGUI( wxCommandEvent& event ) { event.Skip(); }
virtual void UpdateUI( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdate( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOk( wxCommandEvent& event ) { event.Skip(); }


+ 135
- 135
CosMoS/recherche.cpp View File

@@ -2,103 +2,103 @@

#pragma GCC diagnostic ignored "-Wunused-function"

class_recherche::class_recherche(config* configuration, class_bdd* bdd, wxGrid* grid)
class_recherche::class_recherche(class_config* config, class_bdd* bdd, wxGrid* grid_consults)
{
this->configuration = configuration;
this->config = config;
this->bdd = bdd;
this->grid = grid;
curlhandle = curl_easy_init ();
curl_easy_setopt (curlhandle, CURLOPT_WRITEFUNCTION, WriteDataCallback);
curl_easy_setopt (curlhandle, CURLOPT_WRITEDATA, (void*)&curldata);
this->grid_consults = grid_consults;
curl_handle = curl_easy_init ();
curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, WriteDataCallback);
curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, (void*)&curl_data);
}

class_recherche::~class_recherche()
{
curl_easy_cleanup (curlhandle);
curl_easy_cleanup (curl_handle);
curl_global_cleanup ();
}

void class_recherche::start()
void class_recherche::Start()
{
bool firstpass = true;
wxArrayInt selection = grid->GetSelectedRows();
bool is_first_pass = true;
wxArrayInt selection = grid_consults->GetSelectedRows();
if (selection.GetCount() == 0)
for (int i=0; i < grid->GetNumberRows(); i++)
for (int i=0; i < grid_consults->GetNumberRows(); i++)
selection.Add(i);
for (int j=0; j < configuration->getnbrule(); j++)
for (int j=0; j < config->GetNbRules(); j++)
{
if (configuration->getrule(j).inuse)
if (config->GetRule(j).in_use)
{
wxProgressDialog progress_dialog("Recherche", _T("Recherche avec la règle «") + configuration->getrule(j).name + _T("»"), selection.GetCount(), NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME | wxPD_CAN_ABORT);
wxProgressDialog dialog_progress("Recherche", _T("Recherche avec la règle «") + config->GetRule(j).name + _T("»"), selection.GetCount(), NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME | wxPD_CAN_ABORT);
for (unsigned int i=0; i < selection.GetCount(); i++)
{
if (firstpass || (grid->GetCellValue(selection[i], 0) == "0"))
if (is_first_pass || (grid_consults->GetCellValue(selection[i], 0) == "0"))
{
go (selection[i], configuration->getrule(j));
Go (selection[i], config->GetRule(j));
}
if (!progress_dialog.Update(i))
if (!dialog_progress.Update(i))
break;
}
}
firstpass = false;
is_first_pass = false;
}
}

void class_recherche::go(int row, rule regle)
void class_recherche::Go(int row, rule regle)
{
//TODO: coloration de la grille pour les consults avec nouveaux résultats
wxString id = grid->GetCellValue(row, 13);
wxString requete = build(row, regle);
esearch(requete);
parsesearch();
wxString id_consult = grid_consults->GetCellValue(row, 13);
wxString requete = Build(row, regle);
eSearch(requete);
ParseSearch();

wxArrayString idresultbdd = bdd->getidresult(id, true);
wxArrayString list_id_result_bdd = bdd->GetIdResult(id_consult, true);
wxArrayString temp;
if (idresult.GetCount() > 0)
if (list_id_results.GetCount() > 0)
{
for (int i=(int)idresult.GetCount()-1; i >= 0; i--)
for (int i=(int)list_id_results.GetCount()-1; i >= 0; i--)
{
if (idresultbdd.Index(idresult[i]) == wxNOT_FOUND)
if (list_id_result_bdd.Index(list_id_results[i]) == wxNOT_FOUND)
{
temp.Add(idresult[i]);
bdd->addidresult(id, idresult[i]);
temp.Add(list_id_results[i]);
bdd->AddIdResult(id_consult, list_id_results[i]);
}
}
idresult = temp;
bdd->modnbresult(id, bdd->nbresult(id) + idresult.GetCount());
grid->SetCellValue(row, 0, _itoW(bdd->nbresult(id)));
list_id_results = temp;
bdd->SetNbResults(id_consult, bdd->GetNbResults(id_consult) + list_id_results.GetCount());
grid_consults->SetCellValue(row, 0, _itoW(bdd->GetNbResults(id_consult)));
temp.Clear();
for (unsigned int i=0; i < idresult.GetCount(); i++)
if (!(bdd->publiexists(idresult[i])))
temp.Add(idresult[i]);
idresult = temp;
for (unsigned int i=0; i < list_id_results.GetCount(); i++)
if (!(bdd->IsPubli(list_id_results[i])))
temp.Add(list_id_results[i]);
list_id_results = temp;
if (idresult.GetCount() > 0)
if (list_id_results.GetCount() > 0)
{
efetch();
parsefetch();
eFetch();
ParseFetch();
}
}
}

void class_recherche::parsefetch()
void class_recherche::ParseFetch()
{
XMLDocument* doc = new XMLDocument;
doc->Parse(curldata.content);
doc->Parse(curl_data.content);
XMLElement* parcours = doc->RootElement();
parcours = parcours->FirstChildElement("PubmedArticle");
do
{
wxString id, titre, auteurs, abstract, revue, lien, date;
wxString id, title, authors, abstract, journal, link, date;
parcours = parcours->FirstChildElement("MedlineCitation"); //MedlineCitation
id << parcours->FirstChildElement("PMID")->GetText(); // PMID
lien << "http://www.ncbi.nlm.nih.gov/pubmed/" << id;
link << "http://www.ncbi.nlm.nih.gov/pubmed/" << id;
parcours = parcours->FirstChildElement("Article"); // Article
parcours = parcours->FirstChildElement("Journal"); // Journal
parcours = parcours->FirstChildElement("JournalIssue"); // JournalIssue
@@ -111,11 +111,11 @@ void class_recherche::parsefetch()
date << parcours->FirstChildElement("Year")->GetText(); // *Year
parcours = parcours->Parent()->ToElement(); // JournalIssue
if (parcours->NextSiblingElement("ISOAbbreviation"))
revue << parcours->NextSiblingElement("ISOAbbreviation")->GetText(); // *ISOAbbreviation
journal << parcours->NextSiblingElement("ISOAbbreviation")->GetText(); // *ISOAbbreviation
else if (parcours->NextSiblingElement("Title"))
revue << parcours->NextSiblingElement("Title")->GetText();
journal << parcours->NextSiblingElement("Title")->GetText();
parcours = parcours->Parent()->ToElement(); // Journal
titre << parcours->NextSiblingElement("ArticleTitle")->GetText(); // *ArticleTitle
title << parcours->NextSiblingElement("ArticleTitle")->GetText(); // *ArticleTitle
if (parcours->NextSiblingElement("Abstract"))
{
parcours = parcours->NextSiblingElement("Abstract"); // Abstract
@@ -135,85 +135,85 @@ void class_recherche::parsefetch()
do
{
if (parcoursauteurs->FirstChildElement("LastName"))
auteurs << parcoursauteurs->FirstChildElement("LastName")->GetText();
authors << parcoursauteurs->FirstChildElement("LastName")->GetText();
if (parcoursauteurs->FirstChildElement("ForeName"))
auteurs << " " << parcoursauteurs->FirstChildElement("ForeName")->GetText() << ",";
authors << " " << parcoursauteurs->FirstChildElement("ForeName")->GetText() << ",";
else if (parcoursauteurs->FirstChildElement("Initials"))
auteurs << " " << parcoursauteurs->FirstChildElement("Initials")->GetText() << ",";
authors << " " << parcoursauteurs->FirstChildElement("Initials")->GetText() << ",";
else
auteurs << ",";
authors << ",";
parcoursauteurs=parcoursauteurs->NextSiblingElement("Author");
}while(parcoursauteurs);
auteurs = auteurs.BeforeLast(',');
authors = authors.BeforeLast(',');
parcours = parcours->Parent()->Parent()->Parent()->ToElement()->NextSiblingElement("PubmedArticle");
bdd->addpubli(id, titre, auteurs, abstract, revue, lien, date);
bdd->AddPubli(id, title, authors, abstract, journal, link, date);
}while(parcours);
delete(doc);
if (curldata.content)
free (curldata.content);
if (curl_data.content)
free (curl_data.content);
}

void class_recherche::efetch()
void class_recherche::eFetch()
{
bool accessdenied;
bool access_denied;
do
{
accessdenied = false;
access_denied = false;
wxString requete = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=";
for (unsigned int i=0; i < idresult.GetCount(); i++)
requete << idresult[i] << ",";
for (unsigned int i=0; i < list_id_results.GetCount(); i++)
requete << list_id_results[i] << ",";
requete = requete.BeforeLast(',');
curl_easy_setopt (curlhandle, CURLOPT_URL, _C(requete));
curl_easy_setopt (curl_handle, CURLOPT_URL, _C(requete));
if (configuration->IsUseproxy())
if (config->IsUseProxy())
{
curl_easy_setopt (curlhandle, CURLOPT_PROXY, _C(configuration->GetProxyurl()));
curl_easy_setopt (curlhandle, CURLOPT_PROXYPORT, configuration->GetProxyport());
curl_easy_setopt (curl_handle, CURLOPT_PROXY, _C(config->GetProxyUrl()));
curl_easy_setopt (curl_handle, CURLOPT_PROXYPORT, config->GetProxyPort());
}
else
curl_easy_setopt (curlhandle, CURLOPT_PROXY, "");
curl_easy_setopt (curl_handle, CURLOPT_PROXY, "");
curldata.content = (char*) malloc(1);
curldata.size = 0;
curl_data.content = (char*) malloc(1);
curl_data.size = 0;
if (curlhandle)
curl_easy_perform(curlhandle);
if (curl_handle)
curl_easy_perform(curl_handle);
if (wxString(curldata.content).Left(6) == "<HTML>")
if (wxString(curl_data.content).Left(6) == "<HTML>")
{
accessdenied = true;
access_denied = true;
time_t timer = time(NULL);
wxProgressDialog progress_dialog("Erreur proxy", _T("En attente du proxy"), 200, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
wxProgressDialog dialog_progress("Erreur proxy", _T("En attente du proxy"), 200, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
while (time(NULL) < (timer + 200))
progress_dialog.Update(time(NULL) - timer);
progress_dialog.Update(200);
if (curldata.content)
free (curldata.content);
dialog_progress.Update(time(NULL) - timer);
dialog_progress.Update(200);
if (curl_data.content)
free(curl_data.content);
}
}while (accessdenied);
}while (access_denied);
}

void class_recherche::parsesearch()
void class_recherche::ParseSearch()
{
idresult.Clear();
list_id_results.Clear();
XMLDocument* doc = new XMLDocument();
doc->Parse(curldata.content);
doc->Parse(curl_data.content);
XMLElement* parcours = doc->RootElement();
if (parcours->FirstChildElement("ERROR"))
{
nbresult = 0;
nb_results = 0;
delete(doc);
if (curldata.content)
free (curldata.content);
if (curl_data.content)
free (curl_data.content);
return;
}
parcours = parcours->FirstChildElement("Count");
nbresult = atoi(parcours->GetText());
nb_results = atoi(parcours->GetText());
parcours = parcours->NextSiblingElement("RetMax");
int count = atoi(parcours->GetText());
parcours = parcours->NextSiblingElement("IdList");
@@ -222,107 +222,107 @@ void class_recherche::parsesearch()
parcours = parcours->FirstChildElement();
for (int i=0; i < count - 1 ; i++)
{
idresult.Add(parcours->GetText());
list_id_results.Add(parcours->GetText());
parcours = parcours->NextSiblingElement();
}
idresult.Add(parcours->GetText());
list_id_results.Add(parcours->GetText());
parcours = parcours->Parent()->ToElement();
}
delete(doc);
if (curldata.content)
free (curldata.content);
if (curl_data.content)
free (curl_data.content);
}

void class_recherche::esearch(wxString requete)
void class_recherche::eSearch(wxString requete)
{
bool accessdenied;
bool access_denied;
do
{
accessdenied = false;
curl_easy_setopt (curlhandle, CURLOPT_URL, _C(requete));
access_denied = false;
curl_easy_setopt (curl_handle, CURLOPT_URL, _C(requete));
if (configuration->IsUseproxy())
if (config->IsUseProxy())
{
curl_easy_setopt (curlhandle, CURLOPT_PROXY, _C(configuration->GetProxyurl()));
curl_easy_setopt (curlhandle, CURLOPT_PROXYPORT, configuration->GetProxyport());
curl_easy_setopt (curl_handle, CURLOPT_PROXY, _C(config->GetProxyUrl()));
curl_easy_setopt (curl_handle, CURLOPT_PROXYPORT, config->GetProxyPort());
}
else
curl_easy_setopt (curlhandle, CURLOPT_PROXY, "");
curl_easy_setopt (curl_handle, CURLOPT_PROXY, "");
curldata.content = (char*) malloc(1);
curldata.size = 0;
curl_data.content = (char*) malloc(1);
curl_data.size = 0;
if (curlhandle)
curl_easy_perform(curlhandle);
if (curl_handle)
curl_easy_perform(curl_handle);
if (wxString(curldata.content).Left(6) == "<HTML>")
if (wxString(curl_data.content).Left(6) == "<HTML>")
{
accessdenied = true;
access_denied = true;
time_t timer = time(NULL);
wxProgressDialog progress_dialog("Erreur proxy", _T("En attente du proxy"), 200, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
wxProgressDialog dialog_progress("Erreur proxy", _T("En attente du proxy"), 200, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
while (time(NULL) < (timer + 200))
progress_dialog.Update(time(NULL) - timer);
progress_dialog.Update(200);
if (curldata.content)
free (curldata.content);
dialog_progress.Update(time(NULL) - timer);
dialog_progress.Update(200);
if (curl_data.content)
free (curl_data.content);
}
}while (accessdenied);
}while (access_denied);
}

wxString class_recherche::build(int row, rule regle)
wxString class_recherche::Build(int row, rule regle)
{
wxString requete = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=";
bool both = false;
if (grid->GetCellValue(row, 5) == "")
regle.usedemandeur = false;
if (grid_consults->GetCellValue(row, 5) == "")
regle.use_demandeur = false;
if (grid->GetCellValue(row, 7) == "")
regle.useresponsable = false;
if (grid_consults->GetCellValue(row, 7) == "")
regle.use_responsable = false;
if (grid->GetCellValue(row, 8) == "")
regle.useconsultant = false;
if (grid_consults->GetCellValue(row, 8) == "")
regle.use_consultant = false;
if (regle.usedemandeur && regle.useresponsable)
if (regle.use_demandeur && regle.use_responsable)
{
both = true;
requete << "(";
}
if (regle.usedemandeur)
requete << parsedemandeur(grid->GetCellValue(row, 5), grid->GetCellValue(row, 6), regle.opdemandeur);
if (regle.use_demandeur)
requete << ParseDemandeur(grid_consults->GetCellValue(row, 5), grid_consults->GetCellValue(row, 6), regle.op_demandeur);
if (both)
requete << " " << op2W(regle.opboth) << " ";
requete << " " << op2W(regle.op_both) << " ";
if (regle.useresponsable)
requete << parseresponsable(grid->GetCellValue(row,7), regle.opresponsable);
if (regle.use_responsable)
requete << ParseResponsable(grid_consults->GetCellValue(row,7), regle.op_responsable);
if (both)
requete << ")";
if (regle.useconsultant)
requete << " AND " << parseconsultant(grid->GetCellValue(row,8));
if (regle.use_consultant)
requete << " AND " << ParseConsultant(grid_consults->GetCellValue(row,8));
if (regle.useville)
if (regle.use_ville)
requete << " AND " << regle.ville << "[Affiliation]";
if (regle.usesuppl)
if (regle.use_suppl)
requete << " AND " << regle.suppl;
requete << "&retmax=" << _itoW(regle.retmax);
if ((regle.usedebut) || (regle.usefin))
if ((regle.use_debut) || (regle.use_fin))
{
wxDateTime temp;
temp.ParseFormat(grid->GetCellValue(row, 12), "%d/%m/%Y");
temp.ParseFormat(grid_consults->GetCellValue(row, 12), "%d/%m/%Y");
requete << "&datetype=pdat";
if (regle.usedebut)
if (regle.use_debut)
temp += wxDateSpan(regle.debut);
requete << "&mindate=" << temp.Format("%Y/%m/%d");
temp.ParseFormat(grid->GetCellValue(row, 12), "%d/%m/%Y");
if (regle.usefin)
temp.ParseFormat(grid_consults->GetCellValue(row, 12), "%d/%m/%Y");
if (regle.use_fin)
temp += wxDateSpan(regle.fin);
else
temp.SetToCurrent();
@@ -333,13 +333,13 @@ wxString class_recherche::build(int row, rule regle)
return requete;
}

wxString class_recherche::parsedemandeur(wxString nom, wxString prenom, int op)
wxString class_recherche::ParseDemandeur(wxString nom, wxString prenom, int op)
{
wxString out, nom1, nom2, prenom1, prenom2;
bool mult = false;
bool multi = false;
if (nom.Find('/') != wxNOT_FOUND)
{
mult = true;
multi = true;
nom1 = nom.BeforeFirst('/');
nom2 = nom.AfterFirst('/');
}
@@ -362,7 +362,7 @@ wxString class_recherche::parsedemandeur(wxString nom, wxString prenom, int op)
else
prenom2 = prenom2.Left(1);
if (mult)
if (multi)
{
out << "(" << nom1 << " " << prenom1 << "[Author]";
out << " " << op2W(op) << " ";
@@ -374,7 +374,7 @@ wxString class_recherche::parsedemandeur(wxString nom, wxString prenom, int op)
return out;
}

wxString class_recherche::parseresponsable(wxString responsable, int op)
wxString class_recherche::ParseResponsable(wxString responsable, int op)
{
wxString out;
if (responsable.Find('/') == wxNOT_FOUND)
@@ -389,7 +389,7 @@ wxString class_recherche::parseresponsable(wxString responsable, int op)
return out;
}

wxString class_recherche::parseconsultant(wxString consultant)
wxString class_recherche::ParseConsultant(wxString consultant)
{
wxString out, nom, prenom;
prenom = consultant.BeforeFirst(' ');


+ 17
- 17
CosMoS/recherche.h View File

@@ -21,31 +21,31 @@ typedef struct _CurlData {
class class_recherche
{
private:
config* configuration;
class_config* config;
class_bdd* bdd;
wxGrid* grid;
wxGrid* grid_consults;
int nbresult;
wxArrayString idresult;
int nb_results;
wxArrayString list_id_results;
CURL* curlhandle;
CurlData curldata;
CURL* curl_handle;
CurlData curl_data;
void go(int row, rule regle);
void esearch(wxString requete);
void parsesearch();
void efetch();
void parsefetch();
wxString build(int row, rule regle);
wxString parsedemandeur(wxString nom, wxString prenom, int op);
wxString parseresponsable(wxString responsable, int op);
wxString parseconsultant(wxString consultant);
void Go(int row, rule regle);
void eSearch(wxString requete);
void ParseSearch();
void eFetch();
void ParseFetch();
wxString Build(int row, rule regle);
wxString ParseDemandeur(wxString nom, wxString prenom, int op);
wxString ParseResponsable(wxString responsable, int op);
wxString ParseConsultant(wxString consultant);
public:
class_recherche(config* configuration, class_bdd* bdd, wxGrid* grid);
class_recherche(class_config* config, class_bdd* bdd, wxGrid* grid_consults);
~class_recherche();
void start();
void Start();
};



+ 71
- 71
CosMoS/resultats.cpp View File

@@ -1,21 +1,21 @@
#include "resultats.h"

resultats::resultats( wxWindow* parent, class_bdd* bdd, wxGrid* grid )
resultats::resultats( wxWindow* parent, class_bdd* bdd, wxGrid* grid_consults )
:
dialog_resultats( parent )
{
this->bdd = bdd;
this->grid = grid;
this->grid_consults = grid_consults;
changed = false;
}

void resultats::OnCellClick( wxGridEvent& event )
{
currentpubli = event.GetRow();
grid_publis->GoToCell(currentpubli,0);
grid_publis->SetGridCursor(currentpubli,0);
grid_publis->SelectRow(currentpubli);
update_detail();
current_row_publi = event.GetRow();
grid_publis->GoToCell(current_row_publi,0);
grid_publis->SetGridCursor(current_row_publi,0);
grid_publis->SelectRow(current_row_publi);
UpdateUI();
}

void resultats::OnCheckPubli( wxCommandEvent& event )
@@ -23,72 +23,72 @@ void resultats::OnCheckPubli( wxCommandEvent& event )
if (event.GetId() == CHK_PUBLI)
{
int prev_state;
if (list_publi[currentpubli].Left(1) == '@')
if (list_publi[current_row_publi].Left(1) == '@')
prev_state=1;
else
prev_state=0;
list_publi[currentpubli] = list_publi[currentpubli].AfterLast('!').AfterLast('@');
list_publi[current_row_publi] = list_publi[current_row_publi].AfterLast('!').AfterLast('@');
switch (checkbox_publi->Get3StateValue())
{
case wxCHK_CHECKED:
list_publi[currentpubli] = "@" + list_publi[currentpubli];
grid_publis->SetCellBackgroundColour(currentpubli, 0, *wxGREEN);
list_publi[current_row_publi] = "@" + list_publi[current_row_publi];
grid_publis->SetCellBackgroundColour(current_row_publi, 0, *wxGREEN);
if (prev_state == 0)
publi++;
nb_publi++;
break;
case wxCHK_UNDETERMINED:
list_publi[currentpubli] = "!" + list_publi[currentpubli];
grid_publis->SetCellBackgroundColour(currentpubli, 0, *wxLIGHT_GREY);
list_publi[current_row_publi] = "!" + list_publi[current_row_publi];
grid_publis->SetCellBackgroundColour(current_row_publi, 0, *wxLIGHT_GREY);
if (prev_state == 1)
publi--;
nb_publi--;
break;
case wxCHK_UNCHECKED:
grid_publis->SetCellBackgroundColour(currentpubli, 0, grid_publis->GetDefaultCellBackgroundColour());
grid_publis->SetCellBackgroundColour(current_row_publi, 0, grid_publis->GetDefaultCellBackgroundColour());
if (prev_state == 1)
publi--;
nb_publi--;
break;
default:break;
}
}
changed = true;
update_checkpubli();
UpdateCheckUI();
}

void resultats::OnPrev( wxCommandEvent& event )
{
if (changed)
commit_changes();
Commit();
changed = false;
currentrow--;
update();
current_row_consult--;
Update();
}

void resultats::OnNext( wxCommandEvent& event )
{
if (changed)
commit_changes();
Commit();
changed = false;
currentrow++;
update();
current_row_consult++;
Update();
}

void resultats::OnOk( wxCommandEvent& event )
{
if (changed)
commit_changes();
Commit();
changed = false;
Close();
}

void resultats::update()
void resultats::Update()
{
publi=0;
currentid = grid->GetCellValue(currentrow, 13);
nb_publi=0;
current_id_consult = grid_consults->GetCellValue(current_row_consult, 13);
list_publi.Clear();
list_publi = bdd->getidresult(currentid);
list_publi = bdd->GetIdResult(current_id_consult);
if (grid_publis->GetNumberRows() != 0)
grid_publis->DeleteRows(0, grid_publis->GetNumberRows()); //reset de la grille
@@ -106,7 +106,7 @@ void resultats::update()
}
else if (publi_id.Left(1) == "@")
{
publi++;
nb_publi++;
publi_id = publi_id.AfterFirst('@');
grid_publis->SetCellBackgroundColour(i, 0, *wxGREEN);
}
@@ -116,18 +116,18 @@ void resultats::update()
grid_publis->SetCellValue(i, 0, publi_id);
}
currentpubli = 0;
grid_publis->SelectRow(currentpubli);
current_row_publi = 0;
grid_publis->SelectRow(current_row_publi);
grid_publis->SetFocus();
if (grid->GetCellValue(currentrow,2) == "1")
if (grid_consults->GetCellValue(current_row_consult,2) == "1")
checkbox_publichu->SetValue(true);
else
checkbox_publichu->SetValue(false);
if (grid->GetCellValue(currentrow,3) == "1")
if (grid_consults->GetCellValue(current_row_consult,3) == "1")
checkbox_cs->SetValue(true);
else
checkbox_cs->SetValue(false);
update_detail();
UpdateUI();
}
else
{
@@ -143,21 +143,21 @@ void resultats::update()
checkbox_publichu->Hide();
checkbox_cs->Hide();
}
if (currentrow == 0)
if (current_row_consult == 0)
bouton_prec->Disable();
else
bouton_prec->Enable();
if (currentrow == (grid->GetNumberRows() - 1))
if (current_row_consult == (grid_consults->GetNumberRows() - 1))
bouton_suiv->Disable();
else
bouton_suiv->Enable();
grid->SelectRow(currentrow);
grid->GoToCell(currentrow,0);
grid_consults->SelectRow(current_row_consult);
grid_consults->GoToCell(current_row_consult,0);
}

void resultats::update_detail()
void resultats::UpdateUI()
{
wxArrayString detail_publi = bdd->getpubli(grid_publis->GetCellValue(currentpubli, 0));
wxArrayString detail_publi = bdd->GetPublis(grid_publis->GetCellValue(current_row_publi, 0));
textctrl_titre->SetValue(detail_publi[0]);
textctrl_auteurs->SetValue(detail_publi[1]);
textctrl_abstract->SetValue(detail_publi[2]);
@@ -167,20 +167,20 @@ void resultats::update_detail()
hyperlink_lien->SetURL(detail_publi[4]);
checkbox_publi->Enable();
wxCheckBoxState etat;
if (list_publi[currentpubli].Left(1) == "!")
if (list_publi[current_row_publi].Left(1) == "!")
etat = wxCHK_UNDETERMINED;
else if (list_publi[currentpubli].Left(1) == '@')
else if (list_publi[current_row_publi].Left(1) == '@')
etat = wxCHK_CHECKED;
else
etat = wxCHK_UNCHECKED;
checkbox_publi->Set3StateValue(etat);
update_checkpubli();
UpdateCheckUI();
}

void resultats::update_checkpubli()
void resultats::UpdateCheckUI()
{
if (publi > 0)
if (nb_publi > 0)
{
checkbox_publichu->Show();
checkbox_cs->Show();
@@ -195,71 +195,71 @@ void resultats::update_checkpubli()
}
}

void resultats::commit_changes()
void resultats::Commit()
{
unsigned int bitfield = 0;
if (publi > 0)
if (nb_publi > 0)
bitfield |= 1<<1;
if (checkbox_publichu->GetValue())
bitfield |= 1<<2;
if (checkbox_cs->GetValue())
bitfield |= 1<<3;
bdd->modresultpubli(currentrow, bitfield);
bdd->setidresult(currentid, list_publi);
grid->SetCellValue(currentrow, 0, _itoW(bdd->nbresult(currentid)));
bdd->SetResultPubli(current_row_consult, bitfield);
bdd->SetIdResult(current_id_consult, list_publi);
grid_consults->SetCellValue(current_row_consult, 0, _itoW(bdd->GetNbResults(current_id_consult)));
}

void resultats::OnKey( wxKeyEvent& event )
{
if ((event.GetKeyCode() != WXK_SPACE) && (checkbox_publi->Get3StateValue() == wxCHK_UNCHECKED) && (list_publi.GetCount() > 0))
{
list_publi[currentpubli] = "!" + list_publi[currentpubli];
grid_publis->SetCellBackgroundColour(currentpubli, 0, *wxLIGHT_GREY);
list_publi[current_row_publi] = "!" + list_publi[current_row_publi];
grid_publis->SetCellBackgroundColour(current_row_publi, 0, *wxLIGHT_GREY);
checkbox_publi->Set3StateValue(wxCHK_UNDETERMINED);
changed = true;
}
if ((event.GetKeyCode() == WXK_UP) && (currentpubli>0))
if ((event.GetKeyCode() == WXK_UP) && (current_row_publi>0))
{
currentpubli--;
current_row_publi--;
grid_publis->MoveCursorUp(false);
grid_publis->SelectRow(currentpubli);
update_detail();
grid_publis->SelectRow(current_row_publi);
UpdateUI();
}
if ((event.GetKeyCode() == WXK_DOWN) && (currentpubli < grid_publis->GetNumberRows() - 1))
if ((event.GetKeyCode() == WXK_DOWN) && (current_row_publi < grid_publis->GetNumberRows() - 1))
{
currentpubli++;
current_row_publi++;
grid_publis->MoveCursorDown(false);
grid_publis->SelectRow(currentpubli);
update_detail();
grid_publis->SelectRow(current_row_publi);
UpdateUI();
}
wxCommandEvent e;
if ((event.GetKeyCode() == WXK_LEFT) && (currentrow>0))
if ((event.GetKeyCode() == WXK_LEFT) && (current_row_consult>0))
OnPrev(e);
if ((event.GetKeyCode() == WXK_RIGHT) && (currentrow < grid->GetNumberRows() - 1))
if ((event.GetKeyCode() == WXK_RIGHT) && (current_row_consult < grid_consults->GetNumberRows() - 1))
OnNext(e);
if ((event.GetKeyCode() == WXK_SPACE) && (list_publi.GetCount() > 0))
{
if (checkbox_publi->Get3StateValue() != wxCHK_CHECKED)
{
list_publi[currentpubli] = list_publi[currentpubli].AfterLast('!');
list_publi[currentpubli] = "@" + list_publi[currentpubli];
grid_publis->SetCellBackgroundColour(currentpubli, 0, *wxGREEN);
list_publi[current_row_publi] = list_publi[current_row_publi].AfterLast('!');
list_publi[current_row_publi] = "@" + list_publi[current_row_publi];
grid_publis->SetCellBackgroundColour(current_row_publi, 0, *wxGREEN);
checkbox_publi->Set3StateValue(wxCHK_CHECKED);
publi++;
nb_publi++;
}
else
{
list_publi[currentpubli] = list_publi[currentpubli].AfterLast('@');
grid_publis->SetCellBackgroundColour(currentpubli, 0, grid_publis->GetDefaultCellBackgroundColour());
list_publi[current_row_publi] = list_publi[current_row_publi].AfterLast('@');
grid_publis->SetCellBackgroundColour(current_row_publi, 0, grid_publis->GetDefaultCellBackgroundColour());
checkbox_publi->Set3StateValue(wxCHK_UNCHECKED);
publi--;
nb_publi--;
}
changed = true;
update_checkpubli();
UpdateCheckUI();
}
}

+ 12
- 12
CosMoS/resultats.h View File

@@ -16,11 +16,11 @@ class resultats : public dialog_resultats
{
protected:
class_bdd* bdd; //pointeur vers la bdd
wxGrid* grid; //pointeur vers la grille de consults
int currentrow; //index consult courante
wxString currentid; //id de la consult courante
int currentpubli; //index de la publi courante dans la liste pour cette consult
int publi; //compteur de publications
wxGrid* grid_consults; //pointeur vers la grille de consults
int current_row_consult; //index consult courante
wxString current_id_consult; //id de la consult courante
int current_row_publi; //index de la publi courante dans la liste pour cette consult
int nb_publi; //compteur de publications
wxArrayString list_publi; //liste des publis trouvées par la recherche
bool changed; //indicateur de modifications
// Handlers for dialog_resultats events.
@@ -30,16 +30,16 @@ protected:
void OnPrev( wxCommandEvent& event );
void OnNext( wxCommandEvent& event );
void OnOk( wxCommandEvent& event );
void update_detail(); //met à jour les détails pour une publication
void update_checkpubli(); //met à jour les checkboxes
void commit_changes(); //enregistre les modifs dans la bdd
void UpdateUI(); //met à jour les détails pour une publication
void UpdateCheckUI(); //met à jour les checkboxes
void Commit(); //enregistre les modifs dans la bdd
public:
/** Constructor */
resultats( wxWindow* parent, class_bdd* bdd, wxGrid* grid );
void update(); //met à jour la fenêtre pour une consult
resultats( wxWindow* parent, class_bdd* bdd, wxGrid* grid_consults );
void Update(); //met à jour la fenêtre pour une consult
void SetCurrentrow(int currentrow) {this->currentrow = currentrow;}
int GetCurrentrow() const {return currentrow;}
void SetCurrentrow(int current_row_consult) {this->current_row_consult = current_row_consult;}
int GetCurrentrow() const {return current_row_consult;}
//// end generated class members
};


+ 1
- 0
Sante_Pub.workspace View File

@@ -16,6 +16,7 @@
]]>
</Environment>
<BuildMatrix>


+ 51
- 2
Sante_Pub.workspace.session View File

@@ -1,8 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Session Name="/home/satamaxx/Programmes/Sante_Pub/Sante_Pub.workspace">
<int Value="0" Name="m_selectedTab"/>
<int Value="6" Name="m_selectedTab"/>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/Sante_Pub.workspace" Name="m_workspaceName"/>
<TabInfoArray Name="TabInfoArray"/>
<TabInfoArray Name="TabInfoArray">
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/cosmos.cpp" Name="FileName"/>
<int Value="0" Name="FirstVisibleLine"/>
<int Value="46" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/resultatsGUI.h" Name="FileName"/>
<int Value="19" Name="FirstVisibleLine"/>
<int Value="57" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/resultatsGUI.cpp" Name="FileName"/>
<int Value="99" Name="FirstVisibleLine"/>
<int Value="143" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/resultats.h" Name="FileName"/>
<int Value="0" Name="FirstVisibleLine"/>
<int Value="31" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/resultats.cpp" Name="FileName"/>
<int Value="75" Name="FirstVisibleLine"/>
<int Value="98" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/bdd.h" Name="FileName"/>
<int Value="4" Name="FirstVisibleLine"/>
<int Value="35" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/bdd.cpp" Name="FileName"/>
<int Value="120" Name="FirstVisibleLine"/>
<int Value="174" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/misc.h" Name="FileName"/>
<int Value="0" Name="FirstVisibleLine"/>
<int Value="0" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
</TabInfoArray>
<SerializedObject Name="m_breakpoints">
<long Value="0" Name="Count"/>
</SerializedObject>


Loading…
Cancel
Save