summaryrefslogtreecommitdiff
authorallenforsythe <allenforsythe>2003-05-15 10:54:55 (UTC)
committer allenforsythe <allenforsythe>2003-05-15 10:54:55 (UTC)
commit2e756a3677b9d4ef426f06beab7ba595c9878f4a (patch) (side-by-side diff)
tree0776c1d88c1188bb0ee3e84fc5115980275b26df
parent19be94085643ce40e35a58eb419eb6b51a02b8d1 (diff)
downloadopie-2e756a3677b9d4ef426f06beab7ba595c9878f4a.zip
opie-2e756a3677b9d4ef426f06beab7ba595c9878f4a.tar.gz
opie-2e756a3677b9d4ef426f06beab7ba595c9878f4a.tar.bz2
Added limit transaction combobox to transaction prefs
Diffstat (more/less context) (show whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/preferencedialogs.cpp23
-rwxr-xr-xnoncore/apps/qashmoney/preferencedialogs.h6
-rwxr-xr-xnoncore/apps/qashmoney/preferences.cpp8
3 files changed, 34 insertions, 3 deletions
diff --git a/noncore/apps/qashmoney/preferencedialogs.cpp b/noncore/apps/qashmoney/preferencedialogs.cpp
index 3c2fb97..00d52c6 100755
--- a/noncore/apps/qashmoney/preferencedialogs.cpp
+++ b/noncore/apps/qashmoney/preferencedialogs.cpp
@@ -1,195 +1,216 @@
#include "preferencedialogs.h"
#include "preferences.h"
#include <qlabel.h>
extern Preferences *preferences;
DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
{
setCaption( tr( "Date" ) );
QLabel *datelabel = new QLabel ( "Format", this );
dateformat = new QComboBox ( this );
dateformat->setEditable ( FALSE );
dateformat->insertItem ( "yyyymmdd" );
dateformat->insertItem ( "yymmdd" );
dateformat->insertItem ( "mmddyyyy" );
dateformat->insertItem ( "mmddyy" );
dateformat->insertItem ( "yyyyddmm" );
dateformat->insertItem ( "yyddmm" );
dateformat->insertItem ( "ddmmyyyy" );
dateformat->insertItem ( "ddmmyy" );
connect ( dateformat, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateFormat ( int ) ) );
QLabel *dateseparatorlabel = new QLabel ( "Separator", this );
dateseparator = new QComboBox ( this );
dateseparator->insertItem ( "/" );
dateseparator->insertItem ( "-" );
dateseparator->insertItem ( "." );
connect ( dateseparator, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateSeparator ( int ) ) );
defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultDatePreferences () ) );
dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
layout = new QVBoxLayout ( this, 2, 2 );
layout->addWidget ( datelabel );
layout->addWidget ( dateformat );
layout->addWidget ( dateseparatorlabel );
layout->addWidget ( dateseparator );
layout->insertSpacing ( 4, 5 );
layout->addWidget ( defaults );
}
DatePreferences::~DatePreferences ()
{
}
void DatePreferences::changeDateFormat ( int index )
{
index ++;
preferences->changePreference ( 1, index );
}
void DatePreferences::changeDateSeparator ( int index )
{
index ++;
preferences->changePreference ( 2, index );
}
void DatePreferences::setDefaultDatePreferences ()
{
preferences->setDefaultDatePreferences ();
dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
}
// START TRANSACTION PREFERENCES
TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
{
setCaption( tr ( "Transaction" ) );
showclearedtransactions = new QCheckBox ( this );
showclearedtransactions->setText ( "Show Cleared Transactions" );
excludetransfers = new QCheckBox ( this );
excludetransfers->setText ( "Include Transfers In Limit View" );
+ limittransactionsbox = new QHBox ( this );
+ limittransactionsbox->setSpacing ( 2 );
+ limittransactionslabel = new QLabel ( "Limit All Transactions To", limittransactionsbox );
+ limittransactions = new QComboBox ( limittransactionsbox );
+ limittransactions->insertItem ( "14 days" );
+ limittransactions->insertItem ( "30 days" );
+ limittransactions->insertItem ( "60 days" );
+ limittransactions->insertItem ( "90 days" );
+ limittransactions->insertItem ( "180 days" );
+ limittransactions->insertItem ( "365 days" );
+ limittransactions->insertItem ( "All" );
+
if ( preferences->getPreference ( 3 ) == 1 )
showclearedtransactions->setChecked ( TRUE );
else
showclearedtransactions->setChecked ( FALSE );
if ( preferences->getPreference ( 6 ) == 1 )
excludetransfers->setChecked ( TRUE );
else
excludetransfers->setChecked ( FALSE );
defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultTransactionPreferences () ) );
layout = new QVBoxLayout ( this, 2, 2 );
layout->addWidget ( showclearedtransactions );
layout->addWidget ( excludetransfers );
- layout->insertSpacing ( 2, 5 );
+ layout->addWidget ( limittransactionsbox );
+ layout->insertSpacing ( 3, 5 );
layout->addWidget ( defaults );
connect ( showclearedtransactions, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeShowClearedPreference ( bool ) ) );
connect ( excludetransfers, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeExcludeTranfersPreference ( bool ) ) );
+ connect ( limittransactions, SIGNAL ( activated ( int ) ), this, SLOT ( changeLimitTransactionsPreference ( int ) ) );
}
TransactionPreferences::~TransactionPreferences ()
{
}
+void TransactionPreferences::changeLimitTransactionsPreference ( int pref )
+ {
+ preferences->changePreference ( 7, pref );
+ }
+
void TransactionPreferences::changeShowClearedPreference ( bool state )
{
if ( state == TRUE )
preferences->changePreference ( 3, 1 );
else
preferences->changePreference ( 3, 0 );
}
void TransactionPreferences::changeExcludeTranfersPreference ( bool state )
{
if ( state == TRUE )
preferences->changePreference ( 6, 1 );
else
preferences->changePreference ( 6, 0 );
}
void TransactionPreferences::setDefaultTransactionPreferences ()
{
preferences->changePreference ( 3, 0 );
preferences->changePreference ( 6, 0 );
+ preferences->changePreference ( 7, 0 );
showclearedtransactions->setChecked ( FALSE );
+ limittransactions->setCurrentItem ( 0 );
}
// START ACCOUNT PREFERNCES
AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
{
setCaption( tr ( "Account" ) );
currencysupport = new QCheckBox ( this );
currencysupport->setText ( "Enable Currency Support" );
onetouch = new QCheckBox ( this );
onetouch->setText ( "One Touch Account Viewing" );
if ( preferences->getPreference ( 4 ) == 1 )
currencysupport->setChecked ( TRUE );
else
currencysupport->setChecked ( FALSE );
if ( preferences->getPreference ( 5 ) == 1 )
onetouch->setChecked ( TRUE );
else
onetouch->setChecked ( FALSE );
defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultAccountPreferences () ) );
layout = new QVBoxLayout ( this, 2, 2 );
layout->addWidget ( currencysupport );
layout->addWidget ( onetouch );
layout->insertSpacing ( 2, 5 );
layout->addWidget ( defaults );
connect ( currencysupport, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeCurrencySupport ( bool ) ) );
connect ( onetouch, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeOneTouchViewing ( bool ) ) );
}
AccountPreferences::~AccountPreferences ()
{
}
void AccountPreferences::changeCurrencySupport ( bool state )
{
if ( state == TRUE )
preferences->changePreference ( 4, 1 );
else
preferences->changePreference ( 4, 0 );
}
void AccountPreferences::changeOneTouchViewing ( bool state )
{
if ( state == TRUE )
preferences->changePreference ( 5, 1 );
else
preferences->changePreference ( 5, 0 );
}
void AccountPreferences::setDefaultAccountPreferences ()
{
preferences->changePreference ( 4, 0 );
preferences->changePreference ( 5, 0 );
currencysupport->setChecked ( FALSE );
onetouch->setChecked ( FALSE );
}
diff --git a/noncore/apps/qashmoney/preferencedialogs.h b/noncore/apps/qashmoney/preferencedialogs.h
index 97b2dbb..88281b8 100755
--- a/noncore/apps/qashmoney/preferencedialogs.h
+++ b/noncore/apps/qashmoney/preferencedialogs.h
@@ -1,86 +1,90 @@
#include <qcombobox.h>
#include <qdialog.h>
#include <qpushbutton.h>
#include <qpixmap.h>
#include <qgroupbox.h>
#include <qhbuttongroup.h>
#include <qcheckbox.h>
#include <qlayout.h>
+#include <qlabel.h>
+#include <qhbox.h>
#ifndef DATEPREFERENCES_H
#define DATEPREFERENCES_H
class DatePreferences : public QDialog
{
Q_OBJECT
public:
DatePreferences ( QWidget * parent );
~DatePreferences();
QPushButton *defaults;
QComboBox *dateformat;
QComboBox *dateseparator;
QBoxLayout *layout;
public slots:
void changeDateFormat ( int );
void changeDateSeparator ( int );
void setDefaultDatePreferences ();
};
#endif
#ifndef TRANSACTIONPREFERENCES_H
#define TRANSACTIONPREFERENCES_H
class TransactionPreferences : public QDialog
{
Q_OBJECT
public:
TransactionPreferences ( QWidget * parent );
~TransactionPreferences();
QCheckBox *showclearedtransactions;
QCheckBox *excludetransfers;
- QString *limittransactionslabel;
+ QHBox *limittransactionsbox;
+ QLabel *limittransactionslabel;
QComboBox *limittransactions;
QPushButton *defaults;
QBoxLayout *layout;
public slots:
void changeShowClearedPreference ( bool );
void changeExcludeTranfersPreference ( bool );
void setDefaultTransactionPreferences ();
+ void changeLimitTransactionsPreference ( int );
};
#endif
#ifndef ACCOUNTPREFERENCES_H
#define ACCOUNTPREFERENCES_H
class AccountPreferences : public QDialog
{
Q_OBJECT
public:
AccountPreferences ( QWidget * parent );
~AccountPreferences();
QCheckBox *currencysupport;
QCheckBox *onetouch;
QPushButton *defaults;
QBoxLayout *layout;
public slots:
void changeCurrencySupport ( bool );
void changeOneTouchViewing ( bool );
void setDefaultAccountPreferences ();
};
#endif
diff --git a/noncore/apps/qashmoney/preferences.cpp b/noncore/apps/qashmoney/preferences.cpp
index 8783a47..819d5cf 100755
--- a/noncore/apps/qashmoney/preferences.cpp
+++ b/noncore/apps/qashmoney/preferences.cpp
@@ -1,189 +1,195 @@
#include "preferences.h"
#include <stdlib.h>
Preferences::Preferences ()
{
db = sqlite_open ( "qmpreferences.db", 0, NULL );
}
Preferences::~Preferences ()
{
sqlite_close ( db );
}
void Preferences::addPreferences ()
{
// This function checks the preferences database for existing preferences and adds
// them if they are not there. First we set up variables. Preferences are always set
// to non-zero numbers because when we check to see if a preference has been
// added to the database, the result is zero if it hasn't
int rows = 0;
int columns = 0;
char **results;
sqlite_get_table ( db, "select count() from preferences;", &results, 0, 0, 0 );
- if ( atoi ( results [ 1 ] ) != 6 )
+ if ( atoi ( results [ 1 ] ) != 7 )
{
// dateformat preference 1 = yyyymmdd 2 = yymmdd 3 = mmddyyyy 4 = mmddyy
// 5 = yyyyddmm 6 = yyddmm 7 = ddmmyyyy 8 = ddmmyy
sqlite_get_table ( db, "select preference from preferences where id = 1;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into preferences values ( 4, 'dateformat', 0, 0, 0, NULL );", 0, 0, 0 );
// dateseparator preference 1 = / ( forward slash ) 2 = - ( dash ) 3 = . ( period )
rows = 0;
sqlite_get_table ( db, "select preference from preferences where id = 2;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into preferences values ( 1, 'dateseparator', 0, 0, 0, NULL );", 0, 0, 0 );
// showclearedtransactions preference 0 = no 1 = yes
rows = 0;
sqlite_get_table ( db, "select preference from preferences where id = 3;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into preferences values ( 0, 'showclearedtransactions', 0, 0, 0, NULL );", 0, 0, 0 );
// enable currency support preference 0 = no 1 = yes
rows = 0;
sqlite_get_table ( db, "select preference from preferences where id = 4;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into preferences values ( 0, 'enablecurrencysupport', 0, 0, 0, NULL );", 0, 0, 0 );
// one touch account viewing preference 0 = no 1 = yes
rows = 0;
sqlite_get_table ( db, "select preference from preferences where id = 5;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into preferences values ( 0, 'onetouchviewing', 0, 0, 0, NULL );", 0, 0, 0 );
// exclude transfers from limit view 0 = no 1 = yes
rows = 0;
sqlite_get_table ( db, "select preference from preferences where id = 6;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into preferences values ( 0, 'excludetransfersfromlimit', 0, 0, 0, NULL );", 0, 0, 0 );
+
+ // limit number of transactions to 0 = 14 days 1 = 30 days, 2 = 60 days, 3 = 90 days, 4 = 180 days, 5 = 365 days, 6 = all
+ rows = 0;
+ sqlite_get_table ( db, "select preference from preferences where id = 7;", &results, &rows, &columns, 0 );
+ if ( rows == 0 )
+ sqlite_exec ( db, "insert into preferences values ( 0, 'limittransactions', 0, 0, 0, NULL );", 0, 0, 0 );
}
}
void Preferences::initializeColumnPreferences ()
{
int rows = 0;
int columns = 0;
char **results;
// initialize accountname column width
sqlite_get_table ( db, "select width from columns where id = 1;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'accountname', 90, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize accountbalance column width
sqlite_get_table ( db, "select width from columns where id = 2;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'accountbalance', 90, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize transactiondate column width
sqlite_get_table ( db, "select width from columns where id = 3;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'normaltransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize transactionname column width
sqlite_get_table ( db, "select width from columns where id = 4;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'normaltransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize transactionamount column width
sqlite_get_table ( db, "select width from columns where id = 5;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'normaltransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize transactiondate column width
sqlite_get_table ( db, "select width from columns where id = 6;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'extendedtransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize transactionname column width
sqlite_get_table ( db, "select width from columns where id = 7;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'extendedtransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize transactionamount column width
sqlite_get_table ( db, "select width from columns where id = 8;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'extendedtransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize transactionaccount column width
sqlite_get_table ( db, "select width from columns where id = 9;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'transactionaccount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize account name with currency column width
sqlite_get_table ( db, "select width from columns where id = 10;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'accountnamewithcurrency', 100, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize account currency column width
sqlite_get_table ( db, "select width from columns where id = 11;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'currencycolumn', 10, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize account balance with currency column width
sqlite_get_table ( db, "select width from columns where id = 12;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'accountbalancewithcurrency', 50, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize budget line item column
sqlite_get_table ( db, "select width from columns where id = 13;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'budgetlineitem', 50, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize budget budget column
sqlite_get_table ( db, "select width from columns where id = 14;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'budgetbudget', 50, 0, 0, 0, NULL );", 0, 0, 0 );
// initialize budget actual column
sqlite_get_table ( db, "select width from columns where id = 15;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'budgetactual', 50, 0, 0, 0, NULL );", 0, 0, 0 );
}
void Preferences::changeColumnPreference ( int id, int width )
{
sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id );
}
int Preferences::getColumnPreference ( int id )
{
char **results;
sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id );
return atoi ( results [ 1 ] );
}
int Preferences::getPreference ( int id )
{
char **results;
sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id );
return atoi ( results [ 1 ] );
}
QString Preferences::getSeparator ( )
{
int s = getPreference ( 2 );
if ( s == 1 )
return "/";
if ( s ==2 )
return "-";
else
return ".";
}
void Preferences::changePreference ( int id, int newpreference )
{
sqlite_exec_printf ( db, "update preferences set preference = %i where id = %i;", 0, 0, 0, newpreference, id );
}
void Preferences::setDefaultDatePreferences ()
{
sqlite_exec ( db, "update preferences set preference = 4 where id = 1;", 0, 0, 0 );
sqlite_exec ( db, "update preferences set preference = 1 where id = 2;", 0, 0, 0 );
}
QString Preferences::getDate ( int y, int m, int d )
{