~ubuntu-branches/debian/sid/pgadmin3/sid

« back to all changes in this revision

Viewing changes to pgadmin/gqb/gqbTable.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-07-30 12:27:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730122716-fddbh42on721bbs2
Tags: 1.10.0-1
* New upstream release.
* Adjusted watch file to match release candidates.
* Updated to Standards-Version 3.8.2:
  - Moved to Section: database.
  - Add DEB_BUILD_OPTIONS support for parallel building.
  - Move from findstring to filter suggestion for DEB_BUILD_OPTIONS parsing.
* pgagent got split into its own separate source package by upstream.
* Exclude Docs.vcproj from installation.
* Move doc-base.enus from pgadmin3 to pgadmin3-data package, the files are
  in there too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// pgAdmin III - PostgreSQL Tools
 
4
// RCS-ID:      $Id: gqbTable.cpp 7812 2009-04-16 08:29:25Z dpage $
 
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
 
6
// This software is released under the BSD Licence
 
7
//
 
8
// gqbTable.cpp - Table object for GQB
 
9
//
 
10
//////////////////////////////////////////////////////////////////////////
 
11
 
 
12
// App headers
 
13
#include "pgAdmin3.h"
 
14
 
 
15
// wxWindows headers
 
16
#include <wx/wx.h>
 
17
 
 
18
// App headers
 
19
#include "gqb/gqbObject.h"
 
20
#include "gqb/gqbTable.h"
 
21
#include "gqb/gqbColumn.h"
 
22
#include "gqb/gqbArrayCollection.h"
 
23
 
 
24
gqbTable::gqbTable(gqbObject *parent, wxString name, pgConn *connection, type_gqbObject type, OID oid)
 
25
: gqbObjectCollection(name, parent, connection, oid)
 
26
{
 
27
    setType(type);
 
28
}
 
29
 
 
30
 
 
31
gqbIteratorBase* gqbTable::createColumnsIterator()
 
32
{
 
33
    return createIterator();
 
34
}
 
35
 
 
36
 
 
37
void gqbTable::addColumn(gqbColumn *column)
 
38
{
 
39
    this->addObject(column);
 
40
}
 
41
 
 
42
 
 
43
void gqbTable::createObjects(gqbBrowser *_tablesBrowser,  pgConn *_conn, OID oidVal,  wxTreeItemId parentNode)
 
44
{
 
45
    createColumns(_conn, _tablesBrowser, parentNode, oidVal);
 
46
}
 
47
 
 
48
void gqbTable::createColumns(pgConn *conn, gqbBrowser *tablesBrowser, wxTreeItemId parentNode,  OID oidVal)
 
49
{
 
50
 
 
51
    wxString systemRestriction;
 
52
    if (!settings->GetShowSystemObjects())
 
53
        systemRestriction = wxT("\n   AND attnum > 0");
 
54
 
 
55
    wxString sql=
 
56
        wxT("SELECT attname FROM pg_attribute att\n")
 
57
        wxT(" WHERE attrelid = ")
 
58
        + NumToStr(oidVal)
 
59
        + systemRestriction + wxT("\n")
 
60
        wxT("   AND attisdropped IS FALSE\n")
 
61
        wxT(" ORDER BY attnum");
 
62
 
 
63
    pgSet *columns= conn->ExecuteSet(sql);
 
64
    if (columns)
 
65
    {
 
66
        while (!columns->Eof())
 
67
        {
 
68
            if (tablesBrowser)
 
69
            {
 
70
                //Disable, Column SHOULDN'T be added to tree only use for debug purposes tablesBrowser->AppendItem(parentNode, columns->GetVal(wxT("attname")) , -1, -1);
 
71
                wxString tmpname = wxString(columns->GetVal(wxT("attname")));
 
72
                gqbColumn *column = new gqbColumn(this, tmpname, conn);
 
73
                this->addColumn(column);
 
74
                columns->MoveNext();
 
75
            }
 
76
            else
 
77
                break;
 
78
        }
 
79
 
 
80
        delete columns;
 
81
    }
 
82
}
 
83
 
 
84
 
 
85
//work as a synonym for function
 
86
int gqbTable::countCols()
 
87
{
 
88
    return this->countObjects();
 
89
}
 
90
 
 
91
 
 
92
//work as a synonym for function & return correct type
 
93
gqbColumn* gqbTable::getColumnAtIndex(int index)
 
94
{
 
95
    return (gqbColumn *)this->getObjectAtIndex(index);
 
96
}
 
97
 
 
98
 
 
99
int gqbTable::indexColumn(gqbColumn *col)
 
100
{
 
101
    return this->indexObject(col);
 
102
}