mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-08-16 08:34:12 +02:00
2021-01-17 Fred Gleason <fredg@paravelsystems.com>
* Restore support for cart notes in rdlibrary(1). * Added support for cart notes in the 'RDCartDialog' dialog. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
df749a0f70
commit
d18cfa89e5
@ -20813,3 +20813,6 @@
|
||||
'RDCartFilter::groupFilter()' and 'RDCartFilter::typeFilter()'
|
||||
methods.
|
||||
* Refactored 'RDCartDialog' to use the model-based API.
|
||||
2021-01-17 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Restore support for cart notes in rdlibrary(1).
|
||||
* Added support for cart notes in the 'RDCartDialog' dialog.
|
||||
|
@ -79,7 +79,7 @@ RDCartDialog::RDCartDialog(QString *filter,QString *group,QString *schedcode,
|
||||
//
|
||||
// Cart Filter
|
||||
//
|
||||
cart_cart_filter=new RDCartFilter(this);
|
||||
cart_cart_filter=new RDCartFilter(false,this);
|
||||
cart_cart_filter->setUserIsAdmin(user_is_admin);
|
||||
connect(rda,SIGNAL(userChanged()),cart_cart_filter,SLOT(changeUser()));
|
||||
|
||||
@ -96,12 +96,13 @@ RDCartDialog::RDCartDialog(QString *filter,QString *group,QString *schedcode,
|
||||
cart_cart_model->setFont(font());
|
||||
cart_cart_model->setPalette(palette());
|
||||
cart_cart_view->setModel(cart_cart_model);
|
||||
connect(cart_cart_filter,SIGNAL(filterChanged(const QString &)),
|
||||
cart_cart_model,SLOT(setFilterSql(const QString &)));
|
||||
cart_cart_filter->setModel(cart_cart_model);
|
||||
// connect(cart_cart_filter,SIGNAL(filterChanged(const QString &)),
|
||||
// cart_cart_model,SLOT(setFilterSql(const QString &)));
|
||||
connect(cart_cart_model,SIGNAL(modelReset()),this,SLOT(modelResetData()));
|
||||
|
||||
connect(cart_cart_model,SIGNAL(rowCountChanged(int)),
|
||||
cart_cart_filter,SLOT(setMatchCount(int)));
|
||||
// connect(cart_cart_model,SIGNAL(rowCountChanged(int)),
|
||||
// cart_cart_filter,SLOT(setMatchCount(int)));
|
||||
connect(cart_cart_view,SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
this,SLOT(cartDoubleClickedData(const QModelIndex &)));
|
||||
connect(cart_cart_view->selectionModel(),
|
||||
|
@ -25,11 +25,13 @@
|
||||
#include "rdcartfilter.h"
|
||||
#include "rdescape_string.h"
|
||||
|
||||
RDCartFilter::RDCartFilter(QWidget *parent)
|
||||
RDCartFilter::RDCartFilter(bool show_drag_box,QWidget *parent)
|
||||
: RDWidget(parent)
|
||||
{
|
||||
d_show_cart_type=RDCart::All;
|
||||
d_user_is_admin=false;
|
||||
d_model=NULL;
|
||||
d_show_drag_box=show_drag_box;
|
||||
|
||||
d_filter_edit=new QLineEdit(this);
|
||||
d_filter_label=new QLabel(d_filter_edit,tr("Filter:"),this);
|
||||
@ -112,7 +114,7 @@ RDCartFilter::RDCartFilter(QWidget *parent)
|
||||
d_allowdrag_label->setAlignment(Qt::AlignVCenter|Qt::AlignLeft);
|
||||
connect(d_allowdrag_box,SIGNAL(stateChanged(int)),
|
||||
this,SLOT(dragsChangedData(int)));
|
||||
if(!rda->station()->enableDragdrop()) {
|
||||
if((!d_show_drag_box)||(!rda->station()->enableDragdrop())) {
|
||||
d_allowdrag_box->hide();
|
||||
d_allowdrag_label->hide();
|
||||
}
|
||||
@ -367,6 +369,23 @@ void RDCartFilter::setUserIsAdmin(bool state)
|
||||
}
|
||||
|
||||
|
||||
RDLibraryModel *RDCartFilter::model() const
|
||||
{
|
||||
return d_model;
|
||||
}
|
||||
|
||||
|
||||
void RDCartFilter::setModel(RDLibraryModel *model)
|
||||
{
|
||||
connect(this,SIGNAL(filterChanged(const QString &)),
|
||||
model,SLOT(setFilterSql(const QString &)));
|
||||
connect(d_shownotes_box,SIGNAL(stateChanged(int)),
|
||||
model,SLOT(setShowNotes(int)));
|
||||
connect(model,SIGNAL(rowCountChanged(int)),this,SLOT(setMatchCount(int)));
|
||||
model->setShowNotes(d_shownotes_box->isChecked());
|
||||
}
|
||||
|
||||
|
||||
void RDCartFilter::setFilterText(const QString &str)
|
||||
{
|
||||
d_filter_edit->setText(str);
|
||||
@ -385,12 +404,6 @@ void RDCartFilter::setSelectedGroup(const QString &grpname)
|
||||
}
|
||||
|
||||
|
||||
void RDCartFilter::setMatchCount(int matches)
|
||||
{
|
||||
d_matches_edit->setText(QString().sprintf("%d",matches));
|
||||
}
|
||||
|
||||
|
||||
void RDCartFilter::changeUser()
|
||||
{
|
||||
QString sql;
|
||||
@ -438,6 +451,12 @@ void RDCartFilter::filterChangedData(const QString &str)
|
||||
}
|
||||
|
||||
|
||||
void RDCartFilter::setMatchCount(int matches)
|
||||
{
|
||||
d_matches_edit->setText(QString().sprintf("%d",matches));
|
||||
}
|
||||
|
||||
|
||||
void RDCartFilter::searchClickedData()
|
||||
{
|
||||
d_search_button->setDisabled(true);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include <rdlibrarymodel.h>
|
||||
#include <rdprofile.h>
|
||||
#include <rdwidget.h>
|
||||
|
||||
@ -35,7 +36,7 @@ class RDCartFilter : public RDWidget
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
RDCartFilter(QWidget *parent=0);
|
||||
RDCartFilter(bool show_drag_box,QWidget *parent=0);
|
||||
~RDCartFilter();
|
||||
QSize sizeHint() const;
|
||||
QSizePolicy sizePolicy() const;
|
||||
@ -52,14 +53,15 @@ class RDCartFilter : public RDWidget
|
||||
void setLimitSearch(bool state);
|
||||
bool userIsAdmin() const;
|
||||
void setUserIsAdmin(bool state);
|
||||
RDLibraryModel *model() const;
|
||||
static QString phraseFilter(const QString &phrase,bool incl_cuts);
|
||||
static QString groupFilter(const QString &group,const QStringList &groups);
|
||||
static QString typeFilter(bool incl_audio,bool incl_macro,RDCart::Type mask);
|
||||
|
||||
public slots:
|
||||
void setModel(RDLibraryModel *model);
|
||||
void setFilterText(const QString &str);
|
||||
void setSelectedGroup(const QString &grpname);
|
||||
void setMatchCount(int matches);
|
||||
void changeUser();
|
||||
|
||||
signals:
|
||||
@ -68,6 +70,7 @@ class RDCartFilter : public RDWidget
|
||||
void dragEnabledChanged(bool state);
|
||||
|
||||
private slots:
|
||||
void setMatchCount(int matches);
|
||||
void filterChangedData(const QString &str);
|
||||
void searchClickedData();
|
||||
void clearClickedData();
|
||||
@ -80,6 +83,7 @@ class RDCartFilter : public RDWidget
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
private:
|
||||
RDLibraryModel *d_model;
|
||||
QLineEdit *d_filter_edit;
|
||||
QLabel *d_filter_label;
|
||||
QComboBox *d_group_box;
|
||||
@ -94,6 +98,7 @@ class RDCartFilter : public RDWidget
|
||||
QPushButton *d_clear_button;
|
||||
QCheckBox *d_allowdrag_box;
|
||||
QLabel *d_allowdrag_label;
|
||||
bool d_show_drag_box;
|
||||
QCheckBox *d_showaudio_check;
|
||||
QLabel *d_showaudio_label;
|
||||
QCheckBox *d_showmacro_check;
|
||||
|
@ -28,6 +28,7 @@ RDLibraryModel::RDLibraryModel(QObject *parent)
|
||||
d_log_icons=new RDLogIcons();
|
||||
d_font_metrics=NULL;
|
||||
d_bold_font_metrics=NULL;
|
||||
d_show_notes=false;
|
||||
|
||||
//
|
||||
// Column Attributes
|
||||
@ -220,6 +221,11 @@ QVariant RDLibraryModel::data(const QModelIndex &index,int role) const
|
||||
case Qt::DisplayRole:
|
||||
return d_cut_texts.at(index.internalId()-1).at(row).at(col);
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
if(d_show_notes) {
|
||||
return d_notes.at(index.internalId()-1);
|
||||
}
|
||||
|
||||
case Qt::TextAlignmentRole:
|
||||
return d_alignments.at(col);
|
||||
|
||||
@ -251,6 +257,11 @@ QVariant RDLibraryModel::data(const QModelIndex &index,int role) const
|
||||
}
|
||||
return d_font;
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
if(d_show_notes) {
|
||||
return d_notes.at(row);
|
||||
}
|
||||
|
||||
case Qt::TextColorRole:
|
||||
if(col==1) {
|
||||
return d_group_colors.value(d_texts.at(row).at(1).toString());
|
||||
@ -356,6 +367,7 @@ QModelIndex RDLibraryModel::addCart(unsigned cartnum)
|
||||
list_list.push_back(list);
|
||||
d_icons.insert(offset,list);
|
||||
d_texts.insert(offset,list);
|
||||
d_notes.insert(offset,QVariant());
|
||||
d_cart_numbers.insert(offset,0);
|
||||
d_cut_texts.insert(offset,list_list);
|
||||
d_background_colors.insert(offset,QVariant());
|
||||
@ -383,6 +395,7 @@ void RDLibraryModel::removeCart(unsigned cartnum)
|
||||
beginRemoveRows(QModelIndex(),i,i);
|
||||
|
||||
d_texts.removeAt(i);
|
||||
d_notes.removeAt(i);
|
||||
d_cart_numbers.removeAt(i);
|
||||
d_cut_texts.removeAt(i);
|
||||
d_background_colors.removeAt(i);
|
||||
@ -418,6 +431,18 @@ void RDLibraryModel::refreshCart(unsigned cartnum)
|
||||
}
|
||||
|
||||
|
||||
bool RDLibraryModel::showNotes() const
|
||||
{
|
||||
return d_show_notes;
|
||||
}
|
||||
|
||||
|
||||
void RDLibraryModel::setShowNotes(int state)
|
||||
{
|
||||
d_show_notes=state;
|
||||
}
|
||||
|
||||
|
||||
void RDLibraryModel::setFilterSql(const QString &sql)
|
||||
{
|
||||
updateModel(sql);
|
||||
@ -462,9 +487,10 @@ void RDLibraryModel::updateModel(const QString &filter_sql)
|
||||
|
||||
sql=sqlFields()+
|
||||
filter_sql;
|
||||
printf("SQL: %s\n",sql.toUtf8().constData());
|
||||
// printf("SQL: %s\n",sql.toUtf8().constData());
|
||||
beginResetModel();
|
||||
d_texts.clear();
|
||||
d_notes.clear();
|
||||
d_cart_numbers.clear();
|
||||
d_cut_texts.clear();
|
||||
d_background_colors.clear();
|
||||
@ -475,6 +501,7 @@ void RDLibraryModel::updateModel(const QString &filter_sql)
|
||||
while(q->next()) {
|
||||
if(q->value(0).toUInt()!=prev_cartnum) {
|
||||
d_texts.push_back(list);
|
||||
d_notes.push_back(QVariant());
|
||||
d_cart_numbers.push_back(0);
|
||||
d_cut_texts.push_back(list_list);
|
||||
d_background_colors.push_back(QVariant());
|
||||
@ -573,6 +600,7 @@ void RDLibraryModel::updateRow(int row,RDSqlQuery *q)
|
||||
d_texts[row][19]= // Length Deviation
|
||||
QString().sprintf("%u",q->value(20).toUInt());
|
||||
d_texts[row][20]=q->value(21); // Owned By
|
||||
d_notes[row]=q->value(30).toString();
|
||||
|
||||
switch((RDCart::Validity)q->value(22).toUInt()) {
|
||||
case RDCart::NeverValid:
|
||||
@ -664,7 +692,8 @@ QString sql=QString("select ")+
|
||||
"CUTS.END_POINT,"+ // 26
|
||||
"CUTS.TALK_START_POINT,"+ // 27
|
||||
"CUTS.TALK_END_POINT,"+ // 28
|
||||
"CUTS.DESCRIPTION "+ // 29
|
||||
"CUTS.DESCRIPTION,"+ // 29
|
||||
"CART.NOTES "+ // 30
|
||||
"from CART "+
|
||||
"left join GROUPS on CART.GROUP_NAME=GROUPS.NAME "+
|
||||
"left join CUTS on CART.NUMBER=CUTS.CART_NUMBER ";
|
||||
|
@ -62,11 +62,13 @@ class RDLibraryModel : public QAbstractItemModel
|
||||
void removeCart(unsigned cartnum);
|
||||
void refreshRow(const QModelIndex &index);
|
||||
void refreshCart(unsigned cartnum);
|
||||
bool showNotes() const;
|
||||
|
||||
signals:
|
||||
void rowCountChanged(int rows);
|
||||
|
||||
public slots:
|
||||
void setShowNotes(int state);
|
||||
void setFilterSql(const QString &sql);
|
||||
void processNotification(RDNotification *notify);
|
||||
|
||||
@ -78,6 +80,7 @@ class RDLibraryModel : public QAbstractItemModel
|
||||
|
||||
private:
|
||||
QByteArray DumpIndex(const QModelIndex &index,const QString &caption="") const;
|
||||
bool d_show_notes;
|
||||
QPalette d_palette;
|
||||
QFont d_font;
|
||||
QFontMetrics *d_font_metrics;
|
||||
@ -86,6 +89,7 @@ class RDLibraryModel : public QAbstractItemModel
|
||||
QList<QVariant> d_headers;
|
||||
QList<QList<QVariant> > d_texts;
|
||||
QList<QList<QVariant> > d_icons;
|
||||
QList<QVariant> d_notes;
|
||||
QList<QList<QList<QVariant> > > d_cut_texts;
|
||||
QList<QVariant> d_alignments;
|
||||
QList<QVariant> d_background_colors;
|
||||
|
@ -150,7 +150,7 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
|
||||
//
|
||||
// Filter
|
||||
//
|
||||
lib_cart_filter=new RDCartFilter(this);
|
||||
lib_cart_filter=new RDCartFilter(true,this);
|
||||
connect(rda,SIGNAL(userChanged()),lib_cart_filter,SLOT(changeUser()));
|
||||
connect(lib_cart_filter,SIGNAL(selectedGroupChanged(const QString &)),
|
||||
this,SLOT(selectedGroupChangedData(const QString &)));
|
||||
@ -166,16 +166,13 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
|
||||
lib_cart_model=new RDLibraryModel(this);
|
||||
lib_cart_model->setFont(font());
|
||||
lib_cart_model->setPalette(palette());
|
||||
lib_cart_filter->setModel(lib_cart_model);
|
||||
lib_cart_view->setModel(lib_cart_model);
|
||||
connect(lib_cart_filter,SIGNAL(filterChanged(const QString &)),
|
||||
lib_cart_model,SLOT(setFilterSql(const QString &)));
|
||||
connect(lib_cart_view,SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
this,SLOT(cartDoubleClickedData(const QModelIndex &)));
|
||||
connect(lib_cart_filter,SIGNAL(dragEnabledChanged(bool)),
|
||||
this,SLOT(dragsChangedData(bool)));
|
||||
connect(lib_cart_model,SIGNAL(modelReset()),this,SLOT(modelResetData()));
|
||||
connect(lib_cart_model,SIGNAL(rowCountChanged(int)),
|
||||
lib_cart_filter,SLOT(setMatchCount(int)));
|
||||
connect(lib_cart_view,SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
this,SLOT(cartDoubleClickedData(const QModelIndex &)));
|
||||
connect(lib_cart_view->selectionModel(),
|
||||
SIGNAL(selectionChanged(const QItemSelection &,const QItemSelection &)),
|
||||
this,
|
||||
|
Loading…
x
Reference in New Issue
Block a user