2 changes: 1 addition & 1 deletion src/libkst/coredocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Kst {

class ObjectStore;

class KSTCORE_EXPORT CoreDocument
class KSTCORE_EXPORT CoreDocument
{
public:
CoreDocument();
Expand Down
2 changes: 1 addition & 1 deletion src/libkst/objectstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ObjectNameIndex;
// The ObjectStore is responsible for storing all the Objects in an
// application.

class KSTCORE_EXPORT ObjectStore
class KSTCORE_EXPORT ObjectStore
{
public:
ObjectStore();
Expand Down
60 changes: 60 additions & 0 deletions src/libkst/updateserver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/***************************************************************************
* *
* copyright : (C) 2013 C. Barth Netterfield *
* netterfield@astro.utoronto.ca *
* *
* 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. *
* *
***************************************************************************/
#include "updateserver.h"
#include <qapplication.h>

namespace Kst {

UpdateServer *UpdateServer::_self = UpdateServer::self();


UpdateServer* UpdateServer::self() {
if (!_self) {
_self = new UpdateServer;
qAddPostRoutine(UpdateServer::cleanup);
}
return _self;
}


void UpdateServer::cleanup() {
delete _self;
_self = 0;
}

UpdateServer::UpdateServer(): _signalSuspendDepthCounter(0) {

}

UpdateServer::~UpdateServer() {
}


void UpdateServer::endSuspendSignals() {
if (_signalSuspendDepthCounter>0) {
_signalSuspendDepthCounter--;
}
if (_signalRequested) {
requestUpdateSignal();
}
}

void UpdateServer::requestUpdateSignal() {
if (_signalSuspendDepthCounter==0) {
emit objectListsChanged();
_signalRequested = false;
} else {
_signalRequested = true;
}
}

}
59 changes: 59 additions & 0 deletions src/libkst/updateserver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/***************************************************************************
* *
* copyright : (C) 2013 C. Barth Netterfield *
* netterfield@astro.utoronto.ca *
* *
* 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. *
* *
***************************************************************************/

/** this class will provide a signal when an update to object lists in
* dialogs is needed. For instance, when a new vector is added, or its
* name has been changed. */

#ifndef UPDATESERVER_H
#define UPDATESERVER_H

#include "kst_export.h"

#include <QObject>

namespace Kst {

/** A signal is requested by a call to requestUpdateSignal. The signal
* will be emitted when the _signalSuspendDepthCounter is zero. If multiple
* signals are requested while _signalSuspendDepthCounter is non zero, only one
* will be emitted. beginSuspendSignals() increments _signalSuspendDepthCounter.
* endSuspendSignals() decrements it. */
class KSTCORE_EXPORT UpdateServer : public QObject
{
Q_OBJECT
public:
static UpdateServer* self();
void beginSuspendSignals() {_signalSuspendDepthCounter++;}
void endSuspendSignals();
void requestUpdateSignal();

private:
UpdateServer();
~UpdateServer();

static UpdateServer* _self;
static void cleanup();

int _signalSuspendDepthCounter;
bool _signalRequested;

Q_SIGNALS:
void objectListsChanged();

public slots:


};

}
#endif // UPDATESERVER_H
5 changes: 5 additions & 0 deletions src/libkstapp/changedatasampledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "application.h"
#include "dialogdefaults.h"
#include "updatemanager.h"
#include "updateserver.h"

#include <QMessageBox>

Expand Down Expand Up @@ -54,6 +55,7 @@ ChangeDataSampleDialog::ChangeDataSampleDialog(QWidget *parent)
connect(_buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
connect(_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(OKClicked()));
connect(_buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
connect(UpdateServer::self(), SIGNAL(objectListsChanged()), this, SLOT(updateCurveListDialog()));

initializeEntries();
updateButtons();
Expand Down Expand Up @@ -188,6 +190,7 @@ void ChangeDataSampleDialog::updateCurveListDialog() {
if (!exists) {
QListWidgetItem *item = _vectorList->takeItem(i_item);
delete item;
i_item--;
}
}

Expand All @@ -203,6 +206,7 @@ void ChangeDataSampleDialog::updateCurveListDialog() {
if (!exists) {
QListWidgetItem *item = _selectedVectorList->takeItem(i_item);
delete item;
i_item--;
}
}

Expand Down Expand Up @@ -379,6 +383,7 @@ void ChangeDataSampleDialog::apply() {
}

UpdateManager::self()->doUpdates(true);
UpdateServer::self()->requestUpdateSignal();

_dialogDefaults->setValue("vector/range", _dataRange->range());
_dialogDefaults->setValue("vector/start", _dataRange->start());
Expand Down
3 changes: 2 additions & 1 deletion src/libkstapp/changedatasampledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ class ChangeDataSampleDialog : public QDialog, Ui::ChangeDataSampleDialog
void OKClicked();
void apply();

void updateCurveListDialog();

private:
void updateCurveListDialog();

void updateIndexEntries();

ObjectStore *_store;


};

}
Expand Down
6 changes: 6 additions & 0 deletions src/libkstapp/changefiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "mainwindow.h"
#include "application.h"
#include "updatemanager.h"
#include "updateserver.h"
#include "datasourcepluginmanager.h"

#include <QDir>
Expand Down Expand Up @@ -71,6 +72,7 @@ ChangeFileDialog::ChangeFileDialog(QWidget *parent)
connect(_buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));

connect(_configure, SIGNAL(clicked()), this, SLOT(showConfigWidget()));
connect(UpdateServer::self(), SIGNAL(objectListsChanged()), this, SLOT(updatePrimitiveList()));

_dataFile->setFile(_dialogDefaults->value("changedatafile/newFileName",QDir::currentPath()).toString());

Expand Down Expand Up @@ -184,6 +186,7 @@ void ChangeFileDialog::updatePrimitiveList() {
if (!exists) {
QListWidgetItem *item = _changeFilePrimitiveList->takeItem(i_item);
delete item;
i_item--;
}
}

Expand All @@ -199,6 +202,7 @@ void ChangeFileDialog::updatePrimitiveList() {
if (!exists) {
QListWidgetItem *item = _selectedFilePrimitiveList->takeItem(i_item);
delete item;
i_item--;
}
}

Expand Down Expand Up @@ -477,6 +481,8 @@ void ChangeFileDialog::apply() {
}

UpdateManager::self()->doUpdates(true);
UpdateServer::self()->requestUpdateSignal();

kstApp->mainWindow()->document()->setChanged(true);

// store the newly used file as default for the next time the dialog is called
Expand Down
2 changes: 1 addition & 1 deletion src/libkstapp/changefiledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class ChangeFileDialog : public QDialog, Ui::ChangeFileDialog
void OKClicked();
void apply();

private:
void updatePrimitiveList();

private:
ObjectStore *_store;
DataSourcePtr _dataSource;
int _requestID;
Expand Down
1 change: 1 addition & 0 deletions src/libkstapp/commandlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ bool CommandLineParser::processCommandLine(bool *ok) {
_plotItem->view()->resetPlotFontSizes();
}
UpdateManager::self()->doUpdates(true);

return (dataPlotted);
}

Expand Down
2 changes: 0 additions & 2 deletions src/libkstapp/csddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ ObjectPtr CSDDialog::createNewDataObject() {
}
}
}
UpdateManager::self()->doUpdates(true);

