Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaking Reconcile window #99

Merged
merged 5 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Account::Account(const char* name, const bool& isclosed)
fID(0),
fClosed(isclosed),
fCurrentTransaction(0),
fLastCheckNumber(0),
fUseDefaultLocale(true)
{
}
Expand Down Expand Up @@ -36,18 +35,6 @@ Account::SetCurrentTransaction(const uint32& id)
return false;
}

uint16
Account::LookupLastCheckNumber(void)
{
BString command;
command.SetToFormat("SELECT MAX(type) FROM account_%i WHERE type BETWEEN 0 AND 65536;", fID);
CppSQLite3Query query = gDatabase.DBQuery(command.String(), "Account::LookupLastCheckNumber");
if (query.eof())
return 0;

return query.getIntField(0);
}

Fixed
Account::Balance(void)
{
Expand Down
5 changes: 0 additions & 5 deletions src/Account.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class Account : public Notifier {
uint32 CurrentTransaction(void) const { return fCurrentTransaction; }
bool SetCurrentTransaction(const uint32& id);

uint16 LastCheckNumber(void) const { return fLastCheckNumber; }
uint16 LookupLastCheckNumber(void);
void SetLastCheckNumber(const uint16& value) { fLastCheckNumber = value; }

BString AutocompleteCategory(const char* input);
BString AutocompletePayee(const char* input);
// BString AutocompleteType(const char* input);
Expand All @@ -59,7 +55,6 @@ class Account : public Notifier {
uint32 fID;
bool fClosed;
uint32 fCurrentTransaction;
uint32 fLastCheckNumber;
Locale fLocale;
bool fUseDefaultLocale;
};
Expand Down
131 changes: 0 additions & 131 deletions src/CheckNumBox.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions src/CheckNumBox.h

This file was deleted.

3 changes: 0 additions & 3 deletions src/CheckView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ CheckView::MessageReceived(BMessage* msg)
gDatabase.AddTransaction(trans);
acc->SetCurrentTransaction(trans.GetID());

if (trans.Type().TypeCode() == TRANS_NUMERIC)
acc->SetLastCheckNumber(atol(trans.Type().Type()));

MakeEmpty();

gDatabase.GetTransaction(trans.GetID(), trans);
Expand Down
2 changes: 0 additions & 2 deletions src/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ Database::OpenFile(const char* path)
if (!query.eof())
acc->SetCurrentTransaction(query.getInt64Field(0));
query.finalize();

acc->SetLastCheckNumber(acc->LookupLastCheckNumber());
}

fCurrent = (Account*)fList.ItemAt(0);
Expand Down
2 changes: 1 addition & 1 deletion src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ MainWindow::MessageReceived(BMessage* msg)
break;
}

ReconcileWindow* recwin = new ReconcileWindow(BRect(100, 100, 700, 425), acc);
ReconcileWindow* recwin = new ReconcileWindow(BRect(0, 0, 700, 550), acc);
recwin->CenterIn(Frame());
recwin->Show();
break;
Expand Down
31 changes: 24 additions & 7 deletions src/ReconcileItem.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#include "ReconcileItem.h"

#include <ListView.h>
#include <Region.h>
#include <View.h>

#include <stdio.h>
#include <ctime>

#include "CBLocale.h"
#include "Database.h"
#include "Preferences.h"
#include "TransactionData.h"


Expand All @@ -21,17 +25,31 @@ ReconcileItem::~ReconcileItem(void) {}
void
ReconcileItem::DrawItem(BView* owner, BRect frame, bool complete)
{
owner->SetHighUIColor(
IsSelected() ? B_LIST_SELECTED_BACKGROUND_COLOR : B_LIST_BACKGROUND_COLOR);
owner->FillRect(frame);
BListView* list = (BListView*)owner;
int32 index = list->IndexOf(this);

if (IsSelected()) {
owner->SetHighUIColor(B_LIST_SELECTED_BACKGROUND_COLOR);
owner->FillRect(frame);
owner->SetHighUIColor(B_CONTROL_HIGHLIGHT_COLOR);
owner->StrokeRect(frame);
} else {
if (index % 2 == 1) { // darken odd row
owner->SetHighUIColor(B_LIST_BACKGROUND_COLOR,
GetMutedTint(ui_color(B_LIST_BACKGROUND_COLOR), CB_ALT_ROW));
} else
owner->SetHighUIColor(B_LIST_BACKGROUND_COLOR);

owner->FillRect(frame);
}

owner->SetFont(IsReconciled() ? be_bold_font : be_plain_font);
owner->SetHighUIColor(B_LIST_ITEM_TEXT_COLOR);
owner->SetHighUIColor(IsSelected() ? B_LIST_SELECTED_ITEM_TEXT_COLOR : B_LIST_ITEM_TEXT_COLOR);

// Compute vertical alignment factor
font_height fh;
owner->GetFontHeight(&fh);
float fontFactor = ceilf(fh.ascent + fh.descent + fh.leading) / 4 + 1;

// Draw amount first
BString string;
Expand All @@ -42,15 +60,14 @@ ReconcileItem::DrawItem(BView* owner, BRect frame, bool complete)
gCurrentLocale.CurrencyToString(fTransaction.Amount(), string);

float width = owner->StringWidth(string.String());
owner->DrawString(string.String(), BPoint(frame.right - width, frame.bottom));

owner->DrawString(string.String(), BPoint(frame.right - width - 5, frame.bottom - fontFactor));

// Draw Payee next
BRect r(frame);
r.right -= width + 5;
BRegion region(r);
owner->ConstrainClippingRegion(&region);
owner->DrawString(fTransaction.Payee(), BPoint(frame.left + 1, frame.bottom - 2));
owner->DrawString(fTransaction.Payee(), BPoint(frame.left + 5, frame.bottom - fontFactor));
owner->ConstrainClippingRegion(NULL);
}

Expand Down
Loading
Loading