Lucie Gérard 05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00

52 lines
1.5 KiB
C++

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
#include "filelistmodel.h"
#include <QtWidgets>
Window::Window(QWidget *parent)
: QWidget(parent)
{
model = new FileListModel(this);
model->setDirPath(QDir::rootPath());
view = new QListView;
view->setModel(model);
logViewer = new QPlainTextEdit(this);
logViewer->setReadOnly(true);
logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred));
connect(model, &FileListModel::numberPopulated,
this, &Window::updateLog);
connect(view, &QAbstractItemView::activated,
this, &Window::activated);
auto *layout = new QVBoxLayout(this);
layout->addWidget(view);
layout->addWidget(logViewer);
setWindowTitle(tr("Fetch More Example"));
}
void Window::updateLog(const QString &path, int start, int number, int total)
{
const int last = start + number - 1;
const QString nativePath = QDir::toNativeSeparators(path);
const QString message = tr("%1..%2/%3 items from \"%4\" added.")
.arg(start).arg(last).arg(total).arg(nativePath);
logViewer->appendPlainText(message);
}
void Window::activated(const QModelIndex &index)
{
const QFileInfo fi = model->fileInfoAt(index);
if (fi.isDir()) {
logViewer->clear();
model->setDirPath(fi.absoluteFilePath());
}
}