Update of /cvsroot/mahogany/M/src/adb
In directory usw-pr-cvs1:/tmp/cvs-serv16565/src/adb

Modified Files:
        AdbDialogs.cpp AdbEntry.cpp AdbManager.cpp 
Log Message:
implemented support for setting the expansion priority to -1 (meaning: don't use) from 
the address expansion dialog

Index: AdbDialogs.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/adb/AdbDialogs.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -b -u -2 -r1.17 -r1.18
--- AdbDialogs.cpp      18 Apr 2002 00:12:24 -0000      1.17
+++ AdbDialogs.cpp      29 Apr 2002 00:00:52 -0000      1.18
@@ -119,4 +119,5 @@
    wxAdbExpandDialog(ArrayAdbElements& aEverything,
                      ArrayAdbEntries& aMoreEntries,
+                     size_t nGroups,
                      wxFrame *parent);
 
@@ -124,7 +125,9 @@
    int GetSelection() const { return m_listbox->GetSelection(); }
 
+   // control ids
    enum
    {
-      Btn_More = 100
+      Btn_More = 100,
+      Btn_Delete
    };
 
@@ -133,4 +136,12 @@
    void OnLboxDblClick(wxCommandEvent& /* event */) { EndModal(wxID_OK); }
    void OnBtnMore(wxCommandEvent& event);
+   void OnBtnDelete(wxCommandEvent& event);
+   void OnUpdateBtnDelete(wxUpdateUIEvent& event)
+   {
+      // this catches both the case when there is no selection at all and when
+      // a group is selected: as we can't delete groups (yet?), we disable the
+      // delete button then as well
+      event.Enable(m_listbox->GetSelection() >= (int)m_nGroups);
+   }
 
 private:
@@ -138,10 +149,16 @@
    wxListBox *m_listbox;
 
-   // the button to show more entries (may be NULL)
-   wxButton *m_btnMore;
+   // the buttons to show more entries (may be NULL) and to delete the selected
+   // one (never NULL)
+   wxButton *m_btnMore,
+            *m_btnDelete;
 
-   // the entries array
+   // the main and additional alements array
+   ArrayAdbElements& m_aEverything;
    ArrayAdbEntries& m_aMoreEntries;
 
+   // the number of groups in the beginning of m_aEverything
+   size_t m_nGroups;
+
    DECLARE_EVENT_TABLE()
 };
@@ -158,5 +175,10 @@
 BEGIN_EVENT_TABLE(wxAdbExpandDialog, wxManuallyLaidOutDialog)
    EVT_LISTBOX_DCLICK(-1, wxAdbExpandDialog::OnLboxDblClick)
+
    EVT_BUTTON(wxAdbExpandDialog::Btn_More, wxAdbExpandDialog::OnBtnMore)
+   EVT_BUTTON(wxAdbExpandDialog::Btn_Delete, wxAdbExpandDialog::OnBtnDelete)
+
+   EVT_UPDATE_UI(wxAdbExpandDialog::Btn_Delete,
+                 wxAdbExpandDialog::OnUpdateBtnDelete)
 END_EVENT_TABLE()
 
@@ -378,9 +400,12 @@
 wxAdbExpandDialog::wxAdbExpandDialog(ArrayAdbElements& aEverything,
                                      ArrayAdbEntries& aMoreEntries,
+                                     size_t nGroups,
                                      wxFrame *parent)
                  : wxManuallyLaidOutDialog(parent,
                                            _("Expansion options"),
                                            "AdrListSelect"),
