Annotation of sbbs/sbbs3/ctrl/userlistformunit.cpp, revision 1.1.1.2

1.1       root        1: //---------------------------------------------------------------------------
                      2: 
                      3: #include <vcl.h>
                      4: #pragma hdrstop
                      5: 
                      6: #include "UserListFormUnit.h"
                      7: #include "MainFormUnit.h"
                      8: #include "sbbs.h"
                      9: #include "userdat.h"
                     10: //---------------------------------------------------------------------------
                     11: #pragma package(smart_init)
                     12: #pragma resource "*.dfm"
                     13: TUserListForm *UserListForm;
                     14: //---------------------------------------------------------------------------
                     15: __fastcall TUserListForm::TUserListForm(TComponent* Owner)
                     16:     : TForm(Owner)
                     17: {
                     18: }
                     19: //---------------------------------------------------------------------------
                     20: void __fastcall TUserListForm::FormShow(TObject *Sender)
                     21: {
                     22:     char    str[128];
                     23:     int     i,last;
                     24:     user_t  user;
                     25:     TListItem*  Item;
                     26: 
                     27:     ColumnToSort=0;
                     28:     SortBackwards=false;
                     29:     Screen->Cursor=crAppStart;
                     30: 
                     31:     last=lastuser(&MainForm->cfg);
                     32:     ListView->AllocBy=last;
1.1.1.2 ! root       33: 
        !            34:     ListView->Items->BeginUpdate();
1.1       root       35:     for(i=0;i<last;i++) {
                     36:         user.number=i+1;
                     37:         if(getuserdat(&MainForm->cfg,&user)!=0)
                     38:             continue;
                     39:         if(user.misc&DELETED)
                     40:             continue;
                     41:         Item=ListView->Items->Add();
                     42:         Item->Caption=AnsiString(i+1);
                     43:         Item->SubItems->Add(user.alias);
                     44:         Item->SubItems->Add(user.name);
                     45:         Item->SubItems->Add(user.level);
                     46:         Item->SubItems->Add((int)getage(&MainForm->cfg,user.birth));
1.1.1.2 ! root       47:         if(user.sex<=' ' || user.sex&0x80)  /* garbage? */
        !            48:             str[0]=0;
        !            49:         else
        !            50:             sprintf(str,"%c",user.sex);
1.1       root       51:         Item->SubItems->Add(str);
                     52:         Item->SubItems->Add(user.location);
                     53:         Item->SubItems->Add(user.modem);
                     54:         Item->SubItems->Add(user.note);
                     55:         Item->SubItems->Add(user.comp);
                     56:         Item->SubItems->Add(user.phone);
                     57:         Item->SubItems->Add(user.netmail);
                     58:         Item->SubItems->Add(user.logons);
                     59:         Item->SubItems->Add(unixtodstr(&MainForm->cfg,user.firston,str));
                     60:         Item->SubItems->Add(unixtodstr(&MainForm->cfg,user.laston,str));
                     61:     }
1.1.1.2 ! root       62:     ListView->Items->EndUpdate();
        !            63:     
1.1       root       64:     Screen->Cursor=crDefault;
                     65: }
                     66: //---------------------------------------------------------------------------
                     67: void __fastcall TUserListForm::ListViewColumnClick(TObject *Sender,
                     68:       TListColumn *Column)
                     69: {
                     70:     if(Column->Index == ColumnToSort)
                     71:         SortBackwards=!SortBackwards;
                     72:     else
                     73:         SortBackwards=false;
                     74:     ColumnToSort = Column->Index;
                     75:     ((TCustomListView *)Sender)->AlphaSort();
                     76: }
                     77: //---------------------------------------------------------------------------
                     78: void __fastcall TUserListForm::ListViewCompare(TObject *Sender,
                     79:       TListItem *Item1, TListItem *Item2, int Data, int &Compare)
                     80: {
                     81:     /* Decimal compare */
                     82:     if (ColumnToSort == 0 || ColumnToSort==3 || ColumnToSort==4
1.1.1.2 ! root       83:     || ColumnToSort == 12   /* logons */
        !            84:     || ColumnToSort == 13   /* First On */
        !            85:     || ColumnToSort == 14   /* Last On */
        !            86:     ) {
1.1       root       87:         int num1, num2;
                     88: 
                     89:         if(ColumnToSort==0) {
                     90:             num1=Item1->Caption.ToIntDef(0);
                     91:             num2=Item2->Caption.ToIntDef(0);
1.1.1.2 ! root       92:         } else if(ColumnToSort>12) {    /* Date */
        !            93:             int ix = ColumnToSort - 1;
        !            94:             num1=dstrtounix(&MainForm->cfg
        !            95:                 ,Item1->SubItems->Strings[ix].c_str());
        !            96:             num2=dstrtounix(&MainForm->cfg
        !            97:                 ,Item2->SubItems->Strings[ix].c_str());
1.1       root       98:         } else {
                     99:             int ix = ColumnToSort - 1;
                    100:             num1=Item1->SubItems->Strings[ix].ToIntDef(0);
                    101:             num2=Item2->SubItems->Strings[ix].ToIntDef(0);
                    102:         }
                    103:         if(SortBackwards)
                    104:             Compare=(num2-num1);
                    105:         else
                    106:             Compare=(num1-num2);
                    107:     } else {
                    108:         int ix = ColumnToSort - 1;
                    109:         if(SortBackwards)
                    110:             Compare = CompareText(Item2->SubItems->Strings[ix]
                    111:                 ,Item1->SubItems->Strings[ix]);
                    112:         else
                    113:             Compare = CompareText(Item1->SubItems->Strings[ix]
                    114:                 ,Item2->SubItems->Strings[ix]);
                    115:     }
                    116: }
                    117: //---------------------------------------------------------------------------
                    118: void __fastcall TUserListForm::FormClose(TObject *Sender,
                    119:       TCloseAction &Action)
                    120: {
1.1.1.2 ! root      121:     ListView->Items->BeginUpdate();
1.1       root      122:     ListView->Items->Clear();
1.1.1.2 ! root      123:     ListView->Items->EndUpdate();
1.1       root      124: }
                    125: //---------------------------------------------------------------------------
                    126: 
                    127: 
                    128: 
                    129: 
                    130: void __fastcall TUserListForm::EditUserPopupClick(TObject *Sender)
                    131: {
                    132:     char str[256];
                    133: 
                    134:     if(ListView->Selected==NULL)
                    135:         return;
                    136:     sprintf(str,"%sUSEREDIT %s %s"
                    137:         ,MainForm->cfg.exec_dir,MainForm->cfg.data_dir
                    138:         ,ListView->Selected->Caption.c_str());
                    139:     WinExec(str,SW_SHOWNORMAL);
                    140: }
                    141: //---------------------------------------------------------------------------
                    142: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.