summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorJan Darmochwal2010-10-02 18:50:09 +0200
committerJan Darmochwal2010-10-02 18:50:09 +0200
commit6117049617df720fb744a90773a3580b3450b005 (patch)
treec3b605ab7a7c2e9fd9d14572e8c0e69432d6ac76 /src/dialog.cpp
parentfixed bad copy & paste in CMakeLists.txt (diff)
downloadvmchooser-6117049617df720fb744a90773a3580b3450b005.tar.gz
vmchooser-6117049617df720fb744a90773a3580b3450b005.tar.xz
vmchooser-6117049617df720fb744a90773a3580b3450b005.zip
Qt port is almost complete (at least it compiles)
Major change: * struct DataEntry has become class Session with sub-classes XSession and VSession * functions from addInfo.cpp, addPrinters.cpp, addScanners.cpp, readLinSess.cpp, readXmlDir.cpp, runImage.cpp have been moved to XSession and VSession Several minor changes: * new files globals.h and globals.cpp for global variables (replaces constants.h and paths.h) * replaced (all) libxml2, (much) std:: and (most) boost:: stuff by Qt stuff Things left to do: * remove tons of debug printfs * show error messages on errors * tidy up anyoption stuff in main() * highlight session run previously * readGroupXml stuff * tree view (with "X Sessions" and "Virtual Sessions" sections) instead of list view for session selection
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index e4c74a4..a1ab266 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -1,16 +1,14 @@
#include "dialog.h"
#include "ui_dialog.h"
#include "model.h"
-#include "DataEntry.h"
-#include "functions.h"
+#include "session.h"
+#include "save_restore_session.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
- //QAbstractListModel *data = new Model(1000, ui->listView);
- //ui->listView->setModel(data);
}
Dialog::~Dialog()
@@ -36,16 +34,29 @@ void Dialog::on_listView_activated(QModelIndex index)
printf ("Item %d has been activated\n", index.row());
//TODO get rid of this->entries, storing them in the model should be enough
// alternatively use references instead of copies?
- runImage(this->entries.at(index.row()));
- close();
+ Session* s(this->entries_.at(index.row()));
+ if (s->run()) {
+ writeSessionName(s->shortDescription());
+ close();
+ } else {
+ // TODO: error instead of close
+ close();
+ }
}
-void Dialog::addItems(const std::vector<DataEntry>& entries) {
+void Dialog::addItems(const QList<Session*>& entries, const QString& section) {
+ // TODO: section
// TODO: this is not the right way to do this
// we probably do not need a copy of the entries vector in Dialog and Model
- this->entries = entries;
- QAbstractListModel *data = new Model(entries, ui->listView);
+ printf("Dialog::addItems()\n");
+ printf(" before: %d items\n", this->entries_.size());
+ printf(" %d new items\n", entries.size());
+ this->entries_.append(entries);
+ printf(" after: %d items\n", this->entries_.size());
+ QAbstractListModel *data = new Model(this->entries_, ui->listView);
+ QItemSelectionModel *m = ui->listView->selectionModel();
ui->listView->setModel(data);
+ delete m;
}
void Dialog::on_pushButtonAbort_clicked()