Initial file load for the QGIS Clipboard - enabler of a future commit for cut / copy / paste of features.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@3488 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
morb_au 2005-05-28 23:26:50 +00:00
parent 7a1402a25a
commit edfa27c703
2 changed files with 169 additions and 0 deletions

78
src/qgsclipboard.cpp Normal file
View File

@ -0,0 +1,78 @@
/***************************************************************************
qgsclipboard.cpp - QGIS internal clipboard for storage of features
--------------------------------------------------------------------
begin : 20 May, 2005
copyright : (C) 2005 by Brendan Morley
email : morb at ozemail dot com dot au
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#include <fstream>
#include <iostream>
#include "qgsclipboard.h"
QgsClipboard::QgsClipboard()
: mFeatureClipboard(0)
{
}
QgsClipboard::~QgsClipboard()
{
}
void QgsClipboard::replaceWithCopyOf( std::vector<QgsFeature> features )
{
mFeatureClipboard = features;
#ifdef QGISDEBUG
std::cerr << "QgsClipboard::replaceWith: replaced clipboard."
<< std::endl;
#endif
}
std::vector<QgsFeature> QgsClipboard::copyOf()
{
#ifdef QGISDEBUG
std::cerr << "QgsClipboard::copyOf: returning clipboard."
<< std::endl;
#endif
return mFeatureClipboard;
}
void QgsClipboard::clear()
{
mFeatureClipboard.clear();
#ifdef QGISDEBUG
std::cerr << "QgsClipboard::clear: cleared clipboard."
<< std::endl;
#endif
}
void QgsClipboard::insert( QgsFeature& feature )
{
mFeatureClipboard.push_back(feature);
#ifdef QGISDEBUG
std::cerr << "QgsClipboard::insert: inserted " << feature.geometry()->wkt()
<< std::endl;
#endif
}

91
src/qgsclipboard.h Normal file
View File

@ -0,0 +1,91 @@
/***************************************************************************
qgsclipboard.h - QGIS internal clipboard for storage of features
------------------------------------------------------------------
begin : 20 May, 2005
copyright : (C) 2005 by Brendan Morley
email : morb at ozemail dot com dot au
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef QGSCLIPBOARD_H
#define QGSCLIPBOARD_H
#include <vector>
#include "qgsfeature.h"
/**
\brief QGIS internal clipboard for features.
An internal clipboard is required so that features can be retained in
their original fidelity.
The internal clipboard makes a copy of features that are presented to it,
therefore the original objects can safely be destructed independent of
the lifetime of the internal clipboard.
As this class matures it should also be able to accept CSV repesentations
of features in and out of the system clipboard (QClipboard).
TODO: Make it work
*/
class QgsClipboard
{
public:
/**
* Constructor for the clipboard.
*/
QgsClipboard();
//! Destructor
virtual ~QgsClipboard();
/*
* Place a copy of features on the internal clipboard,
* destroying the previous contents.
*/
void replaceWithCopyOf( std::vector<QgsFeature> features );
/*
* Returns a copy of features on the internal clipboard,
* the caller assumes responsibility fot destroying the contents
* when it's done with it.
*/
std::vector<QgsFeature> copyOf();
/*
* Clears the internal clipboard.
*/
void clear();
/*
* Inserts a copy of the feature on the internal clipboard.
*/
void insert( QgsFeature& feature );
private:
/** QGIS-internal vector feature clipboard */
std::vector<QgsFeature> mFeatureClipboard;
};
#endif