-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewwindowlist.cpp
35 lines (32 loc) · 946 Bytes
/
viewwindowlist.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
#include "viewwindowlist.h"
#include <QLabel>
#include <QVBoxLayout>
#include <QDebug>
#include <QVariant>
#include <QListWidget>
#include <QSqlQuery>
#include <QDesktopServices>
#include <QUrl>
ViewWindowList::ViewWindowList(QString subject_id,QWidget *parent) :
QWidget(parent)
{
QVBoxLayout *vbl=new QVBoxLayout();
QListWidget *list=new QListWidget();
QSqlQuery query;
query.exec("select path from files where subject_id=" + subject_id);
while(query.next())
{
list->addItem(query.value(0).toString());
}
vbl->addWidget(list);
setLayout(vbl);
connect(list,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(on_view_clicked(QListWidgetItem*)));
}
void ViewWindowList::on_view_clicked(QListWidgetItem *item)
{
#ifdef Q_OS_LINUX || Q_WS_MAEMO_5
QDesktopServices::openUrl(QUrl("File://"+item->text()));
#else
QDesktopServices::openUrl(QUrl("File:///"+item->text()));
#endif
}