Welcome to mirror list, hosted at ThFree Co, Russian Federation.

qremamain.cpp « src - gitlab.com/Remmina/QRema.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 76b4dd3e79ed9f0d69a89d46391ace984173a470 (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
#include "qremamain.h"
#include "ui_qremamain.h"


QRemaMain::QRemaMain(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::QRemaMain)
{
    ui->setupUi(this);
    QString mPath = "/home/antenore/remmina/profiles";
    dirModel = new QFileSystemModel(this);

    // Set filter
    dirModel->setFilter(QDir::NoDotAndDotDot |
                        QDir::AllDirs);

    // QFileSystemModel requires root path
    dirModel->setRootPath(mPath);

    // 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

    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->setWordWrap( true );
    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));
}