lib

cursoredit.cpp

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.h>
00024 #include <qvariant.h>
00025 #include <qcursor.h>
00026 
00027 #ifdef QT_ONLY
00028 // \tdo
00029 #else
00030 #include <klocale.h>
00031 #include <kdebug.h>
00032 #endif
00033 
00034 #include "property.h"
00035 
00036 using namespace KoProperty;
00037 
00038 //QMap<QString, QVariant> *CursorEdit::m_spValues = 0;
00039 Property::ListData *m_cursorListData = 0;
00040 
00041 
00042 CursorEdit::CursorEdit(Property *property, QWidget *parent, const char *name)
00043 : ComboBox(property, parent, name)
00044 {
00045     /*
00046     if(!m_spValues) {
00047         m_spValues = new QMap<QString, QVariant>();
00048         (*m_spValues)[i18n("Arrow")] = Qt::ArrowCursor;
00049         (*m_spValues)[i18n("Up Arrow")] = Qt::UpArrowCursor;
00050         (*m_spValues)[i18n("Cross")] = Qt::CrossCursor;
00051         (*m_spValues)[i18n("Waiting")] = Qt::WaitCursor;
00052         (*m_spValues)[i18n("iBeam")] = Qt::IbeamCursor;
00053         (*m_spValues)[i18n("Size Vertical")] = Qt::SizeVerCursor;
00054         (*m_spValues)[i18n("Size Horizontal")] = Qt::SizeHorCursor;
00055         (*m_spValues)[i18n("Size Slash")] = Qt::SizeBDiagCursor;
00056         (*m_spValues)[i18n("Size Backslash")] = Qt::SizeFDiagCursor;
00057         (*m_spValues)[i18n("Size All")] = Qt::SizeAllCursor;
00058         (*m_spValues)[i18n("Blank")] = Qt::BlankCursor;
00059         (*m_spValues)[i18n("Split Vertical")] = Qt::SplitVCursor;
00060         (*m_spValues)[i18n("Split Horizontal")] = Qt::SplitHCursor;
00061         (*m_spValues)[i18n("Pointing Hand")] = Qt::PointingHandCursor;
00062         (*m_spValues)[i18n("Forbidden")] = Qt::ForbiddenCursor;
00063         (*m_spValues)[i18n("What's this")] = Qt::WhatsThisCursor;
00064     }*/
00065 
00067     if (!m_cursorListData) {
00068         QValueList<QVariant> keys;
00069         keys 
00070             << Qt::BlankCursor
00071             << Qt::ArrowCursor
00072             << Qt::UpArrowCursor
00073             << Qt::CrossCursor
00074             << Qt::WaitCursor
00075             << Qt::IbeamCursor
00076             << Qt::SizeVerCursor
00077             << Qt::SizeHorCursor
00078             << Qt::SizeBDiagCursor
00079             << Qt::SizeFDiagCursor
00080             << Qt::SizeAllCursor
00081             << Qt::SplitVCursor
00082             << Qt::SplitHCursor
00083             << Qt::PointingHandCursor
00084             << Qt::ForbiddenCursor
00085             << Qt::WhatsThisCursor;
00086         QStringList strings;
00087         strings << i18n("Mouse Cursor Shape", "No Cursor")
00088             << i18n("Mouse Cursor Shape", "Arrow")
00089             << i18n("Mouse Cursor Shape", "Up Arrow")
00090             << i18n("Mouse Cursor Shape", "Cross")
00091             << i18n("Mouse Cursor Shape", "Waiting")
00092             << i18n("Mouse Cursor Shape", "I")
00093             << i18n("Mouse Cursor Shape", "Size Vertical")
00094             << i18n("Mouse Cursor Shape", "Size Horizontal")
00095             << i18n("Mouse Cursor Shape", "Size Slash")
00096             << i18n("Mouse Cursor Shape", "Size Backslash")
00097             << i18n("Mouse Cursor Shape", "Size All")
00098             << i18n("Mouse Cursor Shape", "Split Vertical")
00099             << i18n("Mouse Cursor Shape", "Split Horizontal")
00100             << i18n("Mouse Cursor Shape", "Pointing Hand")
00101             << i18n("Mouse Cursor Shape", "Forbidden")
00102             << i18n("Mouse Cursor Shape", "What's This?");
00103         m_cursorListData = new Property::ListData(keys, strings);
00104     }
00105 
00106     if(property)
00107         property->setListData(new Property::ListData(*m_cursorListData));
00108 }
00109 
00110 CursorEdit::~CursorEdit()
00111 {
00112     delete m_cursorListData;
00113     m_cursorListData = 0;
00114 }
00115 
00116 QVariant
00117 CursorEdit::value() const
00118 {
00119     return QCursor(ComboBox::value().toInt());
00120 }
00121 
00122 void
00123 CursorEdit::setValue(const QVariant &value, bool emitChange)
00124 {
00125     ComboBox::setValue(value.toCursor().shape(), emitChange);
00126 }
00127 
00128 void
00129 CursorEdit::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value)
00130 {
00131     ComboBox::drawViewer(p, cg, r, value.toCursor().shape());
00132 }
00133 
00134 void
00135 CursorEdit::setProperty(Property *prop)
00136 {
00137     if(prop && prop != property())
00138         prop->setListData(new Property::ListData(*m_cursorListData));
00139     ComboBox::setProperty(prop);
00140 }
00141 
00142 #include "cursoredit.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys