~ubuntu-branches/ubuntu/utopic/pgadmin3/utopic-proposed

« back to all changes in this revision

Viewing changes to pgadmin/utils/macros.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2011-06-07 23:03:54 UTC
  • mfrom: (1.3.1 upstream) (13 sid)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20110607230354-3td4j9y71u4ahcvj
Tags: 1.14.0~beta1-1
* New upstream development release, adding Build-Depends on
  postgresql-server-dev-all >= 117~.
* Add Build-Depends on quilt, (un)patch to debian/rules and patch for fixing
  the include for kwlist.h in pgadmin/db/keywords.c.
* Add pg_config --includedir-server output to CPPFLAGS.
* Remove unrecognized configure options: --with-wx-config,
  --with-pgsql-include, --enable-gtk2, --enable-unicode.
* Clean up manually the files that are left behind after the broken
  distclean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//////////////////////////////////////////////////////////////////////////
2
2
//
3
3
// pgAdmin III - PostgreSQL Tools
4
 
// 
5
 
// Copyright (C) 2002 - 2010, The pgAdmin Development Team
 
4
//
 
5
// Copyright (C) 2002 - 2011, The pgAdmin Development Team
6
6
// This software is released under the PostgreSQL Licence
7
7
//
8
8
// macros.cpp - Query macros
59
59
 
60
60
queryMacroList::queryMacroList(xmlTextReaderPtr reader)
61
61
{
62
 
        // Element of type <foo />, meaning empty folder 
 
62
        // Element of type <foo />, meaning empty folder
63
63
        if (xmlTextReaderIsEmptyElement(reader))
64
64
                return;
65
65
 
108
108
{
109
109
        int id = startId;
110
110
        size_t i;
111
 
        
 
111
 
112
112
        for (i = 0; i < macros.GetCount(); i++)
113
113
        {
114
114
                macros.Item(i)->AppendToMenu(menu, id);
117
117
        return id;
118
118
}
119
119
 
120
 
void queryMacroList::AddNewMacro(const wxString &key, const wxString &name, const wxString& query)
 
120
void queryMacroList::AddNewMacro(const wxString &key, const wxString &name, const wxString &query)
121
121
{
122
122
        macros.Add(new queryMacroItem(key, name, query));
123
123
}
138
138
bool queryMacroList::DelMacro(int id)
139
139
{
140
140
        size_t i;
141
 
        
 
141
 
142
142
        for (i = 0; i < macros.GetCount(); i++)
143
143
        {
144
144
                if (macros.Item(i)->GetId() == id)
172
172
queryMacroItem *queryMacroList::FindMacro(int id)
173
173
{
174
174
        size_t i;
175
 
        
 
175
 
176
176
        for (i = 0; i < macros.GetCount(); i++)
177
177
        {
178
178
                if (macros.Item(i)->GetId() == id)
179
179
                        return macros.Item(i);
180
180
        }
181
 
        
 
181
 
182
182
        return NULL;
183
183
}
184
184
 
198
198
void queryMacroList::saveList(xmlTextWriterPtr writer)
199
199
{
200
200
        size_t i;
201
 
        
 
201
 
202
202
        for (i = 0; i < macros.GetCount(); i++)
203
203
        {
204
204
                xmlTextWriterStartElement(writer, XML_STR("macro"));
205
 
                xmlTextWriterWriteAttribute(writer, XML_STR("key"), 
206
 
                        XML_FROM_WXSTRING(macros.Item(i)->GetKey()));
207
 
                xmlTextWriterWriteAttribute(writer, XML_STR("name"), 
208
 
                        XML_FROM_WXSTRING(macros.Item(i)->GetName()));
209
 
                xmlTextWriterWriteString(writer, 
210
 
                        XML_FROM_WXSTRING(macros.Item(i)->GetQuery()));
 
205
                xmlTextWriterWriteAttribute(writer, XML_STR("key"),
 
206
                                            XML_FROM_WXSTRING(macros.Item(i)->GetKey()));
 
207
                xmlTextWriterWriteAttribute(writer, XML_STR("name"),
 
208
                                            XML_FROM_WXSTRING(macros.Item(i)->GetName()));
 
209
                xmlTextWriterWriteString(writer,
 
210
                                         XML_FROM_WXSTRING(macros.Item(i)->GetQuery()));
211
211
                xmlTextWriterEndElement(writer);
212
212
        }
213
213
}
224
224
        if (!wxFile::Access(settings->GetMacrosFile(), wxFile::read))
225
225
                return emptyOnFailure ? (new queryMacroList()) : NULL;
226
226
 
227
 
        reader = xmlReaderForFile((const char *)settings->GetMacrosFile().mb_str(wxConvUTF8),NULL,0);
 
227
        reader = xmlReaderForFile((const char *)settings->GetMacrosFile().mb_str(wxConvUTF8), NULL, 0);
228
228
        if (!reader)
229
229
        {
230
230
                wxMessageBox(_("Failed to load macros file!"));
251
251
{
252
252
        xmlTextWriterPtr writer;
253
253
 
254
 
        writer = xmlNewTextWriterFilename((const char *)settings->GetMacrosFile().mb_str(wxConvUTF8),0);
 
254
        writer = xmlNewTextWriterFilename((const char *)settings->GetMacrosFile().mb_str(wxConvUTF8), 0);
255
255
        if (!writer)
256
256
        {
257
257
                wxMessageBox(_("Failed to open macros file!"));
260
260
        xmlTextWriterSetIndent(writer, 1);
261
261
 
262
262
        if ((xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL) < 0) ||
263
 
                (xmlTextWriterStartElement(writer, XML_STR("macros")) < 0))
 
263
                (xmlTextWriterStartElement(writer, XML_STR("macros")) < 0))
264
264
        {
265
265
                wxMessageBox(_("Failed to write to macros file!"));
266
266
                xmlFreeTextWriter(writer);