• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
ExternalEditorDialog.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2010 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include "ExternalEditorDialog.h"
12 
13 #include <QProcessEnvironment>
14 #include <QFileInfo>
15 #include <QDir>
16 
17 namespace Marble
18 {
19 
20 namespace {
21  QString const merkaartor = "merkaartor";
22  QString const josm = "josm";
23  QString const potlatch = "potlatch";
24 }
25 
26 class ExternalEditorDialogPrivate {
27 public:
28  QString m_defaultEditor;
29 
30  QMap<QString,bool> m_installedEditors;
31 
32  ExternalEditorDialogPrivate();
33 };
34 
35 ExternalEditorDialogPrivate::ExternalEditorDialogPrivate() :
36  m_defaultEditor( potlatch )
37 {
38  QString path = QProcessEnvironment::systemEnvironment().value( "PATH", "/usr/local/bin:/usr/bin:/bin" );
39  foreach( const QString &application, QStringList() << merkaartor << josm ) {
40  m_installedEditors[application] = false;
42  foreach( const QString &dir, path.split( QLatin1Char( ':' ) ) ) {
43  QFileInfo executable( QDir( dir ), application );
44  if ( executable.exists() ) {
45  m_installedEditors[application] = true;
46  break;
47  }
48  }
49  }
50 }
51 
52 ExternalEditorDialog::ExternalEditorDialog( QWidget * parent, Qt::WindowFlags flags ) :
53  QDialog( parent, flags ), d( new ExternalEditorDialogPrivate )
54 {
55  setupUi( this );
56 
57  connect( editorComboBox, SIGNAL(currentIndexChanged(int)),
58  this, SLOT(updateDefaultEditor(int)) );
59 
60  if ( d->m_installedEditors[merkaartor] ) {
61  d->m_defaultEditor = merkaartor;
62  editorComboBox->setCurrentIndex( 1 );
63  } else if ( d->m_installedEditors[josm] ) {
64  d->m_defaultEditor = josm;
65  editorComboBox->setCurrentIndex( 2 );
66  }
67 }
68 
69 ExternalEditorDialog::~ExternalEditorDialog()
70 {
71  delete d;
72 }
73 
74 QString ExternalEditorDialog::externalEditor() const
75 {
76  return d->m_defaultEditor;
77 }
78 
79 bool ExternalEditorDialog::saveDefault() const
80 {
81  return saveDefaultCheckBox->isChecked();
82 }
83 
84 void ExternalEditorDialog::updateDefaultEditor( int index )
85 {
86  QString description;
87 
88  switch( index ) {
89  case 1:
90  d->m_defaultEditor = merkaartor;
91  description = tr( "Merkaartor is an OpenStreetMap editor that is powerful and easy to use. It integrates well into the used workspace." );
92  if ( !d->m_installedEditors[d->m_defaultEditor] ) {
93  description += " <b>" + tr( "Please ask your system administrator to install %1 on your system." ).arg( "Merkaartor") + "</b>";
94  }
95  break;
96  case 2:
97  d->m_defaultEditor = josm;
98  description = tr( "JOSM is a powerful OpenStreetMap editor which is more complex to use than other editors. It is built on the Java platform and therefor runs on all systems for which Java is available but does not integrate well into the workspace. A Java SE-compatible runtime is required." );
99  if ( !d->m_installedEditors[d->m_defaultEditor] ) {
100  description += " <b>" + tr( "Please ask your system administrator to install %1 on your system." ).arg( "JOSM" ) + "</b>";
101  }
102  break;
103  default:
104  d->m_defaultEditor = potlatch;
105  description = tr( "Potlatch is a very easy to use OpenStreetMap editor, though lacks the power of Merkaartor and JOSM. It runs on all platforms for which web browsers with Flash support are available. Performance of Potlatch is depending on the quality of the installed Flash version." );
106  break;
107  }
108 
109  screenshotLabel->setPixmap( QPixmap( ":/data/editors/" + d->m_defaultEditor + ".png" ) );
110  descriptionLabel->setText( description );
111 }
112 
113 }
114 
115 #include "ExternalEditorDialog.moc"
QDialog
QWidget
ExternalEditorDialog.h
Marble::ExternalEditorDialog::externalEditor
QString externalEditor() const
Definition: ExternalEditorDialog.cpp:74
Marble::ExternalEditorDialog::~ExternalEditorDialog
~ExternalEditorDialog()
Definition: ExternalEditorDialog.cpp:69
Marble::ExternalEditorDialog::saveDefault
bool saveDefault() const
Definition: ExternalEditorDialog.cpp:79
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal