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