//////////////////////////////////////////////////////////// //ListEditor //////////////////////////////////////////////////////////// ListEditor::ListEditor(QWidget * parent, QString title) : QDialog(parent) { listTable_ = new Internal::ListTable(this); listTable_->setRowHidden(-1, true); listDelegate_ = new Internal::ListEditorDelegate(listTable_); listTable_->setItemDelegate(listDelegate_); removeRowButton_ = new QPushButton(tr("&delete")); newRowButton_ = new QPushButton(tr("&new")); newRowButton_->setDefault(true); OkButton_ = new QPushButton(tr("&ok")); CancelButton_ = new QPushButton(tr("&cancel")); connect(newRowButton_, SIGNAL(clicked()), listTable_, SLOT(createNewRow())); connect(removeRowButton_, SIGNAL(clicked()), listTable_, SLOT(removeCurrentRow())); QDialogButtonBox * rightLayout = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Vertical); rightLayout->addButton(newRowButton_, QDialogButtonBox::ActionRole); rightLayout->addButton(removeRowButton_, QDialogButtonBox::ActionRole); connect(rightLayout, SIGNAL(accepted()), this, SLOT(accept())); connect(rightLayout, SIGNAL(rejected()), this, SLOT(reject())); QHBoxLayout * mainLayout = new QHBoxLayout; mainLayout->addWidget(listTable_); mainLayout->addWidget(rightLayout); setLayout(mainLayout); QString tit = "List Editor" + title; setWindowTitle(tit); setMinimumSize(800, 500); }
void manageSystemVolumes::itemClicked( QTableWidgetItem * current,bool clicked ) { if( current ){ QMenu m ; m.setFont( this->font() ) ; connect( m.addAction( tr( "Remove Selected Entry" ) ),SIGNAL( triggered() ),this,SLOT( removeCurrentRow() ) ) ; m.addSeparator() ; m.addAction( tr( "Cancel" ) ) ; if( clicked ){ m.exec( QCursor::pos() ) ; }else{ int x = m_ui->tableWidget->columnWidth( 0 ) / 2 ; int y = m_ui->tableWidget->rowHeight( current->row() ) * current->row() + 20 ; m.exec( m_ui->tableWidget->mapToGlobal( QPoint( x,y ) ) ) ; } } }
MainWindow::MainWindow( QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), aboutForm(0), documentationForm(0), preferencesForm(0), toolBar(0), formulaInput(0), cellLabel(0), optionsButton(0), scanButton(0), csvModel(0), table(0), barcodeViewForm(0), optionsDialog(0) { ui->setupUi(this); setAttribute(Qt::WA_Maemo5StackedWindow); barcodeViewForm = new LasBarcodeViewForm(this); optionsDialog = new LasOptionsDialog(this); preferencesForm = new LasPreferencesForm(this); toolBar = new QToolBar(); addToolBar(toolBar); formulaInput = new QLineEdit(); cellLabel = new QLabel(toolBar); cellLabel->setMinimumSize(80, 0); optionsButton = new QPushButton(); optionsButton->setIcon(QIcon(":/icons/dash.svg")); scanButton = new QPushButton(); scanButton->setIcon(QIcon(":/icons/plus.svg")); toolBar->addWidget(scanButton); toolBar->addWidget(cellLabel); toolBar->addWidget(formulaInput); toolBar->addWidget(optionsButton); table = new LasSheet(this); ui->centralLayout->addWidget(table); QSettings settings("pietrzak.org", "Lasagne"); if (settings.contains("currentFilename")) { currentFilename = settings.value("currentFilename").toString(); } else { currentFilename = "/home/user/MyDocs/.documents/Lasagne.csv"; } csvModel = new LasCsvModel(currentFilename, this, true); table->setModel(csvModel); table->resizeAllCells(); // statusBar(); /* connect( table, SIGNAL(currentItemChanged(QTableWidgetItem*, QTableWidgetItem*)), this, SLOT(updateStatus(QTableWidgetItem*))); */ connect( table->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateToolbar(const QModelIndex &))); /* connect( table, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(updateStatus(QTableWidgetItem*))); */ connect( formulaInput, SIGNAL(returnPressed()), this, SLOT(returnPressed())); /* connect( table, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(updateLineEdit(QTableWidgetItem*))); */ // table->updateColor(0); connect( optionsButton, SIGNAL(clicked()), optionsDialog, SLOT(exec())); connect( scanButton, SIGNAL(clicked()), this, SLOT(displayBarcodeForm())); connect( barcodeViewForm, SIGNAL(barcodeFound(QString, QString, QString, QString, QString)), this, SLOT(addNewRow(QString, QString, QString, QString, QString))); /* connect( optionsDialog, SIGNAL(editFormula()), this, SLOT(something())); */ connect( optionsDialog, SIGNAL(clearCell()), this, SLOT(clearCurrentCell())); connect( optionsDialog, SIGNAL(removeRow()), this, SLOT(removeCurrentRow())); connect( optionsDialog, SIGNAL(loadFile()), this, SLOT(load())); connect( optionsDialog, SIGNAL(saveFile()), this, SLOT(save())); connect( optionsDialog, SIGNAL(saveFileAs()), this, SLOT(saveAs())); // Preferences form: connect( preferencesForm, SIGNAL(beepPreference(bool)), barcodeViewForm, SLOT(setBeepPref(bool))); // Initialize beep preference: barcodeViewForm->setBeepPref(preferencesForm->getBeepPref()); connect( preferencesForm, SIGNAL(ignoreLensCover(bool)), barcodeViewForm, SLOT(updateIgnoreCover(bool))); barcodeViewForm->updateIgnoreCover(preferencesForm->getIgnoreCover()); }