F:/KPlato/koffice/libs/koproperty/editors/cursoredit.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2004  Alexander Dymo <cloudtemple@mskat.net>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
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 //QMap<QString, QVariant> *CursorEdit::m_spValues = 0;
00035 Property::ListData *m_cursorListData = 0;
00036 
00037 
00038 CursorEdit::CursorEdit(Property *property, QWidget *parent)
00039 : ComboBox(property, parent)
00040 {
00041         /*
00042         if(!m_spValues) {
00043                 m_spValues = new QMap<QString, QVariant>();
00044                 (*m_spValues)[i18n("Arrow")] = Qt::ArrowCursor;
00045                 (*m_spValues)[i18n("Up Arrow")] = Qt::UpArrowCursor;
00046                 (*m_spValues)[i18n("Cross")] = Qt::CrossCursor;
00047                 (*m_spValues)[i18n("Waiting")] = Qt::WaitCursor;
00048                 (*m_spValues)[i18n("iBeam")] = Qt::IbeamCursor;
00049                 (*m_spValues)[i18n("Size Vertical")] = Qt::SizeVerCursor;
00050                 (*m_spValues)[i18n("Size Horizontal")] = Qt::SizeHorCursor;
00051                 (*m_spValues)[i18n("Size Slash")] = Qt::SizeBDiagCursor;
00052                 (*m_spValues)[i18n("Size Backslash")] = Qt::SizeFDiagCursor;
00053                 (*m_spValues)[i18n("Size All")] = Qt::SizeAllCursor;
00054                 (*m_spValues)[i18n("Blank")] = Qt::BlankCursor;
00055                 (*m_spValues)[i18n("Split Vertical")] = Qt::SplitVCursor;
00056                 (*m_spValues)[i18n("Split Horizontal")] = Qt::SplitHCursor;
00057                 (*m_spValues)[i18n("Pointing Hand")] = Qt::PointingHandCursor;
00058                 (*m_spValues)[i18n("Forbidden")] = Qt::ForbiddenCursor;
00059                 (*m_spValues)[i18n("What's this")] = Qt::WhatsThisCursor;
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"

Généré le Wed Nov 22 23:41:06 2006 pour KPlato par  doxygen 1.5.1-p1