summaryrefslogtreecommitdiffstats
path: root/m4/wint_t.m4
blob: af5ed936cc447baf325b9c2c1ea4fc9b0f620ee5 (plain)
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
# wint_t.m4 serial 2 (gettext-0.17)
dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

dnl From Bruno Haible.
dnl Test whether <wchar.h> has the 'wint_t' type.
dnl Prerequisite: AC_PROG_CC

AC_DEFUN([gt_TYPE_WINT_T],
[
  AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t,
    [AC_TRY_COMPILE([
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
   <wchar.h>.
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
   before <wchar.h>.  */
#include <stddef.h>
#include <stdio.h>
#include <time.h>
#include <wchar.h>
       wint_t foo = (wchar_t)'\0';], ,
       gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)])
  if test $gt_cv_c_wint_t = yes; then
    AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.])
  fi
])
href='#n53'>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
/*
 * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com>
 * 
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 */

// Header include
#include "GlobalScriptGroupModel.h"

// Sigmodr tree includes
#include "GlobalScriptModel.h"

// Sigmod includes
#include <sigmod/GlobalScript.h>
#include <sigmod/Sigmod.h>

// KDE includes
#include <KMenu>

Sigmodr::GlobalScriptGroupModel::GlobalScriptGroupModel(BaseModel* parent, Sigmod::Sigmod* sigmod) :
        GroupModel(parent, sigmod, "Global Scripts")
{
    for (int i = 0; i < sigmod->globalScriptCount(); ++i)
        addObject(sigmod->globalScript(i));
}

Sigmodr::GlobalScriptGroupModel::~GlobalScriptGroupModel()
{
}

QVariant Sigmodr::GlobalScriptGroupModel::data(const int role) const
{
    if (role == Sigmodr::BaseModel::ContextMenuRole)
    {
        KMenu* menu = new KMenu;
        menu->addAction("&Add Global Script", this, SLOT(addObject()));
        return QVariant::fromValue(menu);
    }
    return Sigmodr::GroupModel::data(role);
}

bool Sigmodr::GlobalScriptGroupModel::setData(const QVariant& value, int role)
{
    if (role == Sigmodr::BaseModel::XmlRole)
    {
        QString data = value.toString();
        if (!data.isEmpty())
        {
            QDomDocument xml;
            if (loadFromData(data, &xml) && (xml.doctype().name() == "GlobalScript"))
            {
                addObject(qobject_cast<Sigmod::Sigmod*>(m_object)->newGlobalScript(xml.documentElement()));
                return true;
            }
        }
    }
    return false;
}

QString Sigmodr::GlobalScriptGroupModel::types() const
{
    return "GlobalScript";
}

void Sigmodr::GlobalScriptGroupModel::addObject(Sigmod::Object* object)
{
    if (!object)
        object = qobject_cast<Sigmod::Sigmod*>(m_object)->newGlobalScript();
    if (object->className() == "GlobalScript")
        addChild(new GlobalScriptModel(this, qobject_cast<Sigmod::GlobalScript*>(object)));
}

void Sigmodr::GlobalScriptGroupModel::deleteObject(BaseModel* model)
{
    const int index = find(model);
    if (0 <= index)
    {
        qobject_cast<Sigmod::Sigmod*>(m_object)->deleteGlobalScript(index);
        m_objects[index]->deleteLater();
        m_objects.removeAt(index);
        childRowChanged(index);
    }
}