daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Sep 23rd, 2016 24 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent) :
  5.     QMainWindow(parent),
  6.     ui(new Ui::MainWindow)
  7. {
  8.     ui->setupUi(this);
  9.     ui->adminPasswordTF->setEchoMode(QLineEdit::Password);
  10.  
  11.     repopulateMenuItemsLists();
  12.     repopulateRestaurantLists();
  13.  
  14. }
  15.  
  16. MainWindow::~MainWindow()
  17. {
  18.     delete ui;
  19. }
  20.  
  21. // Prints a QString
  22. void MainWindow::print(QString toPrint) {
  23.     qDebug() << toPrint;
  24. }
  25.  
  26. void MainWindow::buySelectedItem() {
  27.  
  28. }
  29.  
  30. void MainWindow::planTrip() {
  31.  
  32. }
  33.  
  34. void MainWindow::adminLogin() {
  35.     // get username and password
  36.     QString username = ui->adminUsernameTF->text();
  37.     QString password = ui->adminPasswordTF->text();
  38.  
  39.     // clear password tf
  40.     ui->adminPasswordTF->clear();
  41.     // check for correct credentials
  42.     if(username == "rainbowsheep" && password == "12345") {
  43.         print("Logged in to admin dashboard"); // log
  44.         ui->adminDashboardBox->setEnabled(true); // enable
  45.         ui->adminDashboardBox->setTitle("Admin Dashboard - Logged in");
  46.         ui->adminUsernameTF->clear(); // clear username TF
  47.     } else {
  48.         // log
  49.         print("Failed to log into admin dashboard, credentials: ");
  50.         print("USERNAME: " + ui->adminUsernameTF->text());
  51.         print("PASSWORD: " + ui->adminPasswordTF->text());
  52.         ui->adminDashboardBox->setEnabled(false); // un-enable in case already enabled
  53.     }
  54. }
  55.  
  56. void MainWindow::adminLogout() {
  57.     print("Logged out of admin dashboard");
  58.     ui->adminDashboardBox->setEnabled(false);
  59.     ui->adminDashboardBox->setTitle("Admin Dashboard - Not Logged in");
  60. }
  61.  
  62. void MainWindow::addRestaurant() {
  63.  
  64. }
  65.  
  66. void MainWindow::removeRestaurant() {
  67.  
  68. }
  69.  
  70. void MainWindow::addMenuItem() {
  71.  
  72. }
  73.  
  74. void MainWindow::removeMenuItem() {
  75.  
  76. }
  77.  
  78. void MainWindow::selectRestaurant(QModelIndex index) {
  79.     //subpoint & b2 = dynamic_cast<subpoint&>(a);
  80.     StringListModel &model = dynamic_cast<StringListModel&>(ui->listOfRestaurants->model());
  81.     QString restaurantName = model.list.at(index.row());
  82.     qDebug() << restaurantName;
  83. }
  84.  
  85. void MainWindow::repopulateMenuItemsLists() {
  86.     qDebug() << "POPULATE MENU ITEMS";
  87. }
  88.  
  89. void MainWindow::repopulateRestaurantLists() {
  90.     qDebug() << "POPULATE RESTAURANTS";
  91.     QList<Restaurant> list = Database::getInstance()->getRestaurants();
  92. //    ui->listOfRestaurants
  93.     QAbstractItemModel *model = new StringListModel(list);
  94.     ui->listOfRestaurants->setModel(model);
  95. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top