1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "tableselectionpage.hxx"
21 #include "abptypes.hxx"
22 #include "addresssettings.hxx"
23 #include "abspilot.hxx"
24 #include <tools/debug.hxx>
30 TableSelectionPage::TableSelectionPage( OAddressBookSourcePilot
* _pParent
)
31 :AddressBookSourcePage(_pParent
, "SelectTablePage",
32 "modules/sabpilot/ui/selecttablepage.ui")
34 get(m_pTableList
, "table");
35 m_pTableList
->SetSelectHdl( LINK( this, TableSelectionPage
, OnTableSelected
) );
36 m_pTableList
->SetDoubleClickHdl( LINK( this, TableSelectionPage
, OnTableDoubleClicked
) );
39 TableSelectionPage::~TableSelectionPage()
44 void TableSelectionPage::dispose()
47 AddressBookSourcePage::dispose();
50 void TableSelectionPage::ActivatePage()
52 AddressBookSourcePage::ActivatePage();
54 m_pTableList
->GrabFocus();
58 void TableSelectionPage::initializePage()
60 AddressBookSourcePage::initializePage();
62 const AddressSettings
& rSettings
= getSettings();
64 m_pTableList
->Clear();
66 // get the table names
67 const StringBag
& aTableNames
= getDialog()->getDataSource().getTableNames();
68 DBG_ASSERT( aTableNames
.size() > 1, "TableSelectionPage::initializePage: to be called for more than one table only!");
69 // this page should never bother the user if there is 1 or less tables.
72 for (auto const& tableName
: aTableNames
)
73 m_pTableList
->InsertEntry(tableName
);
75 // initially select the proper table
76 m_pTableList
->SelectEntry( rSettings
.sSelectedTable
);
80 IMPL_LINK_NOARG( TableSelectionPage
, OnTableDoubleClicked
, ListBox
&, void )
82 if ( 1 == m_pTableList
->GetSelectedEntryCount() )
83 getDialog()->travelNext();
87 IMPL_LINK_NOARG( TableSelectionPage
, OnTableSelected
, ListBox
&, void )
89 updateDialogTravelUI();
93 bool TableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason
)
95 if (!AddressBookSourcePage::commitPage(_eReason
))
98 AddressSettings
& rSettings
= getSettings();
99 rSettings
.sSelectedTable
= m_pTableList
->GetSelectedEntry();
105 bool TableSelectionPage::canAdvance() const
107 return AddressBookSourcePage::canAdvance()
108 && ( 0 < m_pTableList
->GetSelectedEntryCount() );
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */