Skip to content

Commit

Permalink
Add period from DataView list to DataView item for client
Browse files Browse the repository at this point in the history
  • Loading branch information
serhmarch committed Dec 14, 2024
1 parent 844b58e commit e85bb37
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 85 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.5) # 2.2 - case insensitive syntax

project(ModbusTools VERSION 0.3.8 LANGUAGES CXX)
project(ModbusTools VERSION 0.3.9 LANGUAGES CXX)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
Expand Down
18 changes: 8 additions & 10 deletions src/client/gui/client_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,6 @@ void mbClientUi::setCachedSettings(const MBSETTINGS &settings)
m_scannerUi->setCachedSettings(settings);
}

void mbClientUi::menuSlotViewProject()
{
ui->dockProject->show();
}

void mbClientUi::menuSlotViewLogView()
{
ui->dockLogView->show();
}

void mbClientUi::menuSlotEditPaste()
{
if (core()->isRunning())
Expand Down Expand Up @@ -611,3 +601,11 @@ void mbClientUi::editDevice(mbClientDevice *device)
m_project->setModifiedFlag(true);
}
}

MBSETTINGS mbClientUi::getDataViewItemCreateSettings()
{
MBSETTINGS res;
if (mbClientDataView *wl = dataViewManager()->activeDataView())
res[mbClientDataViewItem::Strings::instance().period] = wl->period();
return res;
}
16 changes: 7 additions & 9 deletions src/client/gui/client_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,13 @@ class mbClientUi : public mbCoreUi
void setCachedSettings(const MBSETTINGS &settings) override;

private Q_SLOTS:
// ----------------------------
// ------------VIEW------------
// ----------------------------
void menuSlotViewProject() override;
void menuSlotViewLogView() override;
// ----------------------------
// ------------EDIT------------
// ----------------------------
void menuSlotEditPaste () override;
void menuSlotEditInsert () override;
void menuSlotEditEdit () override;
void menuSlotEditDelete () override;
void menuSlotEditPaste () override;
void menuSlotEditInsert() override;
void menuSlotEditEdit () override;
void menuSlotEditDelete() override;
// ----------------------------
// ------------PORT------------
// ----------------------------
Expand Down Expand Up @@ -127,6 +122,9 @@ private Q_SLOTS:
void editPort(mbCorePort *port);
void editDevice(mbClientDevice *device);

private:
MBSETTINGS getDataViewItemCreateSettings() override;

private:
Ui::mbClientUi *ui;
// status bar labels
Expand Down
11 changes: 10 additions & 1 deletion src/client/gui/dialogs/client_dialogdataviewitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,22 @@ void mbClientDialogDataViewItem::setCachedSettings(const MBSETTINGS &settings)
it = settings.find(prefix+sItem.period); if (it != end) ui->spPeriod->setValue(it.value().toInt());
}

void mbClientDialogDataViewItem::fillFormInner(const MBSETTINGS &settings)
void mbClientDialogDataViewItem::fillFormEditInner(const MBSETTINGS &settings)
{
const mbClientDataViewItem::Strings &sItem = mbClientDataViewItem::Strings::instance();
int period = settings.value(sItem.period).toInt();
ui->spPeriod->setValue(period);
}

void mbClientDialogDataViewItem::fillFormNewInner(const MBSETTINGS &settings)
{
const mbClientDataViewItem::Strings &sItem = mbClientDataViewItem::Strings::instance();
MBSETTINGS::const_iterator it;
MBSETTINGS::const_iterator end = settings.end();

it = settings.find(sItem.period); if (it != end) ui->spPeriod->setValue(settings.value(sItem.period).toInt());
}

