mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-25 08:58:13 +02:00
2021-02-15 Fred Gleason <fredg@paravelsystems.com>
* Refactored the 'Rivendell Services' dialog to use the model based API. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
edbb464dee
commit
0c5f48290a
@ -21155,3 +21155,6 @@
|
||||
* Removed the 'Q3RangeControl' dependency from 'RDSlider'.
|
||||
2021-02-15 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Removed the 'Q3ListBox' dependency from 'RDListSelector'.
|
||||
2021-02-15 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Refactored the 'Rivendell Services' dialog to use the model
|
||||
based API.
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Service Picker dialog
|
||||
//
|
||||
// (C) Copyright 2012-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2012-2021 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
|
||||
@ -35,9 +35,18 @@ RDListSvcs::RDListSvcs(const QString &caption,QWidget *parent)
|
||||
//
|
||||
// Services
|
||||
//
|
||||
edit_svc_list=new Q3ListBox(this);
|
||||
connect(edit_svc_list,SIGNAL(doubleClicked(Q3ListBoxItem *)),
|
||||
this,SLOT(doubleClickedData(Q3ListBoxItem *)));
|
||||
edit_svc_view=new RDTableView(this);
|
||||
edit_svc_model=new RDServiceListModel(false,this);
|
||||
edit_svc_model->setFont(font());
|
||||
edit_svc_model->setPalette(palette());
|
||||
edit_svc_view->setModel(edit_svc_model);
|
||||
for(int i=2;i<edit_svc_model->columnCount();i++) {
|
||||
edit_svc_view->hideColumn(i);
|
||||
}
|
||||
connect(edit_svc_model,SIGNAL(modelReset()),
|
||||
edit_svc_view,SLOT(resizeColumnsToContents()));
|
||||
connect(edit_svc_view,SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
this,SLOT(cartDoubleClickedData(const QModelIndex &)));
|
||||
|
||||
//
|
||||
// Ok Button
|
||||
@ -77,26 +86,13 @@ QSizePolicy RDListSvcs::sizePolicy() const
|
||||
|
||||
int RDListSvcs::exec(QString *svcname)
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
edit_svcname=svcname;
|
||||
edit_svc_list->clear();
|
||||
sql="select NAME from SERVICES order by NAME";
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
edit_svc_list->insertItem(q->value(0).toString());
|
||||
if(q->value(0).toString()==*edit_svcname) {
|
||||
edit_svc_list->setCurrentItem(edit_svc_list->count()-1);
|
||||
}
|
||||
}
|
||||
delete q;
|
||||
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
|
||||
void RDListSvcs::doubleClickedData(Q3ListBoxItem *item)
|
||||
void RDListSvcs::doubleClickedData(const QModelIndex &index)
|
||||
{
|
||||
okData();
|
||||
}
|
||||
@ -104,9 +100,13 @@ void RDListSvcs::doubleClickedData(Q3ListBoxItem *item)
|
||||
|
||||
void RDListSvcs::okData()
|
||||
{
|
||||
if(edit_svc_list->currentItem()>=0) {
|
||||
*edit_svcname=edit_svc_list->currentText();
|
||||
QModelIndexList rows=edit_svc_view->selectionModel()->selectedRows();
|
||||
|
||||
if(rows.size()!=1) {
|
||||
return;
|
||||
}
|
||||
*edit_svcname=edit_svc_model->serviceName(rows.first());
|
||||
|
||||
done(0);
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ void RDListSvcs::cancelData()
|
||||
|
||||
void RDListSvcs::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
edit_svc_list->setGeometry(10,10,size().width()-20,size().height()-80);
|
||||
edit_svc_view->setGeometry(10,10,size().width()-20,size().height()-80);
|
||||
edit_ok_button->setGeometry(size().width()-180,size().height()-60,80,50);
|
||||
edit_cancel_button->setGeometry(size().width()-90,size().height()-60,80,50);
|
||||
}
|
||||
|
@ -21,10 +21,11 @@
|
||||
#ifndef RDLISTSVCS_H
|
||||
#define RDLISTSVCS_H
|
||||
|
||||
#include <q3listbox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <rddialog.h>
|
||||
#include <rdservicelistmodel.h>
|
||||
#include <rdtableview.h>
|
||||
|
||||
class RDListSvcs : public RDDialog
|
||||
{
|
||||
@ -39,7 +40,7 @@ class RDListSvcs : public RDDialog
|
||||
int exec(QString *svcname);
|
||||
|
||||
private slots:
|
||||
void doubleClickedData(Q3ListBoxItem *item);
|
||||
void doubleClickedData(const QModelIndex &index);
|
||||
void okData();
|
||||
void cancelData();
|
||||
|
||||
@ -47,7 +48,8 @@ class RDListSvcs : public RDDialog
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
private:
|
||||
Q3ListBox *edit_svc_list;
|
||||
RDTableView *edit_svc_view;
|
||||
RDServiceListModel *edit_svc_model;
|
||||
QString *edit_svcname;
|
||||
QPushButton *edit_ok_button;
|
||||
QPushButton *edit_cancel_button;
|
||||
|
Loading…
x
Reference in New Issue
Block a user