~ubuntu-branches/debian/sid/kexi/sid

« back to all changes in this revision

Viewing changes to src/plugins/tables/kexitabledesigner_dataview.cpp

  • Committer: Package Import Robot
  • Author(s): Pino Toscano
  • Date: 2017-06-24 20:10:10 UTC
  • Revision ID: package-import@ubuntu.com-20170624201010-5lrzd5r2vwthwifp
Tags: upstream-3.0.1.1
Import upstream version 3.0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2004-2014 Jarosław Staniek <staniek@kde.org>
 
3
 
 
4
   This program is free software; you can redistribute it and/or
 
5
   modify it under the terms of the GNU Library General Public
 
6
   License as published by the Free Software Foundation; either
 
7
   version 2 of the License, or (at your option) any later version.
 
8
 
 
9
   This program is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this program; see the file COPYING.  If not, write to
 
16
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
 * Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#include "kexitabledesigner_dataview.h"
 
21
 
 
22
#include <kexiutils/utils.h>
 
23
#include <widget/tableview/KexiTableScrollArea.h>
 
24
#include <widget/tableview/KexiDataTableView.h>
 
25
#include <KexiMainWindowIface.h>
 
26
#include <kexi_global.h>
 
27
 
 
28
#include <KDbConnection>
 
29
 
 
30
KexiTableDesigner_DataView::KexiTableDesigner_DataView(QWidget *parent)
 
31
        : KexiDataTableView(parent, true/*db-aware*/)
 
32
{
 
33
    setObjectName("KexiTableDesigner_DataView");
 
34
 
 
35
    // setup main menu actions
 
36
    QList<QAction*> mainMenuActions;
 
37
    mainMenuActions
 
38
            << sharedAction("project_export_data_table")
 
39
            << sharedAction("edit_clear_table");
 
40
 
 
41
    setMainMenuActions(mainMenuActions);
 
42
}
 
43
 
 
44
KexiTableDesigner_DataView::~KexiTableDesigner_DataView()
 
45
{
 
46
//! @todo KEXI3 crash
 
47
    /*TODO
 
48
      if (dynamic_cast<KexiDataTableView*>(tableView())
 
49
        && dynamic_cast<KexiDataTableView*>(tableView())->cursor())
 
50
      {
 
51
        KexiMainWindowIface::global()->project()->dbConnection()->deleteCursor(
 
52
          dynamic_cast<KexiDataTableView*>(tableView())->cursor() );
 
53
      }*/
 
54
}
 
55
 
 
56
tristate KexiTableDesigner_DataView::beforeSwitchTo(Kexi::ViewMode mode, bool *dontStore)
 
57
{
 
58
    Q_UNUSED(dontStore);
 
59
 
 
60
    if (mode != Kexi::DataViewMode) {
 
61
        //accept editing before switching
 
62
        if (!acceptRecordEditing()) {
 
63
            return cancelled;
 
64
        }
 
65
    }
 
66
    return true;
 
67
}
 
68
 
 
69
tristate KexiTableDesigner_DataView::afterSwitchFrom(Kexi::ViewMode mode)
 
70
{
 
71
    Q_UNUSED(mode);
 
72
 
 
73
    if (tempData()->tableSchemaChangedInPreviousView) {
 
74
        KexiUtils::WaitCursor wait;
 
75
        KDbCursor *c
 
76
        = KexiMainWindowIface::global()->project()->dbConnection()->prepareQuery(
 
77
              tempData()->table);
 
78
        if (!c)
 
79
            return false;
 
80
        setData(c);
 
81
        tempData()->tableSchemaChangedInPreviousView = false;
 
82
    }
 
83
    return true;
 
84
}
 
85
 
 
86
KexiTablePartTempData* KexiTableDesigner_DataView::tempData() const
 
87
{
 
88
    return static_cast<KexiTablePartTempData*>(window()->data());
 
89
}
 
90