Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

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 "scribusdoc.h"
00025 #include "spalette.h"
00026 
00027 #include <QListView>
00028 
00029 #include "page.h"
00030 #include "util.h"
00031 
00032 ParaStyleComboBox::ParaStyleComboBox(QWidget* parent) : QComboBox(parent)
00033 {
00034 //  setMinimumSize(QSize(10,static_cast<int>(font().pointSize()*2.5)));
00035 //  setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)1, 0, 0,
00036 //                                           sizePolicy().hasHeightForWidth() ) );
00037     setEditable(false);
00038     addItem( tr("No Style"));
00039     currentDoc = NULL;
00040     connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00041 }
00042 
00043 void ParaStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
00044 {
00045     currentDoc = newCurrentDoc;
00046     updateFormatList();
00047 }
00048 
00049 void ParaStyleComboBox::setFormat(QString name)
00050 {
00051     setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
00052 }
00053 
00054 void ParaStyleComboBox::updateFormatList()
00055 {
00056     disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00057     clear();
00058     if (currentDoc != NULL)
00059     {
00060         QStringList st;
00061         st.clear();
00062         addItem( tr("No Style"));
00063         for (int x = 0; x < currentDoc->paragraphStyles().count(); ++x)
00064             if ( !currentDoc->paragraphStyles()[x].name().isEmpty() )
00065                 st.append(currentDoc->paragraphStyles()[x].name());
00066         st.sort();
00067         addItems(st);
00068     }
00069     QListView *tmpView = dynamic_cast<QListView*>(view());
00070     int tmpWidth = tmpView->sizeHintForColumn(0);
00071     if (tmpWidth > 0)
00072         tmpView->setMinimumWidth(tmpWidth + 24);
00073     connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00074 }
00075 
00076 void ParaStyleComboBox::selFormat(int e)
00077 {
00078     if (e == 0)
00079     {
00080         emit newStyle(QString::null);
00081     }
00082     else
00083     {
00084         emit newStyle(currentText());
00085     }
00086 }
00087 
00088 CharStyleComboBox::CharStyleComboBox(QWidget* parent) : QComboBox(parent)
00089 {
00090 //  setMinimumSize(QSize(10,static_cast<int>(font().pointSize()*2.5)));
00091 //  setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)1, 0, 0,
00092 //                                           sizePolicy().hasHeightForWidth() ) );
00093     setEditable(false);
00094     addItem( tr("No Style"));
00095     currentDoc = NULL;
00096     connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00097 }
00098 
00099 void CharStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
00100 {
00101     currentDoc = newCurrentDoc;
00102     updateFormatList();
00103 }
00104 
00105 void CharStyleComboBox::setFormat(QString name)
00106 {
00107     setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
00108 }
00109 
00110 void CharStyleComboBox::updateFormatList()
00111 {
00112     disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00113     clear();
00114     if (currentDoc != NULL)
00115     {
00116         QStringList st;
00117         st.clear();
00118         addItem( tr("No Style"));
00119         for (int x = 0; x < currentDoc->charStyles().count(); ++x)
00120             if ( !currentDoc->charStyles()[x].name().isEmpty() )
00121                 st.append(currentDoc->charStyles()[x].name());
00122         st.sort();
00123         addItems(st);
00124     }
00125     QListView *tmpView = dynamic_cast<QListView*>(view());
00126     int tmpWidth = tmpView->sizeHintForColumn(0);
00127     if (tmpWidth > 0)
00128         tmpView->setMinimumWidth(tmpWidth + 24);
00129     connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
00130 }
00131 
00132 void CharStyleComboBox::selFormat(int e)
00133 {
00134     if (e == 0)
00135     {
00136         emit newStyle(QString::null);
00137     }
00138     else
00139     {
00140         emit newStyle(currentText());
00141     }
00142 }
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.