void mbClientDialogDataViewItem::fillDataInner(MBSETTINGS &settings) const
{
const mbClientDataViewItem::Strings &sItem = mbClientDataViewItem::Strings::instance();
Expand Down
3 changes: 2 additions & 1 deletion src/client/gui/dialogs/client_dialogdataviewitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class mbClientDialogDataViewItem : public mbCoreDialogDataViewItem
void setCachedSettings(const MBSETTINGS &settings) override;

private:
void fillFormInner(const MBSETTINGS &settings) override;
void fillFormEditInner(const MBSETTINGS &settings) override;
void fillFormNewInner(const MBSETTINGS &settings) override;
void fillDataInner(MBSETTINGS &settings) const override;

private:
Expand Down
8 changes: 4 additions & 4 deletions src/client/win_resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
IDI_ICON1 ICON DISCARDABLE "gui\\icons\\client.ico"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,3,8,0
PRODUCTVERSION 0,3,8,0
FILEVERSION 0,3,9,0
PRODUCTVERSION 0,3,9,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
Expand All @@ -21,11 +21,11 @@ VS_VERSION_INFO VERSIONINFO
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "\0"
VALUE "FileVersion", "0.3.8.0\0"
VALUE "FileVersion", "0.3.9.0\0"
VALUE "LegalCopyright", "\0"
VALUE "OriginalFilename", "client.exe\0"
VALUE "ProductName", "client\0"
VALUE "ProductVersion", "0.3.8.0\0"
VALUE "ProductVersion", "0.3.9.0\0"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 1 addition & 1 deletion src/core/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ void mbCore::logMessageThreadUnsafe(mb::LogFlag /*flag*/, const QString &source,
if (m_settings.useTimestamp)
msg = QString("%1 %2").arg(QDateTime::currentDateTime().toString(m_settings.formatDateTime), msg);
if (m_ui)
m_ui->showMessage(msg);
m_ui->logMessage(msg);
else
std::cout << msg.toStdString();
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/gui/core_logview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void mbCoreLogView::exportLog()
file.close();
}

void mbCoreLogView::showMessage(const QString &message)
void mbCoreLogView::logMessage(const QString &message)
{
m_text->appendPlainText(message);
}
2 changes: 1 addition & 1 deletion src/core/gui/core_logview.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class mbCoreLogView : public QWidget
public Q_SLOTS:
void clear();
void exportLog();
void showMessage(const QString& message);
void logMessage(const QString& message);

Q_SIGNALS:

Expand Down
35 changes: 29 additions & 6 deletions src/core/gui/core_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ void mbCoreUi::initialize()

this->setCentralWidget(m_windowManager->centralWidget());

// Output
m_dockOutput = new QDockWidget("Output", this);
m_dockOutput->setObjectName(QStringLiteral("dockOutput"));
//m_outputView = new mbCoreOutputView(m_dockOutput);
this->addDockWidget(Qt::BottomDockWidgetArea, m_dockOutput);
this->tabifyDockWidget(m_dockOutput, m_ui.dockLogView);

// Menu File
m_ui.actionFileRecent->setMenu(m_menuRecent);
m_ui.actionFileNew ->setShortcuts(QKeySequence::New );
Expand Down Expand Up @@ -279,7 +286,6 @@ void mbCoreUi::initialize()
m_tray->show();
qApp->setQuitOnLastWindowClosed(false);
}

}

bool mbCoreUi::useNameWithSettings() const
Expand Down Expand Up @@ -344,9 +350,9 @@ void mbCoreUi::setCachedSettings(const MBSETTINGS &settings)
m_help->setCachedSettings(settings);
}

void mbCoreUi::showMessage(const QString &message)
void mbCoreUi::logMessage(const QString &message)
{
m_logView->showMessage(message);
m_logView->logMessage(message);
}

void mbCoreUi::menuSlotFileNew()
Expand Down Expand Up @@ -399,6 +405,7 @@ void mbCoreUi::menuSlotFileSave()
menuSlotFileSaveAs();
return;
}
saveProjectInner();
m_project->setWindowsData(m_windowManager->saveWindowsState());
m_project->resetVersion();
if (m_core->builderCore()->saveCore(m_project))
Expand Down Expand Up @@ -500,12 +507,17 @@ void mbCoreUi::menuSlotEditSelectAll()

void mbCoreUi::menuSlotViewProject()
{

m_ui.dockProject->show();
}

void mbCoreUi::menuSlotViewLogView()
{

m_ui.dockLogView->show();
}

void mbCoreUi::menuSlotViewOutput()
{
m_dockOutput->show();
}

void mbCoreUi::menuSlotPortNew()
Expand Down Expand Up @@ -575,7 +587,8 @@ void mbCoreUi::menuSlotDeviceExport()

void mbCoreUi::menuSlotDataViewItemNew()
{
MBSETTINGS p = dialogsCore()->getDataViewItem(MBSETTINGS(), "New Item(s)");
MBSETTINGS ns = getDataViewItemCreateSettings();
MBSETTINGS p = dialogsCore()->getDataViewItem(ns, "New Item(s)");
if (p.count())
{
const mbCoreDataViewItem::Strings &sItem = mbCoreDataViewItem::Strings::instance();
Expand Down Expand Up @@ -1231,3 +1244,13 @@ void mbCoreUi::closeEvent(QCloseEvent *e)
}
}

void mbCoreUi::saveProjectInner()
{
// Note: base implementation do nothing
}

MBSETTINGS mbCoreUi::getDataViewItemCreateSettings()
{
return MBSETTINGS();
}

10 changes: 9 additions & 1 deletion src/core/gui/core_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class mbCoreDataView;
class mbCoreDataViewUi;
class mbCoreProjectUi;
class mbCoreLogView;
class mbCoreOutputView;
class mbCoreHelpUi;

