00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) Qxt Foundation. Some rights reserved. 00004 ** 00005 ** This file is part of the QxtGui module of the Qxt library. 00006 ** 00007 ** This library is free software; you can redistribute it and/or modify it 00008 ** under the terms of the Common Public License, version 1.0, as published 00009 ** by IBM, and/or under the terms of the GNU Lesser General Public License, 00010 ** version 2.1, as published by the Free Software Foundation. 00011 ** 00012 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 00013 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 00014 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 00015 ** FITNESS FOR A PARTICULAR PURPOSE. 00016 ** 00017 ** You should have received a copy of the CPL and the LGPL along with this 00018 ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 00019 ** included with the source distribution for more information. 00020 ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 00021 ** 00022 ** <http://libqxt.org> <foundation@libqxt.org> 00023 ** 00024 ****************************************************************************/ 00025 #include "qxtlistwidget.h" 00026 #include "qxtlistwidget_p.h" 00027 #include "qxtitemdelegate.h" 00028 00029 QxtListWidgetPrivate::QxtListWidgetPrivate() 00030 {} 00031 00032 void QxtListWidgetPrivate::informStartEditing(const QModelIndex& index) 00033 { 00034 QListWidgetItem* item = qxt_p().itemFromIndex(index); 00035 Q_ASSERT(item); 00036 emit qxt_p().itemEditingStarted(item); 00037 } 00038 00039 void QxtListWidgetPrivate::informFinishEditing(const QModelIndex& index) 00040 { 00041 QListWidgetItem* item = qxt_p().itemFromIndex(index); 00042 Q_ASSERT(item); 00043 emit qxt_p().itemEditingFinished(item); 00044 } 00045 00085 QxtListWidget::QxtListWidget(QWidget* parent) : QListWidget(parent) 00086 { 00087 QXT_INIT_PRIVATE(QxtListWidget); 00088 QxtItemDelegate* delegate = new QxtItemDelegate(this); 00089 connect(delegate, SIGNAL(editingStarted(const QModelIndex&)), 00090 &qxt_d(), SLOT(informStartEditing(const QModelIndex&))); 00091 connect(delegate, SIGNAL(editingFinished(const QModelIndex&)), 00092 &qxt_d(), SLOT(informFinishEditing(const QModelIndex&))); 00093 setItemDelegate(delegate); 00094 } 00095 00099 QxtListWidget::~QxtListWidget() 00100 {}