krita

kis_selected_transaction.cc

00001 /*
00002  *  Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #include "kis_types.h"
00019 #include "kis_global.h"
00020 #include "kis_selected_transaction.h"
00021 #include "kis_selection.h"
00022 
00023 KisSelectedTransaction::KisSelectedTransaction(const QString& name, KisPaintDeviceSP device) :
00024     KisTransaction(name, device),
00025     m_device(device),
00026     m_hadSelection(device->hasSelection())
00027 {
00028     m_selTransaction = new KisTransaction(name, device->selection().data());
00029     if(! m_hadSelection) {
00030         m_device->deselect(); // let us not be the cause of select
00031     }
00032 }
00033 
00034 KisSelectedTransaction::~KisSelectedTransaction()
00035 {
00036     delete m_selTransaction;
00037 }
00038 
00039 void KisSelectedTransaction::execute()
00040 {
00041     super::execute();
00042     m_selTransaction->execute();
00043     if(m_redoHasSelection)
00044         m_device->selection();
00045     else
00046         m_device->deselect();
00047     m_device->emitSelectionChanged();
00048 }
00049 
00050 void KisSelectedTransaction::unexecute()
00051 {
00052     m_redoHasSelection = m_device->hasSelection();
00053 
00054     super::unexecute();
00055     m_selTransaction->unexecute();
00056     if(m_hadSelection)
00057         m_device->selection();
00058     else
00059         m_device->deselect();
00060     m_device->emitSelectionChanged();
00061 }
00062 
00063 void KisSelectedTransaction::unexecuteNoUpdate()
00064 {
00065     m_redoHasSelection = m_device->hasSelection();
00066 
00067     super::unexecuteNoUpdate();
00068     m_selTransaction->unexecuteNoUpdate();
00069     if(m_hadSelection)
00070         m_device->selection();
00071     else
00072         m_device->deselect();
00073 }
KDE Home | KDE Accessibility Home | Description of Access Keys