-                   m_aMoreEntries(aMoreEntries)
+                   m_aEverything(aEverything),
+                   m_aMoreEntries(aMoreEntries),
+                   m_nGroups(nGroups)
 {
    /*
@@ -404,4 +429,8 @@
                   : new wxButton(this, Btn_More, _("&More matches"));
 
+   m_btnDelete = new wxButton(this, Btn_Delete, _("&Delete"));
+   m_btnDelete->SetToolTip(_("Don't propose the selected address in this "
+                             "dialog any more and remove it from the list now"));
+
    // we have to fill the listbox here or it won't have the correct size
    size_t nEntryCount = aEverything.GetCount();
@@ -412,4 +441,8 @@
 
    wxLayoutConstraints *c;
+   c = new wxLayoutConstraints;
+   c->right.SameAs(box, wxRight, 2*LAYOUT_X_MARGIN);
+   c->width.AsIs();
+   c->height.AsIs();
 
    if ( m_btnMore )
@@ -417,11 +450,20 @@
       m_btnMore->SetToolTip(_("Show more matching entries"));
 
+      c->bottom.SameAs(box, wxCentreY, LAYOUT_Y_MARGIN);
+      m_btnMore->SetConstraints(c);
+
       c = new wxLayoutConstraints;
       c->right.SameAs(box, wxRight, 2*LAYOUT_X_MARGIN);
-      c->width.AsIs();
-      c->centreY.SameAs(box, wxCentreY);
+      c->width.SameAs(m_btnMore, wxWidth);
       c->height.AsIs();
-      m_btnMore->SetConstraints(c);
+      c->top.Below(m_btnMore, 2*LAYOUT_Y_MARGIN);
    }
+   else // no "More" button
+   {
+      // just position the "Delete" button in the centre
+      c->centreY.SameAs(box, wxCentreY);
+   }
+
+   m_btnDelete->SetConstraints(c);
 
    c = new wxLayoutConstraints;
@@ -435,4 +477,6 @@
    m_listbox->SetConstraints(c);
 
+   m_listbox->SetFocus();
+
    SetDefaultSize(5*wBtn, 10*hBtn);
 }
@@ -450,4 +494,35 @@
 }
 
+void wxAdbExpandDialog::OnBtnDelete(wxCommandEvent& WXUNUSED(event))
+{
+   size_t n = (size_t)m_listbox->GetSelection();
+   CHECK_RET( n >= m_nGroups, "should be disabled" );
+
+   // first remove it from the listbox
+   m_listbox->Delete(n);
+
+   // now remove it from the internal data as well
+   AdbEntry *entry;
+
+   size_t countMain = m_aEverything.GetCount();
+   if ( n < countMain )
+   {
+      entry = (AdbEntry *)m_aEverything[n];
+      m_aEverything.RemoveAt(n);
+   }
+   else // an additional entry
+   {
+      n -= countMain;
+
+      entry = m_aMoreEntries[n];
+      m_aMoreEntries.RemoveAt(n);
+   }
+
+   // remember to not use it for the expansion again
+   entry->SetField(AdbField_ExpandPriority, "-1");
+
+   entry->DecRef();
+}
+
 // ----------------------------------------------------------------------------
 // public interface
@@ -609,4 +684,5 @@
 AdbShowExpandDialog(ArrayAdbElements& aEverything,
                     ArrayAdbEntries& aMoreEntries,
+                    size_t nGroups,
                     wxFrame *parent)
 {
@@ -628,5 +704,5 @@
       default:
          // do show the dialog
-         wxAdbExpandDialog dialog(aEverything, aMoreEntries, parent);
+         wxAdbExpandDialog dialog(aEverything, aMoreEntries, nGroups, parent);
 
          choice = dialog.ShowModal() == wxID_OK ? dialog.GetSelection() : -1;

Index: AdbEntry.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/adb/AdbEntry.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -b -u -2 -r1.8 -r1.9
--- AdbEntry.cpp        26 Apr 2002 13:15:06 -0000      1.8
+++ AdbEntry.cpp        29 Apr 2002 00:00:53 -0000      1.9
@@ -97,7 +97,6 @@
 void AdbEntryStoredInMemory::SetField(size_t n, const wxString& strValue)
 {
-  size_t nCur = m_astrFields.Count();
   // add some empty fields if needed
-  for ( int nAdd = 0; nAdd < (int)(n - nCur + 1); nAdd++ )
+  while ( m_astrFields.Count() <= n )
     m_astrFields.Add(wxGetEmptyString());
 

Index: AdbManager.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/adb/AdbManager.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -b -u -2 -r1.33 -r1.34
--- AdbManager.cpp      16 Apr 2002 22:48:23 -0000      1.33
+++ AdbManager.cpp      29 Apr 2002 00:00:53 -0000      1.34
@@ -142,4 +142,11 @@
     AdbEntry *pEntry = pGroup->GetEntry(aNames[nEntry]);
 
+    if ( pEntry->GetField(AdbField_ExpandPriority) == "-1" )
+    {
+      // never use this one for expansion
+      pEntry->DecRef();
+      continue;
+    }
+
     // we put the entries which match with their nick name in one array and
     // the entries which match anywhere else in the other one: see AdbExpand()
@@ -275,5 +282,5 @@
 
     // let the user choose the one he wants
-    int rc = AdbShowExpandDialog(aEverything, aMoreEntries, frame);
+    int rc = AdbShowExpandDialog(aEverything, aMoreEntries, nGroupCount, frame);
 
     if ( rc != -1 ) {


_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to