KVIrc 5.2.6
Developer APIs
KviHtmlDialog.h
Go to the documentation of this file.
1#ifndef _KVI_HTMLDIALOG_H_
2#define _KVI_HTMLDIALOG_H_
3//=============================================================================
4//
5// File : KviHtmlDialog.h
6// Creation date : Wed 03 Jan 2007 03:36:36 by Szymon Stefanek
7//
8// This file is part of the KVIrc IRC Client distribution
9// Copyright (C) 2007-2010 Szymon Stefanek <pragma at kvirc dot net>
10//
11// This program is FREE software. You can redistribute it and/or
12// modify it under the terms of the GNU General Public License
13// as published by the Free Software Foundation; either version 2
14// of the License, or (at your option) any later version.
15//
16// This program is distributed in the HOPE that it will be USEFUL,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19// See the GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program. If not, write to the Free Software Foundation,
23// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24//
25//=============================================================================
26
27#include "KviQString.h"
28#include "kvi_settings.h"
29
30#include <QPixmap>
31#include <QDialog>
32#include <QUrl>
33#include <QTextBrowser>
34#include <QHash>
35#include <QPixmap>
36
38{
39public:
41 {
42 m_pDoc = new QTextDocument();
43 };
45
46 void addImageResource(const QString & key, const QPixmap & pix)
47 {
48 if(!m_pDoc)
49 m_pDoc = new QTextDocument();
50 QUrl url;
51 url.setPath(key);
52 m_pDoc->addResource(2, url, pix);
53 }
54
55 void addHtmlResource(const QString key, const QString value)
56 {
57 htmlResource.insert(key, value);
58 }
59
60 // input
61
62 // mandatory fields
63 enum Flags
64 {
66 };
67 int iFlags; // da flags :)
68 int iDefaultButton; // the button to use when Enter is pressed (1,2 or 3)
69 int iCancelButton; // the button to use when Esc is pressed (1,2 or 3)
70 QString szHtmlText; // Shouldn't be empty :D
71
72 // optional fields
73 QString szCaption; // KVIrc is used when this is empty
74 QString szUpperLabelText; // no label is shown if this is empty
75 QString szLowerLabelText; // no label is shown if this is empty
76 QString szButton1Text; // OK is used if this is empty
77 QString szButton2Text; // no button is shown if this is empty
78 QString szButton3Text; // no button is shown if this is empty
79 QTextDocument * m_pDoc;
80 QHash<QString, QString> htmlResource;
83
84 QPixmap pixIcon; // may be null
85
86 // output
87 int iSelectedButton; // returns 1,2 or 3
88};
89
90class KviTextBrowser : public QTextBrowser
91{
92public:
93 KviTextBrowser(QWidget * par, KviHtmlDialogData * ht)
94 : QTextBrowser(par), m_pHt(ht){};
96 virtual QVariant loadResource(int type, const QUrl & name)
97 {
98 QString p = m_pHt->htmlResource.value(name.path());
99 if(!p.isEmpty())
100 return QVariant(p);
101 else
102 return QVariant();
103
104 //return QTextBrowser::loadResource(type,name);
105 }
106
107protected:
109};
110
111class KVIRC_API KviHtmlDialog : public QDialog
112{
113 Q_OBJECT
114public:
115 // the dialog does NOT delete this structure and assumes that
116 // it remains alive until the dialog closes (i.e. it may access
117 // the structure in the destructor
118 KviHtmlDialog(QWidget * pParent, KviHtmlDialogData * pData);
120
121protected:
123
124public:
125 // displays the dialog as modal and returns 1,2 or 3
126 static int display(QWidget * pParent, KviHtmlDialogData * pData);
127protected slots:
128 void button1Pressed();
129 void button2Pressed();
130 void button3Pressed();
131
132protected:
133 virtual void reject();
134};
135
136#endif
Helper functions for the QString class.
Definition KviHtmlDialog.h:38
int iFlags
Definition KviHtmlDialog.h:67
QString szButton1Text
Definition KviHtmlDialog.h:76
Flags
Definition KviHtmlDialog.h:64
@ ForceMinimumSize
Definition KviHtmlDialog.h:65
int iSelectedButton
Definition KviHtmlDialog.h:87
QString szLowerLabelText
Definition KviHtmlDialog.h:75
QString szHtmlText
Definition KviHtmlDialog.h:70
QString szButton2Text
Definition KviHtmlDialog.h:77
void addImageResource(const QString &key, const QPixmap &pix)
Definition KviHtmlDialog.h:46
int iDefaultButton
Definition KviHtmlDialog.h:68
QString szButton3Text
Definition KviHtmlDialog.h:78
KviHtmlDialogData()
Definition KviHtmlDialog.h:40
QString szCaption
Definition KviHtmlDialog.h:73
QTextDocument * m_pDoc
Definition KviHtmlDialog.h:79
int iCancelButton
Definition KviHtmlDialog.h:69
~KviHtmlDialogData()
Definition KviHtmlDialog.h:44
void addHtmlResource(const QString key, const QString value)
Definition KviHtmlDialog.h:55
QHash< QString, QString > htmlResource
Definition KviHtmlDialog.h:80
int iMinimumWidth
Definition KviHtmlDialog.h:81
QPixmap pixIcon
Definition KviHtmlDialog.h:84
int iMinimumHeight
Definition KviHtmlDialog.h:82
QString szUpperLabelText
Definition KviHtmlDialog.h:74
Definition KviHtmlDialog.h:112
KviHtmlDialogData * m_pData
Definition KviHtmlDialog.h:122
Definition KviHtmlDialog.h:91
~KviTextBrowser()
Definition KviHtmlDialog.h:95
KviHtmlDialogData * m_pHt
Definition KviHtmlDialog.h:108
KviTextBrowser(QWidget *par, KviHtmlDialogData *ht)
Definition KviHtmlDialog.h:93
virtual QVariant loadResource(int type, const QUrl &name)
Definition KviHtmlDialog.h:96
#define p
Definition detector.cpp:81
This file contains compile time settings.
#define KVIRC_API
Definition kvi_settings.h:127