summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/qcheckbook.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/qcheckbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/qcheckbook.cpp226
1 files changed, 112 insertions, 114 deletions
diff --git a/noncore/apps/checkbook/qcheckbook.cpp b/noncore/apps/checkbook/qcheckbook.cpp
index 797127e..bb7a5ac 100644
--- a/noncore/apps/checkbook/qcheckbook.cpp
+++ b/noncore/apps/checkbook/qcheckbook.cpp
@@ -5,145 +5,143 @@
5#include <qpopupmenu.h> 5#include <qpopupmenu.h>
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qdir.h> 8#include <qdir.h>
9 9
10QCheckBook::QCheckBook() 10QCheckBook::QCheckBook()
11 : QMainWindow(), 11 : QMainWindow(),
12 m_view(), 12 m_view(),
13 m_view2(), 13 m_view2(),
14 m_view3() 14 m_view3()
15{ 15{
16 initCheck = false; 16 initCheck = false;
17 initMM = false; 17 initMM = false;
18 setCaption("Checking"); 18 setCaption("Checking");
19 statusBar()->hide(); 19 statusBar()->hide();
20 menuBar()->hide(); 20 menuBar()->hide();
21 21
22 bar = new QToolBar(this); 22 bar = new QToolBar(this);
23 bar->setHorizontalStretchable( TRUE ); 23 bar->setHorizontalStretchable( TRUE );
24 24
25 addToolBar(bar); 25 addToolBar(bar);
26 26
27 Config config("qcheckbook"); 27 Config config("qcheckbook");
28 config.setGroup("Global"); 28 config.setGroup("Global");
29 QString lastCheck = config.readEntry("LastCheckBook", QString("")); 29 QString lastCheck = config.readEntry("LastCheckBook", QString(""));
30 30
31 QString checkdirname = QDir::homeDirPath(); 31 QString checkdirname = QDir::homeDirPath();
32 checkdirname.append("/.checkbooks/"); 32 checkdirname.append("/.checkbooks/");
33 checkdirname.append(lastCheck); 33 checkdirname.append(lastCheck);
34 QFile f(checkdirname); 34 QFile f(checkdirname);
35 35
36 36
37 if (lastCheck.isEmpty() == false && lastCheck != "" && f.exists() == true) 37 if (lastCheck.isEmpty() == false && lastCheck != "" && f.exists() == true)
38 { 38 {
39 newCheck(lastCheck); 39 newCheck(lastCheck);
40 } else { 40 } else {
41 initMainMenus(); 41 initMainMenus();
42 } 42 }
43 43
44 setToolBarsMovable( FALSE ); 44 setToolBarsMovable( FALSE );
45} 45}
46 46
47void QCheckBook::newCheck(const QString &filename) 47void QCheckBook::newCheck(const QString &filename)
48{ 48{
49 if (filename.isEmpty() == false) 49 if (filename.isEmpty() == false)
50 { 50 {
51 initCheck = true; 51 initCheck = true;
52 if (m_view != 0) 52 if (m_view != 0)
53 { 53 {
54 delete m_view; 54 m_view=0;
55 } 55 delete m_view;
56 m_view = new QCheckView(this, filename); 56 }
57 m_view->hide(); 57 m_view = new QCheckView(this, filename);
58 connect(m_view, SIGNAL(reload(const QString &)), this, SLOT(newCheck(const QString &))); 58 m_view->hide();
59 59 connect(m_view, SIGNAL(reload(const QString &)), this, SLOT(newCheck(const QString &)));
60 if (initMM == true) 60 if (initMM == true)
61 { 61 {
62 delete nb1; 62 delete nb1;
63 } 63 }
64 64 bar->clear();
65 bar->clear(); 65 mbar = new QMenuBar(bar);
66 66 mbar->setMargin(0);
67 mbar = new QMenuBar(bar); 67
68 mbar->setMargin(0); 68 QPixmap newIcon = Resource::loadPixmap( "new" );
69 69 nb2 = new QToolButton( newIcon, "New", QString::null, m_view, SLOT(newClicked()), bar, "new item" );
70 QPixmap newIcon = Resource::loadPixmap( "new" ); 70 QPixmap pixmap = Resource::loadPixmap( "pixmap" );
71 nb2 = new QToolButton( newIcon, "New", QString::null, m_view, SLOT(newClicked()), bar, "new item" ); 71 m_filename = filename;
72 QPixmap pixmap = Resource::loadPixmap( "pixmap" ); 72 nb3 = new QToolButton( pixmap, "Graph", QString::null, this, SLOT(newGraph()), bar, "new graph" );
73 m_filename = filename; 73
74 nb3 = new QToolButton( pixmap, "Graph", QString::null, this, SLOT(newGraph()), bar, "new graph" ); 74 QPixmap closeIcon = Resource::loadPixmap( "close" );
75 75 nb4 = new QToolButton( closeIcon, "Close", QString::null, this, SLOT(initMainMenus()), bar, "close graph" );
76 QPixmap closeIcon = Resource::loadPixmap( "close" ); 76
77 nb4 = new QToolButton( closeIcon, "Close", QString::null, this, SLOT(initMainMenus()), bar, "close graph" ); 77 popup = new QPopupMenu(m_view);
78 78 popup->insertItem("&New Entry", m_view, SLOT(newClicked()));
79 popup = new QPopupMenu(m_view); 79 popup->insertItem("&Graph Checkbook", this, SLOT(newGraph()));
80 popup->insertItem("&New Entry", m_view, SLOT(newClicked())); 80 popup->insertItem("&Close Checkbook", this, SLOT(initMainMenus()));
81 popup->insertItem("&Graph Checkbook", this, SLOT(newGraph())); 81 popup->insertItem("&Exit", this, SLOT(close()));
82 popup->insertItem("&Close Checkbook", this, SLOT(initMainMenus())); 82 mbar->insertItem("&File", popup);
83 popup->insertItem("&Exit", this, SLOT(close())); 83
84 mbar->insertItem("&File", popup); 84 setCentralWidget(m_view);
85 85 m_view->show();
86 setCentralWidget(m_view); 86
87 m_view->show(); 87 Config config("qcheckbook");
88 88 config.setGroup("Global");
89 Config config("qcheckbook"); 89 config.writeEntry("LastCheckBook", filename);
90 config.setGroup("Global"); 90 initMM = false;
91 config.writeEntry("LastCheckBook", filename); 91 }
92 initMM = false;
93 }
94} 92}
95 93
96void QCheckBook::close() 94void QCheckBook::close()
97{ 95{
98 QApplication::exit(); 96 QApplication::exit();
99} 97}
100 98
101void QCheckBook::newGraph() 99void QCheckBook::newGraph()
102{ 100{
103 if (m_filename.isEmpty() == false) 101 if (m_filename.isEmpty() == false)
104 { 102 {
105 m_view2 = new QCheckGraph(m_filename); 103 m_view2 = new QCheckGraph(m_filename);
106 m_view2->showMaximized(); 104 m_view2->showMaximized();
107 } 105 }
108} 106}
109 107
110void QCheckBook::initMainMenus() 108void QCheckBook::initMainMenus()
111{ 109{
112 Config config("qcheckbook"); 110 Config config("qcheckbook");
113 config.setGroup("Global"); 111 config.setGroup("Global");
114 config.writeEntry("LastCheckBook", QString("")); 112 config.writeEntry("LastCheckBook", QString(""));
115 initMM = true; 113 initMM = true;
116 m_filename = ""; 114 m_filename = "";
117 if (m_view3 != 0) 115 if (m_view3 != 0)
118 { 116 {
119 delete m_view3; 117 delete m_view3;
120 } 118 }
121 m_view3 = new QCheckMainMenu(this); 119 m_view3 = new QCheckMainMenu(this);
122 m_view3->hide(); 120 m_view3->hide();
123 121
124 if (initCheck == true) 122 if (initCheck == true)
125 { 123 {
126 delete nb2; 124 delete nb2;
127 delete nb3; 125 delete nb3;
128 delete nb4; 126 delete nb4;
129 } 127 }
130 128
131 bar->clear(); 129 bar->clear();
132 130
133 mbar = new QMenuBar(bar); 131 mbar = new QMenuBar(bar);
134 mbar->setMargin(0); 132 mbar->setMargin(0);
135 133
136 QPixmap newIcon = Resource::loadPixmap( "new" ); 134 QPixmap newIcon = Resource::loadPixmap( "new" );
137 nb1 = new QToolButton( newIcon, "New", QString::null, m_view3, SLOT(newClicked()), bar, "new book" ); 135 nb1 = new QToolButton( newIcon, "New", QString::null, m_view3, SLOT(newClicked()), bar, "new book" );
138 136
139 popup = new QPopupMenu(); 137 popup = new QPopupMenu();
140 popup->insertItem("&New", m_view3, SLOT(newClicked())); 138 popup->insertItem("&New", m_view3, SLOT(newClicked()));
141 popup->insertItem("&Exit", this, SLOT(close())); 139 popup->insertItem("&Exit", this, SLOT(close()));
142 mbar->insertItem("&File", popup); 140 mbar->insertItem("&File", popup);
143 141
144 setCentralWidget(m_view3); 142 setCentralWidget(m_view3);
145 m_view3->show(); 143 m_view3->show();
146 144
147 connect(m_view3, SIGNAL(itemSelected(const QString &)), this, SLOT(newCheck(const QString &))); 145 connect(m_view3, SIGNAL(itemSelected(const QString &)), this, SLOT(newCheck(const QString &)));
148 initCheck = false; 146 initCheck = false;
149} 147}