-
Notifications
You must be signed in to change notification settings - Fork 0
/
booklist.cpp
46 lines (42 loc) · 1.16 KB
/
booklist.cpp
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
#include "booklist.h"
BookList::BookList(QWidget *parent) :
QListView(parent)
{
conn = connService::getService();
conn->dataWrite("booklist admin");
QString result = static_cast<QString>(conn->getBuf()).toUtf8();
QStringList list = result.split('#');
list.removeLast();
list.sort();
model = new QStandardItemModel(list.size(), 1);
for(int row = 0; row < list.size(); row++)
model->setItem(row, new QStandardItem(list.at(row)));
this->setModel(model);
this->show();
}
BookList::~BookList()
{
if(model)
delete model;
}
void BookList::setPWD(QString p)
{
pwd = p;
}
void BookList::mouseDoubleClickEvent(QMouseEvent *e)
{
if(e->button() == Qt::LeftButton)
{
emit onReceiveBook();
this->setEnabled(false);
QModelIndex index = this->currentIndex();
bookTitle = index.data().toString();
if(bookTitle == "")
return;
conn = connService::getService();
//QString pathName = "C:\\pdfsys\\localFiles\\" + bookTitle;
//QFile file(pathName);
conn->setPWD(pwd);
conn->dataWrite(tr("read #%1#%2").arg(bookTitle).arg(pwd));
}
}