tycho: move ProjectModel to Rust so it can be used for magic
parent
1d8ebfb4dc
commit
494ed48981
|
@ -29,7 +29,6 @@ add_library(
|
|||
cc_source/main.cc
|
||||
cc_source/mapprops.cc
|
||||
cc_source/menu.cc
|
||||
cc_source/projectmodel.cc
|
||||
cc_source/projectview.cc
|
||||
resources/resources.qrc
|
||||
ui/about.ui
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
"implementationModule": "qimpl"
|
||||
},
|
||||
"objects": {
|
||||
"Project": {
|
||||
"type": "Object",
|
||||
"ProjectModel": {
|
||||
"type": "List",
|
||||
"functions": {
|
||||
"open": {
|
||||
"return": "bool",
|
||||
|
@ -16,11 +16,27 @@
|
|||
"name": "fname",
|
||||
"type": "QString"
|
||||
}]
|
||||
},
|
||||
"save": {
|
||||
"return": "void",
|
||||
"mut": false
|
||||
},
|
||||
"isDirty": {
|
||||
"return": "bool",
|
||||
"mut": false
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
},
|
||||
"itemProperties": {
|
||||
"rowName": {
|
||||
"type": "quint64",
|
||||
"roles": [["display"]]
|
||||
},
|
||||
"someNumber": {
|
||||
"type": "quint64",
|
||||
"roles": [[], ["display"]]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,24 +5,6 @@
|
|||
#include "bindings.h"
|
||||
#include "../ui/ui_projectview.h"
|
||||
|
||||
class ProjectModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ProjectModel();
|
||||
~ProjectModel();
|
||||
|
||||
bool isDirty() const;
|
||||
|
||||
public slots:
|
||||
bool open(const QString &fname);
|
||||
void save();
|
||||
|
||||
private:
|
||||
Project data;
|
||||
};
|
||||
|
||||
class ProjectView : public QMdiSubWindow, private Ui::ProjectView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
#include "tycho.h"
|
||||
#include "project.h"
|
||||
|
||||
ProjectModel::ProjectModel() :
|
||||
data()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectModel::~ProjectModel()
|
||||
{
|
||||
dbgPrintFunc();
|
||||
}
|
||||
|
||||
bool ProjectModel::isDirty() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProjectModel::open(const QString &fname)
|
||||
{
|
||||
return data.open(fname);
|
||||
}
|
||||
|
||||
void ProjectModel::save()
|
||||
{
|
||||
dbgPrintFunc();
|
||||
}
|
||||
|
||||
// EOF
|
|
@ -15,6 +15,8 @@ ProjectView::ProjectView(QWidget *parent) :
|
|||
setWidget(widget);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
listView->setModel(proj.data());
|
||||
|
||||
dbgPrintFunc();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,47 +1,63 @@
|
|||
//! Project management.
|
||||
|
||||
use crate::qintr::*;
|
||||
use std::{cell::RefCell, fs};
|
||||
use memmap::Mmap;
|
||||
//use memmap::Mmap;
|
||||
use maraiah::map;
|
||||
|
||||
pub struct Project
|
||||
pub struct ProjectModel
|
||||
{
|
||||
emit: ProjectEmitter,
|
||||
wad: RefCell<Option<map::Wad>>,
|
||||
emit: ProjectModelEmitter,
|
||||
}
|
||||
|
||||
impl Drop for Project
|
||||
impl Drop for ProjectModel
|
||||
{
|
||||
fn drop(&mut self)
|
||||
{
|
||||
if cfg!(debug_assertions) {
|
||||
eprintln!("drop Project");
|
||||
eprintln!("drop ProjectModel");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ProjectTrait for Project
|
||||
impl ProjectModelTrait for ProjectModel
|
||||
{
|
||||
fn new(emit: ProjectEmitter) -> Project
|
||||
fn new(emit: ProjectModelEmitter, _: ProjectModelList) -> ProjectModel
|
||||
{
|
||||
if cfg!(debug_assertions) {
|
||||
eprintln!("new Project");
|
||||
eprintln!("new ProjectModel");
|
||||
}
|
||||
|
||||
Project{emit, wad: RefCell::new(None)}
|
||||
ProjectModel{emit}
|
||||
}
|
||||
|
||||
fn emit(&mut self) -> &mut ProjectEmitter
|
||||
fn emit(&mut self) -> &mut ProjectModelEmitter
|
||||
{
|
||||
&mut self.emit
|
||||
}
|
||||
|
||||
fn row_count(&self) -> usize
|
||||
{
|
||||
7
|
||||
}
|
||||
|
||||
fn row_name(&self, row: usize) -> u64
|
||||
{
|
||||
row as u64 + 1
|
||||
}
|
||||
|
||||
fn some_number(&self, row: usize) -> u64
|
||||
{
|
||||
69420
|
||||
}
|
||||
|
||||
fn open(&mut self, path: String) -> bool
|
||||
{
|
||||
if cfg!(debug_assertions) {
|
||||
eprintln!("opening project: {}", &path);
|
||||
}
|
||||
|
||||
let fp = fs::File::open(path);
|
||||
/*
|
||||
let fp = std::fs::File::open(path);
|
||||
let fp = if let Ok(fp) = fp {fp} else {return false;};
|
||||
|
||||
let mm = unsafe {Mmap::map(&fp)};
|
||||
|
@ -51,9 +67,22 @@ impl ProjectTrait for Project
|
|||
self.wad.replace(Some(wad));
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn save(&self)
|
||||
{
|
||||
if cfg!(debug_assertions) {
|
||||
eprintln!("saving project");
|
||||
}
|
||||
}
|
||||
|
||||
fn is_dirty(&self) -> bool
|
||||
{
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
|
|
@ -15,21 +15,12 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<widget class="QListView" name="listView">
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>gay</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>false</bool>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue