-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
56 lines (43 loc) · 1.09 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <odb/transaction.hxx>
#include <odb/schema-catalog.hxx>
#include <odb/sqlite/database.hxx>
#include "artist.hpp"
#include "library.hpp"
#include "cd.hpp"
#include <QtGui/QApplication>
#include "mainwindow.hpp"
void create(Model& m)
{
m.NewDatabase();
}
void populate(Model& model)
{
std::cout<<"Populating... ";
odb::sqlite::database db(model.DatabaseFilename.toStdString(), SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
Library* lib=new Library("1");
Artist* a=new Artist("asd");
Artist* b=new Artist("bsd");
lib->Artists->push_back(a);
lib->Artists->push_back(b);
Album* al=new CD(2005, "alcd");
CD* alb=new CD(2010, "alb");
a->Albums->push_back(alb);
a->Albums->push_back(al);
alb->AddTrack("Track 1", 76);
odb::core::transaction t (db.begin ());
odb::schema_catalog::create_schema (db);
lib->Persist(db);
t.commit();
delete lib;
std::cout<<"COMPLETE"<<std::endl;;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
//create(*w.model);
//populate(*w.model);
w.showMaximized();
return a.exec();
}