File: parameterwidget.h

package info (click to toggle)
postbooks 4.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 112,660 kB
  • ctags: 22,890
  • sloc: cpp: 310,358; sh: 607; xml: 214; python: 140; awk: 104; makefile: 50
file content (129 lines) | stat: -rw-r--r-- 4,160 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * This file is part of the xTuple ERP: PostBooks Edition, a free and
 * open source Enterprise Resource Planning software suite,
 * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
 * It is licensed to you under the Common Public Attribution License
 * version 1.0, the full text of which (including xTuple-specific Exhibits)
 * is available at www.xtuple.com/CPAL.  By using this software, you agree
 * to be bound by its terms.
 */

#ifndef parameterwidget_h
#define parameterwidget_h

#include <QDate>
#include <QSignalMapper>
#include <QMap>
#include <QPair>
#include <QToolButton>
#include <QRegExp>
#include <parameter.h>

#include "widgets.h"
#include "ui_parameterwidget.h"

class ParameterList;
class QTableWidgetItem;

class XTUPLEWIDGETS_EXPORT ParameterWidget : public QWidget, public Ui::ParameterWidget
{
  Q_OBJECT

  Q_ENUMS(ParameterWidgetTypes)
   
  public:
    enum ParameterWidgetTypes
    {
      Crmacct, User, Text, Date, XComBox, Contact,
      Multiselect, GLAccount, Exists, CheckBox, Project,
      Customer, Site, Vendor, Item, Employee, Shipto,
      SalesOrder, WorkOrder, PurchaseOrder, TransferOrder
    };

    ParameterWidget(QWidget *pParent, const char * = 0);
    ~ParameterWidget();
    void appendValue(ParameterList &);
    Q_INVOKABLE void applyDefaultFilterSet();
    Q_INVOKABLE int paramIndex(QString pName);
    Q_INVOKABLE ParameterList parameters();
    Q_INVOKABLE QString filter();
    
 public slots:
    void addParam();
    void append(QString pName, QString pParam, enum ParameterWidgetTypes pType = Text, QVariant pDefault = QVariant(),  bool pRequired = false, QString pExtraInfo =  QString());
    void appendComboBox(QString pName, QString pParam, QString pQuery, QVariant pDefault = QVariant(), bool pRequired = false);
    void appendComboBox(QString pName, QString pParam, int pType, QVariant pDefault = QVariant(), bool pRequired = false);
    void applySaved(int pId = 0, int filter_id = 0);
    void changeFilterObject(int index);
    void clearFilters();
    void removeParam(int);
    void save();
    void setDefault(QString pName, QVariant pDefault = QVariant(), bool pAutoApply = false);
    void setEnabled(QString pName, bool pEnabled);
    void setFiltersVisible(bool visible);
    void setSavedFilters(int defaultId = -1);
    void setSavedFiltersIndex(QString);
    void setType(QString, QString, ParameterWidgetTypes = Text, QVariant pDefault = QVariant(), QVariant extraInfo =  QVariant());
    void setXComboBoxType(QString, QString, enum XComboBox::XComboBoxTypes, QVariant pDefault = QVariant());
    void setXComboBoxType(QString, QString, QString, QVariant pDefault = QVariant());
    void sManageFilters();
    void storeFilterValue(int pId = -1, QObject* filter = 0);
    void setFiltersVisabiltyPreference();
    void toggleSave();
    void setFiltersDefault();

  signals:
    void cleared();
    void filterChanged();
    void filterSetSaved();
    void updated();

  protected:
    virtual void showEvent(QShowEvent *);
    virtual void resetEmptyParameter();

  private:
    enum ParameterWidgetTypes _type;
    QSignalMapper *_filterSignalMapper;
    QMap<int, QString > _usedTypes;
    QString _settingsName, _settingsName2;
    QMap<int, QWidget*> _filterWidgets;
    QMap<int, QPair<QString, QVariant > > _filterValues;
    bool _initialized;
    bool _shared;
    QString _name;

    struct ParamProps {
      QString name;
      QString param;
      ParameterWidgetTypes paramType;
      QVariant defaultValue;
      bool required;
      XComboBox::XComboBoxTypes comboType;
      QString query;
      bool enabled;
    };
    QMap<int, ParamProps*> _params;

  protected:
    int      getFilterIndex(const QWidget *filterwidget);
    QWidget *getFilterWidget(const int index);
    QString  getParameterTypeKey(QString);
    void setSelectedFilter(int filter_id);
    
    bool containsUsedType(QString);

  private slots:
    void repopulateComboboxes();
    void addUsedType();

  protected slots:
    void     resetMultiselect(QTableWidgetItem* item);

};

Q_DECLARE_METATYPE(ParameterWidget*);

void setupParameterWidget(QScriptEngine *engine);

#endif