Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some corrections(Json and correct order of function calls) and some improvements(saveAs,Open). #317

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Core/Commands/TemplateCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ const QString TemplateCommand::getTemplateData() const
{
if (this->sendAsJson)
{
templateData.append("{");
QJsonObject jsonObject;
foreach (KeyValueModel model, this->models)
{
templateData.append(QString("\\\"%1\\\":\\\"%2\\\",").arg(model.getKey())
.arg((this->useUppercaseData == true) ? model.getValue().toUpper() : model.getValue()));
jsonObject[model.getKey()] = (this->useUppercaseData == true) ? model.getValue().toUpper() : model.getValue();
}
templateData.chop(1);
templateData.append("}");
QJsonDocument jsonDocument(jsonObject);
QString strJson(jsonDocument.toJson(QJsonDocument::Compact));
strJson.replace("\"", "\\\"");
templateData.append(strJson);
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Commands/TemplateCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <boost/property_tree/xml_parser.hpp>

#include <QtCore/QString>
#include <QJsonObject>
#include <QJsonDocument>

class QObject;
class QXmlStreamWriter;
Expand Down
3 changes: 2 additions & 1 deletion src/Widgets/Library/DeviceFilterWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ DeviceFilterWidget::DeviceFilterWidget(QWidget* parent)
this->listWidget.addItem(item);
this->lineEditDeviceFilter->setText(item->text());

this->comboBoxDeviceFilter->setView(&this->listWidget);
this->comboBoxDeviceFilter->setModel(this->listWidget.model());
this->comboBoxDeviceFilter->setView(&this->listWidget);


QObject::connect(&this->listWidget, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemPressed(QListWidgetItem*)));
QObject::connect(&DeviceManager::getInstance(), SIGNAL(deviceRemoved()), this, SLOT(deviceRemoved()));
Expand Down
19 changes: 13 additions & 6 deletions src/Widgets/Rundown/RundownTreeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,17 +707,24 @@ void RundownTreeWidget::saveRundown(bool saveAs)
return;

QString path;
if (saveAs)
path = QFileDialog::getSaveFileName(this, "Save Rundown", QDir::homePath(), "Rundown (*.xml)");
if (saveAs) {
if (this->activeRundown == Rundown::DEFAULT_NAME) {
path = QDir::homePath();
}
else {
QFileInfo fi(this->activeRundown);
path = fi.absolutePath();
}
path = QFileDialog::getSaveFileName(this, "Save Rundown", path, "Rundown (*.xml)");
}
else
path = (this->activeRundown == Rundown::DEFAULT_NAME) ? QFileDialog::getSaveFileName(this, "Save Rundown", QDir::homePath(), "Rundown (*.xml)") : this->activeRundown;

// Make sure we have an extension. On *nix system it will not be appended by default.
if (!path.toLower().endsWith(".xml"))
path.append(".xml");

if (!path.isEmpty())
{
// Make sure we have an extension. On *nix system it will not be appended by default.
if (!path.toLower().endsWith(".xml"))
path.append(".xml");
EventManager::getInstance().fireStatusbarEvent(StatusbarEvent("Saving rundown..."));

QFile file(path);
Expand Down
14 changes: 11 additions & 3 deletions src/Widgets/Rundown/RundownWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,17 @@ void RundownWidget::openRundown(const OpenRundownEvent& event)
{
QString path = "";

if (event.getPath().isEmpty())
path = QFileDialog::getOpenFileName(this, "Open Rundown", QDir::homePath(), "Rundown (*.xml)");
else
if (event.getPath().isEmpty()){
QList<QString> paths = DatabaseManager::getInstance().getOpenRecent();
if(paths.count() > 0){
path = paths.at(0);
QFileInfo fi(path);
path = fi.absolutePath();
}else{
path = QDir::homePath();
}
path = QFileDialog::getOpenFileName(this, "Open Rundown", path , "Rundown (*.xml)");
}else
path = event.getPath();

if (!path.isEmpty())
Expand Down