Commit 55a78748 authored by Inge Wallin's avatar Inge Wallin
Browse files

Follow the coding standards

svn path=/trunk/KDE/kdeedu/marble/; revision=717980
parent 68e36dc5
2007-09-26 Inge Wallin <inge@lysator.liu.se>
Make some files follow the coding standards better.
* src/lib/gps/GpxFile.h,
* src/lib/gps/RouteContainer.h,
* src/lib/gps/Track.h,
* src/lib/gps/WaypointContainer.cpp,
* src/lib/gps/Waypoint.h,
* src/lib/gps/GpxFileModel.cpp,
* src/lib/gps/WaypointContainer.h,
* src/lib/gps/GpxFileModel.h:
Follow coding standards
APIDOX
* src/lib/MarbleModel.h: More apidox
* src/lib/MarbleModel.cpp: Improve comments
......
......@@ -7,15 +7,18 @@
//
// Copyright 2007 Andrew Manson <g.real.ate@gmail.com>
//
#ifndef GPXFILE_H
#define GPXFILE_H
#include "AbstractLayer/AbstractLayerInterface.h"
#include <QtCore/Qt>
#include <QtCore/QString>
#include <QtCore/QTextStream>
#include "AbstractLayer/AbstractLayerInterface.h"
class ClipPainter;
class QPoint;
class QSize;
......@@ -28,6 +31,7 @@ class WaypointContainer;
class TrackContainer;
class RouteContainer;
class GpxFile : public AbstractLayerInterface
{
public:
......
......@@ -8,12 +8,16 @@
// Copyright 2007 Andrew Manson <g.real.ate@gmail.com>
//
#include "GpxFileModel.h"
#include <config-marble.h>
#include <QtCore/Qt>
#include <QtCore/QFile>
#include <QDebug>
#include <config-marble.h>
#ifdef QTONLY
#include <QtGui/QFileDialog>
#else
......@@ -23,7 +27,7 @@
GpxFileModel::GpxFileModel( QObject *parent )
: QAbstractItemModel( parent )
: QAbstractItemModel( parent )
{
m_data = new QVector<GpxFile*>();
}
......@@ -39,8 +43,8 @@ void GpxFileModel::saveFile()
QString fileName;
#ifdef QTONLY
fileName = QFileDialog::getSaveFileName( 0, tr("Save File"),
QString(),
tr("GpxFile (*.gpx)"));
QString(),
tr("GpxFile (*.gpx)"));
#else
fileName = KFileDialog::getSaveFileName( KUrl(),
tr("GpxFile (*.gpx)"),
......@@ -49,40 +53,36 @@ void GpxFileModel::saveFile()
#endif
QFile file( fileName );
if (!file.open(QIODevice::WriteOnly | QIODevice::Text) ) {
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) ) {
return;
}
QTextStream out(&file);
GpxFile* gpxFile =static_cast<GpxFile*>(
m_selectedIndex.internalPointer() );
GpxFile *gpxFile = static_cast<GpxFile*>( m_selectedIndex.internalPointer() );
out << (*gpxFile);
}
void GpxFileModel::closeFile()
{
GpxFile* file =static_cast<GpxFile*>(
GpxFile *file =static_cast<GpxFile*>(
m_selectedIndex.internalPointer() );
if ( !file->active() ) {
int index = m_data->indexOf( file );
if ( index >-1 ) {
if ( index > -1 ) {
m_data->remove( index );
emit( layoutChanged() );
emit( updateRegion( BoundingBox() ) );
}
}
}
Qt::ItemFlags GpxFileModel::flags( const QModelIndex &item ) const
{
return (static_cast<GpxFile*>(item.internalPointer()) ) ->flags()
;
return ( static_cast<GpxFile*>( item.internalPointer() ) )->flags();
}
QVariant GpxFileModel::data( const QModelIndex &index, int role )
const
QVariant GpxFileModel::data( const QModelIndex &index, int role ) const
{
if ( !index.isValid() ) {
return QVariant();
......@@ -90,13 +90,11 @@ QVariant GpxFileModel::data( const QModelIndex &index, int role )
if ( role == Qt::DisplayRole ) {
return static_cast<GpxFile*> ( index.internalPointer() )
->display();
return static_cast<GpxFile*> ( index.internalPointer() )->display();
}
if ( role == Qt::CheckStateRole ) {
return static_cast<GpxFile*>( index.internalPointer() )
->checkState();
return static_cast<GpxFile*>( index.internalPointer() )->checkState();
}
return QVariant();
......@@ -104,13 +102,14 @@ QVariant GpxFileModel::data( const QModelIndex &index, int role )
bool GpxFileModel::setData ( const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
int role )
{
if ( role == Qt::CheckStateRole ) {
( static_cast<GpxFile*>( index.internalPointer() ) )
->setCheckState( value.toBool() );
emit ( dataChanged( index, index ) );
emit ( updateRegion( BoundingBox() ) );
return true;
}
......
......@@ -8,23 +8,28 @@
// Copyright 2007 Andrew Manson <g.real.ate@gmail.com>
//
#ifndef GPXFILEMODEL_H
#define GPXFILEMODEL_H
#include "GpxFile.h"
#include "BoundingBox.h"
#include <QtCore/QAbstractItemModel>
#include <QtGui/QItemSelectionModel>
#include <QtCore/QVariant>
#include <QtCore/QVector>
#include "BoundingBox.h"
/**
* @author Andrew Manson <g.real.ate@gmail.com>
*/
class GpxFileModel : public QAbstractItemModel
{
Q_OBJECT
Q_SIGNALS :
void updateRegion( BoundingBox );
void enableActions( bool );
......@@ -41,22 +46,20 @@ public:
QVariant data( const QModelIndex &index,
int role = Qt::DisplayRole ) const;
bool setData ( const QModelIndex & index, const QVariant & value,
int role );
int role = Qt::EditRole );
QModelIndex index ( int row, int column,
const QModelIndex &parent = QModelIndex() )
const;
const QModelIndex &parent = QModelIndex() ) const;
QModelIndex parent ( const QModelIndex & index ) const;
int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
int columnCount ( const QModelIndex & parent = QModelIndex() )
const;
int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
void addFile( GpxFile *file);
void setSelectedIndex( const QModelIndex &);
QVector<GpxFile*>* allFiles();
private:
QModelIndex m_selectedIndex;
QVector<GpxFile*> *m_data;
private:
QModelIndex m_selectedIndex;
QVector<GpxFile*> *m_data;
};
#endif
......@@ -7,11 +7,14 @@
//
// Copyright 2007 Andrew Manson <g.real.ate@gmail.com>
//
#ifndef ROUTECONTAINER_H
#define ROUTECONTAINER_H
#include "AbstractLayer/AbstractLayerContainer.h"
/**
* @brief holds a collection of Routes
*/
......
......@@ -29,10 +29,10 @@
* reception was lost, or the GPS receiver was turned off, start a new
* Track Segment for each continuous span of track data.
*/
class Track : public AbstractLayerContainer,
public AbstractLayerData,
public GpsElement
{
public:
/**
......
......@@ -201,6 +201,7 @@ class Waypoint : public AbstractLayerData, public GpsElement
* @brief m_dgpsid setter
*/
void setDgpsid( const int &gpsdid );
private:
/**
* @brief Elevation (in meters) of the waypoint
......
......@@ -8,8 +8,10 @@
// Copyright 2007 Andrew Manson <g.real.ate@gmail.com>
//
#include "WaypointContainer.h"
WaypointContainer::WaypointContainer()
{
}
......@@ -19,8 +21,8 @@ void WaypointContainer::processVisable()
}
void WaypointContainer::draw( ClipPainter *painter,
const QSize &canvasSize, double radius,
Quaternion invRotAxis )
const QSize &canvasSize, double radius,
Quaternion invRotAxis )
{
const_iterator it;
bool draw;
......@@ -28,14 +30,12 @@ void WaypointContainer::draw( ClipPainter *painter,
painter->setBrush( QBrush( Qt::white ) );
for( it = this->begin(); it < this->constEnd();
it++ )
{
for ( it = this->begin(); it < this->constEnd(); ++it ) {
draw = (*it)->getPixelPos( canvasSize, invRotAxis,
(int)radius, &position );
if ( draw ) {
( *it ) -> draw( painter, position );
( *it )->draw( painter, position );
}
}
}
......
......@@ -20,6 +20,7 @@ class WaypointContainer : public virtual AbstractLayerContainer
WaypointContainer();
WaypointContainer( QString name ):AbstractLayerContainer( name ) {}
virtual ~WaypointContainer() {}
/*
virtual void draw ( ClipPainter *painter, const QPoint &point );
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment