blob: 0bfe541f157fef9b1414fee709c8ce6d644b2122 (
plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#include "qremamain.h"
#include "ui_qremamain.h"
QRemaMain::QRemaMain(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::QRemaMain)
{
ui->setupUi(this);
QString mPath = QDir::homePath() + "/remmina";
qDebug() << "Profile Path: "<< mPath ;
dirModel = new QFileSystemModel(this);
// Set filter
dirModel->setFilter(QDir::NoDotAndDotDot |
QDir::AllDirs);
// QFileSystemModel requires root path
dirModel->setRootPath(mPath);
QSortFilterProxyModel *proxyDirModel = new QSortFilterProxyModel(this);
proxyDirModel->setSourceModel(dirModel);
// Attach the model to the view
ui->treeView->setModel(dirModel);
ui->treeView->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
ui->treeView->setHeaderHidden(true);
ui->treeView->setColumnHidden(1, true);
ui->treeView->setColumnHidden(2, true);
ui->treeView->setColumnHidden(3, true);
ui->treeView->setRootIndex(dirModel->index(mPath));
// FILES
//GKeyFile *keyFile = g_key_file_new();
fileModel = new QFileSystemModel(this);
// Set filter
fileModel->setFilter(QDir::Files | QDir::NoDotAndDotDot);
// QFileSystemModel requires root path
fileModel->setRootPath(mPath);
// Only remmina files
fileModel->setNameFilters(QStringList()<<"*.remmina");
// Attach the model to the view
ui->listView->setModel(fileModel);
ui->listView->setViewMode(QListView::IconMode);
ui->listView->setIconSize(QSize(64, 64));
ui->listView->setResizeMode(QListView::Adjust);
ui->listView->setRootIndex(fileModel->index(mPath));
}
QRemaMain::~QRemaMain()
{
delete ui;
}
void QRemaMain::on_treeView_clicked(const QModelIndex &index)
{
// TreeView clicked
// 1. We need to extract path
// 2. Set that path into our ListView
// Get the full path of the item that's user clicked on
QString mPath = dirModel->fileInfo(index).absoluteFilePath();
ui->listView->setRootIndex(fileModel->setRootPath(mPath));
}
void QRemaMain::on_listView_doubleClicked(const QModelIndex &index)
{
QString sPath = fileModel->fileInfo(index).absoluteFilePath();
QDesktopServices::openUrl(QUrl::fromLocalFile(sPath));
}
void QRemaMain::on_action_Add_triggered()
{
}
|