namespace Ui {
Expand Down Expand Up @@ -84,6 +85,7 @@ class MB_EXPORT mbCoreUi : public QMainWindow
inline mbCoreProjectUi *projectUiCore() const { return m_projectUi; }
inline mbCoreWindowManager *windowManagerCore() const { return m_windowManager; }
inline mbCoreDataViewManager *dataViewManagerCore() const { return m_dataViewManager; }
inline mbCoreProject *projectCore() const { return m_project; }

public:
virtual void initialize();
Expand All @@ -96,7 +98,7 @@ class MB_EXPORT mbCoreUi : public QMainWindow
virtual void setCachedSettings(const MBSETTINGS &settings);

public Q_SLOTS:
void showMessage(const QString& message);
void logMessage(const QString& message);

protected Q_SLOTS:
// ----------------------------
Expand Down Expand Up @@ -127,6 +129,7 @@ protected Q_SLOTS:
// ----------------------------
virtual void menuSlotViewProject();
virtual void menuSlotViewLogView();
virtual void menuSlotViewOutput();
// ----------------------------
// ------------PORT------------
// ----------------------------
Expand Down Expand Up @@ -222,6 +225,8 @@ protected Q_SLOTS:

protected:
void closeEvent(QCloseEvent *e) override;
virtual void saveProjectInner();
virtual MBSETTINGS getDataViewItemCreateSettings();

protected:
mbCore *m_core;
Expand Down Expand Up @@ -310,6 +315,9 @@ protected Q_SLOTS:

QMenu *m_menuRecent;
QAction *m_actionFileRecentClear;
// Output
QDockWidget *m_dockOutput;
mbCoreOutputView *m_outputView;

QLabel *m_lbSystemName;
QLabel *m_lbSystemStatus;
Expand Down
38 changes: 22 additions & 16 deletions src/core/gui/dialogs/core_dialogdataviewitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,6 @@ MBSETTINGS mbCoreDialogDataViewItem::getSettings(const MBSETTINGS &settings, con
return r;
}

void mbCoreDialogDataViewItem::fillFormInner(const MBSETTINGS &/*settings*/)
{
// base implementation do nothing
}

void mbCoreDialogDataViewItem::fillDataInner(MBSETTINGS &/*settings*/) const
{
// base implementation do nothing
}

void mbCoreDialogDataViewItem::fillForm(const MBSETTINGS &settings)
{
const Strings &s = Strings::instance();
Expand Down Expand Up @@ -283,12 +273,13 @@ void mbCoreDialogDataViewItem::fillForm(const MBSETTINGS &settings)
it = settings.find(sItem.stringLengthType ); if (it != end) fillFormStringLengthType (it.value());
it = settings.find(sItem.stringEncoding ); if (it != end) fillFormStringEncoding (it.value());

fillFormInner(settings);
fillFormEditInner(settings);
m_ui.spCount->setValue(count);
m_ui.spCount->setDisabled(true);
}
else // new data
{
fillFormNewInner(settings);
deviceChanged(m_ui.cmbDevice->currentIndex());
m_ui.spCount->setDisabled(false);
}
Expand Down Expand Up @@ -538,6 +529,26 @@ void mbCoreDialogDataViewItem::fillDataStringEncoding(MBSETTINGS &settings, cons
settings[key] = cmb->currentText();
}

void mbCoreDialogDataViewItem::setNonDefaultByteArraySeparator(const QString &s) const
{
m_nonDefaultByteArraySeparator = mb::makeEscapeSequnces(s);
}

void mbCoreDialogDataViewItem::fillFormEditInner(const MBSETTINGS &/*settings*/)
{
// base implementation do nothing
}

void mbCoreDialogDataViewItem::fillFormNewInner(const MBSETTINGS &settings)
{
// base implementation do nothing
}

void mbCoreDialogDataViewItem::fillDataInner(MBSETTINGS &/*settings*/) const
{
// base implementation do nothing
}

void mbCoreDialogDataViewItem::deviceChanged(int i)
{
mbCoreProject *project = mbCore::globalCore()->projectCore();
Expand Down Expand Up @@ -642,8 +653,3 @@ bool mbCoreDialogDataViewItem::isDefaultByteArraySeparator() const
return !m_ui.lnByteArraySeparator->isEnabled();
}

void mbCoreDialogDataViewItem::setNonDefaultByteArraySeparator(const QString &s) const
{
m_nonDefaultByteArraySeparator = mb::makeEscapeSequnces(s);
}

9 changes: 5 additions & 4 deletions src/core/gui/dialogs/core_dialogdataviewitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ class MB_EXPORT mbCoreDialogDataViewItem : public mbCoreDialogSettings
public:
MBSETTINGS getSettings(const MBSETTINGS &settings = MBSETTINGS(), const QString &title = QString()) override;

protected:
virtual void fillFormInner(const MBSETTINGS &settings);
virtual void fillDataInner(MBSETTINGS &settings) const;

protected:
void fillForm(const MBSETTINGS &settings);
void fillFormFormat(const QVariant &v);
Expand All @@ -83,6 +79,11 @@ class MB_EXPORT mbCoreDialogDataViewItem : public mbCoreDialogSettings
void fillDataStringLengthType(MBSETTINGS &settings, const QString &key) const;
void fillDataStringEncoding(MBSETTINGS &settings, const QString &key) const;

protected:
virtual void fillFormEditInner(const MBSETTINGS &settings);
virtual void fillFormNewInner(const MBSETTINGS &settings);
virtual void fillDataInner(MBSETTINGS &settings) const;

protected Q_SLOTS:
void deviceChanged(int i);
void adrTypeChanged(int i);
Expand Down
Loading

0 comments on commit e85bb37

Please sign in to comment.