File: documents.h

package info (click to toggle)
postbooks 4.9.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 103,120 kB
  • sloc: cpp: 288,269; sh: 607; xml: 214; awk: 104; makefile: 49
file content (124 lines) | stat: -rw-r--r-- 3,537 bytes parent folder | download | duplicates (2)
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
/*
 * 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 documents_h
#define documents_h

#include <QWidget>

#include <xsqlquery.h>

#include "widgets.h"
#include "guiclientinterface.h"

#include "ui_documents.h"

#define cNew                  1
#define cEdit                 2
#define cView                 3

struct DocumentMap
{
  int     doctypeId;
  QString doctypeStr;
  QString translation;
  QString idParam;
  QString uiname;
  QString newPriv;

  DocumentMap(int     id,       // enum DocumentSources + extensions
              QString key,
              QString trans,
              QString param,
              QString ui    = QString(),
              QString priv  = QString()) {

    doctypeId   = id;
    doctypeStr  = key;
    translation = trans;
    idParam     = param;
    uiname      = ui;
    newPriv     = priv;
  }
};

class XTUPLEWIDGETS_EXPORT Documents : public QWidget, public Ui::documents
{
  Q_OBJECT

  Q_ENUMS(DocumentSources)

  Q_PROPERTY(int type READ type WRITE setType)

  friend class image;
  friend class file;

  public:
    Documents(QWidget *);

    // If you add to this then add to the documentMap() function in documents.cpp
    enum DocumentSources
    {
      Uninitialized,
      Address,          BBOMHead,           BBOMItem,
      BOMHead,          BOMItem,            BOOHead,
      BOOItem,          CRMAccount,         Contact, 
      Contract,         CreditMemo,         CreditMemoItem,
      Customer,         Employee,           Incident,
      Invoice,          InvoiceItem,
      Item,             ItemSite,           ItemSource,
      Location,         LotSerial,
      Opportunity,      Project,            PurchaseOrder,
      PurchaseOrderItem,ReturnAuth,         ReturnAuthItem,
      Quote,            QuoteItem,          SalesOrder,
      SalesOrderItem,   ShipTo,             TimeExpense,
      Todo,             TransferOrder,      TransferOrderItem,
      Vendor,           Voucher,            Warehouse,
      WorkOrder,                            ProjectTask
    };

    static GuiClientInterface *_guiClientInterface;
    inline int  sourceid()             { return _sourceid; }
    int         type() const;

    static QMap<QString, struct DocumentMap*> &documentMap();

  public slots:
    void setType(int sourceType);
    void setType(QString sourceType);
    void setId(int);
    void setReadOnly(bool);
    void sNewDoc(QString type = QString(), QString ui = QString());
    void sNewImage();
    void sInsertDocass(QString, int);
    void sAttachDoc();
    void sViewDoc();
    void sEditDoc();
    void sOpenDoc(QString mode = "edit");
    void sDetachDoc();
    
    void refresh();

  private slots:
    void handleSelection(bool = false);
    void handleItemSelected();

  private:
    static QMap<QString, struct DocumentMap*> _strMap;
    static QMap<int,     struct DocumentMap*> _intMap;
    int                  _sourceid;
    QString              _sourcetype;
    bool                 _readOnly;

    static bool addToMap(int id, QString key, QString trans, QString param = QString(), QString ui = QString(), QString priv = QString());

};

#endif