|
1 #include <qmainwindow.h> |
|
2 #include <qlistview.h> |
|
3 #include <qstatusbar.h> |
|
4 #include "chartwindow.h" |
|
5 #include "mainpanel.h" |
|
6 |
|
7 |
|
8 ChartWindow::ChartWindow(QWidget *parent, const char *name) |
|
9 : QMainWindow(parent, name, WDestructiveClose) |
|
10 { |
|
11 //QVBoxLayout *mainlayout = new QVBoxLayout(this, 0); |
|
12 |
|
13 // Only the listview in the window |
|
14 accountsList = new QListView(this); |
|
15 |
|
16 accountsList->addColumn( tr("Number") ); |
|
17 accountsList->addColumn( tr("Name") ); |
|
18 accountsList->addColumn( tr("Description") ); |
|
19 accountsList->addColumn( tr("General") ); |
|
20 accountsList->addColumn( tr("Is Account") ); |
|
21 accountsList->addColumn( tr("Enabled") ); |
|
22 accountsList->addColumn( tr("Type") ); |
|
23 accountsList->addColumn( tr("Links") ); |
|
24 |
|
25 accountsList->setAllColumnsShowFocus( true ); |
|
26 |
|
27 |
|
28 // We get the data to be shown |
|
29 QSqlQuery q; |
|
30 |
|
31 q.prepare("SELECT account_num, name, description, general, account, " |
|
32 "enabled, type, links FROM chart"); |
|
33 if(q.exec()) |
|
34 { |
|
35 while(q.next()) { |
|
36 new QListViewItem( accountsList, |
|
37 q.value(0).toString(), // account_num |
|
38 q.value(1).toString(), // name |
|
39 q.value(2).toString(), // description |
|
40 q.value(3).toBool()?"True":"False", // general |
|
41 q.value(4).toBool()?"True":"False", // account |
|
42 q.value(5).toBool()?"True":"False", // enabled |
|
43 q.value(6).toString(), // type |
|
44 q.value(7).toString()); // links |
|
45 } |
|
46 } |
|
47 else |
|
48 qDebug("Query failed when trying to get Chart of accounts"); |
|
49 |
|
50 |
|
51 // Prepare this main window |
|
52 setFocusProxy( accountsList ); |
|
53 setCentralWidget( accountsList ); |
|
54 |
|
55 setCaption( tr("Accounts Chart") ); |
|
56 |
|
57 // Show Status Bar |
|
58 |
|
59 // Needed? |
|
60 statusBar()->clear(); |
|
61 |
|
62 statusBar()->message( tr("Click with right button over any accout to" |
|
63 " perform any action") ); |
|
64 |
|
65 } |
|
66 |
|
67 ChartWindow::~ChartWindow() |
|
68 { |
|
69 } |