askjnfl2
This commit is contained in:
		@@ -31,6 +31,8 @@ SOURCES += main.cpp\
 | 
				
			|||||||
    drukbox.cpp \
 | 
					    drukbox.cpp \
 | 
				
			||||||
    hallsensor.cpp \
 | 
					    hallsensor.cpp \
 | 
				
			||||||
    herkenningsslot.cpp \
 | 
					    herkenningsslot.cpp \
 | 
				
			||||||
 | 
					    idkaart.cpp \
 | 
				
			||||||
 | 
					    kaartslot.cpp \
 | 
				
			||||||
        mainwindow.cpp \
 | 
					        mainwindow.cpp \
 | 
				
			||||||
    schuifdeur.cpp \
 | 
					    schuifdeur.cpp \
 | 
				
			||||||
    sensor.cpp \
 | 
					    sensor.cpp \
 | 
				
			||||||
@@ -45,6 +47,8 @@ HEADERS  += mainwindow.h \
 | 
				
			|||||||
    drukbox.h \
 | 
					    drukbox.h \
 | 
				
			||||||
    hallsensor.h \
 | 
					    hallsensor.h \
 | 
				
			||||||
    herkenningsslot.h \
 | 
					    herkenningsslot.h \
 | 
				
			||||||
 | 
					    idkaart.h \
 | 
				
			||||||
 | 
					    kaartslot.h \
 | 
				
			||||||
    schuifdeur.h \
 | 
					    schuifdeur.h \
 | 
				
			||||||
    sensor.h \
 | 
					    sensor.h \
 | 
				
			||||||
    sleutelslot.h \
 | 
					    sleutelslot.h \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,6 @@ void HerkenningsSlot::vergrendel(){
 | 
				
			|||||||
void HerkenningsSlot::toonKaartenBak(){
 | 
					void HerkenningsSlot::toonKaartenBak(){
 | 
				
			||||||
    afdrukker->clearMedium();
 | 
					    afdrukker->clearMedium();
 | 
				
			||||||
    for (auto &j:kaartenbak){
 | 
					    for (auto &j:kaartenbak){
 | 
				
			||||||
        afdrukker->toonText(j.first);
 | 
					        afdrukker->toonText(j.first + " " + std::to_string(j.second));
 | 
				
			||||||
        afdrukker->toonText(std::to_string(j.second));
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										21
									
								
								idkaart.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								idkaart.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					#include "idkaart.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					IdKaart::IdKaart(std::string naam, std::string adres):id(naam+" "+adres),naamEigenaar(naam), adresEigenaar(adres){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::string IdKaart::userId(){
 | 
				
			||||||
 | 
					    return id;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void IdKaart::geefToegang(KaartSlot*){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void IdKaart::verwijderToegang(KaartSlot*){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool IdKaart::heeftToegangTot(KaartSlot*){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										23
									
								
								idkaart.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								idkaart.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					#ifndef IDKAART_H
 | 
				
			||||||
 | 
					#define IDKAART_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class KaartSlot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class IdKaart{
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    std::string id;
 | 
				
			||||||
 | 
					    std::vector<KaartSlot*> toegang;
 | 
				
			||||||
 | 
					    std::string naamEigenaar;
 | 
				
			||||||
 | 
					    std::string adresEigenaar;
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    IdKaart(std::string, std::string);
 | 
				
			||||||
 | 
					    std::string userId();
 | 
				
			||||||
 | 
					    void geefToegang(KaartSlot*);
 | 
				
			||||||
 | 
					    void verwijderToegang(KaartSlot*);
 | 
				
			||||||
 | 
					    bool heeftToegangTot(KaartSlot*);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // IDKAART_H
 | 
				
			||||||
							
								
								
									
										29
									
								
								kaartslot.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								kaartslot.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					#include "kaartslot.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					KaartSlot::KaartSlot(): vergrendeld(true){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void KaartSlot::vergrendel(){
 | 
				
			||||||
 | 
					    vergrendeld = true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool KaartSlot::isVergrendeld(){
 | 
				
			||||||
 | 
					    return vergrendeld;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void KaartSlot::ontgrendel(std::string id){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void KaartSlot::voegIdKaartToe(IdKaart* a){
 | 
				
			||||||
 | 
					    if(!idKaarten.count(a->userId())){
 | 
				
			||||||
 | 
					        idKaarten[a->userId()] = a;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void KaartSlot::verwijderIdKaart(std::string key){
 | 
				
			||||||
 | 
					    if(idKaarten[key]){
 | 
				
			||||||
 | 
					        idKaarten.erase(key);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										23
									
								
								kaartslot.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								kaartslot.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					#ifndef KAARTSLOT_H
 | 
				
			||||||
 | 
					#define KAARTSLOT_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "slot.h"
 | 
				
			||||||
 | 
					#include "idkaart.h"
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <map>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class KaartSlot : public Slot{
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    std::string plaats;
 | 
				
			||||||
 | 
					    bool vergrendeld;
 | 
				
			||||||
 | 
					    static inline std::map<std::string,IdKaart*> idKaarten{};
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    KaartSlot();
 | 
				
			||||||
 | 
					    void vergrendel();
 | 
				
			||||||
 | 
					    bool isVergrendeld();
 | 
				
			||||||
 | 
					    void ontgrendel(std::string);
 | 
				
			||||||
 | 
					    static void voegIdKaartToe(IdKaart*);
 | 
				
			||||||
 | 
					    static void verwijderIdKaart(std::string);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // KAARTSLOT_H
 | 
				
			||||||
@@ -14,6 +14,8 @@
 | 
				
			|||||||
#include "herkenningsslot.h"
 | 
					#include "herkenningsslot.h"
 | 
				
			||||||
#include "afdrukker.h"
 | 
					#include "afdrukker.h"
 | 
				
			||||||
#include "drukbox.h"
 | 
					#include "drukbox.h"
 | 
				
			||||||
 | 
					#include "kaartslot.h"
 | 
				
			||||||
 | 
					#include "idkaart.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MainWindow::MainWindow(QWidget *parent) :
 | 
					MainWindow::MainWindow(QWidget *parent) :
 | 
				
			||||||
    QMainWindow(parent),
 | 
					    QMainWindow(parent),
 | 
				
			||||||
@@ -24,10 +26,12 @@ MainWindow::MainWindow(QWidget *parent) :
 | 
				
			|||||||
    //sleutelSlot1 = new SleutelSlot("cisco");
 | 
					    //sleutelSlot1 = new SleutelSlot("cisco");
 | 
				
			||||||
    deuren.emplace_back(std::shared_ptr<Deur> (new Schuifdeur(503,250,80,s1)));
 | 
					    deuren.emplace_back(std::shared_ptr<Deur> (new Schuifdeur(503,250,80,s1)));
 | 
				
			||||||
    //deuren[0]->addSlot(new HerkenningsSlot(new Drukbox(ui->textBrowser)));
 | 
					    //deuren[0]->addSlot(new HerkenningsSlot(new Drukbox(ui->textBrowser)));
 | 
				
			||||||
    deuren[0]->addSlot(new SleutelSlot("cisco2"));
 | 
					    //deuren[0]->addSlot(new SleutelSlot("cisco2"));
 | 
				
			||||||
 | 
					    deuren[0]->addSlot(new KaartSlot);
 | 
				
			||||||
    deuren.emplace_back(std::shared_ptr<Deur> (new draaideur(248,140,40,false)));
 | 
					    deuren.emplace_back(std::shared_ptr<Deur> (new draaideur(248,140,40,false)));
 | 
				
			||||||
    deuren[1]->addSlot(new CodeSlot(1234));
 | 
					    //deuren[1]->addSlot(new CodeSlot(1234));
 | 
				
			||||||
    deuren[1]->addSlot(new CodeSlot(5678));
 | 
					    //deuren[1]->addSlot(new CodeSlot(5678));
 | 
				
			||||||
 | 
					    deuren[1]->addSlot(new KaartSlot);
 | 
				
			||||||
    deuren.emplace_back(std::shared_ptr<Deur> (new draaideur(295,290,30,true)));
 | 
					    deuren.emplace_back(std::shared_ptr<Deur> (new draaideur(295,290,30,true)));
 | 
				
			||||||
    deuren[2]->addSlot(new CodeSlot(0000));
 | 
					    deuren[2]->addSlot(new CodeSlot(0000));
 | 
				
			||||||
    deuren[2]->addSlot(new HerkenningsSlot(new Drukbox(ui->textBrowser)));
 | 
					    deuren[2]->addSlot(new HerkenningsSlot(new Drukbox(ui->textBrowser)));
 | 
				
			||||||
@@ -134,3 +138,17 @@ void MainWindow::on_HerkenningAdd_2_returnPressed(){
 | 
				
			|||||||
    b->ontgrendel(ui->HerkenningAdd_2->text().toStdString());
 | 
					    b->ontgrendel(ui->HerkenningAdd_2->text().toStdString());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void MainWindow::on_addIdCard_clicked(){
 | 
				
			||||||
 | 
					    KaartSlot* kaart = new KaartSlot;
 | 
				
			||||||
 | 
					    kaart->voegIdKaartToe(new IdKaart(ui->Naam->text().toStdString(),ui->Adres->text().toStdString()));
 | 
				
			||||||
 | 
					    delete kaart;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void MainWindow::on_deleteIdCard_clicked(){
 | 
				
			||||||
 | 
					   KaartSlot* kaart = new KaartSlot;
 | 
				
			||||||
 | 
					   kaart->verwijderIdKaart(ui->Naam->text().toStdString()+" "+ui->Adres->text().toStdString());
 | 
				
			||||||
 | 
					   delete kaart;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,6 +35,10 @@ private slots:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    void on_HerkenningAdd_2_returnPressed();
 | 
					    void on_HerkenningAdd_2_returnPressed();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void on_addIdCard_clicked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void on_deleteIdCard_clicked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    Ui::MainWindow *ui;
 | 
					    Ui::MainWindow *ui;
 | 
				
			||||||
    Hallsensor *s1;
 | 
					    Hallsensor *s1;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,8 +6,8 @@
 | 
				
			|||||||
   <rect>
 | 
					   <rect>
 | 
				
			||||||
    <x>0</x>
 | 
					    <x>0</x>
 | 
				
			||||||
    <y>0</y>
 | 
					    <y>0</y>
 | 
				
			||||||
    <width>1171</width>
 | 
					    <width>1041</width>
 | 
				
			||||||
    <height>431</height>
 | 
					    <height>669</height>
 | 
				
			||||||
   </rect>
 | 
					   </rect>
 | 
				
			||||||
  </property>
 | 
					  </property>
 | 
				
			||||||
  <property name="windowTitle">
 | 
					  <property name="windowTitle">
 | 
				
			||||||
@@ -144,13 +144,59 @@
 | 
				
			|||||||
     </rect>
 | 
					     </rect>
 | 
				
			||||||
    </property>
 | 
					    </property>
 | 
				
			||||||
   </widget>
 | 
					   </widget>
 | 
				
			||||||
 | 
					   <widget class="QLineEdit" name="Naam">
 | 
				
			||||||
 | 
					    <property name="geometry">
 | 
				
			||||||
 | 
					     <rect>
 | 
				
			||||||
 | 
					      <x>20</x>
 | 
				
			||||||
 | 
					      <y>420</y>
 | 
				
			||||||
 | 
					      <width>114</width>
 | 
				
			||||||
 | 
					      <height>30</height>
 | 
				
			||||||
 | 
					     </rect>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					   </widget>
 | 
				
			||||||
 | 
					   <widget class="QLineEdit" name="Adres">
 | 
				
			||||||
 | 
					    <property name="geometry">
 | 
				
			||||||
 | 
					     <rect>
 | 
				
			||||||
 | 
					      <x>20</x>
 | 
				
			||||||
 | 
					      <y>460</y>
 | 
				
			||||||
 | 
					      <width>114</width>
 | 
				
			||||||
 | 
					      <height>30</height>
 | 
				
			||||||
 | 
					     </rect>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					   </widget>
 | 
				
			||||||
 | 
					   <widget class="QPushButton" name="addIdCard">
 | 
				
			||||||
 | 
					    <property name="geometry">
 | 
				
			||||||
 | 
					     <rect>
 | 
				
			||||||
 | 
					      <x>150</x>
 | 
				
			||||||
 | 
					      <y>420</y>
 | 
				
			||||||
 | 
					      <width>91</width>
 | 
				
			||||||
 | 
					      <height>26</height>
 | 
				
			||||||
 | 
					     </rect>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="text">
 | 
				
			||||||
 | 
					     <string>Add id Card</string>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					   </widget>
 | 
				
			||||||
 | 
					   <widget class="QPushButton" name="deleteIdCard">
 | 
				
			||||||
 | 
					    <property name="geometry">
 | 
				
			||||||
 | 
					     <rect>
 | 
				
			||||||
 | 
					      <x>150</x>
 | 
				
			||||||
 | 
					      <y>460</y>
 | 
				
			||||||
 | 
					      <width>91</width>
 | 
				
			||||||
 | 
					      <height>26</height>
 | 
				
			||||||
 | 
					     </rect>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="text">
 | 
				
			||||||
 | 
					     <string>Delete id Card</string>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					   </widget>
 | 
				
			||||||
  </widget>
 | 
					  </widget>
 | 
				
			||||||
  <widget class="QMenuBar" name="menuBar">
 | 
					  <widget class="QMenuBar" name="menuBar">
 | 
				
			||||||
   <property name="geometry">
 | 
					   <property name="geometry">
 | 
				
			||||||
    <rect>
 | 
					    <rect>
 | 
				
			||||||
     <x>0</x>
 | 
					     <x>0</x>
 | 
				
			||||||
     <y>0</y>
 | 
					     <y>0</y>
 | 
				
			||||||
     <width>1171</width>
 | 
					     <width>1041</width>
 | 
				
			||||||
     <height>23</height>
 | 
					     <height>23</height>
 | 
				
			||||||
    </rect>
 | 
					    </rect>
 | 
				
			||||||
   </property>
 | 
					   </property>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user