summaryrefslogtreecommitdiff
path: root/noncore
authorllornkcor <llornkcor>2002-10-20 14:04:56 (UTC)
committer llornkcor <llornkcor>2002-10-20 14:04:56 (UTC)
commitb915686dd38e99df72db332e1ea0b12a0895bdb3 (patch) (unidiff)
treeac5590b057da22eadc96e44eafad7f4dd27688a5 /noncore
parent6924185b50abfa448daa16a9f7cb6e532ec77ff9 (diff)
downloadopie-b915686dd38e99df72db332e1ea0b12a0895bdb3.zip
opie-b915686dd38e99df72db332e1ea0b12a0895bdb3.tar.gz
opie-b915686dd38e99df72db332e1ea0b12a0895bdb3.tar.bz2
added ability to delete checkbook account
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.pro93
-rw-r--r--noncore/apps/checkbook/qcheckbook.cpp6
-rw-r--r--noncore/apps/checkbook/qcheckbook.h47
-rw-r--r--noncore/apps/checkbook/qcheckmainmenu.cpp143
-rw-r--r--noncore/apps/checkbook/qcheckmainmenu.h23
-rw-r--r--noncore/apps/checkbook/qchecknamebase.cpp81
-rw-r--r--noncore/apps/checkbook/qchecknamebase.h38
7 files changed, 295 insertions, 136 deletions
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro
index e9e2167..cf78739 100644
--- a/noncore/apps/checkbook/checkbook.pro
+++ b/noncore/apps/checkbook/checkbook.pro
@@ -1,50 +1,51 @@
1 TEMPLATE= app 1TEMPLATE = app
2 CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3 HEADERS = config.h \ 3HEADERS = config.h \
4 qcheckbook.h \ 4 qcheckbook.h \
5 qcheckdetails.h \ 5 qcheckdetails.h \
6 qcheckentry.h \ 6 qcheckentry.h \
7 qcheckgraph.h \ 7 qcheckgraph.h \
8 qcheckmainmenu.h \ 8 qcheckmainmenu.h \
9 qcheckname.h \ 9 qcheckname.h \
10 qcheckview.h \ 10 qcheckview.h \
11 qrestrictedcombo.h \ 11 qchecknamebase.h \
12 qrestrictedline.h 12 qrestrictedcombo.h \
13 SOURCES = config.cpp \ 13 qrestrictedline.h
14 main.cpp \ 14SOURCES = config.cpp \
15 qcheckbook.cpp \ 15 main.cpp \
16 qcheckdetails.cpp \ 16 qcheckbook.cpp \
17 qcheckentry.cpp \ 17 qcheckdetails.cpp \
18 qcheckgraph.cpp \ 18 qcheckentry.cpp \
19 qcheckmainmenu.cpp \ 19 qcheckgraph.cpp \
20 qcheckname.cpp \ 20 qcheckmainmenu.cpp \
21 qcheckview.cpp \ 21 qcheckname.cpp \
22 qrestrictedcombo.cpp \ 22 qcheckview.cpp \
23 qrestrictedline.cpp 23 qrestrictedcombo.cpp \
24 INTERFACES= qcheckdetailsbase.ui \ 24 qchecknamebase.cpp \
25 qcheckentrybase.ui \ 25 qrestrictedline.cpp
26 qcheckgraphbase.ui \ 26INTERFACES = qcheckdetailsbase.ui \
27 qcheckmmbase.ui \ 27 qcheckentrybase.ui \
28 qchecknamebase.ui \ 28 qcheckgraphbase.ui \
29 qcheckviewbase.ui 29 qcheckmmbase.ui \
30 qcheckviewbase.ui
30INCLUDEPATH += $(OPIEDIR)/include 31INCLUDEPATH += $(OPIEDIR)/include
31DEPENDPATH += $(OPIEDIR)/include 32DEPENDPATH += $(OPIEDIR)/include
32 LIBS += -lqpe 33LIBS += -lqpe
33 TARGET = checkbook 34TARGET = checkbook
34 DESTDIR = $(OPIEDIR)/bin 35DESTDIR = $(OPIEDIR)/bin
35 36
36TRANSLATIONS = ../../../i18n/de/checkbook.ts \ 37TRANSLATIONS = ../../../i18n/de/checkbook.ts \
37 ../../../i18n/en/checkbook.ts \ 38 ../../../i18n/en/checkbook.ts \
38 ../../../i18n/es/checkbook.ts \ 39 ../../../i18n/es/checkbook.ts \
39 ../../../i18n/fr/checkbook.ts \ 40 ../../../i18n/fr/checkbook.ts \
40 ../../../i18n/hu/checkbook.ts \ 41 ../../../i18n/hu/checkbook.ts \
41 ../../../i18n/ja/checkbook.ts \ 42 ../../../i18n/ja/checkbook.ts \
42 ../../../i18n/ko/checkbook.ts \ 43 ../../../i18n/ko/checkbook.ts \
43 ../../../i18n/no/checkbook.ts \ 44 ../../../i18n/no/checkbook.ts \
44 ../../../i18n/pl/checkbook.ts \ 45 ../../../i18n/pl/checkbook.ts \
45 ../../../i18n/pt/checkbook.ts \ 46 ../../../i18n/pt/checkbook.ts \
46 ../../../i18n/pt_BR/checkbook.ts \ 47 ../../../i18n/pt_BR/checkbook.ts \
47 ../../../i18n/sl/checkbook.ts \ 48 ../../../i18n/sl/checkbook.ts \
48 ../../../i18n/zh_CN/checkbook.ts \ 49 ../../../i18n/zh_CN/checkbook.ts \
49 ../../../i18n/zh_TW/checkbook.ts \ 50 ../../../i18n/zh_TW/checkbook.ts \
50 ../../../i18n/it/checkbook.ts 51 ../../../i18n/it/checkbook.ts
diff --git a/noncore/apps/checkbook/qcheckbook.cpp b/noncore/apps/checkbook/qcheckbook.cpp
index bb7a5ac..26caad9 100644
--- a/noncore/apps/checkbook/qcheckbook.cpp
+++ b/noncore/apps/checkbook/qcheckbook.cpp
@@ -91,6 +91,11 @@ void QCheckBook::newCheck(const QString &filename)
91 } 91 }
92} 92}
93 93
94void QCheckBook::deleteCheck(const QString &filename)
95{
96 qDebug("Deleting "+filename);
97}
98
94void QCheckBook::close() 99void QCheckBook::close()
95{ 100{
96 QApplication::exit(); 101 QApplication::exit();
@@ -136,6 +141,7 @@ void QCheckBook::initMainMenus()
136 141
137 popup = new QPopupMenu(); 142 popup = new QPopupMenu();
138 popup->insertItem("&New", m_view3, SLOT(newClicked())); 143 popup->insertItem("&New", m_view3, SLOT(newClicked()));
144 popup->insertItem("&Delete", m_view3, SLOT(deleteClicked()));
139 popup->insertItem("&Exit", this, SLOT(close())); 145 popup->insertItem("&Exit", this, SLOT(close()));
140 mbar->insertItem("&File", popup); 146 mbar->insertItem("&File", popup);
141 147
diff --git a/noncore/apps/checkbook/qcheckbook.h b/noncore/apps/checkbook/qcheckbook.h
index 52c0d40..64b6628 100644
--- a/noncore/apps/checkbook/qcheckbook.h
+++ b/noncore/apps/checkbook/qcheckbook.h
@@ -11,27 +11,28 @@
11 11
12class QCheckBook : public QMainWindow 12class QCheckBook : public QMainWindow
13{ 13{
14 Q_OBJECT 14 Q_OBJECT
15 public: 15 public:
16 QCheckBook(); 16 QCheckBook();
17 private slots: 17 private slots:
18 void newCheck(const QString &filename); 18 void newCheck(const QString &filename);
19 void newGraph(); 19 void deleteCheck(const QString &filename);
20 void close(); 20 void newGraph();
21 void initMainMenus(); 21 void close();
22 private: 22 void initMainMenus();
23 QCheckView *m_view; 23 private:
24 QCheckGraph *m_view2; 24 QCheckView *m_view;
25 QCheckMainMenu *m_view3; 25 QCheckGraph *m_view2;
26 QToolBar *bar; 26 QCheckMainMenu *m_view3;
27 QMenuBar *mbar; 27 QToolBar *bar;
28 int filemenuid; 28 QMenuBar *mbar;
29 QString m_filename; 29 int filemenuid;
30 QToolButton *nb1; 30 QString m_filename;
31 QToolButton *nb2; 31 QToolButton *nb1;
32 QToolButton *nb3; 32 QToolButton *nb2;
33 QToolButton *nb4; 33 QToolButton *nb3;
34 bool initCheck; 34 QToolButton *nb4;
35 bool initMM; 35 bool initCheck;
36 QPopupMenu *popup; 36 bool initMM;
37 QPopupMenu *popup;
37}; 38};
diff --git a/noncore/apps/checkbook/qcheckmainmenu.cpp b/noncore/apps/checkbook/qcheckmainmenu.cpp
index 2382513..1aead88 100644
--- a/noncore/apps/checkbook/qcheckmainmenu.cpp
+++ b/noncore/apps/checkbook/qcheckmainmenu.cpp
@@ -2,73 +2,104 @@
2#include "qcheckname.h" 2#include "qcheckname.h"
3 3
4QCheckMainMenu::QCheckMainMenu(QWidget *parent) 4QCheckMainMenu::QCheckMainMenu(QWidget *parent)
5 : QCheckMMBase(parent) 5 : QCheckMMBase(parent)
6{ 6{
7 init(); 7 init();
8} 8}
9 9
10void QCheckMainMenu::init() 10void QCheckMainMenu::init()
11{ 11{
12 lstCheckBooks->clear(); 12 lstCheckBooks->clear();
13 QString checkdirname = QDir::homeDirPath(); 13 QString checkdirname = QDir::homeDirPath();
14 checkdirname.append("/.checkbooks"); 14 checkdirname.append("/.checkbooks");
15 QDir checkdir(checkdirname); 15 QDir checkdir(checkdirname);
16 if (checkdir.exists() == true) 16 if (checkdir.exists() == true)
17 { 17 {
18 QStringList checkbooks = checkdir.entryList("*.qcb", QDir::Files|QDir::Readable|QDir::Writable, QDir::Time); 18 QStringList checkbooks = checkdir.entryList("*.qcb", QDir::Files|QDir::Readable|QDir::Writable, QDir::Time);
19 for (QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++) 19 for (QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++)
20 { 20 {
21 (*it) = (*it).remove((*it).find('.'), (*it).length()); 21 (*it) = (*it).remove((*it).find('.'), (*it).length());
22 } 22 }
23 lstCheckBooks->insertStringList(checkbooks); 23 lstCheckBooks->insertStringList(checkbooks);
24 } 24 }
25 lstCheckBooks->clearSelection(); 25 lstCheckBooks->clearSelection();
26 connect(lstCheckBooks, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotSelected(QListBoxItem *))); 26 connect(lstCheckBooks, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotSelected(QListBoxItem *)));
27 lstCheckBooks->clearSelection(); 27 lstCheckBooks->clearSelection();
28} 28}
29 29
30void QCheckMainMenu::slotSelected(QListBoxItem *item) 30void QCheckMainMenu::slotSelected(QListBoxItem *item)
31{ 31{
32 if (item != 0) 32 if (item != 0)
33 { 33 {
34 QString text = item->text(); 34 QString text = item->text();
35 if (text.isEmpty() == false) 35 if (text.isEmpty() == false)
36 { 36 {
37 text.append(".qcb"); 37 text.append(".qcb");
38 QString checkdirname = QDir::homeDirPath(); 38 QString checkdirname = QDir::homeDirPath();
39 checkdirname.append("/.checkbooks/"); 39 checkdirname.append("/.checkbooks/");
40 text.prepend(checkdirname); 40 text.prepend(checkdirname);
41 emit itemSelected(text); 41 emit itemSelected(text);
42 } 42 }
43 } 43 }
44} 44}
45 45
46void QCheckMainMenu::newClicked() 46void QCheckMainMenu::newClicked()
47{ 47{
48 QString checkname = QCheckName::getName(); 48 QString checkname = QCheckName::getName();
49 if (checkname.isEmpty() == false) 49 if (checkname.isEmpty() == false)
50 { 50 {
51 QString checkdirname = QDir::homeDirPath(); 51 QString checkdirname = QDir::homeDirPath();
52 checkdirname.append("/.checkbooks"); 52 checkdirname.append("/.checkbooks");
53 QDir checkdir(checkdirname); 53 QDir checkdir(checkdirname);
54 if (checkdir.exists() == false) 54 if (checkdir.exists() == false)
55 { 55 {
56 checkdir.mkdir(checkdirname); 56 checkdir.mkdir(checkdirname);
57 } 57 }
58 checkdirname.append("/"); 58 checkdirname.append("/");
59 checkdirname.append(checkname); 59 checkdirname.append(checkname);
60 checkdirname.append(".qcb"); 60 checkdirname.append(".qcb");
61 QFile file(checkdirname); 61 QFile file(checkdirname);
62 if (file.exists() == false) 62 if (file.exists() == false)
63 { 63 {
64 file.open(IO_WriteOnly); 64 file.open(IO_WriteOnly);
65 QTextStream os(&file); 65 QTextStream os(&file);
66 os << ""; 66 os << "";
67 file.close(); 67 file.close();
68 } 68 }
69 QFileInfo fi(file); 69 QFileInfo fi(file);
70 QString noextension = fi.fileName(); 70 QString noextension = fi.fileName();
71 noextension = noextension.remove(noextension.find('.'), noextension.length()); 71 noextension = noextension.remove(noextension.find('.'), noextension.length());
72 lstCheckBooks->insertItem(noextension); 72 lstCheckBooks->insertItem(noextension);
73 } 73 }
74}
75
76void QCheckMainMenu::deleteClicked()
77{
78 QString checkname = lstCheckBooks->currentText();
79 if (checkname.isEmpty() == false) {
80 switch ( QMessageBox::warning(this,tr("Delete Account"),tr("Really delete the\n")
81 +checkname+tr(" account?")
82 ,tr("Yes"),tr("No"),0,1,1) ) {
83 case 0: {
84
85 QString checkdirname = QDir::homeDirPath();
86 checkdirname.append("/.checkbooks");
87 QDir checkdir(checkdirname);
88 QString checkDir=checkdirname;
89
90 checkdirname.append("/");
91 checkdirname.append(checkname);
92 checkdirname.append(".qcb");
93 QFile file(checkdirname);
94 if (file.exists() == true) {
95 if(!file.remove()) {
96 QMessageBox::message(tr("Checkbook"),tr("Could not remove account"));
97 return;
98 } else
99 lstCheckBooks->removeItem(lstCheckBooks->currentItem());
100 }
101 }
102 break;
103 }
104 }
74} 105}
diff --git a/noncore/apps/checkbook/qcheckmainmenu.h b/noncore/apps/checkbook/qcheckmainmenu.h
index 456d3df..24d601b 100644
--- a/noncore/apps/checkbook/qcheckmainmenu.h
+++ b/noncore/apps/checkbook/qcheckmainmenu.h
@@ -12,16 +12,17 @@
12 12
13class QCheckMainMenu : public QCheckMMBase 13class QCheckMainMenu : public QCheckMMBase
14{ 14{
15 Q_OBJECT 15 Q_OBJECT
16 public: 16 public:
17 QCheckMainMenu(QWidget *); 17 QCheckMainMenu(QWidget *);
18 signals: 18 signals:
19 void itemSelected(const QString &); 19 void itemSelected(const QString &);
20 private: 20 private:
21 void init(); 21 void init();
22 private slots: 22 private slots:
23 void slotSelected(QListBoxItem *); 23 void slotSelected(QListBoxItem *);
24 public slots: 24 public slots:
25 void newClicked(); 25 void newClicked();
26 void deleteClicked();
26}; 27};
27 28
diff --git a/noncore/apps/checkbook/qchecknamebase.cpp b/noncore/apps/checkbook/qchecknamebase.cpp
new file mode 100644
index 0000000..27bebc1
--- a/dev/null
+++ b/noncore/apps/checkbook/qchecknamebase.cpp
@@ -0,0 +1,81 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'qchecknamebase.ui'
3**
4** Created: Wed Sep 18 09:40:57 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "qchecknamebase.h"
10
11#include <qlabel.h>
12#include <qpushbutton.h>
13#include "qrestrictedline.h"
14#include <qlayout.h>
15#include <qvariant.h>
16#include <qtooltip.h>
17#include <qwhatsthis.h>
18
19/*
20 * Constructs a QCheckNameBase which is a child of 'parent', with the
21 * name 'name' and widget flags set to 'f'
22 *
23 * The dialog will by default be modeless, unless you set 'modal' to
24 * TRUE to construct a modal dialog.
25 */
26QCheckNameBase::QCheckNameBase( QWidget* parent, const char* name, bool modal, WFlags fl )
27 : QDialog( parent, name, modal, fl )
28{
29 if ( !name )
30 setName( "QCheckNameBase" );
31 resize( 228, 108 );
32 setCaption( tr( "Check Book Name" ) );
33
34 TextLabel3 = new QLabel( this, "TextLabel3" );
35 TextLabel3->setGeometry( QRect( 10, 5, 70, 16 ) );
36 QFont TextLabel3_font( TextLabel3->font() );
37 TextLabel3_font.setFamily( "BDF-helvetica" );
38 TextLabel3_font.setPointSize( 19 );
39 TextLabel3_font.setBold( TRUE );
40 TextLabel3->setFont( TextLabel3_font );
41 TextLabel3->setText( tr( "Name..." ) );
42
43 TextLabel4 = new QLabel( this, "TextLabel4" );
44 TextLabel4->setGeometry( QRect( 10, 25, 210, 25 ) );
45 TextLabel4->setText( tr( "Please name your check book.\n(limit: 15 characters):" ) );
46 TextLabel4->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
47
48 cmdDone = new QPushButton( this, "cmdDone" );
49 cmdDone->setGeometry( QRect( 75, 80, 75, 25 ) );
50 cmdDone->setText( tr( "&Done" ) );
51
52 leText = new QRestrictedLine( this, "leText" );
53 leText->setGeometry( QRect( 5, 51, 216, 25 ) );
54 leText->setFocus();
55}
56
57/*
58 * Destroys the object and frees any allocated resources
59 */
60QCheckNameBase::~QCheckNameBase()
61{
62 // no need to delete child widgets, Qt does it all for us
63}
64
65/*
66 * Main event handler. Reimplemented to handle application
67 * font changes
68 */
69bool QCheckNameBase::event( QEvent* ev )
70{
71 bool ret = QDialog::event( ev );
72 if ( ev->type() == QEvent::ApplicationFontChange ) {
73 QFont TextLabel3_font( TextLabel3->font() );
74 TextLabel3_font.setFamily( "BDF-helvetica" );
75 TextLabel3_font.setPointSize( 19 );
76 TextLabel3_font.setBold( TRUE );
77 TextLabel3->setFont( TextLabel3_font );
78 }
79 return ret;
80}
81
diff --git a/noncore/apps/checkbook/qchecknamebase.h b/noncore/apps/checkbook/qchecknamebase.h
new file mode 100644
index 0000000..864ecd6
--- a/dev/null
+++ b/noncore/apps/checkbook/qchecknamebase.h
@@ -0,0 +1,38 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'qchecknamebase.ui'
3**
4** Created: Wed Sep 18 09:40:11 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef QCHECKNAMEBASE_H
10#define QCHECKNAMEBASE_H
11
12#include <qvariant.h>
13#include <qdialog.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class QLabel;
18class QPushButton;
19class QRestrictedLine;
20
21class QCheckNameBase : public QDialog
22{
23 Q_OBJECT
24
25public:
26 QCheckNameBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
27 ~QCheckNameBase();
28
29 QLabel* TextLabel3;
30 QLabel* TextLabel4;
31 QPushButton* cmdDone;
32 QRestrictedLine* leText;
33
34protected:
35 bool event( QEvent* );
36};
37
38#endif // QCHECKNAMEBASE_H