From c3ca9ada173229d161e35ac287de6ccfce22aae5 Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Mon, 16 Dec 2002 22:24:33 +0000 Subject: [PATCH] fix bullet stuff. bullets are now shown and packages are again included (which bug was this?) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5830 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/BulletsModule.C | 167 ++++-- src/frontends/qt2/BulletsModule.h | 46 +- src/frontends/qt2/ChangeLog | 7 + src/frontends/qt2/Makefile.am | 2 - src/frontends/qt2/QDocument.C | 35 +- src/frontends/qt2/QDocumentDialog.C | 20 +- src/frontends/qt2/ui/BulletsModuleBase.ui | 698 ++++++---------------- 7 files changed, 354 insertions(+), 621 deletions(-) diff --git a/src/frontends/qt2/BulletsModule.C b/src/frontends/qt2/BulletsModule.C index ea126db12e..1c6fe43561 100644 --- a/src/frontends/qt2/BulletsModule.C +++ b/src/frontends/qt2/BulletsModule.C @@ -15,20 +15,29 @@ #pragma implementation #endif +#include // for operator % + +#include #include #include #include -#include +#include #include +#include #include "BulletsModule.h" +#include "Bullet.h" #include "ui/BulletsModuleBase.h" #include "QBrowseBox.h" #include "support/filetools.h" #include "bulletstrings.h" BulletsModule::BulletsModule(QWidget * parent, char const * name, WFlags fl) - : BulletsModuleBase(parent, name, fl), le_(bullet1LE) + : BulletsModuleBase(parent, name, fl) { + for (int iter = 0; iter < 4; ++iter) { + bullets_[iter] = ITEMIZE_DEFAULTS[iter]; + } + QPopupMenu * pm = new QPopupMenu(this); QPopupMenu * pm1 = new QPopupMenu(pm); @@ -58,11 +67,9 @@ BulletsModule::BulletsModule(QWidget * parent, char const * name, WFlags fl) pm->insertItem("Ding 2",pm4); pm->insertItem("Ding 3",pm5); pm->insertItem("Ding 4",pm6); + pm->insertItem("Custom...", this, SLOT(setCustom())); - setbullet1TB->setPopup(pm); - setbullet2TB->setPopup(pm); - setbullet3TB->setPopup(pm); - setbullet4TB->setPopup(pm); + setbulletTB->setPopup(pm); // insert pixmaps string bmfile; @@ -102,71 +109,161 @@ BulletsModule::BulletsModule(QWidget * parent, char const * name, WFlags fl) connect(ding4_, SIGNAL(selected(int, int)), this, SLOT(ding4(int, int))); - connect(setbullet1TB, SIGNAL(pressed()), - this, SLOT(setlevel1())); + // update the view + for (int iter = 0; iter < 4; ++iter) { + setBullet(iter,bullets_[iter]); + } + activeitem_ = bulletsLV->firstChild(); + activebullet_ = &bullets_[0]; +} - connect(setbullet2TB, SIGNAL(pressed()), - this, SLOT(setlevel2())); - connect(setbullet3TB, SIGNAL(pressed()), - this, SLOT(setlevel3())); +BulletsModule::~BulletsModule() +{ +} - connect(setbullet4TB, SIGNAL(pressed()), - this, SLOT(setlevel4())); +QPixmap BulletsModule::getPixmap(int font, int character) +{ + int col = character%6; + int row = (character - col)/6; + switch(font) { + case 0: + return standard_->pixmap(row,col); + case 1: + return maths_->pixmap(row,col); + case 2: + return ding1_->pixmap(row,col); + case 3: + return ding2_->pixmap(row,col); + case 4: + return ding3_->pixmap(row,col); + case 5: + return ding4_->pixmap(row,col); + default: + return standard_->pixmap(row,col); + } } -BulletsModule::~BulletsModule() +QListViewItem * BulletsModule::getItem(int level) { + QListViewItemIterator it(bulletsLV->firstChild()); + for(int i=0; isetText(bullets_standard[6*row + col]); + activeitem_ = getItem(level); + activebullet_ = &bullets_[level]; } -void BulletsModule::maths(int row, int col) + +void BulletsModule::setActive(QListViewItem * item) { - le_->setText(bullets_amssymb[6*row + col]); + activeitem_ = item; + activebullet_ = &bullets_[item->depth()]; } -void BulletsModule::ding1(int row, int col) + +void BulletsModule::setBullet(int font, int character) { - le_->setText(bullets_psnfss1[6*row + col]); + activeitem_->setText(0,""); + activeitem_->setPixmap(0,getPixmap(font,character)); + + activebullet_->setFont(font); + activebullet_->setCharacter(character); } -void BulletsModule::ding2(int row, int col) + +void BulletsModule::setBullet(string text) { - le_->setText(bullets_psnfss2[6*row + col]); + activeitem_->setPixmap(0,QPixmap()); + activeitem_->setText(0,text.c_str()); + + activebullet_->setText(text); } -void BulletsModule::ding3(int row, int col) + +void BulletsModule::setBullet(int level, const Bullet & bullet) { - le_->setText(bullets_psnfss3[6*row + col]); + setActive(level); + bullets_[level] = bullet; + // set size + setSize(bullet.getSize()+1); + // set pixmap + if (bullet.getFont()!=-1) { + setBullet(bullet.getFont(), + bullet.getCharacter()); + } else { + setBullet(bullet.getText()); + } } -void BulletsModule::ding4(int row, int col) + +Bullet BulletsModule::getBullet(int level) { - le_->setText(bullets_psnfss4[6*row + col]); + return bullets_[level]; } -void BulletsModule::setlevel1() + +void BulletsModule::setSize(int size) { - le_ = bullet1LE; + activeitem_->setText(1,bulletsizeCO->text(size)); + activebullet_->setSize(size-1); } -void BulletsModule::setlevel2() + +void BulletsModule::standard(int row, int col) { - le_ = bullet2LE; + setBullet(0,6*row + col); } -void BulletsModule::setlevel3() +void BulletsModule::maths(int row, int col) +{ + setBullet(1,6*row + col); +} + + +void BulletsModule::ding1(int row, int col) +{ + setBullet(2,6*row + col); +} + + +void BulletsModule::ding2(int row, int col) { - le_ = bullet3LE; + setBullet(3,6*row + col); } -void BulletsModule::setlevel4() + +void BulletsModule::ding3(int row, int col) +{ + setBullet(4,6*row + col); +} + + +void BulletsModule::ding4(int row, int col) +{ + setBullet(5,6*row + col); +} + + +void BulletsModule::setCustom() { - le_ = bullet4LE; + bool ok = FALSE; + QString text = QInputDialog::getText( + _( "Bullets" ), + _( "Enter a custom bullet" ), + QLineEdit::Normal, + QString::null, &ok, this ); + + activeitem_->setPixmap(0,QPixmap()); + activeitem_->setText(0,text); + activebullet_->setText(text.latin1()); + activebullet_->setFont(-1); } diff --git a/src/frontends/qt2/BulletsModule.h b/src/frontends/qt2/BulletsModule.h index 97fe0a8e5d..e0c0a4e119 100644 --- a/src/frontends/qt2/BulletsModule.h +++ b/src/frontends/qt2/BulletsModule.h @@ -19,9 +19,11 @@ #include "ui/BulletsModuleBase.h" #include "LString.h" #include +#include "Bullet.h" +#include class QBrowseBox; -class QLineEdit; +class QListViewItem; class BulletsModule : public BulletsModuleBase { @@ -31,6 +33,11 @@ public: WFlags fl = 0); ~BulletsModule(); + /// + void setBullet(int level, const Bullet & bullet); + /// + Bullet getBullet(int level); + protected slots: /// void standard(int row, int col); @@ -44,26 +51,37 @@ protected slots: void ding3(int row, int col); /// void ding4(int row, int col); - /// - void setlevel1(); - /// - void setlevel2(); - /// - void setlevel3(); - /// - void setlevel4(); - - + /// set custom (text) bullet + void setCustom(); + /// make level active + void setActive(QListViewItem*); + /// set size + void setSize(int size); + private: - QLineEdit * le_; - + /// get the pixmap that matches font/character + QPixmap getPixmap(int font, int character); + /// get the qlistviewitem of level + QListViewItem * getItem(int level); + /// make level active + void setActive(int level); + /// set bullet for standard font/character + void setBullet(int font, int character); + /// set bullet for custom text + void setBullet(string text); + /// pointer to the bullet of the level we're at + Bullet * activebullet_; + /// qlistviewitem of the level we're at + QListViewItem * activeitem_; + /// store results + boost::array bullets_; + QBrowseBox * standard_; QBrowseBox * maths_; QBrowseBox * ding1_; QBrowseBox * ding2_; QBrowseBox * ding3_; QBrowseBox * ding4_; - }; #endif // BULLETSMODULE_H diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index a278e41c51..0e4e3372c2 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,10 @@ +2002-12-16 Edwin Leuven + + * BulletsModule.[Ch]: Fix bulletstuff + * QDocument.C: + * QDocumentDialog.C: + * ui/BulletsModuleBase.ui: + 2002-12-12 John Levon * QSpellcheckerDialog.h: diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index 9ee32ce63a..2ef8641292 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -20,8 +20,6 @@ libqt2_la_SOURCES = \ Alert_pimpl.C \ qgridview.h \ qgridview.cpp \ - bulletstrings.h \ - bulletstrings.C \ BulletsModule.C \ BulletsModule.h \ QBrowseBox.C \ diff --git a/src/frontends/qt2/QDocument.C b/src/frontends/qt2/QDocument.C index acc1cea0c2..fc94045f09 100644 --- a/src/frontends/qt2/QDocument.C +++ b/src/frontends/qt2/QDocument.C @@ -206,15 +206,10 @@ void QDocument::apply() dialog_->numberingModule->sectionnrDepthSB->value(); // bullets - params.user_defined_bullets[0].setText(dialog_->bulletsModule->bullet1LE->text().latin1()); - params.user_defined_bullets[1].setText(dialog_->bulletsModule->bullet2LE->text().latin1()); - params.user_defined_bullets[2].setText(dialog_->bulletsModule->bullet3LE->text().latin1()); - params.user_defined_bullets[3].setText(dialog_->bulletsModule->bullet4LE->text().latin1()); - - params.user_defined_bullets[0].setSize(dialog_->bulletsModule->bulletsize1CO->currentItem()-1); - params.user_defined_bullets[1].setSize(dialog_->bulletsModule->bulletsize2CO->currentItem()-1); - params.user_defined_bullets[2].setSize(dialog_->bulletsModule->bulletsize3CO->currentItem()-1); - params.user_defined_bullets[3].setSize(dialog_->bulletsModule->bulletsize4CO->currentItem()-1); + params.user_defined_bullets[0] = dialog_->bulletsModule->getBullet(0); + params.user_defined_bullets[1] = dialog_->bulletsModule->getBullet(1); + params.user_defined_bullets[2] = dialog_->bulletsModule->getBullet(2); + params.user_defined_bullets[3] = dialog_->bulletsModule->getBullet(3); // packages switch (dialog_->packagesModule->lspacingCO->currentItem()) { @@ -427,24 +422,10 @@ void QDocument::update_contents() params.tocdepth); // bullets - QString s; - s = params.user_defined_bullets[0].getText().c_str(); - dialog_->bulletsModule->bullet1LE->setText(s); - s = params.user_defined_bullets[1].getText().c_str(); - dialog_->bulletsModule->bullet2LE->setText(s); - s = params.user_defined_bullets[2].getText().c_str(); - dialog_->bulletsModule->bullet3LE->setText(s); - s = params.user_defined_bullets[3].getText().c_str(); - dialog_->bulletsModule->bullet4LE->setText(s); - - dialog_->bulletsModule->bulletsize1CO->setCurrentItem( - params.user_defined_bullets[0].getSize() + 1); - dialog_->bulletsModule->bulletsize2CO->setCurrentItem( - params.user_defined_bullets[1].getSize() + 1); - dialog_->bulletsModule->bulletsize3CO->setCurrentItem( - params.user_defined_bullets[2].getSize() + 1); - dialog_->bulletsModule->bulletsize4CO->setCurrentItem( - params.user_defined_bullets[3].getSize() + 1); + dialog_->bulletsModule->setBullet(0,params.user_defined_bullets[0]); + dialog_->bulletsModule->setBullet(1,params.user_defined_bullets[1]); + dialog_->bulletsModule->setBullet(2,params.user_defined_bullets[2]); + dialog_->bulletsModule->setBullet(3,params.user_defined_bullets[3]); // packages char const * enc[] = { diff --git a/src/frontends/qt2/QDocumentDialog.C b/src/frontends/qt2/QDocumentDialog.C index 37c09d4d94..323c703b07 100644 --- a/src/frontends/qt2/QDocumentDialog.C +++ b/src/frontends/qt2/QDocumentDialog.C @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -237,24 +238,11 @@ QDocumentDialog::QDocumentDialog(QDocument * form) connect(paperModule->facingPagesCB, SIGNAL(toggled(bool)), this , SLOT(change_adaptor())); - // bullets - connect(bulletsModule->bullet1LE, SIGNAL(textChanged(const QString&)), + // bullets + connect(bulletsModule->bulletsizeCO, SIGNAL(activated(int)), this , SLOT(change_adaptor())); - connect(bulletsModule->bulletsize1CO, SIGNAL(activated(int)), + connect(bulletsModule->bulletsLV, SIGNAL(selectionChanged()), this , SLOT(change_adaptor())); - connect(bulletsModule->bullet2LE, SIGNAL(textChanged(const QString&)), - this , SLOT(change_adaptor())); - connect(bulletsModule->bulletsize2CO, SIGNAL(activated(int)), - this , SLOT(change_adaptor())); - connect(bulletsModule->bullet3LE, SIGNAL(textChanged(const QString&)), - this , SLOT(change_adaptor())); - connect(bulletsModule->bulletsize3CO, SIGNAL(activated(int)), - this , SLOT(change_adaptor())); - connect(bulletsModule->bullet4LE, SIGNAL(textChanged(const QString&)), - this , SLOT(change_adaptor())); - connect(bulletsModule->bulletsize4CO, SIGNAL(activated(int)), - this , SLOT(change_adaptor())); - } diff --git a/src/frontends/qt2/ui/BulletsModuleBase.ui b/src/frontends/qt2/ui/BulletsModuleBase.ui index 1e70e074f4..3e42853499 100644 --- a/src/frontends/qt2/ui/BulletsModuleBase.ui +++ b/src/frontends/qt2/ui/BulletsModuleBase.ui @@ -13,19 +13,15 @@ 0 0 - 335 - 216 + 199 + 166 caption - Form3 + Form1 - - mouseTracking - true - - + margin 11 @@ -34,369 +30,191 @@ spacing 6 - - QLayoutWidget - - name - Layout5 + + QListView + + + text + Bullets + + + clickable + true + + + resizeable + true + + + + + text + Size + + + clickable + true + + + resizeable + true + + + + + text + - - - margin - 0 + + text + default + + + pixmap + + + + pixmap + + + + + text + - - spacing - 6 + + text + default - - QComboBox - - - text - default - - - - - text - tiny - - - - - text - script - - - - - text - footnote - - - - - text - small - - - - - text - normal - - - - - text - large - - - - - text - Large - - - - - text - LARGE - - - - - text - huge - - - - - text - Huge - - - - name - bulletsize4CO - - - toolTip - Level 4 bullet size - - - - QLineEdit - - name - bullet3LE - - - sizePolicy - - 3 - 0 - - + + pixmap + + + + pixmap + + + - toolTip - Level 3 bullet - - - - QToolButton - - name - setbullet2TB - - - focusPolicy - TabFocus - - text - Choose - - - popupDelay - 1 + - toolTip - Shows menu with bullet options - - - - QToolButton - - name - setbullet1TB - - - focusPolicy - TabFocus - - text - Choose - - - popupDelay - 1 + default - toolTip - Shows menu with bullet options - - - - QLineEdit - - name - bullet1LE - - - sizePolicy - - 3 - 0 - + pixmap + - toolTip - Level 1 bullet + pixmap + - - - QComboBox - - - text - default - - - - - text - tiny - - - - - text - script - - - - - text - footnote - - - - - text - small - - text - normal - - - - - text - large + - - - - text - Large - - - text - LARGE + default - - - text - huge + pixmap + - - - text - Huge + pixmap + - - name - bulletsize1CO - - - toolTip - Level 1 bullet size - - - - - name - Spacer3 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QLabel - - name - sizeL - - - text - Si&ze: - - - buddy - bulletsize1CO - - - + + + + + name + bulletsLV + + + enabled + true + + + sizePolicy + + 7 + 5 + + + + allColumnsShowFocus + true + + + rootIsDecorated + true + + + + + name + Spacer2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout1 + + + + margin + 0 + + + spacing + 6 + + QToolButton name - setbullet4TB - - - focusPolicy - TabFocus + setbulletTB text - Choose + Set &Bullet popupDelay 1 - - toolTip - Shows menu with bullet options - - - - QLabel - - name - latexL - - - text - Name - - - buddy - bullet1LE - - - - QLabel - - name - TextLabel1_3 - - - text - Level &3 : - - - buddy - bullet3LE - - - - QLabel - - name - TextLabel1 - - - text - Level &1 : - - - buddy - bullet1LE - - + name - Spacer2 + Spacer1 orientation - Vertical + Horizontal sizeType @@ -410,81 +228,22 @@ - + QLabel name - TextLabel1_4 + TextLabel1 text - Level &4 : + &Size: buddy - bullet4LE - - - - QLineEdit - - name - bullet2LE - - - sizePolicy - - 3 - 0 - - - - toolTip - Level 2 bullet - - - - QLineEdit - - name - bullet4LE - - - sizePolicy - - 3 - 0 - - - - toolTip - Level 4 bullet + bulletsizeCO - - QToolButton - - name - setbullet3TB - - - focusPolicy - TabFocus - - - text - Choose - - - popupDelay - 1 - - - toolTip - Shows menu with bullet options - - - + QComboBox @@ -554,142 +313,27 @@ name - bulletsize3CO - - - toolTip - Level 3 bullet size + bulletsizeCO - - QComboBox - - - text - default - - - - - text - tiny - - - - - text - script - - - - - text - footnote - - - - - text - small - - - - - text - normal - - - - - text - large - - - - - text - Large - - - - - text - LARGE - - - - - text - huge - - - - - text - Huge - - - - name - bulletsize2CO - - - toolTip - Level 2 bullet size - - - - QLabel - - name - TextLabel1_2 - - - text - Level &2 : - - - buddy - bullet2LE - - - + - - - name - Spacer25 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - + - - bullet1LE - setbullet1TB - bulletsize1CO - bullet2LE - setbullet2TB - bulletsize2CO - bullet3LE - setbullet3TB - bulletsize3CO - bullet4LE - setbullet4TB - bulletsize4CO - + + + bulletsizeCO + activated(int) + BulletsModuleBase + setSize(int) + + + bulletsLV + selectionChanged(QListViewItem*) + BulletsModuleBase + setActive(QListViewItem*) + + setActive(QListViewItem*) + setSize(int) + -- 2.39.2