File: MGTableBrowserList.h

package info (click to toggle)
mysql-gui-tools 5.0r12-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 105,540 kB
  • ctags: 50,897
  • sloc: sql: 348,439; pascal: 285,780; cpp: 94,578; ansic: 90,768; objc: 33,761; sh: 25,629; xml: 10,924; yacc: 10,755; java: 9,986; php: 2,806; python: 2,068; makefile: 1,945; perl: 3
file content (153 lines) | stat: -rw-r--r-- 5,712 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* Copyright (C) 2004 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef _MGTABLEBROWSERLIST_H_
#define _MGTABLEBROWSERLIST_H_


#include "MGBrowserList.h"
#include "myx_library.h"
#include "MGPtrWrap.h"


Glib::ustring MGSchemaObjectNameFromTable(const Glib::ustring &catalog,
                                        const Glib::ustring &schema,
                                        const Glib::ustring &table);


bool MGTableFromSchemaObjectName(const Glib::ustring &objectName,
                                 Glib::ustring &catalog,
                                 Glib::ustring &schema,
                                 Glib::ustring &table);


class MGTableBrowserList : public MGBrowserList {
  public:
    enum RowType {
      Schema,
      Table,
      Column,
      SP,
      Parameter
    };
 
    class Columns : public Gtk::TreeModel::ColumnRecord {
      public:
        Columns() {
          add(icon); add(text); add(type); add(data); add(weight);
        };
        Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
        Gtk::TreeModelColumn<Glib::ustring> text;
        Gtk::TreeModelColumn<RowType> type;
        Gtk::TreeModelColumn<void*> data;
        Gtk::TreeModelColumn<int> weight;
    } _columns;

    typedef sigc::signal0<void> RowActivateSignal;
    typedef sigc::slot3<bool,const Glib::ustring&,const Glib::ustring&,MYX_SCHEMA_TABLES *&> FetchSchemaTablesSlot;
    typedef sigc::slot3<bool,const Glib::ustring&,const Glib::ustring&,MYX_SCHEMA_STORED_PROCEDURES *&> FetchSchemaSPsSlot;

  protected:
    Glib::RefPtr<MGPtrWrap<MYX_CATALOGS*> > _catalogs;
    MYX_SCHEMA_TABLES *_tables;

    Glib::RefPtr<Gdk::Pixbuf> _schema_icon;
    Glib::RefPtr<Gdk::Pixbuf> _table_icon;
    Glib::RefPtr<Gdk::Pixbuf> _column_icon;
    Glib::RefPtr<Gdk::Pixbuf> _sp_icon;
    Glib::RefPtr<Gdk::Pixbuf> _view_icon;
    Glib::RefPtr<Gdk::Pixbuf> _key_icon;

    RowType _leaf_type;

    bool _show_tables;
    bool _show_sps;

    RowActivateSignal _signal_row_activate;
    FetchSchemaTablesSlot _fetch_schema_tables;
    FetchSchemaSPsSlot _fetch_schema_sps;

    // the following data and set_selection_info() function
    // helps keep schema tree state between schema reloads
    Glib::ustring _selected_schema_name;
    Glib::ustring _selected_schema_entity_name;
    RowType _selected_row_type;
    bool _schema_is_expanded;

    void set_selection_info(const char *schema_name,
      const char *entity_name, RowType rowtype, bool schema_exp);

    int get_search_type();

    void row_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *col);
    void row_selected();

    void update_menu();

    void drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time);

    virtual void refresh_list(const Glib::ustring &filter);

    bool refresh_table_list(const Gtk::TreeIter &piter,
                            MYX_SCHEMA_TABLES *tables,
                            const Glib::ustring &filter);
    bool refresh_sp_list(const Gtk::TreeIter &piter,
                         MYX_SCHEMA_STORED_PROCEDURES *sps,
                         const Glib::ustring &filter);

    void on_row_expanded(const Gtk::TreeModel::iterator&, const Gtk::TreeModel::Path&);
    void on_row_collapsed(const Gtk::TreeModel::iterator&, const Gtk::TreeModel::Path&);

  public:
    MGTableBrowserList(const Glib::ustring &caption,
                       RowType leaf_type=Table);
    
    void set_show_sps(bool flag);

    void set_catalogs(const Glib::RefPtr<MGPtrWrap<MYX_CATALOGS*> > &catalogs);
    
    void set_fetch_schema_tables_func(const FetchSchemaTablesSlot &slot);
    void set_fetch_schema_sps_func(const FetchSchemaSPsSlot &slot);

    RowActivateSignal signal_row_activate() const { return _signal_row_activate; };

    Gtk::TreeIter find_table(const Glib::ustring &catalog,
                             const Glib::ustring &schema,
                             const Glib::ustring &table="");

    void set_node_bold(const Gtk::TreeIter &iter, bool flag);

//    std::list<Gtk::TreeIter> get_selected_nodes();

    RowType get_type(const Gtk::TreeIter &iter);
    Glib::ustring get_catalog(const Gtk::TreeIter &iter);
    Glib::ustring get_schema(const Gtk::TreeIter &iter);
    Glib::ustring get_table(const Gtk::TreeIter &iter);
    Glib::ustring get_table_column(const Gtk::TreeIter &iter);
    Glib::ustring get_procedure(const Gtk::TreeIter &iter, bool &is_function);
    MYX_SCHEMA *get_schema_object(const Gtk::TreeIter &iter);

    bool is_view(const Gtk::TreeIter &iter);

    MYX_SCHEMA_TABLE *get_table(const Gtk::TreeIter &iter,
                                Glib::ustring &name);
    Glib::ustring get_column(const Gtk::TreeIter &iter);

    Glib::RefPtr<MGPtrWrap<MYX_CATALOGS*> > get_catalogs() { return _catalogs; };
};


#endif /* _MGTABLEBROWSERLIST_H_ */