mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#include "commonview.h"
|
|
#include <QFile>
|
|
#include <QMessageBox>
|
|
|
|
|
|
CommonView::CommonView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
|
|
QWidget(parent),
|
|
connectorToServer(connectorToServer),
|
|
treeWidget(nullptr),
|
|
typeView(type),
|
|
archiveVisible(false),
|
|
notLoggedInVisible(false),
|
|
adminMode(false),
|
|
authComplited(false),
|
|
lastCurrentID(0),
|
|
typeObject(TypeObject::objInstructor)
|
|
{
|
|
treeWidget = new QTreeWidget();
|
|
|
|
treeWidget->setIconSize(QSize(20, 20));
|
|
treeWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
|
|
|
|
updateMyStyleSheet();
|
|
}
|
|
|
|
void CommonView::setItemColorArchive(QTreeWidgetItem *item)
|
|
{
|
|
setItemColor(item,QColor(250, 250, 150));
|
|
}
|
|
|
|
void CommonView::setItemColorNoArchive(QTreeWidgetItem *item)
|
|
{
|
|
setItemColor(item,QColor(255, 255, 255));
|
|
}
|
|
|
|
void CommonView::setItemColor(QTreeWidgetItem *item, QColor color)
|
|
{
|
|
for (int i = 0; i < item->columnCount(); i++)
|
|
item->setBackground(i, color);
|
|
}
|
|
|
|
void CommonView::updateMyStyleSheet()
|
|
{
|
|
QString styleSheet = loadStyleSheet();
|
|
styleSheet = styleSheet.replace("\n", "");
|
|
treeWidget->setStyleSheet(styleSheet);
|
|
|
|
QString style = treeWidget->styleSheet();
|
|
int i = 0;
|
|
}
|
|
|
|
QString CommonView::loadStyleSheet()
|
|
{
|
|
QString fileName = "./styleSheetTreeWidget.css";
|
|
QFile styleSheetTreeWidgetFile(fileName);
|
|
if (!styleSheetTreeWidgetFile.open(QFile::ReadOnly | QFile::Text))
|
|
{
|
|
QMessageBox::critical(this, tr("Attention!"), tr("The file could not be opened ") + fileName);
|
|
return QStringLiteral("");
|
|
}
|
|
else
|
|
{
|
|
QByteArray byteArray = styleSheetTreeWidgetFile.readAll();
|
|
styleSheetTreeWidgetFile.close();
|
|
|
|
QString style = byteArray;
|
|
return style;
|
|
}
|
|
}
|