spalette.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00035
00036
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
00091
00092
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 }