Exemplo n.º 1
0
MainWidget::MainWidget(QWidget *parent,const char *name)
  :QWidget(parent,name)
{
  //
  // Read Command Options
  //
  RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdgpimon","\n");
  delete cmd;

  //
  // Set Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMaximumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());
  setMaximumHeight(sizeHint().height());

  //
  // Create Font
  //
  QFont font("helvetica",10,QFont::Normal);
  font.setPixelSize(10);
  setFont(font);
  QFont main_font("helvetica",12,QFont::Bold);
  main_font.setPixelSize(12);

  //
  // Create And Set Icon
  //
  gpi_rivendell_map=new QPixmap(rivendell_xpm);
  setIcon(*gpi_rivendell_map);

  //
  // Load Local Configs
  //
  gpi_config=new RDConfig();
  gpi_config->load();

  //
  // Open Database
  //
  gpi_db=QSqlDatabase::addDatabase(gpi_config->mysqlDriver());
  if(!gpi_db) {
    QMessageBox::warning(this,tr("Database Error"),
		    tr("Can't Connect","Unable to connect to mySQL Server!"));
    exit(0);
  }
  gpi_db->setDatabaseName(gpi_config->mysqlDbname());
  gpi_db->setUserName(gpi_config->mysqlUsername());
  gpi_db->setPassword(gpi_config->mysqlPassword());
  gpi_db->setHostName(gpi_config->mysqlHostname());
  if(!gpi_db->open()) {
    QMessageBox::warning(this,tr("Can't Connect"),
			 tr("Unable to connect to mySQL Server!"));
    gpi_db->removeDatabase(gpi_config->mysqlDbname());
    exit(0);
  }
  new RDDbHeartbeat(gpi_config->mysqlHeartbeatInterval(),this);

  //
  // RIPC Connection
  //
  gpi_ripc=new RDRipc(gpi_config->stationName());
  gpi_ripc->setIgnoreMask(true);
  connect(gpi_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
  connect(gpi_ripc,SIGNAL(gpiStateChanged(int,int,bool)),
	  this,SLOT(gpiStateChangedData(int,int,bool)));
  connect(gpi_ripc,SIGNAL(gpoStateChanged(int,int,bool)),
	  this,SLOT(gpoStateChangedData(int,int,bool)));
  connect(gpi_ripc,SIGNAL(gpiMaskChanged(int,int,bool)),
	  this,SLOT(gpiMaskChangedData(int,int,bool)));
  connect(gpi_ripc,SIGNAL(gpoMaskChanged(int,int,bool)),
	  this,SLOT(gpoMaskChangedData(int,int,bool)));
  connect(gpi_ripc,SIGNAL(gpiCartChanged(int,int,int,int)),
	  this,SLOT(gpiCartChangedData(int,int,int,int)));
  connect(gpi_ripc,SIGNAL(gpoCartChanged(int,int,int,int)),
	  this,SLOT(gpoCartChangedData(int,int,int,int)));
  gpi_ripc->connectHost("localhost",RIPCD_TCP_PORT,gpi_config->password());

  //
  // RDStation
  //
  gpi_station=new RDStation(gpi_config->stationName());

  //
  // RDMatrix;
  //
  gpi_matrix=NULL;

  //
  // Type Selector
  //
  gpi_type_box=new QComboBox(this,"gpi_type_box");
  gpi_type_box->setGeometry(80,10,120,21);
  gpi_type_box->insertItem(tr("GPI (Inputs)"));
  gpi_type_box->insertItem(tr("GPO (Outputs)"));
  QLabel *label=
    new QLabel(gpi_type_box,tr("Show:"),this,"gpi_type_label");
  label->setGeometry(20,10,55,21);
  label->setFont(main_font);
  label->setAlignment(AlignRight|AlignVCenter);
  connect(gpi_type_box,SIGNAL(activated(int)),
	  this,SLOT(matrixActivatedData(int)));

  //
  // Matrix Selector
  //
  gpi_matrix_box=new QComboBox(this,"gpi_matrix_box");
  gpi_matrix_box->setGeometry(280,10,80,21);
  for(int i=0;i<MAX_MATRICES;i++) {
    gpi_matrix_box->insertItem(QString().sprintf("%d",i));
  }
  label=new QLabel(gpi_matrix_box,tr("Matrix:"),this,"gpi_matrix_label");
  label->setGeometry(220,10,55,21);
  label->setFont(main_font);
  label->setAlignment(AlignRight|AlignVCenter);
  connect(gpi_matrix_box,SIGNAL(activated(int)),
	  this,SLOT(matrixActivatedData(int)));

  //
  // GPI Indicators
  //
  for(int i=0;i<GPIMON_ROWS;i++) {
    for(int j=0;j<GPIMON_COLS;j++) {
      gpi_labels[i*GPIMON_COLS+j]=new GpiLabel(this);
      gpi_labels[i*GPIMON_COLS+j]->setGeometry(10+64*j,40+78*i,
					       gpi_labels[i*GPIMON_COLS+j]->
					       sizeHint().width(),
					       gpi_labels[i*GPIMON_COLS+j]->
					       sizeHint().height());
    }
  }

  //
  // Up Button
  //
  gpi_up_button=
    new RDTransportButton(RDTransportButton::Up,this,"gpi_up_button");
  gpi_up_button->setGeometry(10,sizeHint().height()-60,80,50);
  connect(gpi_up_button,SIGNAL(clicked()),this,SLOT(upData()));

  //
  // Down Button
  //
  gpi_down_button=
    new RDTransportButton(RDTransportButton::Down,this,"gpi_down_button");
  gpi_down_button->setGeometry(100,sizeHint().height()-60,80,50);
  connect(gpi_down_button,SIGNAL(clicked()),this,SLOT(downData()));

  //
  // Color Key
  //
  label=new QLabel(tr("Green = ON Cart"),this);
  label->setGeometry(200,sizeHint().height()-50,300,12);
  label->setFont(main_font);
  label->setAlignment(AlignLeft|AlignVCenter);
  QPalette p=palette();
  p.setColor(QPalette::Active,QColorGroup::Foreground,darkGreen);
  p.setColor(QPalette::Inactive,QColorGroup::Foreground,darkGreen);
  p.setColor(QPalette::Disabled,QColorGroup::Foreground,darkGreen);
  label->setPalette(p);

  label=new QLabel(tr("Red = OFF Cart"),this);
  label->setGeometry(200,sizeHint().height()-32,300,12);
  label->setFont(main_font);
  label->setAlignment(AlignLeft|AlignVCenter);
  p.setColor(QPalette::Active,QColorGroup::Foreground,darkRed);
  p.setColor(QPalette::Inactive,QColorGroup::Foreground,darkRed);
  p.setColor(QPalette::Disabled,QColorGroup::Foreground,darkRed);
  label->setPalette(p);


  //
  // Close Button
  //
  gpi_close_button=new QPushButton(this,"gpi_close_button");
  gpi_close_button->setGeometry(sizeHint().width()-90,sizeHint().height()-60,
				80,50);
  gpi_close_button->setFont(main_font);
  gpi_close_button->setText(tr("&Close"));
  connect(gpi_close_button,SIGNAL(clicked()),this,SLOT(quitMainWidget()));

  //
  // Start Up Timer
  //
  QTimer *timer=new QTimer(this,"start_up_timer");
  connect(timer,SIGNAL(timeout()),this,SLOT(startUpData()));
  timer->start(GPIMON_START_UP_DELAY,true);
}
Exemplo n.º 2
0
MainWidget::MainWidget(QWidget *parent,const char *name)
  :QWidget(parent,name)
{
  //
  // HACK: Disable the Broken Custom SuSE Dialogs
  //
#ifndef WIN32
  setenv("QT_NO_KDE_INTEGRATION","1",1);
#endif  // WIN32

  //
  // Read Command Options
  //
  bool cmd_generate = false;
  bool cmd_merge_music = false;
  bool cmd_merge_traffic = false;
  QString cmd_service = NULL;
  QDate cmd_date = QDate::currentDate().addDays(1);

  RDCmdSwitch *cmd=
    new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdlogmanager","\n");
  for(unsigned i=0;i<cmd->keys();i++)
     {
     if (cmd->key(i)=="-g")
       cmd_generate = true;
     if (cmd->key(i)=="-m")
       cmd_merge_music = true;
     if (cmd->key(i)=="-t")
       cmd_merge_traffic = true;
     if (cmd->key(i)=="-s")
       if (i+1<cmd->keys())
         {
         i++;
         cmd_service = cmd->key(i);
         }
     if (cmd->key(i)=="-d")
       if (i+1<cmd->keys())
         {
         i++;
         cmd_date = QDate::currentDate().addDays(cmd->key(i).toInt());
         }
    }
  delete cmd;

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMaximumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());
  setMaximumHeight(sizeHint().height());

  //
  // Ensure that the system daemons are running
  //
#ifndef WIN32
  RDInitializeDaemons();
#endif  // WIN32

  //
  // Load Local Configs
  //
  log_config=new RDConfig();
  log_config->load();
  setCaption(tr("RDLogManager"));

  //
  // Open Database
  //
  QString err;
  log_db=RDInitDb(&err);
  if(!log_db) {
    QMessageBox::warning(this,tr("Can't Connect"),err);
    exit(0);
  }
  new RDDbHeartbeat(log_config->mysqlHeartbeatInterval(),this);

  //
  // Allocate Global Resources
  //
  rdstation_conf=new RDStation(log_config->stationName());
   
  //
  // CAE Connection
  //
#ifndef WIN32
  rdcae=new RDCae(parent,name);
  rdcae->connectHost("localhost",CAED_TCP_PORT,log_config->password());
#endif  // WIN32

  //
  // RIPC Connection
  //
  rdripc=new RDRipc(log_config->stationName());
  connect(rdripc,SIGNAL(userChanged()),this,SLOT(userData()));
  rdripc->connectHost("localhost",RIPCD_TCP_PORT,log_config->password());

  //
  // User
  //
  rduser=NULL;

  //
  // Generate Fonts
  //
  QFont default_font("Helvetica",12,QFont::Normal);
  default_font.setPixelSize(12);
  qApp->setFont(default_font);
  QFont button_font=QFont("Helvetica",12,QFont::Bold);
  button_font.setPixelSize(12);
  QFont label_font=QFont("Helvetica",12,QFont::Bold);
  label_font.setPixelSize(12);
  QFont day_font=QFont("Helvetica",12,QFont::Normal);
  day_font.setPixelSize(12);

  //
  // Create And Set Icon
  //
  log_rivendell_map=new QPixmap(rivendell_xpm);
  setIcon(*log_rivendell_map);

  //
  // Filters
  //
  event_filter=new QString();
  clock_filter=new QString();

  //
  // Title Label
  //
  QLabel *label=new QLabel(tr("RDLogManager"),this,"title_label");
  label->setGeometry(0,5,sizeHint().width(),32);
  label->setFont(label_font);
  label->setAlignment(AlignHCenter);
  label=new QLabel(tr("Select an operation:"),this,"instruction_label");
  label->setGeometry(0,25,sizeHint().width(),16);
  label->setFont(day_font);
  label->setAlignment(AlignCenter);

  //
  //  Edit Events Button
  //
  log_events_button=new QPushButton(this,"events_button");
  log_events_button->setGeometry(10,45,sizeHint().width()-20,50);
  log_events_button->setFont(button_font);
  log_events_button->setText(tr("Edit &Events"));
  connect(log_events_button,SIGNAL(clicked()),this,SLOT(eventsData()));

  //
  //  Edit Clocks Button
  //
  log_clocks_button=new QPushButton(this,"clocks_button");
  log_clocks_button->setGeometry(10,95,sizeHint().width()-20,50);
  log_clocks_button->setFont(button_font);
  log_clocks_button->setText(tr("Edit C&locks"));
  connect(log_clocks_button,SIGNAL(clicked()),this,SLOT(clocksData()));

  //
  //  Edit Grids Button
  //
  log_grids_button=new QPushButton(this,"grid_button");
  log_grids_button->setGeometry(10,145,sizeHint().width()-20,50);
  log_grids_button->setFont(button_font);
  log_grids_button->setText(tr("Edit G&rids"));
  connect(log_grids_button,SIGNAL(clicked()),this,SLOT(gridsData()));

  //
  //  Generate Logs Button
  //
  log_logs_button=new QPushButton(this,"logs_button");
  log_logs_button->setGeometry(10,195,sizeHint().width()-20,50);
  log_logs_button->setFont(button_font);
  log_logs_button->setText(tr("&Generate Logs"));
  connect(log_logs_button,SIGNAL(clicked()),this,SLOT(generateData()));

  //
  //  Generate Reports Button
  //
  log_reports_button=new QPushButton(this,"reports_button");
  log_reports_button->setGeometry(10,245,sizeHint().width()-20,50);
  log_reports_button->setFont(button_font);
  log_reports_button->setText(tr("Manage &Reports"));
  connect(log_reports_button,SIGNAL(clicked()),this,SLOT(reportsData()));

  //
  //  Close Button
  //
  log_close_button=new QPushButton(this,"close_button");
  log_close_button->setGeometry(10,sizeHint().height()-60,
				sizeHint().width()-20,50);
  log_close_button->setFont(button_font);
  log_close_button->setText(tr("&Close"));
  log_close_button->setDefault(true);
  connect(log_close_button,SIGNAL(clicked()),this,SLOT(quitMainWidget()));

  if (cmd_generate)
    {
    GenerateLog *generatelog=new GenerateLog(this,"list_grids",1,&cmd_service,&cmd_date);
    delete generatelog;
    }
  if (cmd_merge_music)
    {
    GenerateLog *generatelog=new GenerateLog(this,"list_grids",2,&cmd_service,&cmd_date);
    delete generatelog;
    }
  if (cmd_merge_traffic)
    {
    GenerateLog *generatelog=new GenerateLog(this,"list_grids",3,&cmd_service,&cmd_date);
    delete generatelog;
    }
   if (cmd_generate || cmd_merge_music ||cmd_merge_traffic )
    quitMainWidget();

#ifndef WIN32
  signal(SIGCHLD,SigHandler);
#endif  // WIN32
}
Exemplo n.º 3
0
MainWidget::MainWidget(QWidget *parent)
  :Q3MainWindow(parent)
{
  new RDApplication(RDApplication::Gui,"rdlogedit",RDLOGEDIT_USAGE);

  QString str1;
  QString str2;
  log_log_list=NULL;
  QString sql;
  RDSqlQuery *q;

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());

  //
  // Ensure that the system daemons are running
  //
