Subversion Repositories Scribus

Rev

Rev 13809 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13809 pierre 1
/***************************************************************************
2
 *   Copyright (C) 2009 by Pierre Marchand                                 *
3
 *   pierre@oep-h.com                                                      *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License, or     *
8
 *   (at your option) any later version.                                   *
9
 *                                                                         *
10
 *   This program is distributed in the hope that it will be useful,       *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
 *   GNU General Public License for more details.                          *
14
 *                                                                         *
15
 *   You should have received a copy of the GNU General Public License     *
16
 *   along with this program; if not, write to the                         *
17
 *   Free Software Foundation, Inc.,                                       *
18122 mrdocs 18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
13809 pierre 19
 ***************************************************************************/
20
 
21
#include "openpalettemanager.h"
22
#include "ui/openpalette.h"
23
 
24
#include <QCoreApplication>
25
 
26
 
27
OpenPaletteManager * OpenPaletteManager::instance = 0;
28
OpenPaletteManager::OpenPaletteManager(QObject *parent)
29
                :QObject(parent)
30
{
31
}
32
 
33
 
34
OpenPaletteManager * OpenPaletteManager::that()
35
{
36
        if(!instance)
37
        {
38
                instance = new OpenPaletteManager(QCoreApplication::instance());
39
                Q_ASSERT(instance);
40
        }
41
        return instance;
42
}
43
 
44
void OpenPaletteManager::savePaletteCollection(const QString& filepath)
45
{
46
        // TODO
47
}
48
 
49
void OpenPaletteManager::loadPaletteCollection(const QString& filepath)
50
{
51
        // TODO
52
}
53
 
54
void OpenPaletteManager::newPalette(QWidget * parent)
55
{
56
        OpenPalette * op(new OpenPalette(parent));
57
        that()->palettes << op;
58
        connect(op, SIGNAL(changed()), that(), SLOT(catchPalette()));
59
        connect(op, SIGNAL(destroyed()), that(), SLOT(unRegisterPalette()));
60
        op->show();
61
        emit that()->changed();
62
}
63
 
64
unsigned int OpenPaletteManager::count()
65
{
66
        return that()->palettes.count();
67
}
68
 
69
QString OpenPaletteManager::title(unsigned int idx)
70
{
71
        if(idx < count())
72
                return that()->palettes.at(idx)->windowTitle();
73
        // Should never happen
74
        return QString();
75
}
76
 
77
QVariant OpenPaletteManager::paletteProperty(unsigned int idx, const QString& prop)
78
{
79
        if(idx < count())
80
                return that()->palettes.at(idx)->property(prop.toAscii());
81
        return QVariant();
82
}
83
 
84
bool OpenPaletteManager::paletteProperty(unsigned int idx, const QString& prop, const QVariant& val)
85
{
86
        if(idx < count())
87
        {
88
                return that()->palettes.at(idx)->setProperty(prop.toAscii(), val);
89
        }
90
        return false;
91
}
92
 
93
QStringList OpenPaletteManager::items(unsigned int idx)
94
{
95
        if(idx < count())
96
                return that()->palettes.at(idx)->hostedList();
97
        return QStringList();
98
}
99
 
100
void OpenPaletteManager::setItems(unsigned int idx, const QStringList& ilist)
101
{
102
        if(idx < count())
103
        {
104
                that()->palettes.at(idx)->setHosted(ilist);
105
                emit that()->changed();
106
        }
107
}
108
 
109
void OpenPaletteManager::subChanges(QObject * subscriber, const char * method)
110
{
111
        connect(that(), SIGNAL(changed()), subscriber, method);
112
}
113
 
114
void OpenPaletteManager::unRegisterPalette()
115
{
116
        OpenPalette * op(reinterpret_cast<OpenPalette*>(sender()));
117
        palettes.removeAll(op);
118
        emit changed();
119
}
120
 
121
void OpenPaletteManager::catchPalette()
122
{
123
        emit changed();
124
}
125
 
126
 
127
 
128