LibreOffice Module extensions (master) 1
tableselectionpage.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include "abptypes.hxx"
22#include "addresssettings.hxx"
23#include "abspilot.hxx"
24#include <tools/debug.hxx>
25
26
27namespace abp
28{
29
31 : AddressBookSourcePage(pPage, pController, "modules/sabpilot/ui/selecttablepage.ui", "SelectTablePage")
32 , m_xTableList(m_xBuilder->weld_tree_view("table"))
33 {
34 m_xTableList->connect_changed( LINK( this, TableSelectionPage, OnTableSelected ) );
35 m_xTableList->connect_row_activated( LINK( this, TableSelectionPage, OnTableDoubleClicked ) );
36 }
37
39 {
40 }
41
43 {
45
46 m_xTableList->grab_focus();
47 }
48
50 {
52
53 const AddressSettings& rSettings = getSettings();
54
55 m_xTableList->clear();
56
57 // get the table names
58 const StringBag& aTableNames = getDialog()->getDataSource().getTableNames();
59 DBG_ASSERT( aTableNames.size() > 1, "TableSelectionPage::initializePage: to be called for more than one table only!");
60 // this page should never bother the user if there is 1 or less tables.
61
62 // fill the list
63 for (auto const& tableName : aTableNames)
64 m_xTableList->append_text(tableName);
65
66 // initially select the proper table
67 m_xTableList->select_text(rSettings.sSelectedTable);
68 }
69
70 IMPL_LINK_NOARG( TableSelectionPage, OnTableDoubleClicked, weld::TreeView&, bool )
71 {
72 if (m_xTableList->count_selected_rows() == 1)
73 getDialog()->travelNext();
74 return true;
75 }
76
78 {
79 updateDialogTravelUI();
80 }
81
83 {
85 return false;
86
87 AddressSettings& rSettings = getSettings();
88 rSettings.sSelectedTable = m_xTableList->get_selected_text();
89
90 return true;
91 }
92
94 {
96 && (m_xTableList->count_selected_rows() > 0);
97 }
98
99} // namespace abp
100
101/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
the base class for all tab pages in the address book source wizard
Definition: abspage.hxx:36
virtual void Activate() override
Definition: abspage.cxx:34
OAddressBookSourcePilot * getDialog()
Definition: abspage.cxx:46
AddressSettings & getSettings()
Definition: abspage.cxx:56
const ODataSource & getDataSource() const
Definition: abspilot.hxx:55
const StringBag & getTableNames() const
retrieves the tables names from the connection
TableSelectionPage(weld::Container *pPage, OAddressBookSourcePilot *pController)
virtual void Activate() override
virtual ~TableSelectionPage() override
virtual bool canAdvance() const override
virtual void initializePage() override
virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override
std::unique_ptr< weld::TreeView > m_xTableList
virtual bool canAdvance() const override
virtual bool commitPage(WizardTypes::CommitPageReason _eReason) override
virtual void initializePage() override
#define DBG_ASSERT(sCon, aError)
std::set< OUString > StringBag
Definition: abptypes.hxx:34
IMPL_LINK_NOARG(FinalPage, OnEntryNameModified, weld::Entry &, void)
const char * tableName