SensorLogger::SensorLogger( QWidget *parent, const QString& title, SharedSettings *workSheetSettings ) : KSGRD::SensorDisplay( parent, title, workSheetSettings ) { mModel = new LogSensorModel( this ); mModel->setForegroundColor( KSGRD::Style->firstForegroundColor() ); mModel->setBackgroundColor( KSGRD::Style->backgroundColor() ); mModel->setAlarmColor( KSGRD::Style->alarmColor() ); QLayout *layout = new QHBoxLayout(this); mView = new LogSensorView( this ); layout->addWidget(mView); setLayout(layout); mView->header()->setStretchLastSection( true ); mView->setRootIsDecorated( false ); mView->setItemsExpandable( false ); mView->setModel( mModel ); setPlotterWidget( mView ); connect( mView, SIGNAL(contextMenuRequest(QModelIndex,QPoint)), this, SLOT(contextMenuRequest(QModelIndex,QPoint)) ); QPalette palette = mView->palette(); palette.setColor( QPalette::Base, KSGRD::Style->backgroundColor() ); mView->setPalette( palette ); setTitle( i18n( "Sensor Logger" ) ); setMinimumSize( 50, 25 ); }
LogFile::LogFile(QWidget *parent, const QString& title, SharedSettings *workSheetSettings) : KSGRD::SensorDisplay(parent, title, workSheetSettings) { kDebug() << "Making sensor logger"; logFileID= 0; lfs = NULL; QLayout *layout = new QHBoxLayout(this); monitor = new QListWidget(this); layout->addWidget(monitor); setLayout(layout); setMinimumSize(50, 25); monitor->setContextMenuPolicy( Qt::CustomContextMenu ); connect(monitor, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showContextMenu(QPoint))); setPlotterWidget(monitor); }
bool ProcessController::addSensor(const QString& hostName, const QString& sensorName, const QString& sensorType, const QString& title) { if (sensorType != "table") return false; QStackedLayout *layout = new QStackedLayout(this); mProcessList = new KSysGuardProcessList(this, hostName); mProcessList->setUpdateIntervalMSecs(0); //we will call updateList() manually mProcessList->setContentsMargins(0,0,0,0); mProcessList->setScriptingEnabled(true); addActions(mProcessList->actions()); connect(mProcessList, &KSysGuardProcessList::updated, this, &ProcessController::updated); connect(mProcessList, &KSysGuardProcessList::processListChanged, this, &ProcessController::processListChanged); mProcessList->setContextMenuPolicy( Qt::CustomContextMenu ); connect(mProcessList, &KSysGuardProcessList::customContextMenuRequested, this, &ProcessController::showContextMenu); layout->addWidget(mProcessList); /** To use a remote sensor, we need to drill down through the layers, to connect to the remote processes. Then connect to its signals and slots. * It's horrible I know :( */ if(!hostName.isEmpty() && hostName != "localhost") { KSysGuard::Processes *processes = mProcessList->processModel()->processController(); mProcesses = processes; if(processes) { connect(processes, &KSysGuard::Processes::runCommand, this, &ProcessController::runCommand); } } setPlotterWidget(mProcessList); QTimer::singleShot(0, mProcessList->filterLineEdit(), SLOT(setFocus())); registerSensor(new KSGRD::SensorProperties(hostName, sensorName, sensorType, title)); /* This just triggers the first communication. The full set of * requests are send whenever the sensor reconnects (detected in * sensorError(). */ sensors().at(0)->setIsOk(true); //Assume it is okay from the start setSensorOk(sensors().at(0)->isOk()); emit processListChanged(); return true; }
ListView::ListView(QWidget* parent, const QString& title, SharedSettings *workSheetSettings) : KSGRD::SensorDisplay(parent, title, workSheetSettings) { QVBoxLayout *layout = new QVBoxLayout(this); mUnits = UnitsKB; mView = new QTreeView(this); // QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); // proxyModel->setSourceModel(&mModel); mView->setModel(&mModel); mModel.setSortRole(Qt::UserRole); layout->addWidget(mView); this->setLayout(layout); mView->setContextMenuPolicy( Qt::CustomContextMenu ); mView->header()->setContextMenuPolicy( Qt::CustomContextMenu ); connect(mView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showContextMenu(QPoint))); connect(mView->header(), SIGNAL(customContextMenuRequested(QPoint)), SLOT(showColumnContextMenu(QPoint))); mView->setAlternatingRowColors(true); mView->header()->setMovable(true); mView->setSelectionMode( QAbstractItemView::NoSelection ); mView->setUniformRowHeights(true); mView->setRootIsDecorated(false); mView->header()->setSortIndicatorShown(true); mView->header()->setClickable(true); mView->setSortingEnabled(true); /* QPalette palette; palette.setColor(backgroundRole(), KSGRD::Style->backgroundColor()); setPalette(palette);*/ setMinimumSize(50, 25); setPlotterWidget(mView); setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); mView->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); }