summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/qcheckmainmenu.cpp
authorkergoth <kergoth>2002-09-15 17:23:20 (UTC)
committer kergoth <kergoth>2002-09-15 17:23:20 (UTC)
commit9bd6edd077df796677c9d069200172f930ac1304 (patch) (side-by-side diff)
tree3b473d4280249b5ade8e5276758cc8f9aa3c2822 /noncore/apps/checkbook/qcheckmainmenu.cpp
parent33ec9ead7ce30bf9450b9048506f0bda49ba4791 (diff)
downloadopie-9bd6edd077df796677c9d069200172f930ac1304.zip
opie-9bd6edd077df796677c9d069200172f930ac1304.tar.gz
opie-9bd6edd077df796677c9d069200172f930ac1304.tar.bz2
Reverting to checkbook in its previous state, hopefully i got everything.
Diffstat (limited to 'noncore/apps/checkbook/qcheckmainmenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/qcheckmainmenu.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/noncore/apps/checkbook/qcheckmainmenu.cpp b/noncore/apps/checkbook/qcheckmainmenu.cpp
new file mode 100644
index 0000000..2382513
--- a/dev/null
+++ b/noncore/apps/checkbook/qcheckmainmenu.cpp
@@ -0,0 +1,74 @@
+#include "qcheckmainmenu.h"
+#include "qcheckname.h"
+
+QCheckMainMenu::QCheckMainMenu(QWidget *parent)
+ : QCheckMMBase(parent)
+{
+ init();
+}
+
+void QCheckMainMenu::init()
+{
+ lstCheckBooks->clear();
+ QString checkdirname = QDir::homeDirPath();
+ checkdirname.append("/.checkbooks");
+ QDir checkdir(checkdirname);
+ if (checkdir.exists() == true)
+ {
+ QStringList checkbooks = checkdir.entryList("*.qcb", QDir::Files|QDir::Readable|QDir::Writable, QDir::Time);
+ for (QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++)
+ {
+ (*it) = (*it).remove((*it).find('.'), (*it).length());
+ }
+ lstCheckBooks->insertStringList(checkbooks);
+ }
+ lstCheckBooks->clearSelection();
+ connect(lstCheckBooks, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotSelected(QListBoxItem *)));
+ lstCheckBooks->clearSelection();
+}
+
+void QCheckMainMenu::slotSelected(QListBoxItem *item)
+{
+ if (item != 0)
+ {
+ QString text = item->text();
+ if (text.isEmpty() == false)
+ {
+ text.append(".qcb");
+ QString checkdirname = QDir::homeDirPath();
+ checkdirname.append("/.checkbooks/");
+ text.prepend(checkdirname);
+ emit itemSelected(text);
+ }
+ }
+}
+
+void QCheckMainMenu::newClicked()
+{
+ QString checkname = QCheckName::getName();
+ if (checkname.isEmpty() == false)
+ {
+ QString checkdirname = QDir::homeDirPath();
+ checkdirname.append("/.checkbooks");
+ QDir checkdir(checkdirname);
+ if (checkdir.exists() == false)
+ {
+ checkdir.mkdir(checkdirname);
+ }
+ checkdirname.append("/");
+ checkdirname.append(checkname);
+ checkdirname.append(".qcb");
+ QFile file(checkdirname);
+ if (file.exists() == false)
+ {
+ file.open(IO_WriteOnly);
+ QTextStream os(&file);
+ os << "";
+ file.close();
+ }
+ QFileInfo fi(file);
+ QString noextension = fi.fileName();
+ noextension = noextension.remove(noextension.find('.'), noextension.length());
+ lstCheckBooks->insertItem(noextension);
+ }
+}