Bugfix: Replace "URL" with "URI" where we aren't actually working with URLs
[novacoin.git] / src / qt / guiutil.h
1 #ifndef GUIUTIL_H
2 #define GUIUTIL_H
3
4 #include <QString>
5
6 QT_BEGIN_NAMESPACE
7 class QFont;
8 class QLineEdit;
9 class QWidget;
10 class QDateTime;
11 class QUrl;
12 class QAbstractItemView;
13 QT_END_NAMESPACE
14 class SendCoinsRecipient;
15
16 /** Static utility functions used by the Bitcoin Qt UI.
17  */
18 class GUIUtil
19 {
20 public:
21     // Create human-readable string from date
22     static QString dateTimeStr(qint64 nTime);
23     static QString dateTimeStr(const QDateTime &datetime);
24
25     // Render bitcoin addresses in monospace font
26     static QFont bitcoinAddressFont();
27
28     // Set up widgets for address and amounts
29     static void setupAddressWidget(QLineEdit *widget, QWidget *parent);
30     static void setupAmountWidget(QLineEdit *widget, QWidget *parent);
31
32     // Parse "bitcoin:" URI into recipient object, return true on succesful parsing
33     // See Bitcoin URI definition discussion here: https://bitcointalk.org/index.php?topic=33490.0
34     static bool parseBitcoinURI(const QUrl &, SendCoinsRecipient *out);
35     static bool parseBitcoinURI(QString uri, SendCoinsRecipient *out);
36
37     // HTML escaping for rich text controls
38     static QString HtmlEscape(const QString& str, bool fMultiLine=false);
39     static QString HtmlEscape(const std::string& str, bool fMultiLine=false);
40
41     /** Copy a field of the currently selected entry of a view to the clipboard. Does nothing if nothing
42         is selected.
43        @param[in] column  Data column to extract from the model
44        @param[in] role    Data role to extract from the model
45        @see  TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress
46      */
47     static void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole);
48
49     /** Get save file name, mimics QFileDialog::getSaveFileName, except that it appends a default suffix
50         when no suffix is provided by the user.
51
52       @param[in] parent  Parent window (or 0)
53       @param[in] caption Window caption (or empty, for default)
54       @param[in] dir     Starting directory (or empty, to default to documents directory)
55       @param[in] filter  Filter specification such as "Comma Separated Files (*.csv)"
56       @param[out] selectedSuffixOut  Pointer to return the suffix (file type) that was selected (or 0).
57                   Can be useful when choosing the save file format based on suffix.
58      */
59     static QString getSaveFileName(QWidget *parent=0, const QString &caption=QString(),
60                                    const QString &dir=QString(), const QString &filter=QString(),
61                                    QString *selectedSuffixOut=0);
62
63
64     /** Get connection type to call object slot in GUI thread with invokeMethod. The call will be blocking.
65
66        @returns If called from the GUI thread, return a Qt::DirectConnection.
67                 If called from another thread, return a Qt::BlockingQueuedConnection.
68     */
69     static Qt::ConnectionType blockingGUIThreadConnection();
70
71 };
72
73 #endif // GUIUTIL_H