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
|
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/*
* sccombobox.h
* ScribusCVS
*
* Created by Andreas Vox on 01.10.05.
* Copyright 2005 under GPL2. All rights reserved.
*
*/
#include "colorcombo.h"
#include "commonstrings.h"
// #include "qdebug.h"
ColorCombo::ColorCombo( QWidget* parent ) : QComboBox(parent)
{
#ifdef Q_WS_MAC
// setStyle( new ColorCombo::ScMacStyle() );
#endif
setEditable(false);
ColorListBox* lb = new ColorListBox(this);
setModel( lb->model() );
setItemDelegate( lb->itemDelegate() );
setView( lb );
}
ColorCombo::ColorCombo( bool rw, QWidget* parent ) : QComboBox(parent)
{
#ifdef Q_WS_MAC
// setStyle( new ColorCombo::ScMacStyle() );
#endif
setEditable(rw);
ColorListBox* lb = new ColorListBox(this);
setModel( lb->model() );
setItemDelegate( lb->itemDelegate() );
setView( lb );
}
QString ColorCombo::currentColor() const
{
return currentText();
}
void ColorCombo::updateBox(ColorList& list, ColorCombo::PixmapType pixType , bool insertNone)
{
ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
if ( clb )
{
clb->clear();
if ( insertNone )
{
clb->addItem(CommonStrings::tr_NoneColor);
clb->item(0)->setData(Qt::UserRole, CommonStrings::None);
}
if ( pixType == ColorCombo::fancyPixmaps )
clb->insertItems(list, ColorListBox::fancyPixmap);
else if ( pixType == ColorCombo::widePixmaps )
clb->insertItems(list, ColorListBox::widePixmap);
else if ( pixType == ColorCombo::smallPixmaps )
clb->insertItems(list, ColorListBox::smallPixmap);
}
}
void ColorCombo::insertItems(ColorList& list, ColorCombo::PixmapType pixType)
{
ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
if ( clb )
{
if ( pixType == ColorCombo::fancyPixmaps )
clb->insertItems(list, ColorListBox::fancyPixmap);
else if ( pixType == ColorCombo::widePixmaps )
clb->insertItems(list, ColorListBox::widePixmap);
else if ( pixType == ColorCombo::smallPixmaps )
clb->insertItems(list, ColorListBox::smallPixmap);
}
}
void ColorCombo::insertSmallItem( const ScColor& col, ScribusDoc* doc, const QString& colName )
{
ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
if ( clb )
clb->addItem( new ColorPixmapItem(ColorPixmapValue(col, doc, colName)), ColorListBox::smallPixmap );
}
void ColorCombo::insertWideItem ( const ScColor& col, ScribusDoc* doc, const QString& colName )
{
ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
if ( clb )
clb->addItem( new ColorPixmapItem(ColorPixmapValue(col, doc, colName)), ColorListBox::widePixmap );
}
void ColorCombo::insertFancyItem( const ScColor& col, ScribusDoc* doc, const QString& colName )
{
ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
if ( clb )
clb->addItem( new ColorPixmapItem(ColorPixmapValue(col, doc, colName)), ColorListBox::fancyPixmap );
}
|