diff --git a/ADeditor/ADeditor b/ADeditor/ADeditor index a982a76..cfefb00 100755 Binary files a/ADeditor/ADeditor and b/ADeditor/ADeditor differ diff --git a/ADeditor/alienmodel.cpp b/ADeditor/alienmodel.cpp index efcde06..b046d76 100644 --- a/ADeditor/alienmodel.cpp +++ b/ADeditor/alienmodel.cpp @@ -1,12 +1,18 @@ #include "alienmodel.h" -AlienModel::AlienModel(QListmaliens, QObject *parent) : +AlienModel::AlienModel(QList maliens, QObject *parent) : QAbstractListModel(parent) { aliens = maliens; } +void AlienModel::refresh(QList maliens) +{ + aliens = maliens; +} + + int AlienModel::rowCount(const QModelIndex &) const { return aliens.count(); diff --git a/ADeditor/alienmodel.h b/ADeditor/alienmodel.h index 2098248..72797c3 100644 --- a/ADeditor/alienmodel.h +++ b/ADeditor/alienmodel.h @@ -11,7 +11,7 @@ public: explicit AlienModel(QList aliens, QObject *parent = 0); int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role) const; - + void refresh(QList aliens); signals: public slots: diff --git a/ADeditor/alientablemodel.o b/ADeditor/alientablemodel.o deleted file mode 100644 index 72756f8..0000000 Binary files a/ADeditor/alientablemodel.o and /dev/null differ diff --git a/ADeditor/data.xml b/ADeditor/data.xml deleted file mode 100644 index 6283cd1..0000000 --- a/ADeditor/data.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ADeditor/data2.xml b/ADeditor/data2.xml index 764b336..8b3f43c 100644 --- a/ADeditor/data2.xml +++ b/ADeditor/data2.xml @@ -1,9 +1,10 @@ - - - + + + + @@ -14,7 +15,7 @@ - + diff --git a/ADeditor/mainwindow.cpp b/ADeditor/mainwindow.cpp index 96b7456..977a34f 100644 --- a/ADeditor/mainwindow.cpp +++ b/ADeditor/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "alienmodel.h" + +#include MainWindow::MainWindow(QWidget *parent) : @@ -10,8 +11,8 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); adloader = new Loader(this); adloader->load("data2.xml"); - QAbstractItemModel * model = new AlienModel(adloader->aliens.values()); - ui->lvAliens->setModel(model); + alModel = new AlienModel(adloader->aliens.values()); + ui->lvAliens->setModel((QAbstractItemModel * )alModel); connect(ui->lvAliens->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvAliens_select(QModelIndex, QModelIndex))); ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(0,0),QItemSelectionModel::Select); } @@ -38,13 +39,19 @@ void MainWindow::changeEvent(QEvent *e) void MainWindow::on_cbAlArmor_toggled(bool checked) { + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; ui->sbAlArmor->setEnabled(checked); + if (checked) adloader->aliens[id].armor = ui->sbAlArmor->value(); + else adloader->aliens[id].armor = 0; } void MainWindow::on_cbAlRegeneration_toggled(bool checked) { + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; ui->sbAlregeneration->setEnabled(checked); + if (checked) adloader->aliens[id].regeneration = ui->sbAlregeneration->value(); + else adloader->aliens[id].regeneration = 0; } @@ -70,7 +77,88 @@ void MainWindow::on_pbSave_clicked() { adloader->save("data2.xml"); adloader->load("data2.xml"); - QAbstractItemModel * model = new AlienModel(adloader->aliens.values()); - ui->lvAliens->setModel(model); - ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(0,0),QItemSelectionModel::Select); + alModel->refresh(adloader->aliens.values()); +} + +void MainWindow::on_sbAlHealth_valueChanged(double value) +{ + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + adloader->aliens[id].health = value; +} + +void MainWindow::on_sbAlArmor_valueChanged(double value) +{ + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + adloader->aliens[id].armor = value; +} + +void MainWindow::on_sbAlregeneration_valueChanged(double value) +{ + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + adloader->aliens[id].regeneration = value; +} + +void MainWindow::on_sbAlSpeed_valueChanged(double value) +{ + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + adloader->aliens[id].speed = value; +} + +void MainWindow::on_sbAlPrise_valueChanged(int val) +{ + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + adloader->aliens[id].prise = val; +} + +void MainWindow::on_sbAlScore_valueChanged(int val) +{ + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + adloader->aliens[id].score = val; +} + +void MainWindow::on_cbAlIsFly_clicked(bool checked) +{ + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + adloader->aliens[id].isFlying = checked; +} + +void MainWindow::on_leAlName_editingFinished() +{ + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + adloader->aliens[id].name = ui->leAlName->text(); + alModel->refresh(adloader->aliens.values()); + ui->lvAliens->setModel((QAbstractItemModel * )alModel); +} + +void MainWindow::on_pbAlAdd_clicked() +{ + int i = 1; + while (adloader->aliens.contains(i)) i++; + tbAlien al; + al.id = i; + adloader->aliens.insert(al.id,al); + int index = adloader->aliens.keys().indexOf(i); + alModel->refresh(adloader->aliens.values()); + ui->lvAliens->setModel((QAbstractItemModel * )alModel); + ui->lvAliens->reset(); + ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(index,0),QItemSelectionModel::Select); +} + +void MainWindow::on_pbAlDel_clicked() +{ + QMessageBox msgBox; + int id = adloader->aliens.keys().at(ui->lvAliens->currentIndex().row()); + msgBox.setText(tr("Delete alien %1 id=%2").arg(adloader->aliens.value(id).name).arg(id)); + msgBox.setInformativeText(tr("Are you sure?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + if (ret == QMessageBox::Ok) + { + adloader->aliens.remove(id); + alModel->refresh(adloader->aliens.values()); + ui->lvAliens->setModel((QAbstractItemModel * )alModel); + ui->lvAliens->reset(); + ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(0,0),QItemSelectionModel::Select); + } } diff --git a/ADeditor/mainwindow.h b/ADeditor/mainwindow.h index 5365225..ac5d0e3 100644 --- a/ADeditor/mainwindow.h +++ b/ADeditor/mainwindow.h @@ -5,7 +5,8 @@ #include #include -#include "../loader.h" +#include "alienmodel.h" + namespace Ui { class MainWindow; @@ -23,9 +24,20 @@ protected: private: Ui::MainWindow *ui; Loader * adloader; + AlienModel * alModel; private slots: - void on_pbSave_clicked(); + void on_pbAlDel_clicked(); + void on_pbAlAdd_clicked(); + void on_leAlName_editingFinished(); + void on_cbAlIsFly_clicked(bool checked); + void on_sbAlScore_valueChanged(int ); + void on_sbAlPrise_valueChanged(int ); + void on_sbAlSpeed_valueChanged(double ); + void on_sbAlregeneration_valueChanged(double ); + void on_sbAlArmor_valueChanged(double ); + void on_sbAlHealth_valueChanged(double ); + void on_pbSave_clicked(); void lvAliens_select(QModelIndex, QModelIndex); void on_cbAlRegeneration_toggled(bool checked); void on_cbAlArmor_toggled(bool checked); diff --git a/ADeditor/mainwindow.ui b/ADeditor/mainwindow.ui index f02f9c1..34f7bf1 100644 --- a/ADeditor/mainwindow.ui +++ b/ADeditor/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 516 - 435 + 468 @@ -76,7 +76,20 @@ - + + + 1 + + + 999999999.000000000000000 + + + 10.000000000000000 + + + 99.000000000000000 + + @@ -100,6 +113,9 @@ false + + 999999999.000000000000000 + @@ -124,6 +140,15 @@ false + + 1 + + + 999999999.000000000000000 + + + 5.000000000000000 + @@ -147,7 +172,23 @@ - + + + + + + 5 + + + 99.000000000000000 + + + 0.010000000000000 + + + 0.010000000000000 + + @@ -170,7 +211,11 @@ - + + + 999999999 + + @@ -193,7 +238,11 @@ - + + + 999999999 + + diff --git a/ADeditor/moc_alientablemodel.cpp b/ADeditor/moc_alientablemodel.cpp deleted file mode 100644 index bb04aa0..0000000 --- a/ADeditor/moc_alientablemodel.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** Meta object code from reading C++ file 'alientablemodel.h' -** -** Created: Tue Aug 24 14:03:38 2010 -** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include "alientablemodel.h" -#if !defined(Q_MOC_OUTPUT_REVISION) -#error "The header file 'alientablemodel.h' doesn't include ." -#elif Q_MOC_OUTPUT_REVISION != 62 -#error "This file was generated using the moc from 4.6.2. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -QT_BEGIN_MOC_NAMESPACE -static const uint qt_meta_data_AlienTableModel[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 0, 0, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - 0 // eod -}; - -static const char qt_meta_stringdata_AlienTableModel[] = { - "AlienTableModel\0" -}; - -const QMetaObject AlienTableModel::staticMetaObject = { - { &QAbstractTableModel::staticMetaObject, qt_meta_stringdata_AlienTableModel, - qt_meta_data_AlienTableModel, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &AlienTableModel::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *AlienTableModel::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *AlienTableModel::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_AlienTableModel)) - return static_cast(const_cast< AlienTableModel*>(this)); - return QAbstractTableModel::qt_metacast(_clname); -} - -int AlienTableModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QAbstractTableModel::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - return _id; -} -QT_END_MOC_NAMESPACE diff --git a/ADeditor/moc_alientablemodel.o b/ADeditor/moc_alientablemodel.o deleted file mode 100644 index 80bfec7..0000000 Binary files a/ADeditor/moc_alientablemodel.o and /dev/null differ diff --git a/settreader.o b/settreader.o deleted file mode 100644 index c4df5ff..0000000 Binary files a/settreader.o and /dev/null differ