#ifndef WIN32
  RDInitializeDaemons();
#endif  // WIN32

  //
  // Load Local Configs
  //
  str1=QString("RDLogEdit")+"v"+VERSION+" - "+tr("Host");
  str2=tr("User")+": ["+tr("Unknown")+"]";
  setCaption(QString().sprintf("%s: %s, %s",(const char *)str1,
			       (const char *)rda->config()->stationName(),
			       (const char *)str2));
  log_import_path=RDGetHomeDir();

#ifndef WIN32
  rda->cae()->connectHost();
#endif  // WIN32

  //
  // RIPC Connection
  //
#ifndef WIN32
  connect(rda->ripc(),SIGNAL(connected(bool)),this,SLOT(connectedData(bool)));
  connect(rda->ripc(),SIGNAL(userChanged()),this,SLOT(userData()));
  rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
#endif  // WIN32

  // 
  // Create Fonts
  //
  QFont default_font("Helvetica",12,QFont::Normal);
  default_font.setPixelSize(12);
  qApp->setFont(default_font);
  QFont button_font=QFont("Helvetica",12,QFont::Bold);
  button_font.setPixelSize(12);

  //
  // Create Icons
  //
  log_rivendell_map=new QPixmap(rivendell_xpm);
  setIcon(*log_rivendell_map);
  log_greencheckmark_map=new QPixmap(greencheckmark_xpm);
  log_redx_map=new QPixmap(redx_xpm);
  log_whiteball_map=new QPixmap(whiteball_xpm);
  log_greenball_map=new QPixmap(greenball_xpm);
  log_redball_map=new QPixmap(redball_xpm);

  //
  // User
  //
