This repository was archived by the owner on May 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapdata.cpp
More file actions
53 lines (44 loc) · 1.31 KB
/
mapdata.cpp
File metadata and controls
53 lines (44 loc) · 1.31 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
#include "mapdata.h"
#include "ui_mapdata.h"
MapData::MapData(QWidget *parent) :
QDialog(parent),
ui(new Ui::MapData)
{
ui->setupUi(this);
this->setupModel();
mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->addMapping(ui->lineEdit,0);
mapper->addMapping(ui->plainTextEdit,1);
connect(ui->tmbPrev,SIGNAL(clicked()),mapper,SLOT(toPrevious()));
connect(ui->tmbNext,SIGNAL(clicked()),mapper,SLOT(toNext()));
connect(mapper,SIGNAL(currentIndexChanged(int)),this,SLOT(tombolApdet(int)));
mapper->toFirst();
}
MapData::~MapData()
{
delete ui;
}
void MapData::setupModel()
{
model = new QStandardItemModel(5, 2, this);
QStringList namaNama;
namaNama << "Joko" << "Slamet" << "Budi" << "Anto" << "Raharjo";
QStringList alamat;
alamat << "Kandeman, Batang"
<< "Semarang Jawa Tengah"
<< "Jakarta Indonesia"
<< "Tokyo Japan"
<< "Hongkong";
for (int row =0; row < 5; ++row) {
QStandardItem * item = new QStandardItem(namaNama[row]);
model->setItem(row,0,item);
item = new QStandardItem(alamat[row]);
model->setItem(row,1,item);
}
}
void MapData::tombolApdet(int row)
{
ui->tmbPrev->setEnabled(row > 0);
ui->tmbNext->setEnabled(row < model->rowCount() - 1);
}