From b915686dd38e99df72db332e1ea0b12a0895bdb3 Mon Sep 17 00:00:00 2001 From: llornkcor Date: Sun, 20 Oct 2002 14:04:56 +0000 Subject: added ability to delete checkbook account --- (limited to 'noncore') 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 @@ -TEMPLATE = app -CONFIG = qt warn_on release -HEADERS = config.h \ - qcheckbook.h \ - qcheckdetails.h \ - qcheckentry.h \ - qcheckgraph.h \ - qcheckmainmenu.h \ - qcheckname.h \ - qcheckview.h \ - qrestrictedcombo.h \ - qrestrictedline.h -SOURCES = config.cpp \ - main.cpp \ - qcheckbook.cpp \ - qcheckdetails.cpp \ - qcheckentry.cpp \ - qcheckgraph.cpp \ - qcheckmainmenu.cpp \ - qcheckname.cpp \ - qcheckview.cpp \ - qrestrictedcombo.cpp \ - qrestrictedline.cpp -INTERFACES = qcheckdetailsbase.ui \ - qcheckentrybase.ui \ - qcheckgraphbase.ui \ - qcheckmmbase.ui \ - qchecknamebase.ui \ - qcheckviewbase.ui +TEMPLATE = app +CONFIG = qt warn_on release +HEADERS = config.h \ + qcheckbook.h \ + qcheckdetails.h \ + qcheckentry.h \ + qcheckgraph.h \ + qcheckmainmenu.h \ + qcheckname.h \ + qcheckview.h \ + qchecknamebase.h \ + qrestrictedcombo.h \ + qrestrictedline.h +SOURCES = config.cpp \ + main.cpp \ + qcheckbook.cpp \ + qcheckdetails.cpp \ + qcheckentry.cpp \ + qcheckgraph.cpp \ + qcheckmainmenu.cpp \ + qcheckname.cpp \ + qcheckview.cpp \ + qrestrictedcombo.cpp \ + qchecknamebase.cpp \ + qrestrictedline.cpp +INTERFACES = qcheckdetailsbase.ui \ + qcheckentrybase.ui \ + qcheckgraphbase.ui \ + qcheckmmbase.ui \ + qcheckviewbase.ui INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -TARGET = checkbook -DESTDIR = $(OPIEDIR)/bin +LIBS += -lqpe +TARGET = checkbook +DESTDIR = $(OPIEDIR)/bin TRANSLATIONS = ../../../i18n/de/checkbook.ts \ - ../../../i18n/en/checkbook.ts \ - ../../../i18n/es/checkbook.ts \ - ../../../i18n/fr/checkbook.ts \ - ../../../i18n/hu/checkbook.ts \ - ../../../i18n/ja/checkbook.ts \ - ../../../i18n/ko/checkbook.ts \ - ../../../i18n/no/checkbook.ts \ - ../../../i18n/pl/checkbook.ts \ - ../../../i18n/pt/checkbook.ts \ - ../../../i18n/pt_BR/checkbook.ts \ - ../../../i18n/sl/checkbook.ts \ - ../../../i18n/zh_CN/checkbook.ts \ - ../../../i18n/zh_TW/checkbook.ts \ - ../../../i18n/it/checkbook.ts + ../../../i18n/en/checkbook.ts \ + ../../../i18n/es/checkbook.ts \ + ../../../i18n/fr/checkbook.ts \ + ../../../i18n/hu/checkbook.ts \ + ../../../i18n/ja/checkbook.ts \ + ../../../i18n/ko/checkbook.ts \ + ../../../i18n/no/checkbook.ts \ + ../../../i18n/pl/checkbook.ts \ + ../../../i18n/pt/checkbook.ts \ + ../../../i18n/pt_BR/checkbook.ts \ + ../../../i18n/sl/checkbook.ts \ + ../../../i18n/zh_CN/checkbook.ts \ + ../../../i18n/zh_TW/checkbook.ts \ + ../../../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) } } +void QCheckBook::deleteCheck(const QString &filename) +{ + qDebug("Deleting "+filename); +} + void QCheckBook::close() { QApplication::exit(); @@ -136,6 +141,7 @@ void QCheckBook::initMainMenus() popup = new QPopupMenu(); popup->insertItem("&New", m_view3, SLOT(newClicked())); + popup->insertItem("&Delete", m_view3, SLOT(deleteClicked())); popup->insertItem("&Exit", this, SLOT(close())); mbar->insertItem("&File", popup); 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 @@ class QCheckBook : public QMainWindow { - Q_OBJECT - public: - QCheckBook(); - private slots: - void newCheck(const QString &filename); - void newGraph(); - void close(); - void initMainMenus(); - private: - QCheckView *m_view; - QCheckGraph *m_view2; - QCheckMainMenu *m_view3; - QToolBar *bar; - QMenuBar *mbar; - int filemenuid; - QString m_filename; - QToolButton *nb1; - QToolButton *nb2; - QToolButton *nb3; - QToolButton *nb4; - bool initCheck; - bool initMM; - QPopupMenu *popup; + Q_OBJECT + public: + QCheckBook(); + private slots: + void newCheck(const QString &filename); + void deleteCheck(const QString &filename); + void newGraph(); + void close(); + void initMainMenus(); + private: + QCheckView *m_view; + QCheckGraph *m_view2; + QCheckMainMenu *m_view3; + QToolBar *bar; + QMenuBar *mbar; + int filemenuid; + QString m_filename; + QToolButton *nb1; + QToolButton *nb2; + QToolButton *nb3; + QToolButton *nb4; + bool initCheck; + bool initMM; + QPopupMenu *popup; }; 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 @@ #include "qcheckname.h" QCheckMainMenu::QCheckMainMenu(QWidget *parent) - : QCheckMMBase(parent) + : QCheckMMBase(parent) { - init(); + 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(); + 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); - } - } + 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); - } + 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); + } +} + +void QCheckMainMenu::deleteClicked() +{ + QString checkname = lstCheckBooks->currentText(); + if (checkname.isEmpty() == false) { + switch ( QMessageBox::warning(this,tr("Delete Account"),tr("Really delete the\n") + +checkname+tr(" account?") + ,tr("Yes"),tr("No"),0,1,1) ) { + case 0: { + + QString checkdirname = QDir::homeDirPath(); + checkdirname.append("/.checkbooks"); + QDir checkdir(checkdirname); + QString checkDir=checkdirname; + + checkdirname.append("/"); + checkdirname.append(checkname); + checkdirname.append(".qcb"); + QFile file(checkdirname); + if (file.exists() == true) { + if(!file.remove()) { + QMessageBox::message(tr("Checkbook"),tr("Could not remove account")); + return; + } else + lstCheckBooks->removeItem(lstCheckBooks->currentItem()); + } + } + break; + } + } } 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 @@ class QCheckMainMenu : public QCheckMMBase { - Q_OBJECT - public: - QCheckMainMenu(QWidget *); - signals: - void itemSelected(const QString &); - private: - void init(); - private slots: - void slotSelected(QListBoxItem *); - public slots: - void newClicked(); + Q_OBJECT + public: + QCheckMainMenu(QWidget *); + signals: + void itemSelected(const QString &); + private: + void init(); + private slots: + void slotSelected(QListBoxItem *); + public slots: + void newClicked(); + void deleteClicked(); }; 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 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'qchecknamebase.ui' +** +** Created: Wed Sep 18 09:40:57 2002 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "qchecknamebase.h" + +#include +#include +#include "qrestrictedline.h" +#include +#include +#include +#include + +/* + * Constructs a QCheckNameBase which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +QCheckNameBase::QCheckNameBase( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, fl ) +{ + if ( !name ) + setName( "QCheckNameBase" ); + resize( 228, 108 ); + setCaption( tr( "Check Book Name" ) ); + + TextLabel3 = new QLabel( this, "TextLabel3" ); + TextLabel3->setGeometry( QRect( 10, 5, 70, 16 ) ); + QFont TextLabel3_font( TextLabel3->font() ); + TextLabel3_font.setFamily( "BDF-helvetica" ); + TextLabel3_font.setPointSize( 19 ); + TextLabel3_font.setBold( TRUE ); + TextLabel3->setFont( TextLabel3_font ); + TextLabel3->setText( tr( "Name..." ) ); + + TextLabel4 = new QLabel( this, "TextLabel4" ); + TextLabel4->setGeometry( QRect( 10, 25, 210, 25 ) ); + TextLabel4->setText( tr( "Please name your check book.\n(limit: 15 characters):" ) ); + TextLabel4->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); + + cmdDone = new QPushButton( this, "cmdDone" ); + cmdDone->setGeometry( QRect( 75, 80, 75, 25 ) ); + cmdDone->setText( tr( "&Done" ) ); + + leText = new QRestrictedLine( this, "leText" ); + leText->setGeometry( QRect( 5, 51, 216, 25 ) ); + leText->setFocus(); +} + +/* + * Destroys the object and frees any allocated resources + */ +QCheckNameBase::~QCheckNameBase() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * Main event handler. Reimplemented to handle application + * font changes + */ +bool QCheckNameBase::event( QEvent* ev ) +{ + bool ret = QDialog::event( ev ); + if ( ev->type() == QEvent::ApplicationFontChange ) { + QFont TextLabel3_font( TextLabel3->font() ); + TextLabel3_font.setFamily( "BDF-helvetica" ); + TextLabel3_font.setPointSize( 19 ); + TextLabel3_font.setBold( TRUE ); + TextLabel3->setFont( TextLabel3_font ); + } + return ret; +} + 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 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'qchecknamebase.ui' +** +** Created: Wed Sep 18 09:40:11 2002 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef QCHECKNAMEBASE_H +#define QCHECKNAMEBASE_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QLabel; +class QPushButton; +class QRestrictedLine; + +class QCheckNameBase : public QDialog +{ + Q_OBJECT + +public: + QCheckNameBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~QCheckNameBase(); + + QLabel* TextLabel3; + QLabel* TextLabel4; + QPushButton* cmdDone; + QRestrictedLine* leText; + +protected: + bool event( QEvent* ); +}; + +#endif // QCHECKNAMEBASE_H -- cgit v0.9.0.2