#ifndef WIN32
  //
  // Load Audio Assignments
  //
  RDSetMixerPorts(rda->config()->stationName(),rda->cae());
#else 
  rda->setUser(RD_USER_LOGIN_NAME);
#endif  // WIN32

  //
  // Service Selector
  //
  log_service_box=new QComboBox(this);
  log_service_box->setFont(default_font);
  connect(log_service_box,SIGNAL(activated(const QString &)),
	  this,SLOT(filterChangedData(const QString &)));
  log_service_box->insertItem(tr("ALL"));
  sql="select NAME from SERVICES order by NAME";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    log_service_box->insertItem(q->value(0).toString());
  }
  delete q;
  log_service_label=new QLabel(log_service_box,tr("Service")+":",this);
  log_service_label->setFont(button_font);
  log_service_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);

  //
  // Filter
  //
  log_filter_edit=new QLineEdit(this);
  log_filter_edit->setFont(default_font);
  connect(log_filter_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(filterChangedData(const QString &)));
  log_filter_label=new QLabel(log_filter_edit,tr("Filter")+":",this);
  log_filter_label->setFont(button_font);
  log_filter_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  log_filter_button=new QPushButton(tr("Clear"),this);
  log_filter_button->setFont(button_font);
  connect(log_filter_button,SIGNAL(clicked()),this,SLOT(filterClearedData()));

  //
  // Show Recent Checkbox
  //
  log_recent_check=new QCheckBox(this);
  connect(log_recent_check,SIGNAL(toggled(bool)),this,SLOT(recentData(bool)));
  log_recent_label=
    new QLabel(log_recent_check,tr("Show Only Recent Logs"),this);
  log_recent_label->setFont(button_font);

  //
  // Log List
  //
  log_log_list=new Q3ListView(this);
  log_log_list->setFont(default_font);
  log_log_list->setAllColumnsShowFocus(true);
  log_log_list->setItemMargin(5);
  connect(log_log_list,
	  SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)),
	  this,
	  SLOT(logDoubleclickedData(Q3ListViewItem *,const QPoint &,int)));
  log_log_list->addColumn("");
  log_log_list->setColumnAlignment(0,Qt::AlignCenter);
  log_log_list->addColumn(tr("LOG NAME"));
  log_log_list->setColumnAlignment(1,Qt::AlignHCenter);
  log_log_list->addColumn(tr("DESCRIPTION"));
  log_log_list->setColumnAlignment(2,Qt::AlignLeft);
  log_log_list->addColumn(tr("SERVICE"));
  log_log_list->setColumnAlignment(3,Qt::AlignLeft);
  log_log_list->addColumn(tr("MUSIC"));
  log_log_list->setColumnAlignment(4,Qt::AlignCenter);
  log_log_list->addColumn(tr("TRAFFIC"));
  log_log_list->setColumnAlignment(5,Qt::AlignCenter);
  log_log_list->addColumn(tr("TRACKS"));
  log_log_list->setColumnAlignment(6,Qt::AlignHCenter);
  log_log_list->addColumn(tr("VALID FROM"));
  log_log_list->setColumnAlignment(7,Qt::AlignHCenter);
  log_log_list->addColumn(tr("VALID TO"));
  log_log_list->setColumnAlignment(8,Qt::AlignHCenter);
  log_log_list->addColumn(tr("AUTO REFRESH"));
  log_log_list->setColumnAlignment(9,Qt::AlignHCenter);
  log_log_list->addColumn(tr("ORIGIN"));
  log_log_list->setColumnAlignment(10,Qt::AlignLeft);
  log_log_list->addColumn(tr("LAST LINKED"));
  log_log_list->setColumnAlignment(11,Qt::AlignLeft);
  log_log_list->addColumn(tr("LAST MODIFIED"));
  log_log_list->setColumnAlignment(12,Qt::AlignLeft);

  RefreshList();

  //
  // Add Button
  //
  log_add_button=new QPushButton(this);
  log_add_button->setFont(button_font);
  log_add_button->setText(tr("&Add"));
  connect(log_add_button,SIGNAL(clicked()),this,SLOT(addData()));

  //
  // Edit Button
  //
  log_edit_button=new QPushButton(this);
  log_edit_button->setFont(button_font);
  log_edit_button->setText(tr("&Edit"));
  connect(log_edit_button,SIGNAL(clicked()),this,SLOT(editData()));

  //
  // Delete Button
  //
  log_delete_button=new QPushButton(this);
  log_delete_button->setFont(button_font);
  log_delete_button->setText(tr("&Delete"));
  connect(log_delete_button,SIGNAL(clicked()),this,SLOT(deleteData()));

  //
  // Tracker Button
  //
  log_track_button=new QPushButton(this);
  log_track_button->setFont(button_font);
  log_track_button->setText(tr("Voice\n&Tracker"));
  connect(log_track_button,SIGNAL(clicked()),this,SLOT(trackData()));
