Lts/Viewer: Migrate CMakeLists.txt to Qt6 and add missing submodules
- Updated all CMakeLists.txt files to use Qt6:: libraries - Added LtsFileDialog submodule (copied from qt5-before) - Added LtsReportDisplay submodule (copied from qt5-before) - Enabled both submodules in main Viewer CMakeLists.txt - Qt5::Core/Widgets → Qt6::Core/Widgets in all Viewer modules Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
45eb8ee689
commit
01dce5fe52
16 files changed
+1876
-4
No files matched your search
@@ -8,5 +8,5 @@ ADD_SUBDIRECTORY(SituationMap)
|
||||
IF(BUILD_RTI)
|
||||
ADD_SUBDIRECTORY(LtsDataView)
|
||||
ENDIF()
|
||||
# ADD_SUBDIRECTORY(LtsFileDialog) # Not yet migrated
|
||||
# ADD_SUBDIRECTORY(LtsReportDisplay) # Not yet migrated
|
||||
ADD_SUBDIRECTORY(LtsFileDialog)
|
||||
ADD_SUBDIRECTORY(LtsReportDisplay)
|
||||
@@ -0,0 +1,68 @@
|
||||
#
|
||||
# CMakeLists.txt for File Dialog
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Iuliana Ojog, SLSE, 2017-07-12
|
||||
#
|
||||
|
||||
SET(ltsFileDialog_SRCS
|
||||
lts_file_dialog_widget.h
|
||||
lts_file_dialog_widget.cpp
|
||||
lts_file_dialog.h
|
||||
lts_file_dialog.cpp
|
||||
lts_dialog_model_folder.h
|
||||
lts_dialog_model_folder.cpp
|
||||
lts_dialog_model_file.h
|
||||
lts_dialog_model_file.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(ltsFileDialog_SRCS
|
||||
lts_file_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY2(WS LtsFileDialog SHARED ${ltsFileDialog_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(LtsFileDialog
|
||||
PRIVATE
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
nglwidgets
|
||||
ngltools
|
||||
svcFlmCommon
|
||||
svcOpmCommon
|
||||
svcExmCommon
|
||||
LtsUtilsCoreHeaderOnly
|
||||
LtsUtilsGuiConnectDialog
|
||||
PUBLIC
|
||||
Qt6::Core
|
||||
Qt6::Widgets
|
||||
)
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(LtsFileDialog
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
|
||||
# Test-Executable
|
||||
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION LtsFileDialogTest test.cpp)
|
||||
NGL_TARGET_LINK_LIBRARIES(LtsFileDialogTest
|
||||
PRIVATE
|
||||
LtsFileDialog
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
nglwidgets
|
||||
ngltools
|
||||
nglcoreapplication
|
||||
svcFlmClient
|
||||
svcOpmClient
|
||||
svcExmClient
|
||||
# RTI::nddscpp2
|
||||
ddsconnector
|
||||
PUBLIC
|
||||
Qt6::Core
|
||||
Qt6::Widgets
|
||||
)
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* from FileManagement - FileContent model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-07-11
|
||||
*/
|
||||
|
||||
#include "lts_dialog_model_file.h"
|
||||
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
#include <QMimeData>
|
||||
|
||||
#include <Services/FileManagement/flm_translation.h>
|
||||
|
||||
using namespace LtsWidgets;
|
||||
//-------------------------------------------------------------------------------------
|
||||
// DialogModelFile
|
||||
//-------------------------------------------------------------------------------------
|
||||
DialogModelFile::DialogModelFile(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<FileManagement::FileContent>({tr("Name"),
|
||||
tr("Template"),
|
||||
tr("Type"),
|
||||
tr("Category"),
|
||||
tr("Status"),
|
||||
tr("Exercise"),
|
||||
tr("Phase"),
|
||||
tr("Operator"),
|
||||
tr("Used"),
|
||||
tr("Uses"),
|
||||
tr("Last modified"),
|
||||
tr("Properties")},
|
||||
parent)
|
||||
, m_flmDtc(nullptr)
|
||||
, m_opmDtc(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
bool DialogModelFile::initModel(const std::shared_ptr<FileManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const QString &xmlType,
|
||||
const std::function<bool(const FileManagement::FileContent &, const QString &)> &predicate)
|
||||
{
|
||||
m_flmDtc = dtc;
|
||||
m_opmDtc = opmDtc;
|
||||
|
||||
clear();
|
||||
|
||||
// insert Model
|
||||
auto files = [this, xmlType, predicate](const FileManagement::FileContent & fc)
|
||||
{
|
||||
if (!predicate(fc, xmlType))
|
||||
return;
|
||||
insertRow(fc);
|
||||
};
|
||||
m_flmDtc->fileContents(files);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
QVariant DialogModelFile::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return {};
|
||||
|
||||
const FileManagement::FileContent &fl = getRowData(index.row());
|
||||
|
||||
switch(role)
|
||||
{
|
||||
case Qt::BackgroundRole:
|
||||
{
|
||||
if (fl.fileStatus() == FileManagement::FileStatus::Deleted)
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
return QGuiApplication::palette().color(QPalette::Active, QPalette::Base);
|
||||
}
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return QString::fromStdString(fl.name());
|
||||
case ISTEMPLATE:
|
||||
return fl.isTemplate() ? tr("Yes") : tr("No");
|
||||
case FOLDER:
|
||||
return fl.folderId();
|
||||
case FILETYPE:
|
||||
return FileManagement::toString(fl.fileType());
|
||||
case FILECATEGORY:
|
||||
return FileManagement::toString(fl.fileCategory());
|
||||
case FILESTATUS:
|
||||
return FileManagement::toString(fl.fileStatus());
|
||||
case OPERATOR:
|
||||
return QString::fromStdString(m_opmDtc->user(fl.operatorId()).name());
|
||||
case EXERCISE:
|
||||
return fl.exerciseId().is_set() ? fl.exerciseId().get() : QVariant();
|
||||
case PHASE:
|
||||
return fl.phaseId().is_set() ? fl.phaseId().get() : QVariant();
|
||||
case USEDBY:
|
||||
return fl.isUsedBy() ? tr("Yes") : tr("No");
|
||||
case USES:
|
||||
return fl.usedBy();
|
||||
case LASTMODIFIED:
|
||||
return DTG::toStringMSec(fl.lastModified());
|
||||
case PROPERTIES:
|
||||
return QString::fromStdString(fl.properties());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
if (index.column() == NAME && fl.isHidden())
|
||||
return QIcon(QLatin1String(":/style/lock.svg"));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
int DialogModelFile::findFileIdFromName(const QString &fileName) const
|
||||
{
|
||||
const int rc = rowCount();
|
||||
for (int row = 0; row < rc; ++row)
|
||||
{
|
||||
const FileManagement::FileContent &fl = getRowData(row);
|
||||
if (QString::fromStdString(fl.name()) == fileName)
|
||||
{
|
||||
return fl.m_id();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
const QLatin1String MIMETYPE("application/LtsDialogModelFile/FileId");
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
QStringList DialogModelFile::mimeTypes() const { return QStringList() << MIMETYPE; }
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
QMimeData * DialogModelFile::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
if (indexes.isEmpty()) return nullptr;
|
||||
if (indexes.size() > 1) return nullptr;
|
||||
|
||||
const QModelIndex & index = indexes.first();
|
||||
const FileManagement::FileContent & fl = getRowData(index.row());
|
||||
int id = fl.m_id();
|
||||
|
||||
if (id <= 0) return nullptr;
|
||||
|
||||
QMimeData * mimeData = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
|
||||
mimeData->setData( MIMETYPE, encodedData.setNum(id) );
|
||||
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
void DialogFileProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<DialogModelFile*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool DialogFileProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case LASTMODIFIED:
|
||||
return dataLeft.lastModified() < dataRight.lastModified();
|
||||
case NAME:
|
||||
case ISTEMPLATE:
|
||||
case FILETYPE:
|
||||
case FILECATEGORY:
|
||||
case FILESTATUS:
|
||||
case EXERCISE:
|
||||
case PHASE:
|
||||
case OPERATOR:
|
||||
case USEDBY:
|
||||
case USES:
|
||||
|
||||
case PROPERTIES:
|
||||
case FOLDER:
|
||||
case COUNT:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* from FileManagement - FileContent model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-07-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/FileManagement/flm_dtc.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
// --------------------------------------------------------
|
||||
namespace LtsWidgets
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
enum Columns
|
||||
{
|
||||
NAME = 0,
|
||||
ISTEMPLATE,
|
||||
FILETYPE,
|
||||
FILECATEGORY,
|
||||
FILESTATUS,
|
||||
EXERCISE,
|
||||
PHASE,
|
||||
OPERATOR,
|
||||
USEDBY,
|
||||
USES,
|
||||
LASTMODIFIED,
|
||||
PROPERTIES,
|
||||
FOLDER,
|
||||
COUNT,
|
||||
};
|
||||
|
||||
// --------------------------------------------------------
|
||||
class DialogModelFile : public LtsWidgets::LtsAbstractTableModel<FileManagement::FileContent>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DialogModelFile(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<FileManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const QString &xmlType,
|
||||
const std::function<bool(const FileManagement::FileContent &, const QString &)> &predicate);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
|
||||
int findFileIdFromName(const QString &fileName) const;
|
||||
|
||||
QStringList mimeTypes() const override;
|
||||
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
|
||||
Qt::DropActions supportedDragActions() const override
|
||||
{
|
||||
return Qt::CopyAction | Qt::MoveAction;
|
||||
}
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &modelIndex) const override
|
||||
{
|
||||
return LtsWidgets::LtsAbstractTableModel<FileManagement::FileContent>::flags(modelIndex) | Qt::ItemIsDragEnabled;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
|
||||
friend class DialogFileProxyModel;
|
||||
};
|
||||
|
||||
class DialogFileProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
DialogModelFile *m_sourceModel = nullptr;
|
||||
};
|
||||
}
|
||||
+344
@@ -0,0 +1,344 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* from FileManangement - Folder model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-07-11
|
||||
*/
|
||||
|
||||
#include "lts_dialog_model_folder.h"
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
//#include <QtCore/QDebug>
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
// DialogModelFolder
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
DialogModelFolder::DialogModelFolder(QObject *parent
|
||||
, NGLTreeItem *rootItem
|
||||
, const std::shared_ptr<FileManagement::Interface::Dtc> &dtc
|
||||
, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc
|
||||
, const QStringList &header)
|
||||
: NGLTreeModel(parent, rootItem, header)
|
||||
, m_flmDtc(dtc)
|
||||
, m_exmDtc(exmDtc)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
QVariant DialogModelFolder::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal)
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case ID:
|
||||
return tr("Id");
|
||||
case NAME:
|
||||
return tr("Folder");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NGLTreeModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
QVariant DialogModelFolder::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return {};
|
||||
|
||||
NGLTreeItem *item = privateData(index);
|
||||
if (item->data().canConvert<FileManagement::Folder>())
|
||||
{
|
||||
FileManagement::Folder folderData = item->data().value<FileManagement::Folder>();
|
||||
|
||||
switch(role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return getFolderName(folderData);
|
||||
case ID:
|
||||
return folderData.m_id();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case Qt::UserRole:
|
||||
return folderData.m_id();
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
if (folderData.isHidden())
|
||||
return item->icon();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
FileManagement::Folder DialogModelFolder::getFolder(const QModelIndex &idx) const
|
||||
{
|
||||
return privateData(idx)->data().value<FileManagement::Folder>();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
QString DialogModelFolder::getFolderName(const FileManagement::Folder &folderData) const
|
||||
{
|
||||
QString folderName = QString::fromStdString(folderData.name());
|
||||
if (folderName.startsWith(QStringLiteral("$")))
|
||||
{
|
||||
folderName.remove(0,1);
|
||||
if (folderName.startsWith(QStringLiteral("EX_")))
|
||||
{
|
||||
int exId = folderName.remove(0,3).toInt();
|
||||
return QString::fromStdString(m_exmDtc->exercise(exId).name());
|
||||
}
|
||||
if (folderName.startsWith(QStringLiteral("PH_")))
|
||||
{
|
||||
int phId = folderName.remove(0,3).toInt();
|
||||
return QString::fromStdString(m_exmDtc->exercisePhase(phId).name());
|
||||
}
|
||||
return FileManagement::trFolderName(folderName.toStdString());
|
||||
}
|
||||
return FileManagement::trFolderName(folderName.toStdString());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
bool DialogModelFolder::isRowRemovable(NGLTreeItem *parentItem) const
|
||||
{
|
||||
if (!parentItem)
|
||||
return false;
|
||||
FileManagement::Folder folderData = parentItem->data().value<FileManagement::Folder>();
|
||||
return folderData.isEditable();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
bool DialogModelFolder::initModel(int exerciseId, const QVector<FileManagement::MainFolder> &mainFolders)
|
||||
{
|
||||
NGLTreeModel::resetModel();
|
||||
|
||||
QMap<qint32,FileManagement::Folder> tmap;
|
||||
QHash<int, QModelIndex> parentItemIndexCache;
|
||||
QVector<int> idsToExclude;
|
||||
|
||||
auto cbFolders = [exerciseId, &tmap, &idsToExclude, &mainFolders] (const FileManagement::Folder &data)
|
||||
{
|
||||
if (data.isDeleted())
|
||||
return;
|
||||
if (exerciseId > 0)
|
||||
{
|
||||
QString folderName = QString::fromStdString(data.name());
|
||||
if (folderName.startsWith(QStringLiteral("$EX_")))
|
||||
{
|
||||
int exId = folderName.remove(0, 4).toInt();
|
||||
if (exId != exerciseId)
|
||||
idsToExclude.append(data.m_id());
|
||||
}
|
||||
}
|
||||
FileManagement::MainFolder mainFolder = static_cast<FileManagement::MainFolder::type>(data.path()[0]);
|
||||
//qCritical() << "Folder = " << QString::fromStdString(data.name()) << ", mainFolder = " << mainFolder.underlying();
|
||||
if (!mainFolders.contains(mainFolder))
|
||||
{
|
||||
// qCritical() << "Excluded id = " << data.m_id();
|
||||
idsToExclude.append(data.m_id());
|
||||
}
|
||||
|
||||
tmap.insert(data.m_id(), data);
|
||||
};
|
||||
m_flmDtc->folders(cbFolders);
|
||||
|
||||
parentItemIndexCache.insert(0, QModelIndex()); //root
|
||||
|
||||
for (QMap<qint32, FileManagement::Folder>::const_iterator iter = tmap.constBegin();
|
||||
iter != tmap.constEnd(); ++iter)
|
||||
{
|
||||
int folderId = iter.key();
|
||||
int parentId = 0;
|
||||
FileManagement::Folder fld = iter.value();
|
||||
|
||||
if (fld.path().size() > 1)
|
||||
{
|
||||
parentId = fld.path().at(fld.path().size() - 2);
|
||||
int idPos2 = fld.path().at(1);
|
||||
if (idsToExclude.contains(idPos2))
|
||||
continue;
|
||||
}
|
||||
else // main Folders
|
||||
{
|
||||
if (idsToExclude.contains(fld.m_id()))
|
||||
continue;
|
||||
}
|
||||
|
||||
QVariant data;
|
||||
data.setValue(fld);
|
||||
|
||||
if (!parentItemIndexCache.contains(parentId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QModelIndex pIndex = parentItemIndexCache.value(parentId);
|
||||
int rowPos = -1;
|
||||
onInsertRow(rowPos, pIndex, fld);
|
||||
parentItemIndexCache.insert(folderId, index(rowPos, 0, pIndex));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool DialogModelFolder::onInsertRow(int &row, const QModelIndex &parent, const FileManagement::Folder &folderData)
|
||||
{
|
||||
row = rowCount(parent);
|
||||
QVariant data;
|
||||
data.setValue(folderData);
|
||||
QIcon icon;
|
||||
if (folderData.isHidden())
|
||||
icon = QIcon(QLatin1String(":/style/lock.svg"));
|
||||
NGLTreeItem *item = new NGLTreeItem(data, icon);
|
||||
item->setModified(true);
|
||||
|
||||
return NGLTreeModel::insertRow(row, parent, item);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool DialogModelFolder::onUpdateRow(const QModelIndex &index, const FileManagement::Folder &folderData)
|
||||
{
|
||||
QVariant data;
|
||||
data.setValue(folderData);
|
||||
|
||||
QIcon icon;
|
||||
if (folderData.isHidden())
|
||||
icon = QIcon(QLatin1String(":/style/lock.svg"));
|
||||
return setItemData(index, data, icon);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool DialogModelFolder::onDeleteRow(const QModelIndex &idx, bool isFirstItem)
|
||||
{
|
||||
while(rowCount(idx) > 0)
|
||||
{
|
||||
onDeleteRow(NGLTreeModel::index(0, 0, idx),false);
|
||||
}
|
||||
if (isFirstItem) //edit mode
|
||||
{
|
||||
NGLTreeItem *item = privateData(idx);
|
||||
FileManagement::Folder data = item->data().value<FileManagement::Folder>();
|
||||
data.isDeleted(true);
|
||||
}
|
||||
removeRow(idx.row(), idx.parent());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
QModelIndex DialogModelFolder::getIndex(int folderId) const
|
||||
{
|
||||
QModelIndexList list = match(index(0, 0), Qt::UserRole, QVariant::fromValue(folderId), 1, Qt::MatchRecursive);
|
||||
|
||||
if (!list.isEmpty())
|
||||
return list.first();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void DialogModelProxyFolder::setSourceModel(QAbstractItemModel *model)
|
||||
{
|
||||
m_sourceModel = qobject_cast<DialogModelFolder*>(model);
|
||||
QSortFilterProxyModel::setSourceModel(model);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool DialogModelProxyFolder::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (!m_sourceModel || source_left.column() != source_right.column())
|
||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
const NGLTreeItem *itemLeft = m_sourceModel->privateData(source_left);
|
||||
const NGLTreeItem *itemRight = m_sourceModel->privateData(source_right);
|
||||
if (!itemLeft || !itemRight)
|
||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
const FileManagement::Folder left = itemLeft->data().value<FileManagement::Folder>();
|
||||
const FileManagement::Folder right = itemRight->data().value<FileManagement::Folder>();
|
||||
|
||||
if (left.m_id() == FileManagement::MainFolder::GlobalDocuments || right.m_id() == FileManagement::MainFolder::GlobalDocuments ||
|
||||
left.m_id() == FileManagement::MainFolder::UserDocuments || right.m_id() == FileManagement::MainFolder::UserDocuments ||
|
||||
left.m_id() == FileManagement::MainFolder::ExerciseDocuments || right.m_id() == FileManagement::MainFolder::ExerciseDocuments)
|
||||
{
|
||||
return left.m_id() < right.m_id();
|
||||
}
|
||||
|
||||
if (QString::fromStdString(left.name()) != QString::fromStdString(right.name()))
|
||||
{
|
||||
return (QString::fromStdString(left.name()) < QString::fromStdString(right.name()));
|
||||
}
|
||||
|
||||
return left.m_id() < right.m_id();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void DialogModelProxyFolder::sort(int column, Qt::SortOrder order)
|
||||
{
|
||||
Qt::SortOrder myOrder = order;
|
||||
if (column == 0)
|
||||
myOrder = Qt::AscendingOrder;
|
||||
QSortFilterProxyModel::sort(column, myOrder);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool DialogModelProxyFolder::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
if (!m_sourceModel || !source_parent.isValid())
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
if (m_operatorId == 0) // no filter for admin
|
||||
return true;
|
||||
|
||||
NGLTreeItem *parent = m_sourceModel->privateData(source_parent);
|
||||
if (!parent)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
NGLTreeItem *child = parent->child(source_row);
|
||||
if (!child)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
const FileManagement::Folder data = child->data().value<FileManagement::Folder>();
|
||||
if (data.operatorId() != m_operatorId)
|
||||
{
|
||||
// it's user folder -> check if it's in user documents and hide if it's not for the current operator
|
||||
for (int p : data.path())
|
||||
{
|
||||
if (p == FileManagement::MainFolder::UserDocuments)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void DialogModelProxyFolder::setOperatorId(int operatorId)
|
||||
{
|
||||
if (m_operatorId == operatorId)
|
||||
return;
|
||||
m_operatorId = operatorId;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
} // namespace LtsWidgets
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* from FileManangement - Folder Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-07-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/FileManagement/flm_dtc.h>
|
||||
#include <Services/ExerciseManagement/exm_dtc.h>
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
|
||||
class QTableWidget;
|
||||
// -------------------------------------------------------------------------------------
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class DialogModelFolder : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
NAME,
|
||||
ID
|
||||
};
|
||||
|
||||
explicit DialogModelFolder(QObject *parent
|
||||
, NGLTreeItem *rootItem
|
||||
, const std::shared_ptr<FileManagement::Interface::Dtc> &dtc
|
||||
, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc
|
||||
, const QStringList &header);
|
||||
|
||||
bool initModel(int exerciseId, const QVector<FileManagement::MainFolder> &mainFolders);
|
||||
|
||||
bool isRowRemovable(NGLTreeItem *parentItem) const;
|
||||
FileManagement::Folder getFolder(const QModelIndex &idx) const;
|
||||
QModelIndex getIndex(int folderId) const;
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override final;
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
QString getFolderName(const FileManagement::Folder &folderData) const;
|
||||
|
||||
public Q_SLOTS :
|
||||
bool onInsertRow(int &row, const QModelIndex &parent, const FileManagement::Folder &folderData);
|
||||
bool onUpdateRow(const QModelIndex &index, const FileManagement::Folder &folderData);
|
||||
bool onDeleteRow(const QModelIndex &idx, bool isFirstItem = true);
|
||||
|
||||
private:
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
class DialogModelProxyFolder : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using QSortFilterProxyModel::QSortFilterProxyModel;
|
||||
void setOperatorId(int operatorId);
|
||||
void setSourceModel(QAbstractItemModel *model) override;
|
||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
|
||||
DialogModelFolder *m_sourceModel = nullptr;
|
||||
int m_operatorId = 0;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
Q_DECLARE_METATYPE(FileManagement::Folder)
|
||||
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* LtsFileDialogWidget and LtsFileDialog - custom widgets
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-07-11
|
||||
*/
|
||||
|
||||
#include "lts_file_dialog.h"
|
||||
#include "ui_lts_file_dialog.h"
|
||||
|
||||
#include "lts_file_dialog_widget.h"
|
||||
#include "lts_dialog_model_folder.h"
|
||||
#include "lts_dialog_model_file.h"
|
||||
#include <Services/FileManagement/flm_translation.h>
|
||||
|
||||
#include <Viewer/LtsDataView/lts_data_view.h>
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
// LtsFileDialog
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
LtsFileDialog::LtsFileDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_editItemWidget(new LtsFileDialogWidget(this))
|
||||
, m_buttonBox (new LtsWidgets::LtsDialogButtonBox(this))
|
||||
{
|
||||
LtsWidgets::DialogButton btnSelectFile = LtsWidgets::DialogButton::Load;
|
||||
|
||||
m_buttonBox->setText(btnSelectFile, tr("Select File"));
|
||||
m_buttonBox->setToolTip(btnSelectFile, tr("Select file from library"));
|
||||
m_buttonBox->setButtonEnabled(btnSelectFile, false);
|
||||
m_buttonBox->setButtonVisible(btnSelectFile, true);
|
||||
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &LtsFileDialog::close);
|
||||
|
||||
//hide ok and apply
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->hide();
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
LtsFileDialog::~LtsFileDialog()
|
||||
{
|
||||
delete m_editItemWidget;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
bool LtsFileDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<FileManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
|
||||
const FileDialogMode &dlgMode,
|
||||
const QVector<FileManagement::MainFolder> &mainFolders,
|
||||
const QVector<FileManagement::FileType> &fileTypes,
|
||||
const int &folderId,
|
||||
const QString &buttonName,
|
||||
const QString &xmlType)
|
||||
{
|
||||
if (!m_editItemWidget->init(session, dtc, opmDtc, exmDtc, dlgMode, mainFolders, fileTypes, folderId, xmlType))
|
||||
return false;
|
||||
|
||||
m_dialogMode = dlgMode;
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->addWidget(m_editItemWidget);
|
||||
layout->addWidget(m_buttonBox);
|
||||
this->setLayout(layout);
|
||||
|
||||
if (!buttonName.isEmpty())
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Load, buttonName);
|
||||
m_buttonBox->setToolTip(LtsWidgets::DialogButton::Load, buttonName);
|
||||
}
|
||||
|
||||
if (m_dialogMode == FileDialogMode::modeSaveFile)
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, m_editItemWidget, &LtsFileDialogWidget::onChooseFileName);
|
||||
else if (m_dialogMode == FileDialogMode::modeOpenFile)
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, m_editItemWidget, &LtsFileDialogWidget::onSelectFile);
|
||||
|
||||
connect(m_editItemWidget, &LtsFileDialogWidget::enableButtons, this, &LtsFileDialog::enaDisa);
|
||||
connect(m_editItemWidget, &LtsFileDialogWidget::accepted, this, &LtsFileDialog::accept);
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &LtsFileDialog::reject);
|
||||
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
int LtsFileDialog::getSelectedFileId() const
|
||||
{
|
||||
return m_editItemWidget->m_selectedFileContent.m_id();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
FileManagement::FileContent LtsFileDialog::getSelectedFile() const
|
||||
{
|
||||
return m_editItemWidget->m_selectedFileContent;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
int LtsFileDialog::getSelectedFolder() const
|
||||
{
|
||||
return m_editItemWidget->m_selectedFolderId;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
QString LtsFileDialog::getFileName() const
|
||||
{
|
||||
return m_editItemWidget->m_fileName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
void LtsFileDialog::enaDisa()
|
||||
{
|
||||
LtsWidgets::DialogButton btnSelectFile = LtsWidgets::DialogButton::Load;
|
||||
m_buttonBox->setButtonEnabled(btnSelectFile, false);
|
||||
|
||||
QModelIndex idxFile = m_editItemWidget->m_ui->widgetFiles->currentIndex();
|
||||
if (m_dialogMode == FileDialogMode::modeOpenFile && idxFile.isValid())
|
||||
m_buttonBox->setButtonEnabled(btnSelectFile, true);
|
||||
|
||||
if (m_dialogMode == FileDialogMode::modeSaveFile && !m_editItemWidget->m_fileName.isEmpty())
|
||||
m_buttonBox->setButtonEnabled(btnSelectFile, true);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
} // namespace LtsWidgets
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* LtsFileDialogWidget and LtsFileDialog - custom widgets
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-07-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
#include <Services/ExerciseManagement/exm_dtc.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog_button_box.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
#include <LtsFileDialog/ltsfiledialog_export.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class LtsFileDialogWidget;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// LtsFileDialog
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
namespace LtsWidgets
|
||||
{
|
||||
enum FileDialogMode
|
||||
{
|
||||
modeOpenFile = 0, // used as modal select file to open
|
||||
modeSaveFile = 1 // used as modal select folder to save file
|
||||
};
|
||||
|
||||
class LtsFileDialogWidget;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
class LTSFILEDIALOG_EXPORT LtsFileDialog : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class LtsFileDialogWidget;
|
||||
public:
|
||||
explicit LtsFileDialog(QWidget *parent = nullptr);
|
||||
~LtsFileDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<FileManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
|
||||
const FileDialogMode &dlgMode = FileDialogMode::modeOpenFile,
|
||||
const QVector<FileManagement::MainFolder> &mainFolders = {},
|
||||
const QVector<FileManagement::FileType> &fileTypes = {FileManagement::FileType::Unknown},
|
||||
const int &folderId = 0,
|
||||
const QString &buttonName = QString(),
|
||||
const QString &xmlType = QString());
|
||||
|
||||
int getSelectedFileId() const;
|
||||
FileManagement::FileContent getSelectedFile() const;
|
||||
int getSelectedFolder() const;
|
||||
QString getFileName() const;
|
||||
|
||||
private:
|
||||
void enaDisa();
|
||||
|
||||
private:
|
||||
LtsFileDialogWidget *m_editItemWidget{nullptr};
|
||||
LtsWidgets::LtsDialogButtonBox *m_buttonBox{nullptr};
|
||||
FileDialogMode m_dialogMode{FileDialogMode::modeOpenFile};
|
||||
};
|
||||
|
||||
} // namespace LtsWidgets
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LtsFileDialogWidget</class>
|
||||
<widget class="QWidget" name="LtsFileDialogWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>925</width>
|
||||
<height>559</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Exercise Management</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblFolder">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Selected Folder:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblSelectedFolder">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="tvFolder">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widgetFiles">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="showColumnCount" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolButtonsVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblFilter">
|
||||
<property name="text">
|
||||
<string>Filtering:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblFile">
|
||||
<property name="text">
|
||||
<string>Selected File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leFile">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+391
@@ -0,0 +1,391 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* LtsFileDialogWidget and LtsFileDialog - custom widgets
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Iuliana Ojog & Mike Wille, SLSE, 2017-09-15
|
||||
*/
|
||||
|
||||
#include "lts_file_dialog_widget.h"
|
||||
#include "lts_file_dialog.h"
|
||||
#include "lts_dialog_model_file.h"
|
||||
#include "lts_dialog_model_folder.h"
|
||||
#include "ui_lts_file_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
#include <Services/FileManagement/flm_translation.h>
|
||||
#include <ConnectDialog/connect_dialog_nt.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
|
||||
#include <QItemSelectionModel>
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
LtsFileDialogWidget::LtsFileDialogWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::LtsFileDialogWidget)
|
||||
, m_selectedFileContent(FileManagement::FileContent())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
LtsFileDialogWidget::~LtsFileDialogWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
bool LtsFileDialogWidget::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<FileManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
|
||||
const FileDialogMode &dlgMode,
|
||||
const QVector<FileManagement::MainFolder> &mainFolders,
|
||||
const QVector<FileManagement::FileType> &fileTypes,
|
||||
const int &folderId,
|
||||
const QString &xmlType)
|
||||
{
|
||||
m_session = session;
|
||||
m_dtc = dtc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_exmDtc = exmDtc;
|
||||
m_dialogMode = dlgMode;
|
||||
m_fileTypes = fileTypes;
|
||||
m_selectedFolderId = folderId;
|
||||
m_xmlType = xmlType;
|
||||
m_mainFolders = mainFolders;
|
||||
|
||||
if ((dtc.get() == nullptr) || (opmDtc.get() == nullptr))
|
||||
return false;
|
||||
|
||||
m_dtc->enableFolder();
|
||||
m_dtc->waitForHistoricalDataFolder();
|
||||
m_dtc->enableFileContent();
|
||||
m_dtc->waitForHistoricalDataFileContent();
|
||||
m_opmDtc->enableUser();
|
||||
m_opmDtc->waitForHistoricalDataUser();
|
||||
m_exmDtc->enableExercise();
|
||||
m_exmDtc->waitForHistoricalDataExercise();
|
||||
m_exmDtc->enableExercisePhase();
|
||||
m_exmDtc->waitForHistoricalDataExercisePhase();
|
||||
|
||||
// DDS connects
|
||||
connect(m_dtc.get(), &FileManagement::Interface::Dtc::folderChanged, this, &LtsFileDialogWidget::onFolderChanged);
|
||||
connect(m_dtc.get(), &FileManagement::Interface::Dtc::fileContentChanged, this, &LtsFileDialogWidget::onFileChanged);
|
||||
|
||||
// model folder
|
||||
QVariant data;
|
||||
FileManagement::Folder dummyFolder;
|
||||
data.setValue(dummyFolder);
|
||||
NGLTreeItem *rootItem = new NGLTreeItem(data, QIcon());
|
||||
|
||||
m_modelFolder = new DialogModelFolder(this, rootItem, m_dtc, m_exmDtc,
|
||||
QStringList()
|
||||
<< tr("Name") << tr("Id"));
|
||||
|
||||
m_modelFolder->initModel(m_session->exerciseId(), m_mainFolders);
|
||||
|
||||
m_proxyModelFolder = new DialogModelProxyFolder(this);
|
||||
m_proxyModelFolder->setOperatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
m_proxyModelFolder->setSourceModel(m_modelFolder);
|
||||
m_proxyModelFolder->sort(DialogModelFolder::Columns::ID, Qt::AscendingOrder);
|
||||
|
||||
// UI
|
||||
m_ui->tvFolder->setModel(m_proxyModelFolder);
|
||||
m_ui->tvFolder->expandAll();
|
||||
m_ui->tvFolder->setExpanded(m_proxyModelFolder->index(0,0),true);
|
||||
m_ui->tvFolder->hideColumn(DialogModelFolder::Columns::ID);
|
||||
|
||||
// SelectionModel Folder
|
||||
QItemSelectionModel *selectionModelFolder = m_ui->tvFolder->selectionModel();
|
||||
connect(selectionModelFolder, &QItemSelectionModel::selectionChanged, this, &LtsFileDialogWidget::onFolderSelectionChanged);
|
||||
|
||||
// model file
|
||||
m_modelFile = new DialogModelFile(this);
|
||||
|
||||
// initial all valid, not-deleted files
|
||||
auto predicate = [](const FileManagement::FileContent &fc, const QString &xmlType)
|
||||
{
|
||||
return (!fc.isDeleted() && fc.fileStatus() == FileManagement::FileStatus::Valid &&
|
||||
(xmlType.isEmpty() || fc.properties().find(xmlType.toStdString()) != std::string::npos));
|
||||
};
|
||||
m_modelFile->initModel(m_dtc, m_opmDtc, xmlType, predicate);
|
||||
|
||||
// auto predicate = [](const FileManagement::FileContent &fc)
|
||||
// {
|
||||
// return (!fc.isDeleted() && fc.fileStatus() == FileManagement::FileStatus::Valid);
|
||||
// };
|
||||
// m_modelFile->initModel(m_dtc, m_opmDtc, m_xmlType, predicate);
|
||||
|
||||
// UI file
|
||||
m_ui->widgetFiles->seamless();
|
||||
m_proxyModelFile = new DialogFileProxyModel(this);
|
||||
m_proxyModelFile->setSourceModel(m_modelFile);
|
||||
m_ui->widgetFiles->setModel(m_proxyModelFile);
|
||||
|
||||
m_ui->widgetFiles->hideColumn(FOLDER);
|
||||
|
||||
// double click to select file
|
||||
connect(m_ui->widgetFiles, &LtsDataView::LtsDataView::signalDoubleClicked, this, &LtsFileDialogWidget::onSelectFile);
|
||||
|
||||
// initial folder selection
|
||||
selectFolder();
|
||||
|
||||
// selection changed File
|
||||
connect(m_ui->widgetFiles, &LtsDataView::LtsDataView::signalSelectionChanged, this, &LtsFileDialogWidget::enaDisa);
|
||||
|
||||
// enable filename edit
|
||||
if (m_dialogMode == FileDialogMode::modeSaveFile)
|
||||
{
|
||||
m_ui->leFile->setEnabled(true);
|
||||
connect(m_ui->leFile, &QLineEdit::textChanged, this, &LtsFileDialogWidget::saveFileName);
|
||||
}
|
||||
|
||||
// filtering on fileTypes
|
||||
if (m_fileTypes.contains(FileManagement::FileType::Unknown)) // no filtering
|
||||
m_ui->lblFilter->setVisible(false);
|
||||
else
|
||||
{
|
||||
QString labelFilter = tr("Filtering:") + QLatin1String(" <b>");
|
||||
QStringList types;
|
||||
types.reserve(m_fileTypes.size());
|
||||
for (auto &ft : m_fileTypes)
|
||||
types << toString(ft);
|
||||
labelFilter += types.join(QLatin1String(", "));
|
||||
labelFilter += QLatin1String("</b>");
|
||||
m_ui->lblFilter->setText(labelFilter);
|
||||
}
|
||||
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
void LtsFileDialogWidget::selectFolder()
|
||||
{
|
||||
QModelIndex idx;
|
||||
QItemSelectionModel *selectionModelFolder = m_ui->tvFolder->selectionModel();
|
||||
if (m_selectedFolderId > 0)
|
||||
idx = m_proxyModelFolder->mapFromSource(m_modelFolder->getIndex(m_selectedFolderId));
|
||||
if (idx.isValid())
|
||||
selectionModelFolder->setCurrentIndex(idx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
else
|
||||
selectionModelFolder->setCurrentIndex(m_modelFolder->index(0,0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
void LtsFileDialogWidget::onFolderSelectionChanged(const QItemSelection& /*selected*/,
|
||||
const QItemSelection& /*deselected*/)
|
||||
{
|
||||
enaDisa();
|
||||
|
||||
auto predicate = [this](const FileManagement::FileContent & fc, const QString &xmlType)
|
||||
{
|
||||
return showFile(fc, xmlType);
|
||||
};
|
||||
|
||||
m_modelFile->initModel(m_dtc, m_opmDtc, m_xmlType, predicate);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
void LtsFileDialogWidget::requestReadingSelectedFile()
|
||||
{
|
||||
emit readSelectedFile(m_selectedFileContent.m_id());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
FileManagement::FileContent LtsFileDialogWidget::onSelectFile()
|
||||
{
|
||||
QModelIndex selIndex = m_ui->widgetFiles->currentIndex();
|
||||
|
||||
if (!selIndex.isValid())
|
||||
return FileManagement::FileContent();
|
||||
|
||||
m_selectedFileContent = m_modelFile->getRowData(selIndex.row());
|
||||
|
||||
emit accepted();
|
||||
|
||||
return m_selectedFileContent;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
void LtsFileDialogWidget::onChooseFileName()
|
||||
{
|
||||
if ((m_dialogMode == FileDialogMode::modeSaveFile) && (!m_fileName.isEmpty()))
|
||||
{
|
||||
emit accepted();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void LtsFileDialogWidget::onFolderChanged(const FileManagement::Folder &data, DataModification modType)
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(modType);
|
||||
m_modelFolder->initModel(m_session->exerciseId(), m_mainFolders);
|
||||
m_ui->tvFolder->expandAll();
|
||||
m_ui->tvFolder->setExpanded(m_proxyModelFolder->index(0,0),true);
|
||||
// select last selected folder
|
||||
selectFolder();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void LtsFileDialogWidget::onFileChanged(const FileManagement::FileContent &data, DataModification modType)
|
||||
{
|
||||
bool condition = showFile(data, m_xmlType);
|
||||
|
||||
int row = 0;
|
||||
QModelIndex selIndex = m_ui->widgetFiles->currentIndex();
|
||||
|
||||
if (selIndex.isValid())
|
||||
row = selIndex.row();
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_modelFile->removeRow(row);
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eAdded && condition)
|
||||
{
|
||||
m_modelFile->insertRow(data);
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eModified && condition)
|
||||
{
|
||||
m_modelFile->setRowData(row, data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
QString LtsFileDialogWidget::dragMimeType() const
|
||||
{
|
||||
return (m_modelFile) ? m_modelFile->mimeTypes().value(0) : QString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
void LtsFileDialogWidget::saveFileName(const QString &name)
|
||||
{
|
||||
m_fileName = name;
|
||||
m_selectedFileContent = FileManagement::FileContent();
|
||||
|
||||
emit enableButtons();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
QModelIndex LtsFileDialogWidget::selectedIndexViewFolder()
|
||||
{
|
||||
QItemSelectionModel *selectionModel = m_ui->tvFolder->selectionModel();
|
||||
QModelIndexList indexL = selectionModel->selectedRows(0);
|
||||
if(indexL.size() == 0)
|
||||
return {};
|
||||
return m_proxyModelFolder->mapToSource(indexL.at(0));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
void LtsFileDialogWidget::enaDisa()
|
||||
{
|
||||
QModelIndex idxFolder = selectedIndexViewFolder();
|
||||
|
||||
if (idxFolder.isValid())
|
||||
{
|
||||
QString folderName = m_modelFolder->getFolderName(m_modelFolder->getFolder(idxFolder));
|
||||
m_ui->lblSelectedFolder->setText(folderName);
|
||||
m_selectedFolderId = m_modelFolder->getFolder(idxFolder).m_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->lblSelectedFolder->setText(tr("None"));
|
||||
m_selectedFolderId = 0;
|
||||
}
|
||||
|
||||
// files
|
||||
QModelIndex idxFile = m_ui->widgetFiles->currentIndex();
|
||||
if (idxFile.isValid())
|
||||
{
|
||||
m_selectedFileContent = m_modelFile->getRowData(m_ui->widgetFiles->currentIndex().row());
|
||||
m_fileName = QString::fromStdString(m_selectedFileContent.name());
|
||||
m_ui->leFile->setText(m_fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedFileContent = FileManagement::FileContent();
|
||||
if (m_dialogMode != FileDialogMode::modeSaveFile)
|
||||
{
|
||||
m_fileName = QString();
|
||||
m_ui->leFile->setText(m_fileName);
|
||||
}
|
||||
}
|
||||
|
||||
emit enableButtons();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
bool LtsFileDialogWidget::showFile(const FileManagement::FileContent &fc, const QString &xmlType)
|
||||
{
|
||||
if (fc.isDeleted())
|
||||
return false;
|
||||
|
||||
if (fc.folderId() != m_selectedFolderId)
|
||||
return false;
|
||||
|
||||
if (!m_fileTypes.isEmpty() && !m_fileTypes.contains(fc.fileType()))
|
||||
return false;
|
||||
|
||||
if (fc.fileStatus() != FileManagement::FileStatus::Valid)
|
||||
return false;
|
||||
|
||||
// get folder selected
|
||||
const QModelIndex selIndex = selectedIndexViewFolder();
|
||||
const NGLTreeItem *item = m_modelFolder->privateData(selIndex);
|
||||
const FileManagement::Folder fld = item->data().value<FileManagement::Folder>();
|
||||
const auto &fldPath = fld.path();
|
||||
|
||||
// filter in USER DOCUMENTS folder and subfolders
|
||||
if (LtsUtils::isInVector(fldPath, FileManagement::MainFolder::UserDocuments))
|
||||
{
|
||||
const int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
// filter on User Category and OperatorId
|
||||
if (fc.fileCategory() == FileManagement::FileCategory::User &&
|
||||
fc.operatorId() != operatorId)
|
||||
return false;
|
||||
}
|
||||
|
||||
// filter in EXERCISE DOCUMENTS folder and subfolders
|
||||
if (LtsUtils::isInVector(fldPath, FileManagement::MainFolder::ExerciseDocuments))
|
||||
{
|
||||
// filter on Category = Exercise
|
||||
if (fc.fileCategory() != FileManagement::FileCategory::Exercise)
|
||||
return false;
|
||||
if (m_session->exerciseId() > 0)
|
||||
{
|
||||
// filter on exact exerciseId
|
||||
if (fc.exerciseId() != m_session->exerciseId())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// filter on XmlType
|
||||
if (fc.fileType() == FileManagement::FileType::Xml && !xmlType.isEmpty() && fc.properties().size() > 0)
|
||||
{
|
||||
const QString &prop = QString::fromStdString(fc.properties());
|
||||
if (!prop.contains(xmlType, Qt::CaseSensitive))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
} // namespace LtsWidgets
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* LtsFileDialogWidget and LtsFileDialog - custom widgets
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Iuliana Ojog & Mike Wille, SLSE, 2017-09-15
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "lts_file_dialog.h"
|
||||
|
||||
#include <LtsFileDialog/ltsfiledialog_export.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class DialogModelFile;
|
||||
class DialogModelFolder;
|
||||
class DialogModelProxyFolder;
|
||||
class DialogFileProxyModel;
|
||||
|
||||
class LTSFILEDIALOG_EXPORT LtsFileDialogWidget : public QWidget
|
||||
{
|
||||
friend class LtsFileDialog;
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LtsFileDialogWidget(QWidget *parent = nullptr);
|
||||
~LtsFileDialogWidget();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<FileManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
|
||||
const FileDialogMode &dlgMode = FileDialogMode::modeOpenFile,
|
||||
const QVector<FileManagement::MainFolder> &mainFolders = {},
|
||||
const QVector<FileManagement::FileType> &fileTypes = {FileManagement::FileType::Unknown},
|
||||
const int &folderId = 0,
|
||||
const QString &xmlType = QString());
|
||||
|
||||
void requestReadingSelectedFile();
|
||||
QString dragMimeType() const;
|
||||
|
||||
signals:
|
||||
void enableButtons();
|
||||
void accepted();
|
||||
void readSelectedFile(int fileId);
|
||||
|
||||
private:
|
||||
void enaDisa();
|
||||
void saveFileName(const QString &name);
|
||||
|
||||
QModelIndex selectedIndexViewFolder();
|
||||
void selectFolder();
|
||||
|
||||
protected slots:
|
||||
// folders
|
||||
void onFolderSelectionChanged(const QItemSelection & /*selected*/,
|
||||
const QItemSelection& /*deselected*/);
|
||||
void onFolderChanged(const FileManagement::Folder &data, DataModification modType);
|
||||
|
||||
// files
|
||||
FileManagement::FileContent onSelectFile();
|
||||
void onChooseFileName();
|
||||
void onFileChanged(const FileManagement::FileContent &data, DataModification modType);
|
||||
bool showFile(const FileManagement::FileContent &fc, const QString &xmlType);
|
||||
|
||||
private:
|
||||
DialogModelFolder *m_modelFolder{nullptr};
|
||||
DialogModelProxyFolder *m_proxyModelFolder{nullptr};
|
||||
DialogModelFile *m_modelFile{nullptr};
|
||||
DialogFileProxyModel *m_proxyModelFile{nullptr};
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
|
||||
Ui::LtsFileDialogWidget *m_ui{nullptr};
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
|
||||
int m_selectedFolderId{-1};
|
||||
FileManagement::FileContent m_selectedFileContent;
|
||||
|
||||
QString m_fileName;
|
||||
QVector<FileManagement::FileType> m_fileTypes;
|
||||
QString m_xmlType;
|
||||
FileDialogMode m_dialogMode;
|
||||
QVector<FileManagement::MainFolder> m_mainFolders;
|
||||
};
|
||||
|
||||
} // namespace LtsWidgets
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Test for LtsDataView and their AbstractDisplayWidgets
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-14
|
||||
*/
|
||||
|
||||
#include "lts_file_dialog.h"
|
||||
#include <QApplication>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// Init the logger
|
||||
NGL::NGLLoggerBootstrap::createNGLRootLogger("log4cxx.props", true);
|
||||
NGL::INGLLogger &m_logger = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("Test");
|
||||
STARTUP_LOG(m_logger);
|
||||
|
||||
// init dds
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(74, IDL::PartitionType::Global));
|
||||
if (!m_ddsConnector->init())
|
||||
return -1;
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
INFO_LOG(m_logger) << "create FLM dtc";
|
||||
m_dtc = FileManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
bool bRet = m_dtc->enableAll();
|
||||
|
||||
INFO_LOG(m_logger) << "create OPM dtc";
|
||||
m_opmDtc = OperatorManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
bRet &= m_opmDtc->enableUser();
|
||||
|
||||
INFO_LOG(m_logger) << "create EXM dtc";
|
||||
m_exmDtc = ExerciseManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
bRet &= m_exmDtc->enableExercise();
|
||||
bRet &= m_exmDtc->enableExercisePhase();
|
||||
|
||||
INFO_LOG(m_logger) << "bRet = " << bRet;
|
||||
|
||||
// create dialog
|
||||
LtsWidgets::LtsFileDialog *view = new LtsWidgets::LtsFileDialog();
|
||||
|
||||
// init dialog
|
||||
view->init(nullptr, m_dtc, m_opmDtc, m_exmDtc, LtsWidgets::FileDialogMode::modeOpenFile, {FileManagement::MainFolder::GlobalDocuments}, {FileManagement::FileType::Jpg}, 6, QStringLiteral("Select") );
|
||||
|
||||
view->setMinimumWidth(800);
|
||||
view->setMinimumHeight(600);
|
||||
view->resize(view->sizeHint());
|
||||
|
||||
view->show();
|
||||
|
||||
int ret = app.exec();
|
||||
|
||||
view->deleteLater();
|
||||
|
||||
SHUTDOWN_LOG(m_logger);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# CMakeLists.txt for File Dialog
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Iuliana Ojog, SLSE, 2017-07-12
|
||||
#
|
||||
|
||||
FIND_PACKAGE(KDReports REQUIRED)
|
||||
|
||||
SET(ltsReportDisplay_SRCS
|
||||
lts_report_display_widget.h
|
||||
lts_report_display_widget.cpp
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY2(WS LtsReportDisplay SHARED ${ltsReportDisplay_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(LtsReportDisplay
|
||||
PRIVATE
|
||||
LtsWidgets
|
||||
PUBLIC
|
||||
Qt6::Widgets
|
||||
KDReports::KDReports
|
||||
)
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(LtsReportDisplay
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Shows a report of combat power in form of curves
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "lts_report_display_widget.h"
|
||||
|
||||
#include <QResizeEvent>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
// Taken from KDReportsLayoutHelper.cpp START
|
||||
// (WebCMS-TES-UAE-RP 2953 Falsche Positionierung im AAR)
|
||||
QT_BEGIN_NAMESPACE
|
||||
Q_GUI_EXPORT extern int qt_defaultDpi(); // This is what QTextDocument uses...
|
||||
QT_END_NAMESPACE
|
||||
// Taken from KDReportsLayoutHelper.cpp END
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
|
||||
LtsReportDisplayWidget::LtsReportDisplayWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
// setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
// minimale Breite, danach sollte die ScrollArea einen horizontalen Scrollbar darstellen
|
||||
setMinimumWidth(400);
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
}
|
||||
|
||||
void LtsReportDisplayWidget::setReport(KDReports::Report *report)
|
||||
{
|
||||
m_report = report;
|
||||
update();
|
||||
}
|
||||
|
||||
void LtsReportDisplayWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
if (!m_report)
|
||||
{
|
||||
QWidget::paintEvent(event);
|
||||
return;
|
||||
}
|
||||
if (m_pixmap.size() != size())
|
||||
{
|
||||
QImage img(size(), QImage::Format_ARGB32);
|
||||
QPainter p(&img);
|
||||
p.fillRect(rect(), Qt::white);
|
||||
m_report->paintPage(0, p);
|
||||
p.end();
|
||||
m_pixmap = QPixmap::fromImage(img);
|
||||
}
|
||||
QPainter p(this);
|
||||
p.drawPixmap(0, 0, m_pixmap);
|
||||
p.end();
|
||||
}
|
||||
|
||||
void LtsReportDisplayWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
if (!m_report)
|
||||
return;
|
||||
qreal withPixel = size().width();
|
||||
// qreal withMM = withPixel / physicalDpiX() * 25.4;
|
||||
qreal withMM = withPixel / qt_defaultDpi() * 25.4;
|
||||
m_report->setWidthForEndlessPrinter(withMM);
|
||||
|
||||
if (!m_bNewMinSizeSlotCalled)
|
||||
{
|
||||
m_bNewMinSizeSlotCalled = true;
|
||||
QTimer::singleShot(10, this, &LtsReportDisplayWidget::setNewMinimumSize);
|
||||
}
|
||||
}
|
||||
|
||||
void LtsReportDisplayWidget::setNewMinimumSize()
|
||||
{
|
||||
m_bNewMinSizeSlotCalled = false;
|
||||
if (!m_report)
|
||||
return;
|
||||
// die neue minimale Höhe festlegen um ggf. einen vertikalen Scrollbar anzuzeigen
|
||||
QSize newSize = m_report->paperSize().toSize();
|
||||
// DEBUG_LOG(m_logger) << "old min height: " << minimumHeight() << " - new min height: " << newSize.height() << END_LOG;
|
||||
// Zur Erklärung: es kann passieren, dass die ScrollArea entscheidet, dass der vertikale Scrollbar jetzt nicht mehr nötig ist
|
||||
// dies triggert ein resize Event und demnach eine neue Breite. Dadurch verändert sich dann natürlich auch die
|
||||
// neue minimale Höhe was widerrum dazu führt, dass der Scrollbar wieder nötig ist usw.
|
||||
// deshalb eine kleine hysterese, hoffentlich reicht es so
|
||||
if (minimumHeight() >= newSize.height() && minimumHeight() - 20 <= newSize.height())
|
||||
return;
|
||||
setMinimumHeight(newSize.height());
|
||||
}
|
||||
|
||||
} // namespace LtsWidgets
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Shows a report of combat power in form of curves
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPixmap>
|
||||
|
||||
#include <KDReports/KDReportsReport>
|
||||
#include <LtsReportDisplay/ltsreportdisplay_export.h>
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
|
||||
class LTSREPORTDISPLAY_EXPORT LtsReportDisplayWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LtsReportDisplayWidget(QWidget *parent = nullptr);
|
||||
~LtsReportDisplayWidget() = default;
|
||||
|
||||
void setReport(KDReports::Report *report);
|
||||
|
||||
public slots:
|
||||
void setNewMinimumSize();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
bool m_bNewMinSizeSlotCalled{false};
|
||||
QPixmap m_pixmap;
|
||||
KDReports::Report *m_report{nullptr};
|
||||
};
|
||||
|
||||
}
|
||||
+2
-2
@@ -30,11 +30,11 @@ NGL_TARGET_LINK_LIBRARIES(advancedSymbologyXML_Gui
|
||||
situationMapGeometryModel
|
||||
advancedSymbology
|
||||
NGLLogger
|
||||
Qt5::Gui
|
||||
Qt6::Gui
|
||||
PUBLIC
|
||||
LtsWidgets
|
||||
NGLLogger
|
||||
Qt5::Core
|
||||
Qt6::Core
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(advancedSymbologyXML_Gui)
|
||||
|
||||
Reference in new issue
Block a user