00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "cursoredit.h"
00022
00023 #include <QMap>
00024 #include <QVariant>
00025 #include <QCursor>
00026
00027 #include <klocale.h>
00028 #include <kdebug.h>
00029
00030 #include "property.h"
00031
00032 using namespace KoProperty;
00033
00034
00035 Property::ListData *m_cursorListData = 0;
00036
00037
00038 CursorEdit::CursorEdit(Property *property, QWidget *parent)
00039 : ComboBox(property, parent)
00040 {
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00063 if (!m_cursorListData) {
00064 QList<QVariant> keys;
00065 keys
00066 << Qt::BlankCursor
00067 << Qt::ArrowCursor
00068 << Qt::UpArrowCursor
00069 << Qt::CrossCursor
00070 << Qt::WaitCursor
00071 << Qt::IBeamCursor
00072 << Qt::SizeVerCursor
00073 << Qt::SizeHorCursor
00074 << Qt::SizeBDiagCursor
00075 << Qt::SizeFDiagCursor
00076 << Qt::SizeAllCursor
00077 << Qt::SplitVCursor
00078 << Qt::SplitHCursor
00079 << Qt::PointingHandCursor
00080 << Qt::ForbiddenCursor
00081 << Qt::WhatsThisCursor;
00082 QStringList strings;
00083 strings << i18nc("Mouse Cursor Shape", "No Cursor")
00084 << i18nc("Mouse Cursor Shape", "Arrow")
00085 << i18nc("Mouse Cursor Shape", "Up Arrow")
00086 << i18nc("Mouse Cursor Shape", "Cross")
00087 << i18nc("Mouse Cursor Shape", "Waiting")
00088 << i18nc("Mouse Cursor Shape", "I")
00089 << i18nc("Mouse Cursor Shape", "Size Vertical")
00090 << i18nc("Mouse Cursor Shape", "Size Horizontal")
00091 << i18nc("Mouse Cursor Shape", "Size Slash")
00092 << i18nc("Mouse Cursor Shape", "Size Backslash")
00093 << i18nc("Mouse Cursor Shape", "Size All")
00094 << i18nc("Mouse Cursor Shape", "Split Vertical")
00095 << i18nc("Mouse Cursor Shape", "Split Horizontal")
00096 << i18nc("Mouse Cursor Shape", "Pointing Hand")
00097 << i18nc("Mouse Cursor Shape", "Forbidden")
00098 << i18nc("Mouse Cursor Shape", "What's This?");
00099 m_cursorListData = new Property::ListData(keys, strings);
00100 }
00101
00102 if(property)
00103 property->setListData(new Property::ListData(*m_cursorListData));
00104 }
00105
00106 CursorEdit::~CursorEdit()
00107 {
00108 delete m_cursorListData;
00109 m_cursorListData = 0;
00110 }
00111
00112 QVariant
00113 CursorEdit::value() const
00114 {
00115 return QCursor((Qt::CursorShape)ComboBox::value().toInt());
00116 }
00117
00118 void
00119 CursorEdit::setValue(const QVariant &value, bool emitChange)
00120 {
00121 ComboBox::setValue(value.value<QCursor>().shape(), emitChange);
00122 }
00123
00124 void
00125 CursorEdit::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value)
00126 {
00127 ComboBox::drawViewer(p, cg, r, value.value<QCursor>().shape());
00128 }
00129
00130 void
00131 CursorEdit::setProperty(Property *prop)
00132 {
00133 if(prop && prop != property())
00134 prop->setListData(new Property::ListData(*m_cursorListData));
00135 ComboBox::setProperty(prop);
00136 }
00137
00138 #include "cursoredit.moc"