00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "bildauswahl.h"
00025 #include <QPushButton>
00026 #include <QAction>
00027
00031 Bildauswahl::Bildauswahl(QWidget *p)
00032 :QToolBar(tr("Bildauswahl"), p) {
00033
00034 m_bildlist = new QComboBox(this);
00035 m_bildlist->setSizeAdjustPolicy(QComboBox::AdjustToContents);
00036 QObject::connect(m_bildlist, SIGNAL(currentIndexChanged(const QString&)),
00037 this, SLOT(selectedImageChanged(const QString&)));
00038
00039 m_first = addAction(tr("<<"), this, SLOT(firstPressed()));
00040 m_first->setToolTip(tr("Springe zu erstem Bild"));
00041 m_prev = addAction(tr("<"), this, SLOT(prevPressed()));
00042 m_prev->setToolTip(tr("Vorheriges Bild"));
00043 m_selectBox = addWidget(m_bildlist); m_selectBox->setVisible(true);
00044 m_selectBox->setToolTip(tr("Aktuelle Bilderliste"));
00045 m_next = addAction(tr(">"), this, SLOT(nextPressed()));
00046 m_next->setToolTip(tr("Naechstes Bild"));
00047 m_last = addAction(tr(">>"), this, SLOT(lastPressed()));
00048 m_last->setToolTip(tr("Springe zu letztem Bild"));
00049
00050 setAllowedAreas(Qt::AllToolBarAreas);
00051 setMovable(true);
00052
00053 updateStatus();
00054 }
00055
00061 void Bildauswahl::setImageList(const QStringList &bilder) {
00062 m_bildlist->clear();
00063 m_bildlist->addItems(bilder);
00064 m_bildlist->setCurrentIndex(0);
00065 if(!bilder.empty())
00066 emit bildGeaendert(bilder.first());
00067 updateStatus();
00068 }
00069
00070 void Bildauswahl::firstPressed() {
00071 if(0 != m_bildlist->currentIndex()) {
00072 m_bildlist->setCurrentIndex(0);
00073
00074 }
00075 updateStatus();
00076 }
00077
00078 void Bildauswahl::prevPressed() {
00079 if(0 != m_bildlist->currentIndex()) {
00080 m_bildlist->setCurrentIndex(m_bildlist->currentIndex()-1);
00081
00082 }
00083 updateStatus();
00084 }
00085
00086 void Bildauswahl::nextPressed() {
00087 if(m_bildlist->count()-1 > m_bildlist->currentIndex()) {
00088 m_bildlist->setCurrentIndex(m_bildlist->currentIndex()+1);
00089
00090 }
00091 updateStatus();
00092 }
00093
00094 void Bildauswahl::lastPressed() {
00095 if(m_bildlist->count()-1 > m_bildlist->currentIndex()) {
00096 m_bildlist->setCurrentIndex(m_bildlist->count()-1);
00097
00098 }
00099 updateStatus();
00100 }
00101
00102 void Bildauswahl::selectedImageChanged(const QString &bild) {
00103 emit bildGeaendert(bild);
00104 updateStatus();
00105 }
00106
00111 void Bildauswahl::updateStatus() {
00112 if(0 == m_bildlist->count()) {
00113 m_first->setEnabled(false);
00114 m_prev->setEnabled(false);
00115 m_next->setEnabled(false);
00116 m_last->setEnabled(false);
00117 } else {
00118 m_first->setEnabled(true);
00119 m_last->setEnabled(true);
00120
00121 if(0 == m_bildlist->currentIndex()) {
00122 m_prev->setEnabled(false);
00123 } else {
00124 m_prev->setEnabled(true);
00125 }
00126 if(m_bildlist->count() - 1 <= m_bildlist->currentIndex()) {
00127 m_next->setEnabled(false);
00128 } else {
00129 m_next->setEnabled(true);
00130 }
00131 }
00132 }