return ObjectPtr(image.data());
}
Expand Down Expand Up @@ -346,7 +345,6 @@ ObjectPtr CSDDialog::editExistingDataObject() const {
csd->unlock();
}
}
UpdateManager::self()->doUpdates(true);

return dataObject();
}
Expand Down
3 changes: 0 additions & 3 deletions src/libkstapp/curvedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,6 @@ ObjectPtr CurveDialog::createNewDataObject() {
}
}

UpdateManager::self()->doUpdates(true);

return ObjectPtr(curve.data());
}

Expand Down Expand Up @@ -601,7 +599,6 @@ ObjectPtr CurveDialog::editExistingDataObject() const {
}
}

UpdateManager::self()->doUpdates(true);
return dataObject();
}

Expand Down
8 changes: 5 additions & 3 deletions src/libkstapp/datadialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "application.h"
#include "updatemanager.h"
#include "sessionmodel.h"
#include "updateserver.h"

namespace Kst {

Expand Down Expand Up @@ -175,11 +176,12 @@ void DataDialog::slotApply() {
ptr = editExistingDataObject();
}
setDataObject(ptr);

UpdateManager::self()->doUpdates();
UpdateServer::self()->requestUpdateSignal();

kstApp->mainWindow()->document()->setChanged(true);
if (do_session_reset) {
kstApp->mainWindow()->document()->session()->triggerReset();
}

clearModified();
}

Expand Down
14 changes: 4 additions & 10 deletions src/libkstapp/datamanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "image.h"
#include "csd.h"
#include "basicplugin.h"
#include "updateserver.h"

#include <QHeaderView>
#include <QToolBar>
Expand Down Expand Up @@ -260,14 +261,6 @@ void DataManager::showEditDialog() {
}


bool DataManager::event(QEvent * event) {
if ((event->type() == QEvent::WindowActivate) || (event->type() == QEvent::Show)) {
_doc->session()->triggerReset();
}
return QDialog::event(event);
}


void DataManager::showVectorDialog() {
QString tmp;
DialogLauncher::self()->showVectorDialog(tmp);
Expand Down Expand Up @@ -381,7 +374,8 @@ void DataManager::deleteObject() {
_doc->objectStore()->removeObject(primitive);
}
_currentObject = 0;
_doc->session()->triggerReset();
UpdateServer::self()->requestUpdateSignal();

// Now select the next item
_session->selectionModel()->select(_proxyModel->mapFromSource(model->index(row,0)), QItemSelectionModel::Select);
// Cleanup and return
Expand Down Expand Up @@ -504,7 +498,7 @@ void DataManager::purge() {
do {
setUsedFlags();
} while (_doc->objectStore()->deleteUnsetUsedFlags());
_doc->session()->triggerReset();
UpdateServer::self()->requestUpdateSignal();
_session->reset();
}

Expand Down
2 changes: 0 additions & 2 deletions src/libkstapp/datamanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class DataManager : public QDialog, Ui::DataManager
void addToPlot(QAction* action);
void removeFromPlot(QAction* action);

virtual bool event(QEvent * event);

void setUsedFlags();
void purge();

Expand Down
2 changes: 2 additions & 0 deletions src/libkstapp/datawizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "datasourcepluginmanager.h"
#include "sharedaxisboxitem.h"
#include "boxitem.h"
#include "updateserver.h"


namespace Kst {
Expand Down Expand Up @@ -1267,6 +1268,7 @@ void DataWizard::finished() {
QApplication::restoreOverrideCursor();
accept();

UpdateServer::self()->requestUpdateSignal();
}

}
Expand Down
4 changes: 4 additions & 0 deletions src/libkstapp/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <commandlineparser.h>
#include "objectstore.h"
#include "updatemanager.h"
#include "updateserver.h"

#include <QDebug>
#include <QFile>
Expand Down Expand Up @@ -418,6 +419,9 @@ bool Document::open(const QString& file) {
// Restore current app path
QDir::setCurrent(restorePath);


UpdateServer::self()->requestUpdateSignal();

return _isOpen = true;
}

Expand Down
Loading