#ifdef WIN32
  log_track_button->hide();
#endif

  //
  // Log Report Button
  //
  log_report_button=new QPushButton(this);
  log_report_button->setFont(button_font);
  log_report_button->setText(tr("Log\nReport"));
  connect(log_report_button,SIGNAL(clicked()),this,SLOT(reportData()));

  //
  // Close Button
  //
  log_close_button=new QPushButton(this);
  log_close_button->setFont(button_font);
  log_close_button->setText(tr("&Close"));
  connect(log_close_button,SIGNAL(clicked()),this,SLOT(quitMainWidget()));

#ifndef WIN32
  // 
  // Setup Signal Handling 
  //
  ::signal(SIGCHLD,SigHandler);
#endif  // WIN32
}
MainWidget::MainWidget(QWidget *parent)
  :QMainWindow(parent)
{
  QString str1;
  QString str2;

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());

  //
  // Load Local Configs
  //
  str1=QString("RDCastManager")+" v"+VERSION+" - "+tr("Host");
  str2=QString(tr("User: [Unknown]"));
  setCaption(QString().sprintf("%s: %s, %s",(const char *)str1,
			       (const char *)rda->config()->stationName(),
			       (const char *)str2));

  //
  // RIPC Connection
  //
#ifndef WIN32
  connect(rda->ripc(),SIGNAL(userChanged()),this,SLOT(userChangedData()));
  rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
