#include <qxtconfigdialog_p.h>
Public Slots | |
void | setCurrentIndex (int row, int column) |
void | setCurrentIndex (int index) |
Public Member Functions | |
void | init (QxtConfigDialog::IconPosition position=QxtConfigDialog::West) |
void | initTable () |
void | relayout () |
QTableWidgetItem * | item (int index) const |
Public Attributes | |
QSplitter * | splitter |
QStackedWidget * | stack |
QWidget * | buttons |
QxtConfigTableWidget * | table |
QxtConfigDialog::IconPosition | pos |
Friends | |
class | QxtConfigDialog |
Definition at line 57 of file qxtconfigdialog_p.h.
void QxtConfigDialogPrivate::init | ( | QxtConfigDialog::IconPosition | position = QxtConfigDialog::West ) |
Definition at line 116 of file qxtconfigdialog.cpp.
References buttons, initTable(), pos, QxtPrivate< QxtConfigDialog >::qxt_p(), relayout(), setCurrentIndex(), splitter, stack, and table.
{ QxtConfigDialog* p = &qxt_p(); splitter = new QSplitter(p); stack = new QStackedWidget(p); table = new QxtConfigTableWidget(p); pos = position; QObject::connect(table, SIGNAL(currentCellChanged(int, int, int, int)), this, SLOT(setCurrentIndex(int, int))); QObject::connect(stack, SIGNAL(currentChanged(int)), p, SIGNAL(currentIndexChanged(int))); #if QT_VERSION >= 0x040200 buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, p); QObject::connect(buttons, SIGNAL(accepted()), p, SLOT(accept())); QObject::connect(buttons, SIGNAL(rejected()), p, SLOT(reject())); #else // QT_VERSION >= 0x040200 buttons = new QWidget(p); QHBoxLayout* layout = new QHBoxLayout(buttons); QPushButton* okButton = new QPushButton(QxtConfigDialog::tr("&OK")); QPushButton* cancelButton = new QPushButton(QxtConfigDialog::tr("&Cancel")); QObject::connect(okButton, SIGNAL(clicked()), p, SLOT(accept())); QObject::connect(cancelButton, SIGNAL(clicked()), p, SLOT(reject())); layout->addStretch(); layout->addWidget(okButton); layout->addWidget(cancelButton); #endif QVBoxLayout* layout = new QVBoxLayout(p); layout->addWidget(splitter); layout->addWidget(buttons); initTable(); relayout(); }
void QxtConfigDialogPrivate::initTable | ( | ) |
Definition at line 148 of file qxtconfigdialog.cpp.
References table.
Referenced by init().
{ table->horizontalHeader()->hide(); table->verticalHeader()->hide(); table->setEditTriggers(QAbstractItemView::NoEditTriggers); table->setTabKeyNavigation(true); table->setAcceptDrops(false); table->setDragEnabled(false); table->setShowGrid(false); table->setSelectionMode(QAbstractItemView::SingleSelection); }
QTableWidgetItem * QxtConfigDialogPrivate::item | ( | int | index ) | const |
Definition at line 249 of file qxtconfigdialog.cpp.
References QxtConfigDialog::North, pos, and table.
Referenced by setCurrentIndex().
{ return pos == QxtConfigDialog::North ? table->item(0, index) : table->item(index, 0); }
void QxtConfigDialogPrivate::relayout | ( | ) |
Definition at line 160 of file qxtconfigdialog.cpp.
References QxtConfigDialog::East, QxtConfigDialog::North, pos, splitter, stack, table, and QxtConfigDialog::West.
Referenced by init().
{ if (pos == QxtConfigDialog::North) { splitter->setOrientation(Qt::Vertical); table->setRowCount(1); table->setColumnCount(0); table->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); table->verticalHeader()->setResizeMode(QHeaderView::Stretch); table->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); table->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } else { splitter->setOrientation(Qt::Horizontal); table->setRowCount(0); table->setColumnCount(1); table->horizontalHeader()->setResizeMode(QHeaderView::Stretch); table->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); table->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); } // clear for (int i = splitter->count() - 1; i >= 0; --i) { splitter->widget(i)->setParent(0); } // relayout switch (pos) { case QxtConfigDialog::North: // +-----------+ // | Icons | // +-----------| // | Stack | // +-----------| // | Buttons | // +-----------+ splitter->addWidget(table); splitter->addWidget(stack); break; case QxtConfigDialog::West: // +---+-------+ // | I | | // | c | | // | o | Stack | // | n | | // | s | | // +---+-------+ // | Buttons | // +-----------+ splitter->addWidget(table); splitter->addWidget(stack); break; case QxtConfigDialog::East: // +-------+---+ // | | I | // | | c | // | Stack | o | // | | n | // | | s | // +-------+---+ // | Buttons | // +-----------+ splitter->addWidget(stack); splitter->addWidget(table); break; default: qWarning("QxtConfigDialogPrivate::relayout(): unknown position"); break; } if (pos == QxtConfigDialog::East) { splitter->setStretchFactor(0, 10); splitter->setStretchFactor(1, 1); } else { splitter->setStretchFactor(0, 1); splitter->setStretchFactor(1, 10); } }
void QxtConfigDialogPrivate::setCurrentIndex | ( | int | index ) | [slot] |
Definition at line 262 of file qxtconfigdialog.cpp.
References QxtConfigDialog::cleanupPage(), QxtConfigDialog::initializePage(), item(), QxtPrivate< QxtConfigDialog >::qxt_p(), stack, and table.
{ int previousIndex = stack->currentIndex(); if (previousIndex != -1 && previousIndex != index) qxt_p().cleanupPage(previousIndex); stack->setCurrentIndex(index); table->setCurrentItem(item(index)); if (index != -1) qxt_p().initializePage(index); }
void QxtConfigDialogPrivate::setCurrentIndex | ( | int | row, |
int | column | ||
) | [slot] |
Definition at line 254 of file qxtconfigdialog.cpp.
References QxtConfigDialog::North, and pos.
Referenced by init().
{ if (pos == QxtConfigDialog::North) setCurrentIndex(column); else setCurrentIndex(row); }
friend class QxtConfigDialog [friend] |
Definition at line 62 of file qxtconfigdialog_p.h.
QWidget* QxtConfigDialogPrivate::buttons |
Definition at line 74 of file qxtconfigdialog_p.h.
Referenced by init().
Definition at line 77 of file qxtconfigdialog_p.h.
Referenced by init(), item(), relayout(), and setCurrentIndex().
QSplitter* QxtConfigDialogPrivate::splitter |
Definition at line 69 of file qxtconfigdialog_p.h.
Referenced by init(), and relayout().
QStackedWidget* QxtConfigDialogPrivate::stack |
Definition at line 70 of file qxtconfigdialog_p.h.
Referenced by init(), relayout(), and setCurrentIndex().
Definition at line 76 of file qxtconfigdialog_p.h.
Referenced by init(), initTable(), item(), relayout(), and setCurrentIndex().