Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Member Functions | Public Attributes | Private Slots | Private Member Functions | Private Attributes
tfDia Class Reference

#include <tfdia.h>

Collaboration diagram for tfDia:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 tfDia ()
 ~tfDia ()

Public Attributes

std::vector< tfFilter * > filters

Private Slots

void saveTextChanged (const QString &text)
void createFilterRow (tfFilter *after)
void removeRow (tfFilter *tff)
void clearClicked ()
void okClicked ()
void cancelClicked ()
void deleteClicked ()
void loadFilter (const QString &name)
void resizeEvent (QResizeEvent *e)

Private Member Functions

void clear ()
void createLayout ()
void createFilter (PrefsTable *table)
void writeFilterRow (PrefsTable *table, int row, tfFilter *filter)
void storeLastFilter ()

Private Attributes

PrefsContext * prefs
QBoxLayout * layout
QBoxLayout * alayout
QComboBox * filtersCombo
QLineEdit * saveEdit
QPushButton * clearButton
QPushButton * deleteButton
QPushButton * okButton
QPushButton * cancelButton
QString currentFilter
QScrollView * qsv
QFrame * vbox
int currentIndex

Detailed Description

Definition at line 22 of file tfdia.h.


Constructor & Destructor Documentation

Definition at line 23 of file tfdia.cpp.

             : QDialog()
{
       setCaption( tr("Create filter"));
       setIcon(loadIcon("AppIcon.png"));
       setMinimumWidth(524);
       prefs = PrefsManager::instance()->prefsFile->getPluginContext("TextFilter");
       setGeometry(prefs->getInt("x", 0),
                prefs->getInt("y", 0),
                prefs->getInt("width", 400),
                prefs->getInt("height", 300));
       createLayout();
       resize(width() + 10, height() + 10);
}

Here is the call graph for this function:

Definition at line 317 of file tfdia.cpp.

{
       for (uint i = 0; i < filters.size(); ++i)
              delete filters[i];
       QRect r = geometry();
       prefs->set("x", r.x());
       prefs->set("y", r.y());
       prefs->set("width", width());
       prefs->set("height", height());
}

Member Function Documentation

void tfDia::cancelClicked ( ) [private, slot]

Definition at line 241 of file tfdia.cpp.

