File: filecluster.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 (94 lines) | stat: -rw-r--r-- 3,108 bytes parent folder | download | duplicates (5)
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
/*
 * 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 FILECLUSTER_H
#define FILECLUSTER_H

#include "widgets.h"
#include "parameter.h"
#include "xtreewidget.h"

#include <QFileDialog>
#include <QLineEdit>
#include <QKeyEvent>
#include <QPushButton>
#include <QWidget>

class FileLineEdit : public QLineEdit
{
  Q_OBJECT

  public:
    FileLineEdit(QWidget * parent = 0);

  protected:
    virtual void keyPressEvent(QKeyEvent *event);

  signals:
    void requestList();
    void requestSearch();
};

/*
  FileCluster allows the user to enter a string or browse the filesystem.
  The text() of the FileCluster should name a file or directory. The ellipsis
  button instantiates a QFileDialog, so the class has methods to control that
  QFileDialog.
 */

class XTUPLEWIDGETS_EXPORT FileCluster : public QWidget
{
  Q_OBJECT

  Q_PROPERTY(QString		    caption READ caption     WRITE setCaption )
  Q_PROPERTY(bool	        listVisible READ listVisible WRITE setListVisible )
  Q_PROPERTY(QFileDialog::FileMode fileMode READ fileMode    WRITE setFileMode )
  Q_PROPERTY(bool	           readOnly READ isReadOnly  WRITE setReadOnly )
  Q_PROPERTY(QString		       text READ text	     WRITE setText )

  public:
    FileCluster(QWidget*, const char* = 0);
    ~FileCluster();

    virtual inline QString caption()	 const	{ return _caption; };
    virtual inline void    clear()		{ _file->clear(); };
    virtual inline QString dir()	 const	{ return _dir; };
    virtual inline QFileDialog::FileMode fileMode() const { return _fileMode; };
    virtual inline bool	   isReadOnly()	 const	{ return _file->isReadOnly(); };
    virtual inline bool	   listVisible() const	{ return _list->isVisible(); };
    virtual inline void    setListVisible(bool b) { _list->setVisible(b); };
    virtual inline void    setReadOnly(bool b)	  { _file->setReadOnly(b);
						    setListVisible(! b); };
    virtual inline QString text()	 const	  { return _file->text(); };

  public slots:
    virtual void sEllipses();
    virtual void setCaption(const QString &s) { _caption = s; } ;
    virtual void setDir(const QString &s)     { _dir = s; } ;
    virtual void setEnabled(const bool b)     { _file->setEnabled(b);
						_list->setEnabled(! isReadOnly()); } ;
    virtual void setFileMode(const QFileDialog::FileMode &m) { _fileMode = m; };
    virtual void setFilter(const QString &s)  { _filter = s; } ;
    virtual void setText(const QString &s)    { _file->setText(s); };

  signals:
    void editingFinished();
    void textChanged(const QString&);

  protected:
    QString			_caption;
    QString			_dir;
    FileLineEdit		*_file;
    QString			_filter;
    QPushButton			*_list;
    QFileDialog::FileMode	_fileMode;
};

#endif