[Marble-commits] KDE/kdeedu/marble/src/lib
Thibaut Gridel
tgridel at free.fr
Mon Jan 10 21:35:04 CET 2011
SVN commit 1213564 by tgridel:
remove KmlFileViewItem and use GeoDataDocument directly
M +0 -1 CMakeLists.txt
M +11 -21 FileManager.cpp
M +1 -2 FileManager.h
M +8 -9 FileViewModel.cpp
M +3 -5 GeoDataTreeModel.cpp
D KmlFileViewItem.cpp
D KmlFileViewItem.h
M +9 -12 PlacemarkManager.cpp
--- trunk/KDE/kdeedu/marble/src/lib/CMakeLists.txt #1213563:1213564
@@ -150,7 +150,6 @@
FileLoader.cpp
FileManager.cpp
FileViewModel.cpp
- KmlFileViewItem.cpp
PositionTracking.cpp
DataMigration.cpp
--- trunk/KDE/kdeedu/marble/src/lib/FileManager.cpp #1213563:1213564
@@ -16,7 +16,6 @@
#include "FileLoader.h"
#include "FileViewModel.h"
-#include "KmlFileViewItem.h"
#include "MarbleDebug.h"
#include "MarbleDataFacade.h"
#include "GeoDataTreeModel.h"
@@ -39,7 +38,7 @@
MarbleDataFacade* m_datafacade;
QList<FileLoader*> m_loaderList;
QStringList m_pathList;
- QList < KmlFileViewItem* > m_fileItemList;
+ QList < GeoDataDocument* > m_fileItemList;
};
}
@@ -58,8 +57,8 @@
}
}
- foreach ( KmlFileViewItem *file, d->m_fileItemList ) {
- delete file;
+ foreach ( GeoDataDocument *document, d->m_fileItemList ) {
+ closeFile( d->m_fileItemList.indexOf( document ) );
}
delete d;
@@ -117,7 +116,7 @@
void FileManager::removeFile( const QString& key )
{
for ( int i = 0; i < d->m_fileItemList.size(); ++i ) {
- if ( key == d->m_fileItemList.at(i)->name() ) {
+ if ( key == d->m_fileItemList.at(i)->fileName() ) {
closeFile( i );
return;
}
@@ -127,20 +126,13 @@
void FileManager::saveFile( int index )
{
- if ( index < d->m_fileItemList.size() ) {
- d->m_fileItemList.at( index )->saveFile();
}
-}
void FileManager::closeFile( int index )
{
- mDebug() << "FileManager::closeFile";
+ mDebug() << "FileManager::closeFile " << d->m_fileItemList.at( index )->fileName();
if ( index < d->m_fileItemList.size() ) {
emit fileRemoved( index );
- KmlFileViewItem *file = d->m_fileItemList.at( index );
- if ( file ) {
- delete file->document();
- }
delete d->m_fileItemList.at( index );
d->m_fileItemList.removeAt( index );
}
@@ -151,7 +143,7 @@
return d->m_fileItemList.size();
}
-KmlFileViewItem * FileManager::at( int index )
+GeoDataDocument * FileManager::at( int index )
{
if ( index < d->m_fileItemList.size() ) {
return d->m_fileItemList.at( index );
@@ -161,15 +153,13 @@
void FileManager::addGeoDataDocument( GeoDataDocument* document )
{
- KmlFileViewItem* item = new KmlFileViewItem( document );
- d->m_fileItemList.append( item );
- emit fileAdded( d->m_fileItemList.indexOf( item ) );
+ d->m_fileItemList.append( document );
+ emit fileAdded( d->m_fileItemList.indexOf( document ) );
- // now get the document that will be preserved throughout the life time
- GeoDataDocument* doc = item->document();
- if ( doc->name().isEmpty() && !doc->fileName().isEmpty() )
+ if ( document->name().isEmpty() && !document->fileName().isEmpty() )
{
- doc->setName( doc->fileName() );
+ QFileInfo file( document->fileName() );
+ document->setName( file.baseName() );
}
}
--- trunk/KDE/kdeedu/marble/src/lib/FileManager.h #1213563:1213564
@@ -19,7 +19,6 @@
namespace Marble
{
-class KmlFileViewItem;
class FileManagerPrivate;
class GeoDataDocument;
class MarbleDataFacade;
@@ -81,7 +80,7 @@
void closeFile( int index );
int size() const;
- KmlFileViewItem *at( int index );
+ GeoDataDocument *at( int index );
Q_SIGNALS:
--- trunk/KDE/kdeedu/marble/src/lib/FileViewModel.cpp #1213563:1213564
@@ -11,12 +11,11 @@
// Own
#include "FileViewModel.h"
+#include "GeoDataDocument.h"
+#include "FileManager.h"
#include <QtGui/QItemSelectionModel>
-#include "KmlFileViewItem.h"
-#include "FileManager.h"
-
using namespace Marble;
FileViewModel::FileViewModel( QObject* parent ) :
@@ -46,13 +45,13 @@
if ( row < m_manager->size() ) {
if ( index.column() == 0 ) {
- const KmlFileViewItem& item = *m_manager->at( row );
+ const GeoDataDocument *document = m_manager->at( row );
if ( role == Qt::CheckStateRole ) {
- return item.isShown () ? Qt::Checked : Qt::Unchecked;
+ return document->isVisible() ? Qt::Checked : Qt::Unchecked;
}
if ( role == Qt::DisplayRole ) {
- return item.name();
+ return document->name();
}
}
}
@@ -81,12 +80,12 @@
if ( index.column() == 0 ) {
if ( role == Qt::CheckStateRole ) {
- KmlFileViewItem& item = *m_manager->at( row );
+ GeoDataDocument *document = m_manager->at( row );
bool newValue = value.toBool ();
- if ( item.isShown() != newValue ) {
+ if ( document->isVisible() != newValue ) {
- item.setShown( newValue );
+ document->setVisible( newValue );
emit dataChanged( index, index );
emit modelChanged();
return true;
--- trunk/KDE/kdeedu/marble/src/lib/GeoDataTreeModel.cpp #1213563:1213564
@@ -26,7 +26,6 @@
#include "GeoDataStyle.h"
#include "GeoDataTypes.h"
#include "FileManager.h"
-#include "KmlFileViewItem.h"
#include "MarbleDebug.h"
#include "MarblePlacemarkModel.h"
@@ -401,12 +400,11 @@
void GeoDataTreeModel::addDocument( int index )
{
- KmlFileViewItem *file =
- static_cast<KmlFileViewItem*>(d->m_fileManager->at(index));
- if (file)
+ GeoDataDocument *document = d->m_fileManager->at(index);
+ if (document)
{
beginResetModel();
- d->m_rootDocument->append( file->document() ) ;
+ d->m_rootDocument->append( document ) ;
endResetModel();
}
}
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.cpp #1213563:1213564
@@ -20,7 +20,6 @@
#include "MarbleDebug.h"
#include "FileManager.h"
-#include "KmlFileViewItem.h"
#include "MarbleDirs.h"
#include "MarblePlacemarkModel.h"
#include "MarbleDataFacade.h"
@@ -87,21 +86,20 @@
void PlacemarkManager::addGeoDataDocument( int index )
{
- KmlFileViewItem *file = d->m_fileManager->at(index);
- if (file)
+ GeoDataDocument *document = d->m_fileManager->at(index);
+ if (document)
{
- const GeoDataDocument &document = *file->document();
- QVector<GeoDataPlacemark*> result = recurseContainer(file->document());
+ QVector<GeoDataPlacemark*> result = recurseContainer(document);
if (!result.isEmpty())
{
createFilterProperties( result );
- setupStyle( file->document(), result );
+ setupStyle( document, result );
int start = d->m_placemarkContainer.size();
d->m_placemarkContainer << result;
d->m_sizeForDocument.resize(index+1);
d->m_sizeForDocument[index] = result.size();
mDebug() << "PlacemarkManager::addGeoDataDocument:"
- << document.fileName() << " size " << result.size();
+ << document->fileName() << " size " << result.size();
model()->addPlacemarks( start, result.size() );
}
@@ -110,10 +108,9 @@
void PlacemarkManager::removeGeoDataDocument( int index )
{
- KmlFileViewItem *file = d->m_fileManager->at(index);
- if (file)
+ GeoDataDocument *document = d->m_fileManager->at(index);
+ if (document)
{
- const GeoDataDocument &document = *file->document();
int start = 0;
for ( int i = 0; i < index; ++i )
{
@@ -124,9 +121,9 @@
if (d->m_sizeForDocument.size() > index)
d->m_sizeForDocument.remove(index);
mDebug() << "PlacemarkManager::removeGeoDataDocument:"
- << document.fileName() << " size " << size;
+ << document->fileName() << " size " << size;
model()->removePlacemarks(
- document.fileName(), start, size );
+ document->fileName(), start, size );
}
}
More information about the Marble-commits
mailing list