-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfcfront.cpp
More file actions
69 lines (59 loc) · 1.71 KB
/
fcfront.cpp
File metadata and controls
69 lines (59 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "fcfront.h"
#include "ui_fcfront.h"
#include "server.h"
#include <QDebug>
FCFront::FCFront(QString group_name, QString text, int index, bool send_card, QWidget *parent) :
QWidget(parent),
ui(new Ui::FCFront)
{
ui->setupUi(this);
groupID = group_name;
edit_front(text, index, send_card);
ui->front_widget->setCurrentIndex(0);
current_index = index;
}
FCFront::~FCFront()
{
delete ui;
}
/*
* Sets front label and text box with flashcard text
* if send_card is set, card info is sent to server
* otherwise only the ui is updated
***/
void FCFront::edit_front(QString text, int index, bool send_card)
{
qDebug() << "SENDING-> " + server::FLASHCARD_SET_FRONT + " " + groupID + " " + QString::number(index) + " " + text;
if(send_card)
{
server::send(server::FLASHCARD_SET_FRONT + groupID + " " + QString::number(index) + " " + text);
}
ui->front_text->setPlainText(text); // Sets ui with text
ui->front_label->setText(text);
}
// ** PROBABLY NOT NEEDED **
// Displays front label
void FCFront::display_front()
{
QString text = ui->front_text->toPlainText();
ui->front_label->setText(text);
ui->front_widget->setCurrentIndex(0);
}
/*
* Displays the editing side of the front card
***/
void FCFront::display_edit_front()
{
QString text = ui->front_label->text();
ui->front_text->setPlainText(text);
ui->front_widget->setCurrentIndex(1);
}
void FCFront::on_set_front_btn_clicked()
{
QString text = ui->front_text->toPlainText(); // get the current edited text and pass it to edit
edit_front(text, current_index, true);
ui->front_widget->setCurrentIndex(0);
}
void FCFront::set_index(int index){
current_index = index;
}