mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2026-01-12 07:35:55 +01:00
2018-02-06 Fred Gleason <fredg@paravelsystems.com>
* Refactored the RDListLogs class to use RDApplication. * Converted rdadmin(1) to use RDApplication.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Select a Rivendell Log
|
||||
//
|
||||
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2004,2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@@ -20,15 +20,16 @@
|
||||
|
||||
#include <qpushbutton.h>
|
||||
#include <qdatetime.h>
|
||||
#include <rddb.h>
|
||||
#include <rdescape_string.h>
|
||||
#include <rdlist_logs.h>
|
||||
|
||||
#include "rdapplication.h"
|
||||
#include "rddb.h"
|
||||
#include "rdescape_string.h"
|
||||
#include "rdlist_logs.h"
|
||||
|
||||
RDListLogs::RDListLogs(QString *logname,RDLogFilter::FilterMode mode,
|
||||
RDUser *user,RDConfig *config,QWidget *parent)
|
||||
QWidget *parent)
|
||||
: QDialog(parent,"",true)
|
||||
{
|
||||
list_config=config;
|
||||
list_logname=logname;
|
||||
|
||||
//
|
||||
@@ -50,7 +51,7 @@ RDListLogs::RDListLogs(QString *logname,RDLogFilter::FilterMode mode,
|
||||
//
|
||||
// Log Filter
|
||||
//
|
||||
list_filter_widget=new RDLogFilter(mode,user,config,this);
|
||||
list_filter_widget=new RDLogFilter(mode,this);
|
||||
connect(list_filter_widget,SIGNAL(filterChanged(const QString &)),
|
||||
this,SLOT(filterChangedData(const QString &)));
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Select a Rivendell Log
|
||||
//
|
||||
// (C) Copyright 2007,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2007,2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// The RDListLogs class creates a basic dialog that displays a list of logs
|
||||
// (log name, description, and service) and allows the user to select one. If
|
||||
@@ -26,21 +26,18 @@
|
||||
#ifndef RDLIST_LOGS_H
|
||||
#define RDLIST_LOGS_H
|
||||
|
||||
#include <qsqldatabase.h>
|
||||
#include <qdialog.h>
|
||||
#include <qlistview.h>
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <rdlogfilter.h>
|
||||
#include <rduser.h>
|
||||
|
||||
class RDListLogs : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RDListLogs(QString *logname,RDLogFilter::FilterMode mode,
|
||||
RDUser *user,RDConfig *config,QWidget *parent=0);
|
||||
RDListLogs(QString *logname,RDLogFilter::FilterMode mode,QWidget *parent=0);
|
||||
QSize sizeHint() const;
|
||||
QSizePolicy sizePolicy() const;
|
||||
|
||||
@@ -58,7 +55,6 @@ class RDListLogs : public QDialog
|
||||
void RefreshList();
|
||||
QListView *list_log_list;
|
||||
QString *list_logname;
|
||||
RDConfig *list_config;
|
||||
QPushButton *list_ok_button;
|
||||
QPushButton *list_cancel_button;
|
||||
RDLogFilter *list_filter_widget;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Filter widget for picking Rivendell logs.
|
||||
//
|
||||
// (C) Copyright 2017 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2017-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@@ -18,13 +18,13 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include "rdapplication.h"
|
||||
#include "rddb.h"
|
||||
#include "rd.h"
|
||||
#include "rdescape_string.h"
|
||||
#include "rdlogfilter.h"
|
||||
|
||||
RDLogFilter::RDLogFilter(RDLogFilter::FilterMode mode,RDUser *user,
|
||||
RDConfig *config,QWidget *parent)
|
||||
RDLogFilter::RDLogFilter(RDLogFilter::FilterMode mode,QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QString sql;
|
||||
@@ -64,15 +64,13 @@ RDLogFilter::RDLogFilter(RDLogFilter::FilterMode mode,RDUser *user,
|
||||
break;
|
||||
|
||||
case RDLogFilter::UserFilter:
|
||||
if(user!=NULL) {
|
||||
setUser(user);
|
||||
}
|
||||
changeUser();
|
||||
break;
|
||||
|
||||
case RDLogFilter::StationFilter:
|
||||
filter_service_box->insertItem(tr("ALL"));
|
||||
sql=QString("select SERVICE_NAME from SERVICE_PERMS where ")+
|
||||
"STATION_NAME=\""+RDEscapeString(config->stationName())+"\"";
|
||||
"STATION_NAME=\""+RDEscapeString(rda->config()->stationName())+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
filter_service_box->insertItem(q->value(0).toString());
|
||||
@@ -167,19 +165,22 @@ QString RDLogFilter::whereSql() const
|
||||
}
|
||||
|
||||
|
||||
void RDLogFilter::setUser(RDUser *user)
|
||||
void RDLogFilter::changeUser()
|
||||
{
|
||||
filter_service_box->clear();
|
||||
filter_service_box->insertItem(tr("ALL"));
|
||||
QString sql=QString("select SERVICE_NAME from USER_SERVICE_PERMS where ")+
|
||||
"USER_NAME=\""+RDEscapeString(user->name())+"\"";
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
filter_service_box->insertItem(q->value(0).toString());
|
||||
if(filter_filter_mode==RDLogFilter::UserFilter) {
|
||||
filter_service_box->clear();
|
||||
filter_service_box->insertItem(tr("ALL"));
|
||||
QString sql=QString("select SERVICE_NAME from USER_SERVICE_PERMS where ")+
|
||||
"USER_NAME=\""+RDEscapeString(rda->user()->name())+"\"";
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
filter_service_box->insertItem(q->value(0).toString());
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
|
||||
|
||||
void RDLogFilter::filterChangedData(const QString &str)
|
||||
{
|
||||
emit filterChanged(whereSql());
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Filter widget for picking Rivendell logs.
|
||||
//
|
||||
// (C) Copyright 2017 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2017-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@@ -29,20 +29,19 @@
|
||||
#include <qstringlist.h>
|
||||
#include <qwidget.h>
|
||||
|
||||
#include <rdconfig.h>
|
||||
#include <rduser.h>
|
||||
|
||||
class RDLogFilter : public QWidget
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
enum FilterMode {NoFilter=0,UserFilter=1,StationFilter=2};
|
||||
RDLogFilter(FilterMode mode,RDUser *user,RDConfig *config,QWidget *parent=0);
|
||||
RDLogFilter(FilterMode mode,QWidget *parent=0);
|
||||
~RDLogFilter();
|
||||
QSize sizeHint() const;
|
||||
QSizePolicy sizePolicy() const;
|
||||
QString whereSql() const;
|
||||
void setUser(RDUser *user);
|
||||
|
||||
public slots:
|
||||
void changeUser();
|
||||
|
||||
signals:
|
||||
void filterChanged(const QString &where_sql);
|
||||
|
||||
Reference in New Issue
Block a user