Skip to content
Snippets Groups Projects
Commit 05c1e8f4 authored by rswindell's avatar rswindell
Browse files

Created new UserListForm to display a sortable list of all users in the database.

parent ca3409eb
No related branches found
No related tags found
No related merge requests found
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "UserListFormUnit.h"
#include "MainFormUnit.h"
#include "sbbs.h"
#include "userdat.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TUserListForm *UserListForm;
//---------------------------------------------------------------------------
__fastcall TUserListForm::TUserListForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TUserListForm::FormShow(TObject *Sender)
{
char str[128];
int i,last;
user_t user;
TListItem* Item;
ColumnToSort=0;
SortBackwards=false;
Screen->Cursor=crAppStart;
last=lastuser(&MainForm->cfg);
ListView->AllocBy=last;
for(i=0;i<last;i++) {
user.number=i+1;
if(getuserdat(&MainForm->cfg,&user)!=0)
continue;
if(user.misc&DELETED)
continue;
Item=ListView->Items->Add();
Item->Caption=AnsiString(i+1);
Item->SubItems->Add(user.alias);
Item->SubItems->Add(user.name);
Item->SubItems->Add(user.level);
Item->SubItems->Add((int)getage(&MainForm->cfg,user.birth));
sprintf(str,"%c",user.sex);
Item->SubItems->Add(str);
Item->SubItems->Add(user.location);
Item->SubItems->Add(user.modem);
Item->SubItems->Add(user.note);
Item->SubItems->Add(user.comp);
Item->SubItems->Add(user.phone);
Item->SubItems->Add(user.netmail);
Item->SubItems->Add(user.logons);
Item->SubItems->Add(unixtodstr(&MainForm->cfg,user.firston,str));
Item->SubItems->Add(unixtodstr(&MainForm->cfg,user.laston,str));
}
Screen->Cursor=crDefault;
}
//---------------------------------------------------------------------------
void __fastcall TUserListForm::ListViewColumnClick(TObject *Sender,
TListColumn *Column)
{
if(Column->Index == ColumnToSort)
SortBackwards=!SortBackwards;
else
SortBackwards=false;
ColumnToSort = Column->Index;
((TCustomListView *)Sender)->AlphaSort();
}
//---------------------------------------------------------------------------
void __fastcall TUserListForm::ListViewCompare(TObject *Sender,
TListItem *Item1, TListItem *Item2, int Data, int &Compare)
{
/* Decimal compare */
if (ColumnToSort == 0 || ColumnToSort==3 || ColumnToSort==4
|| ColumnToSort == 12) {
int num1, num2;
if(ColumnToSort==0) {
num1=Item1->Caption.ToIntDef(0);
num2=Item2->Caption.ToIntDef(0);
} else {
int ix = ColumnToSort - 1;
num1=Item1->SubItems->Strings[ix].ToIntDef(0);
num2=Item2->SubItems->Strings[ix].ToIntDef(0);
}
if(SortBackwards)
Compare=(num2-num1);
else
Compare=(num1-num2);
} else {
int ix = ColumnToSort - 1;
if(SortBackwards)
Compare = CompareText(Item2->SubItems->Strings[ix]
,Item1->SubItems->Strings[ix]);
else
Compare = CompareText(Item1->SubItems->Strings[ix]
,Item2->SubItems->Strings[ix]);
}
}
//---------------------------------------------------------------------------
void __fastcall TUserListForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
ListView->Items->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TUserListForm::EditUserPopupClick(TObject *Sender)
{
char str[256];
if(ListView->Selected==NULL)
return;
sprintf(str,"%sUSEREDIT %s %s"
,MainForm->cfg.exec_dir,MainForm->cfg.data_dir
,ListView->Selected->Caption.c_str());
WinExec(str,SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------
object UserListForm: TUserListForm
Left = 387
Top = 308
Width = 870
Height = 640
Caption = 'Synchronet User List'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = False
OnClose = FormClose
OnShow = FormShow
PixelsPerInch = 120
TextHeight = 16
object ListView: TListView
Left = 0
Top = 0
Width = 862
Height = 608
Align = alClient
Columns = <
item
Caption = 'Num'
Width = 40
end
item
Caption = 'Alias'
Width = 100
end
item
Caption = 'Name'
Width = 100
end
item
Caption = 'Lev'
Width = 40
end
item
Caption = 'Age'
Width = 40
end
item
Caption = 'Sex'
Width = 40
end
item
Caption = 'Location'
Width = 100
end
item
Caption = 'Protocol'
Width = 70
end
item
Caption = 'Address'
Width = 100
end
item
Caption = 'Host Name'
Width = 100
end
item
Caption = 'Phone'
Width = 100
end
item
Caption = 'Email'
Width = 100
end
item
Caption = 'Logons'
Width = 60
end
item
Caption = 'First On'
Width = 70
end
item
Caption = 'Last On'
Width = 70
end>
PopupMenu = PopupMenu
SortType = stText
TabOrder = 0
ViewStyle = vsReport
OnColumnClick = ListViewColumnClick
OnCompare = ListViewCompare
end
object PopupMenu: TPopupMenu
Left = 232
Top = 96
object EditUserPopup: TMenuItem
Caption = 'Edit User'
OnClick = EditUserPopupClick
end
end
end
//---------------------------------------------------------------------------
#ifndef UserListFormUnitH
#define UserListFormUnitH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <Menus.hpp>
//---------------------------------------------------------------------------
class TUserListForm : public TForm
{
__published: // IDE-managed Components
TListView *ListView;
TPopupMenu *PopupMenu;
TMenuItem *EditUserPopup;
void __fastcall FormShow(TObject *Sender);
void __fastcall ListViewColumnClick(TObject *Sender,
TListColumn *Column);
void __fastcall ListViewCompare(TObject *Sender, TListItem *Item1,
TListItem *Item2, int Data, int &Compare);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall EditUserPopupClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TUserListForm(TComponent* Owner);
int ColumnToSort;
bool SortBackwards;
};
//---------------------------------------------------------------------------
extern PACKAGE TUserListForm *UserListForm;
//---------------------------------------------------------------------------
#endif
......@@ -9,7 +9,7 @@
TextFileEditUnit.obj TelnetFormUnit.obj FtpFormUnit.obj MailFormUnit.obj
NodeFormUnit.obj StatsFormUnit.obj AboutBoxFormUnit.obj
StatsLogFormUnit.obj CodeInputFormUnit.obj ClientFormUnit.obj
SpyFormUnit.obj ..\ringbuf.obj"/>
SpyFormUnit.obj ..\ringbuf.obj UserListFormUnit.obj"/>
<RESFILES value="sbbsctrl.res"/>
<IDLFILES value=""/>
<IDLGENFILES value=""/>
......@@ -18,14 +18,15 @@
MailCfgDlgUnit.dfm FtpCfgDlgUnit.dfm TextFileEditUnit.dfm
TelnetFormUnit.dfm FtpFormUnit.dfm MailFormUnit.dfm NodeFormUnit.dfm
StatsFormUnit.dfm AboutBoxFormUnit.dfm StatsLogFormUnit.dfm
CodeInputFormUnit.dfm ClientFormUnit.dfm SpyFormUnit.dfm"/>
CodeInputFormUnit.dfm ClientFormUnit.dfm SpyFormUnit.dfm
UserListFormUnit.dfm"/>
<LIBFILES value="sbbs.lib mailsrvr.lib ftpsrvr.lib"/>
<LIBRARIES value="vcl50.lib"/>
<SPARELIBS value="vcl50.lib"/>
<LIBRARIES value="IcsBcb50.lib vcl50.lib"/>
<SPARELIBS value="vcl50.lib IcsBcb50.lib"/>
<PACKAGES value="vcl50.bpi vclx50.bpi vcljpg50.bpi bcbsmp50.bpi vclmid50.bpi vcldb50.bpi
vclbde50.bpi inet50.bpi inetdb50.bpi vcldbx50.bpi qrpt50.bpi teeui50.bpi
teedb50.bpi tee50.bpi dss50.bpi nmfast50.bpi dclocx50.bpi"/>
<PATHCPP value=".;.."/>
<PATHCPP value=".;..\..\sbbs3"/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
......
......@@ -58,6 +58,7 @@ USEFORM("ClientFormUnit.cpp", ClientForm);
USEFORM("SpyFormUnit.cpp", SpyForm);
USEUNIT("..\ringbuf.c");
USEUNIT("emulvt.pas");
USEFORM("UserListFormUnit.cpp", UserListForm);
//---------------------------------------------------------------------------
#include "MainFormUnit.h"
#include "SpyFormUnit.h"
......@@ -78,6 +79,7 @@ WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
Application->CreateForm(__classid(TNodeForm), &NodeForm);
Application->CreateForm(__classid(TStatsForm), &StatsForm);
Application->CreateForm(__classid(TClientForm), &ClientForm);
Application->CreateForm(__classid(TUserListForm), &UserListForm);
Application->Run();
}
catch (Exception &exception)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment