27 #include "../../../common/SystemApplicationSettings.h" 28 #include "../../../dataaccess/utils/Utils.h" 29 #include "../../af/events/LayerEvents.h" 30 #include "../../af/ApplicationController.h" 34 #include <QApplication> 38 #include <QMessageBox> 44 #include <boost/filesystem.hpp> 64 if(pixmap.empty() ==
false)
65 m_action->setIcon(QIcon::fromTheme(pixmap.c_str()));
75 std::string type = dataSource->getType();
79 std::string fpath = dataSource->getConnectionInfo().uri();
82 if(hasSpatialIndex ==
false)
86 QSettings settings(QSettings::IniFormat,
88 QApplication::instance()->organizationName(),
89 QApplication::instance()->applicationName());
91 bool question = settings.value(
"vp_config/default_question",
93 bool option = settings.value(
"vp_config/spatial_index_as_default",
99 QCheckBox *askAgain =
new QCheckBox(
"Would you like to save this setting and not ask again?");
101 QMessageBox question(QMessageBox::Question, tr(
"Vector Processing"),
102 tr(
"Would you like to add spatial index on output layer?"));
103 question.addButton(QMessageBox::No);
104 question.addButton(QMessageBox::Yes);
105 question.setCheckBox(askAgain);
107 int addSpatialIndex = question.exec();
109 std::unique_ptr<QCheckBox> checkBoxState(question.checkBox());
111 if(addSpatialIndex == QMessageBox::Yes)
113 if(checkBoxState->isChecked() ==
true)
115 settings.setValue(
"vp_config/default_question",
false);
116 settings.setValue(
"vp_config/spatial_index_as_default",
true);
123 if(checkBoxState->isChecked() ==
true)
125 settings.setValue(
"vp_config/default_question",
false);
126 settings.setValue(
"vp_config/spatial_index_as_default",
false);
152 std::list<te::map::AbstractLayerPtr> allLayers = e.
m_layers;
154 std::list<te::map::AbstractLayerPtr> layers;
156 for (std::list<te::map::AbstractLayerPtr>::iterator it = allLayers.begin(); it != allLayers.end(); ++it)
158 if ((*it)->isValid())
159 layers.push_back(*it);
164 if (!selectedlayer || !selectedlayer->isValid())
167 std::list<te::map::AbstractLayerPtr> result;
169 result.push_back(selectedlayer);
171 for (std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin(); it != layers.end(); ++it)
173 if ((*it)->getId() != selectedlayer->getId())
174 result.push_back(*it);
183 QFileInfo fileInfo(path);
186 QString fileName = fileInfo.fileName();
189 QDir dir(fileInfo.absolutePath());
192 QString qixFile = fileName;
193 qixFile.replace(
".shp",
".qix");
194 if(dir.exists(qixFile))
198 QString sbnFile = fileName;
199 sbnFile.replace(
".shp",
".sbn");
200 if(dir.exists(sbnFile))
212 std::string command =
"CREATE SPATIAL INDEX ON " + layer->getDataSetName();
214 dataSource->execute(command);
216 QApplication::restoreOverrideCursor();
227 QSettings settings(QSettings::IniFormat,
228 QSettings::UserScope,
229 QApplication::instance()->organizationName(),
230 QApplication::instance()->applicationName());
232 bool contains = settings.contains(QString(
"vp_config/default_question"));
233 if (contains ==
false)
235 settings.beginGroup(
"vp_config");
238 settings.setValue(
"vp_config/default_question",
true);
239 settings.setValue(
"vp_config/spatial_index_as_default",
false);
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
This event signals that a new layer was created.
te::map::AbstractLayerPtr m_layer
Layer selected.
This event is used to get a single layer selected in layer tree.
boost::shared_ptr< DataSource > DataSourcePtr
QMenu * m_menu
Parent Menu.
void createAction(std::string name, std::string pixmap="")
Create and set the actions parameters.
This file defines the abstract class AbstractAction.
void createSpatialIndex(te::map::AbstractLayerPtr layer)
bool hasShapeFileSpatialIndex(const QString &path)
static T & getInstance()
It returns a reference to the singleton instance.
void addNewLayer(te::map::AbstractLayerPtr layer)
Add a new layer into layer explorer widget.
AbstractAction(QMenu *menu)
Constructor.
QAction * m_action
Action used to call the process.
std::list< te::map::AbstractLayerPtr > m_layers
std::list< te::map::AbstractLayerPtr > getLayers()
Get the list of layers from app.
virtual ~AbstractAction()
Destructor.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void triggered(te::qt::af::evt::Event *e)
virtual void onActionActivated(bool checked)=0
Slot function used when a action was selected.