#endif  // WIN32

  //
  // User
  //
  rda->setUser(RD_USER_LOGIN_NAME);

  // 
  // Create Fonts
  //
  QFont default_font("Helvetica",12,QFont::Normal);
  default_font.setPixelSize(12);
  qApp->setFont(default_font);
  QFont button_font=QFont("Helvetica",12,QFont::Bold);
  button_font.setPixelSize(12);

  //
  // Create Icons
  //
  cast_rivendell_map=new QPixmap(rivendell_xpm);
  setIcon(*cast_rivendell_map);
  cast_greencheckmark_map=new QPixmap(greencheckmark_xpm);
  cast_redx_map=new QPixmap(redx_xpm);

  //
  // Feed List
  //
  cast_feed_list=new RDListView(this);
  cast_feed_list->setFont(default_font);
  cast_feed_list->setAllColumnsShowFocus(true);
  cast_feed_list->setItemMargin(5);
  connect(cast_feed_list,
	  SIGNAL(doubleClicked(QListViewItem *,const QPoint &,int)),
	  this,
	  SLOT(feedDoubleclickedData(QListViewItem *,const QPoint &,int)));
  cast_feed_list->addColumn("");
  cast_feed_list->setColumnAlignment(0,Qt::AlignCenter);
  cast_feed_list->addColumn(tr("Key Name"));
  cast_feed_list->setColumnAlignment(1,Qt::AlignHCenter);
  cast_feed_list->addColumn(tr("Feed Name"));
  cast_feed_list->setColumnAlignment(2,Qt::AlignLeft);
  cast_feed_list->addColumn(tr("Description"));
  cast_feed_list->setColumnAlignment(3,Qt::AlignLeft);
  cast_feed_list->addColumn(tr("Casts"));
  cast_feed_list->setColumnAlignment(3,Qt::AlignCenter);

  //
  // Open Button
  //
  cast_open_button=new QPushButton(this);
  cast_open_button->setFont(button_font);
  cast_open_button->setText(tr("&View\nFeed"));
  connect(cast_open_button,SIGNAL(clicked()),this,SLOT(openData()));

  //
  // Close Button
  //
  cast_close_button=new QPushButton(this);
  cast_close_button->setFont(button_font);
  cast_close_button->setText(tr("&Close"));
  connect(cast_close_button,SIGNAL(clicked()),this,SLOT(quitMainWidget()));
}
Exemplo n.º 5
0
MainWidget::MainWidget(QWidget *parent,const char *name)
  :QWidget(parent,name)
{
  QString sql;
  QSqlQuery *q;

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMaximumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());
  setMaximumHeight(sizeHint().height());

  //
  // Create Fonts
  //
  QFont font=QFont("Helvetica",12,QFont::Bold);
  font.setPixelSize(12);
  QFont default_font("Helvetica",12,QFont::Normal);
  default_font.setPixelSize(12);
  QFont title_font=QFont("Helvetica",16,QFont::Bold);
  title_font.setPixelSize(16);
  qApp->setFont(default_font);

  //
  // Create And Set Icon
  //
  mdb_callcommander_map=new QPixmap(callcommander_xpm);
  setIcon(*mdb_callcommander_map);

  //
  // Reload Socket
  //
  admin_reload_socket=new Q3SocketDevice(Q3SocketDevice::Datagram);

  //
  // Load Configs
  //
  admin_config=new MldConfig();
  admin_config->load();

  //
  // Open Database
  //

  /*
  QStringList drivers=QSqlDatabase::drivers();
  for(unsigned i=0;i<drivers.size();i++) {
      QMessageBox::information(this,"DRIVERS",drivers[i]);
  }
  */
  OpenDb(admin_config->mysqlDbname(),admin_config->mysqlUsername(),
	 admin_config->mysqlPassword(),admin_config->mysqlHostname(),true);

  //
  // Log In
  //
  QString password;
  Login *login=new Login(&admin_loginname,&password,true,this);
  if(login->exec()!=0) {
    exit(0);
  }
  sql=QString("select LOGIN_NAME from USERS where ")+
    "(LOGIN_NAME=\""+EscapeString(admin_loginname)+"\")&&"+
    "(PASSWORD=\""+EscapeString(password)+"\")";
  q=new QSqlQuery(sql);
  if(q->size()<=0) {
    QMessageBox::information(this,"Login Failed","Invalid Login!");
    exiting=true;
    delete q;
  }
  else {
    delete q;
    sql=
      QString().sprintf("select ADMIN_PRIV from USERS where LOGIN_NAME=\"%s\"",
			(const char *)admin_loginname);
    q=new QSqlQuery(sql);
    q->first();
    if(q->value(0).toString().lower()!="y") {
      QMessageBox::information(this,"Login Failed",
		      "This user does not have \nadministrative permissions!");
      exiting=true;
    }
    delete q;
    setCaption(QString().sprintf("Call Administrator - User: %s",
				 (const char *)admin_loginname));
  }

  //
  // Title
  //
  QLabel *label=new QLabel("CallCommander",this,"main_title_label");
  label->setGeometry(10,5,sizeHint().width()-20,20);
  label->setFont(title_font);
  label->setAlignment(Qt::AlignCenter);

  label=new QLabel("Database Administrator",this,"sub_title_label");
  label->setGeometry(10,25,sizeHint().width()-20,20);
  label->setFont(default_font);
  label->setAlignment(Qt::AlignCenter);

  //
  // Manage Users Button
  //
  QPushButton *button=new QPushButton(this,"users_button");
  button->setGeometry(10,50,120,60);
  button->setFont(font);
  button->setText("Manage\n&Users");
  connect(button,SIGNAL(clicked()),this,SLOT(manageUsersData()));

  //
  // Manage Shows Button
  //
  button=new QPushButton(this,"shows_button");
  button->setGeometry(150,50,120,60);
  button->setFont(font);
  button->setText("Manage\n&Shows");
  connect(button,SIGNAL(clicked()),this,SLOT(manageShowsData()));

  //
  // Manage Directory Button
  //
  button=new QPushButton(this,"directory_button");
  button->setGeometry(10,120,120,60);
  button->setFont(font);
  button->setText("Manage\n&Directory");
  connect(button,SIGNAL(clicked()),this,SLOT(manageDirectoryData()));

  //
  // CallerID Source Button
  //
  button=new QPushButton(this,"callerid_button");
  button->setGeometry(150,120,120,60);
  button->setFont(font);
  button->setText("Manage &CallerID\nSources");
  connect(button,SIGNAL(clicked()),this,SLOT(manageCallerIdData()));

  //
  // Manage Virtual Systems Vutton
  //
  button=new QPushButton(this,"virtual_button");
  button->setGeometry(10,190,120,60);
  button->setFont(font);
  button->setText("Manage &Virtual\nSystems");
  connect(button,SIGNAL(clicked()),this,SLOT(manageVirtualData()));

  //
  // Logic Modules Button
  //
  button=new QPushButton(this,"logic_modules_button");
  button->setGeometry(150,190,120,60);
  button->setFont(font);
  button->setText("Manage &Logic\nModules");
  connect(button,SIGNAL(clicked()),this,SLOT(manageLogicModuleData()));

  //
  // System Info Button
  //
  button=new QPushButton(this,"sysinfo_button");
  button->setGeometry(80,260,120,60);
  button->setFont(font);
  button->setText("System\n&Info");
  connect(button,SIGNAL(clicked()),this,SLOT(showInfoData()));

  //
  // Quit Button
  //
  button=new QPushButton(this,"quit_button");
  button->setGeometry(10,sizeHint().height()-70,sizeHint().width()-20,60);
  button->setFont(font);
  button->setText("&Quit");
  connect(button,SIGNAL(clicked()),this,SLOT(quitMainWidget()));
}