{
       storeLastFilter();
       reject();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfDia::clear ( ) [private]

Definition at line 213 of file tfdia.cpp.

{
       for (uint i = 0; i < filters.size(); ++i)
       {
              filters[i]->hide();
              delete filters[i];
       }
       filters.clear();
}

Here is the caller graph for this function:

void tfDia::clearClicked ( ) [private, slot]

Definition at line 207 of file tfdia.cpp.

{
       clear();
       createFilterRow(NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfDia::createFilter ( PrefsTable *  table) [private]

Definition at line 154 of file tfdia.cpp.

{
       if (table->width() != 10)
              createFilterRow(NULL);
       else
       {
              for (uint i = 0; i < static_cast<uint>(table->height()); ++i)
              {
                     tfFilter* tmp = new tfFilter(vbox, "tfFilter",
                                                                       table->getInt(i, 0, 0),
                                                                       table->get(i, 1, ""),
                                                                       table->get(i, 2, ""),
                                                                       table->get(i, 3, ""),
                                                                       table->getInt(i, 4, 0),
                                                                       table->getInt(i, 5, 0),
                                                                       table->getInt(i, 6, 0),
                                                                       table->getBool(i, 7, true),
                                                                       table->getBool(i, 8, true),
                                                                       table->getBool(i, 9, false));
                     filters.push_back(tmp);
                     alayout->addWidget(tmp);
                     tmp->show();
                     vbox->adjustSize();
                     if (filters.size() == 2)
                            filters[0]->setRemovable(true);
                     connect(tmp, SIGNAL(addClicked(tfFilter*)), this, SLOT(createFilterRow(tfFilter*)));
                     connect(tmp, SIGNAL(removeClicked(tfFilter*)), this, SLOT(removeRow(tfFilter*)));
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfDia::createFilterRow ( tfFilter after) [private, slot]

Definition at line 119 of file tfdia.cpp.

{
       tfFilter* tmp = new tfFilter(vbox, "tfFilter");
       if (after == NULL)
       {
              filters.push_back(tmp);
              alayout->addWidget(tmp);
       }
       else
       {
              std::vector<tfFilter*>::iterator it = filters.begin();
              uint i = 0;
              for (i= 0; i < filters.size(); ++i, ++it)
              {
                     if (filters[i] == after)
                     {
                            ++it;
                            ++i;
                            break;
                     }
              }
              filters.insert(it, tmp);
              alayout->insertWidget(static_cast<int>(i), tmp);
       }
       tmp->show();
       vbox->adjustSize();
       if (filters.size() == 2)
              filters[0]->setRemovable(true);
       else if (filters.size() == 1)
              filters[0]->setRemovable(false);

       connect(tmp, SIGNAL(addClicked(tfFilter*)), this, SLOT(createFilterRow(tfFilter*)));
       connect(tmp, SIGNAL(removeClicked(tfFilter*)), SLOT(removeRow(tfFilter*)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfDia::createLayout ( ) [private]

Definition at line 37 of file tfdia.cpp.

{
       currentFilter = "tf_lastUsed";
       currentIndex = 0;
       
       layout = new QVBoxLayout(this);

       QBoxLayout* layout1 = new QHBoxLayout(0, 5, 5, "layout1");
       clearButton = new QPushButton( tr("C&lear"), this, "clearButton");
       layout1->addWidget(clearButton);
       layout1->addStretch(10);
       deleteButton = new QPushButton( tr("&Delete"), this, "deleteButton");
       deleteButton->setEnabled(false);
       layout1->addWidget(deleteButton);
       filtersCombo = new QComboBox(0, this, "filtersCombo");
       filtersCombo->setMinimumSize(QSize(150, 0));
       filtersCombo->setEditable(false);
       filtersCombo->setDuplicatesEnabled(false);
       QToolTip::add(filtersCombo, tr("Choose a previously saved filter"));
       PrefsTable* filterNames = prefs->getTable("tf_Filters");
       filtersCombo->insertItem("");
       for (int i = 0; i < filterNames->height(); ++i)
       {
              QString fname = filterNames->get(i, 0, "");
              fname = fname.right(fname.length() - 3);
              filtersCombo->insertItem(fname);   
       }
       layout1->addWidget(filtersCombo);
       layout->addLayout(layout1);

       QBoxLayout* flayout = new QHBoxLayout(0,0,0, "flayout");
       QFrame* f = new QFrame(this, "f");
       f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
       flayout->addWidget(f);
       layout->addLayout(flayout);

       
       qsv = new QScrollView(this, "qsv");
       QVBoxLayout *a1layout = new QVBoxLayout(0, 5, 12, "a1layout");
       vbox = new QFrame(this);
       vbox->setFixedWidth(qsv->viewport()->width());
       qsv->viewport()->resize(width() - 12, vbox->height());
       a1layout->addWidget(qsv);
       qsv->addChild(vbox);
       layout->addLayout(a1layout);
       
       alayout = new QVBoxLayout(vbox, 5,12, "alayout");
       
       createFilter(prefs->getTable("tf_lastUsed"));
       filters[0]->setRemovable((filters.size() >= 2));
       
       QBoxLayout* flayout2 = new QHBoxLayout(0,0,0, "flayout2");
       QFrame* f2 = new QFrame(this, "f2");
       f2->setFrameStyle(QFrame::HLine | QFrame::Sunken);
       flayout2->addWidget(f2);
       layout->addLayout(flayout2);

       QBoxLayout* layout2 = new QHBoxLayout(0, 5, 5, "layout2");
       saveEdit = new QLineEdit(this, "saveEdit");
       QToolTip::add(saveEdit, tr("Give a name to this filter for saving"));
       layout2->addWidget(saveEdit, 10);
       if (prefs->getBool("save_hint", true))
       {
              saveEdit->setText( tr("Give a name for saving"));
              prefs->set("save_hint", false);
       }
       layout2->addSpacing(20);
       okButton = new QPushButton(CommonStrings::tr_OK, this, "okButton");
       layout2->addWidget(okButton, 0);
       cancelButton = new QPushButton(CommonStrings::tr_Cancel, this, "cancelButton");
       layout2->addWidget(cancelButton, 0);
       layout->addLayout(layout2);
       

       connect(filtersCombo, SIGNAL(activated(const QString&)), this, SLOT(loadFilter(const QString&)));
       connect(clearButton, SIGNAL(clicked()), this, SLOT(clearClicked()));
       connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked()));
       connect(okButton, SIGNAL(clicked()), this, SLOT(okClicked()));
       connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));
       connect(saveEdit, SIGNAL(textChanged(const QString&)), this, SLOT(saveTextChanged(const QString&)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfDia::deleteClicked ( ) [private, slot]

Definition at line 284 of file tfdia.cpp.

{
       if (currentIndex != 0)
       {
              PrefsTable* t = prefs->getTable("tf_Filters");
              t->removeRow(0, currentFilter);
              prefs->removeTable(currentFilter);
              filtersCombo->removeItem(currentIndex);
              filtersCombo->setCurrentItem(0);
              clear();
              saveEdit->setText("");
              deleteButton->setEnabled(false);
              createFilter(prefs->getTable("tf_lastUsed"));
              currentIndex = 0;
              currentFilter = "tf_lastUsed";
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfDia::loadFilter ( const QString &  name) [private, slot]

Definition at line 261 of file tfdia.cpp.

{
       if (currentFilter == "tf_lastUsed")
              storeLastFilter();
       if (filtersCombo->currentItem() == 0)
       {
              deleteButton->setEnabled(false);
              clear();
              createFilter(prefs->getTable("tf_lastUsed"));
              currentFilter = "tf_lastUsed";
              currentIndex = 0;
       }
       else if (prefs->containsTable("tf_" + name))
       {
              deleteButton->setEnabled(true);
              clear();
              createFilter(prefs->getTable("tf_"+name));
              currentFilter = "tf_" + name;
              currentIndex = filtersCombo->currentItem();
       }
       saveEdit->setText(name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfDia::okClicked ( ) [private, slot]

Definition at line 223 of file tfdia.cpp.

{
       storeLastFilter();
       if ((!saveEdit->text().isEmpty()) && (saveEdit->text() != tr("Give a name to this filter for saving")))
       {
              PrefsTable* savedFilters = prefs->getTable("tf_Filters");
              if (savedFilters->find(0, QString("tf_" + saveEdit->text())) == -1)
                     savedFilters->set(savedFilters->height(), 0, QString("tf_" + saveEdit->text()));
              prefs->removeTable("tf_" + saveEdit->text());
              PrefsTable* newFilter = prefs->getTable("tf_" + saveEdit->text());
              for (uint i = 0; i < filters.size(); ++i)
              {
                     writeFilterRow(newFilter, i, filters[i]);
              }
       }
       accept();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfDia::removeRow ( tfFilter tff) [private, slot]

Definition at line 185 of file tfdia.cpp.

{
       std::vector<tfFilter*>::iterator it = filters.begin();
       for (uint i = 0; i < filters.size(); ++i, ++it)
       {
              if (filters[i] == tff)
              {
                     filters[i]->hide();
                     delete filters[i];
                     filters.erase(it);
              }
       }
       if (filters.size() == 1)
              filters[0]->setRemovable(false);
}

Here is the caller graph for this function:

void tfDia::resizeEvent ( QResizeEvent *  e) [private, slot]

Definition at line 312 of file tfdia.cpp.

{
       vbox->setFixedWidth(qsv->viewport()->width());
}
void tfDia::saveTextChanged ( const QString &  text) [private, slot]

Definition at line 201 of file tfdia.cpp.

{
       filtersCombo->setCurrentItem(0);
       filtersCombo->setCurrentText(text);
}

Here is the caller graph for this function:

void tfDia::storeLastFilter ( ) [private]

Definition at line 302 of file tfdia.cpp.

{
       prefs->removeTable("tf_lastUsed");
       PrefsTable* lastUsed = prefs->getTable("tf_lastUsed");
       for (uint i = 0; i < filters.size(); ++i)
       {
              writeFilterRow(lastUsed, i, filters[i]);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfDia::writeFilterRow ( PrefsTable *  table,
int  row,
tfFilter filter 
) [private]

Definition at line 247 of file tfdia.cpp.

{
       table->set(row, 0, filter->getAction());
       table->set(row, 1, filter->regExp());
       table->set(row, 2, filter->replaceWith());
       table->set(row, 3, filter->getPStyleName());
       table->set(row, 4, filter->getLessThan());
       table->set(row, 5, filter->getMoreThan());
       table->set(row, 6, filter->getStyle());
       table->set(row, 7, filter->removeMatch());
       table->set(row, 8, filter->isEnabled());
       table->set(row, 9, filter->isRegExp());
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

QBoxLayout* tfDia::alayout [private]

Definition at line 28 of file tfdia.h.

QPushButton* tfDia::cancelButton [private]

Definition at line 34 of file tfdia.h.

QPushButton* tfDia::clearButton [private]

Definition at line 31 of file tfdia.h.

QString tfDia::currentFilter [private]

Definition at line 35 of file tfdia.h.

Definition at line 38 of file tfdia.h.

QPushButton* tfDia::deleteButton [private]

Definition at line 32 of file tfdia.h.

std::vector<tfFilter*> tfDia::filters

Definition at line 55 of file tfdia.h.

QComboBox* tfDia::filtersCombo [private]

Definition at line 29 of file tfdia.h.

QBoxLayout* tfDia::layout [private]

Definition at line 27 of file tfdia.h.

QPushButton* tfDia::okButton [private]

Definition at line 33 of file tfdia.h.

PrefsContext* tfDia::prefs [private]

Definition at line 26 of file tfdia.h.

QScrollView* tfDia::qsv [private]

Definition at line 36 of file tfdia.h.

QLineEdit* tfDia::saveEdit [private]

Definition at line 30 of file tfdia.h.

QFrame* tfDia::vbox [private]

Definition at line 37 of file tfdia.h.


The documentation for this class was generated from the following files: