Back to index

scribus-ng  1.3.4.dfsg+svn20071115
spalette.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008                           spalette.cpp  -  description
00009                              -------------------
00010     begin                : Wed Apr 25 2001
00011     copyright            : (C) 2001 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #include <qlistbox.h>
00025 #include "scribusdoc.h"
00026 #include "spalette.h"
00027 #include "spalette.moc"
00028 
00029 #include "page.h"
00030 
00031 ParaStyleComboBox::ParaStyleComboBox(QWidget* parent) : QComboBox(true, parent, "Sfloat")
00032 {
00033 //     setMinimumSize(QSize(10,static_cast<int>(font().pointSize()*2.5)));
00034 //     setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)1, 0, 0,
00035 //                                                                     sizePolicy().hasHeightForWidth() ) );
00036        setEditable(false);
00037        insertItem( tr("No Style"));
00038        currentDoc = NULL;
00039        connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00040 }
00041 
00042 void ParaStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
00043 {
00044        currentDoc = newCurrentDoc;
00045        updateFormatList();
00046 }
00047 
00048 void ParaStyleComboBox::setFormat(QString name)
00049 {
00050        setCurrentText(name.isEmpty() ? tr("No Style") : name);
00051 }
00052 
00053 void ParaStyleComboBox::updateFormatList()
00054 {
00055        disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00056        clear();
00057        if (currentDoc != NULL)
00058        {
00059               QStringList st;
00060               st.clear();
00061               insertItem( tr("No Style"));
00062               for (uint x = 0; x < currentDoc->paragraphStyles().count(); ++x)
00063                      if ( !currentDoc->paragraphStyles()[x].name().isEmpty() )
00064                             st.append(currentDoc->paragraphStyles()[x].name());
00065               st.sort();
00066               insertStringList(st);
00067        }
00068        listBox()->setMinimumWidth(listBox()->maxItemWidth()+24);
00069        connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00070 }
00071 
00072 void ParaStyleComboBox::selFormat(int e)
00073 {
00074        if (e == 0)
00075        {
00076               emit newStyle(QString::null);
00077        }
00078        else
00079        {
00080               emit newStyle(currentText());
00081        }
00082 }
00083 
00084 CharStyleComboBox::CharStyleComboBox(QWidget* parent) : QComboBox(true, parent, "Sfloat")
00085 {
00086 //     setMinimumSize(QSize(10,static_cast<int>(font().pointSize()*2.5)));
00087 //     setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)1, 0, 0,
00088 //                                                                     sizePolicy().hasHeightForWidth() ) );
00089        setEditable(false);
00090        insertItem( tr("No Style"));
00091        currentDoc = NULL;
00092        connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00093 }
00094 
00095 void CharStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
00096 {
00097        currentDoc = newCurrentDoc;
00098        updateFormatList();
00099 }
00100 
00101 void CharStyleComboBox::setFormat(QString name)
00102 {
00103        setCurrentText(name.isEmpty() ? tr("No Style") : name);
00104 }
00105 
00106 void CharStyleComboBox::updateFormatList()
00107 {
00108        disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00109        clear();
00110        if (currentDoc != NULL)
00111        {
00112               QStringList st;
00113               st.clear();
00114               insertItem( tr("No Style"));
00115               for (uint x = 0; x < currentDoc->charStyles().count(); ++x)
00116                      if ( !currentDoc->charStyles()[x].name().isEmpty() )
00117                             st.append(currentDoc->charStyles()[x].name());
00118               st.sort();
00119               insertStringList(st);
00120        }
00121        listBox()->setMinimumWidth(listBox()->maxItemWidth()+24);
00122        connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00123 }
00124 
00125 void CharStyleComboBox::selFormat(int e)
00126 {
00127        if (e == 0)
00128        {
00129               emit newStyle(QString::null);
00130        }
00131        else
00132        {
00133               emit newStyle(currentText());
00134        }
00135 }