Skip to content

Commit

Permalink
Add option to hide/show Recent/Samples panel in open dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Jan 17, 2017
1 parent 3a0178e commit fe93b11
Show file tree
Hide file tree
Showing 9 changed files with 1,371 additions and 1,277 deletions.
4 changes: 3 additions & 1 deletion DataViewer/MergeTableDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ void MergeTableDlg::OnOpenClick( wxCommandEvent& ev )
wxLogMessage("Entering MergeTableDlg::OnOpenClick()");
try {
ConnectDatasourceDlg dlg(this);
if (dlg.ShowModal() != wxID_OK) return;

if (dlg.ShowModal() != wxID_OK)
return;

wxString proj_title = dlg.GetProjectTitle();
wxString layer_name = dlg.GetLayerName();
Expand Down
54 changes: 38 additions & 16 deletions DialogTools/ConnectDatasourceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,36 +364,42 @@ BEGIN_EVENT_TABLE( ConnectDatasourceDlg, wxDialog )
END_EVENT_TABLE()


ConnectDatasourceDlg::ConnectDatasourceDlg(wxWindow* parent, const wxPoint& pos, const wxSize& size)
ConnectDatasourceDlg::ConnectDatasourceDlg(wxWindow* parent, const wxPoint& pos,
const wxSize& size)
:datasource(0), scrl(0), recent_panel(0)
{
base_xrcid_recent_thumb = 7000;
base_xrcid_sample_thumb = 7500;

// init controls defined in parent class
DatasourceDlg::Init();
ds_names.Add("GeoDa Project File (*.gda)|*.gda");

SetParent(parent);
CreateControls();
SetPosition(pos);

RecentDatasource recent_ds;
if (recent_ds.GetRecords() > 0) {
wxBoxSizer* sizer;
sizer = new wxBoxSizer( wxVERTICAL );

InitRecentPanel();
sizer->Add( scrl, 1, wxEXPAND | wxRIGHT, 5 );

recent_panel->SetSizer( sizer );
recent_panel->Layout();
sizer->Fit( recent_panel );

if (GdaConst::show_recent_sample_connect_ds_dialog) {
RecentDatasource recent_ds;
if (recent_ds.GetRecords() > 0) {
wxBoxSizer* sizer;
sizer = new wxBoxSizer( wxVERTICAL );

InitRecentPanel();
sizer->Add( scrl, 1, wxEXPAND | wxRIGHT, 5 );

recent_panel->SetSizer( sizer );
recent_panel->Layout();
sizer->Fit( recent_panel );
}

InitSamplePanel();
} else {
recent_nb->Hide();
}

InitSamplePanel();

m_drag_drop_box->SetDropTarget(new DnDFile(this));

Bind(wxEVT_COMMAND_MENU_SELECTED, &ConnectDatasourceDlg::BrowseDataSource,
this, DatasourceDlg::ID_DS_START, ID_DS_START + ds_names.Count());

Expand Down Expand Up @@ -567,6 +573,12 @@ void ConnectDatasourceDlg::CreateControls()
recent_nb->SetSelection(1);
recent_panel = XRCCTRL(*this, "dsRecentListSizer", wxPanel);
smaples_panel = XRCCTRL(*this, "dsSampleList", wxPanel);
noshow_recent = XRCCTRL(*this, "IDC_NOSHOW_RECENT_SAMPLES", wxCheckBox);

noshow_recent->Bind(wxEVT_CHECKBOX, &ConnectDatasourceDlg::OnNoShowRecent, this);
if (!GdaConst::show_recent_sample_connect_ds_dialog) {
noshow_recent->Hide();
}

// create controls defined in parent class
DatasourceDlg::CreateControls();
Expand All @@ -576,6 +588,16 @@ void ConnectDatasourceDlg::CreateControls()
m_webservice_url->SetAutoList(ws_url_cands);
}

void ConnectDatasourceDlg::OnNoShowRecent( wxCommandEvent& event)
{
recent_nb->Hide();
noshow_recent->Hide();
GetSizer()->Fit(this);

GdaConst::show_recent_sample_connect_ds_dialog = false;
OGRDataAdapter::GetInstance().AddEntry("show_recent_sample_connect_ds_dialog", "0");
}

/**
* This functions handles the event of user click the "lookup" button in
* Web Service tab
Expand Down
3 changes: 3 additions & 0 deletions DialogTools/ConnectDatasourceDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class ConnectDatasourceDlg: public DatasourceDlg
wxPanel* smaples_panel;
wxScrolledWindow* scrl;
wxNotebook* recent_nb;
wxCheckBox* noshow_recent;

int base_xrcid_recent_thumb;
int base_xrcid_sample_thumb;
Expand All @@ -132,6 +133,8 @@ class ConnectDatasourceDlg: public DatasourceDlg
void OnSample(wxCommandEvent& event);
void OnRecentDelete(wxCommandEvent& event);

void OnNoShowRecent(wxCommandEvent& event);

DECLARE_EVENT_TABLE()
};

Expand Down
42 changes: 38 additions & 4 deletions DialogTools/ReportBugDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ void PreferenceDlg::Init()
grid_sizer1->Add(new wxStaticText(vis_page, wxID_ANY, _("System:")), 1,
wxTOP | wxBOTTOM, 20);
grid_sizer1->AddSpacer(10);


wxString lbl8 = _("Show Recent/Samples panel in Connect Datasource Dialog:");
wxStaticText* lbl_txt8 = new wxStaticText(vis_page, wxID_ANY, lbl8);
cbox8 = new wxCheckBox(vis_page, XRCID("PREF_SHOW_RECENT"), "", wxDefaultPosition);
grid_sizer1->Add(lbl_txt8, 1, wxEXPAND);
grid_sizer1->Add(cbox8, 0, wxALIGN_RIGHT);
cbox8->Bind(wxEVT_CHECKBOX, &PreferenceDlg::OnShowRecent, this);

wxString lbl4 = _("Disable crash detection for bug report:");
wxStaticText* lbl_txt4 = new wxStaticText(vis_page, wxID_ANY, lbl4);
Expand Down Expand Up @@ -328,8 +336,8 @@ void PreferenceDlg::Init()
void PreferenceDlg::OnReset(wxCommandEvent& ev)
{
GdaConst::use_cross_hatching = false;
GdaConst::transparency_highlighted = 209;
GdaConst::transparency_unhighlighted = 255;
GdaConst::transparency_highlighted = 255;
GdaConst::transparency_unhighlighted = 100;
//GdaConst::transparency_map_on_basemap = 200;
GdaConst::use_basemap_by_default = false;
GdaConst::default_basemap_selection = 0;
Expand All @@ -339,13 +347,14 @@ void PreferenceDlg::OnReset(wxCommandEvent& ev)
GdaConst::disable_auto_upgrade = false;
GdaConst::plot_transparency_highlighted = 255;
GdaConst::plot_transparency_unhighlighted = 50;
GdaConst::show_recent_sample_connect_ds_dialog = true;

SetupControls();

OGRDataAdapter& ogr_adapt = OGRDataAdapter::GetInstance();
ogr_adapt.AddEntry("use_cross_hatching", "0");
ogr_adapt.AddEntry("transparency_highlighted", "209");
ogr_adapt.AddEntry("transparency_unhighlighted", "255");
ogr_adapt.AddEntry("transparency_highlighted", "255");
ogr_adapt.AddEntry("transparency_unhighlighted", "100");
ogr_adapt.AddEntry("use_basemap_by_default", "0");
ogr_adapt.AddEntry("default_basemap_selection", "0");
ogr_adapt.AddEntry("hide_sys_table_postgres", "0");
Expand All @@ -354,6 +363,7 @@ void PreferenceDlg::OnReset(wxCommandEvent& ev)
ogr_adapt.AddEntry("disable_auto_upgrade", "0");
ogr_adapt.AddEntry("plot_transparency_highlighted", "255");
ogr_adapt.AddEntry("plot_transparency_unhighlighted", "50");
ogr_adapt.AddEntry("show_recent_sample_connect_ds_dialog", "1");
}

void PreferenceDlg::SetupControls()
Expand All @@ -378,6 +388,7 @@ void PreferenceDlg::SetupControls()
cbox5->SetValue(GdaConst::disable_auto_upgrade);
cbox21->SetValue(GdaConst::hide_sys_table_postgres);
cbox22->SetValue(GdaConst::hide_sys_table_sqlite);
cbox8->SetValue(GdaConst::show_recent_sample_connect_ds_dialog);
}

void PreferenceDlg::ReadFromCache()
Expand Down Expand Up @@ -481,6 +492,17 @@ void PreferenceDlg::ReadFromCache()
}
}

vector<string> show_recent_sample_connect_ds_dialog = OGRDataAdapter::GetInstance().GetHistory("show_recent_sample_connect_ds_dialog");
if (!show_recent_sample_connect_ds_dialog.empty() ) {
long sel_l = 0;
wxString sel = show_recent_sample_connect_ds_dialog[0];
if (sel.ToLong(&sel_l)) {
if (sel_l == 1)
GdaConst::show_recent_sample_connect_ds_dialog = true;
else if (sel_l == 0)
GdaConst::show_recent_sample_connect_ds_dialog = false;
}
}
}

void PreferenceDlg::OnSlider1(wxScrollEvent& ev)
Expand Down Expand Up @@ -631,6 +653,18 @@ void PreferenceDlg::OnDisableAutoUpgrade(wxCommandEvent& ev)

}
}
void PreferenceDlg::OnShowRecent(wxCommandEvent& ev)
{
int sel = ev.GetSelection();
if (sel == 0) {
GdaConst::show_recent_sample_connect_ds_dialog = false;
OGRDataAdapter::GetInstance().AddEntry("show_recent_sample_connect_ds_dialog", "0");
} else {
GdaConst::show_recent_sample_connect_ds_dialog = true;
OGRDataAdapter::GetInstance().AddEntry("show_recent_sample_connect_ds_dialog", "1");

}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
ReportResultDlg::ReportResultDlg( wxWindow* parent, wxString issue_url,
Expand Down
3 changes: 3 additions & 0 deletions DialogTools/ReportBugDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class PreferenceDlg : public wxDialog
wxCheckBox* cbox4;
// auto upgrade
wxCheckBox* cbox5;
// show recent
wxCheckBox* cbox8;
// postgresql
wxCheckBox* cbox21;
// sqlite
Expand All @@ -103,6 +105,7 @@ class PreferenceDlg : public wxDialog
void OnChoice3(wxCommandEvent& ev);
void OnDisableCrashDetect(wxCommandEvent& ev);
void OnDisableAutoUpgrade(wxCommandEvent& ev);
void OnShowRecent(wxCommandEvent& ev);

void OnSlider6(wxScrollEvent& ev);
void OnSlider7(wxScrollEvent& ev);
Expand Down
1 change: 1 addition & 0 deletions GdaConst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ wxFont* GdaConst::small_font = 0;
wxFont* GdaConst::medium_font = 0;
wxFont* GdaConst::large_font = 0;

bool GdaConst::show_recent_sample_connect_ds_dialog = true;
bool GdaConst::use_cross_hatching = false;
int GdaConst::transparency_highlighted = 255;
int GdaConst::transparency_unhighlighted = 100;
Expand Down
1 change: 1 addition & 0 deletions GdaConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ class GdaConst {
static const wxColour legend_background_color; // white

// Preferences
static bool show_recent_sample_connect_ds_dialog;
static bool use_cross_hatching;
static int transparency_highlighted;
static int transparency_unhighlighted;
Expand Down
Loading

0 comments on commit fe93b11

Please sign in to comment.