int ObjectTableView::addObject(const SceneObject *sceneObject)
	{
		QStandardItem *itemObjectName = new QStandardItem(QString::fromStdString(sceneObject->getName()));
		itemObjectName->setData(qVariantFromValue(sceneObject), Qt::UserRole + 1);
		itemObjectName->setEditable(false);

		std::string pathFileName;
		if(sceneObject->getModel()->getMeshes())
		{
			pathFileName = sceneObject->getModel()->getMeshes()->getMeshFilename();
		}
		QStandardItem *itemMeshFile = new QStandardItem(QString::fromStdString(FileHandler::getFileName(pathFileName)));
		itemMeshFile->setToolTip(QString::fromStdString(pathFileName));
		itemMeshFile->setData(qVariantFromValue(sceneObject), Qt::UserRole + 1);
		itemMeshFile->setEditable(false);

		int nextRow = objectsListModel->rowCount();
		objectsListModel->insertRow(nextRow);
		objectsListModel->setItem(nextRow, 0, itemObjectName);
		objectsListModel->setItem(nextRow, 1, itemMeshFile);

		resizeRowsToContents();

		return nextRow;
	}
void QCustomTableWidget::addCharacter(int index)
{
    if(pChangeCharacterDial->exec()==QDialog::Accepted)
    {
        // updating the CharacterList
        if (pCharacters != NULL)
        {
            Character character(pChangeCharacterDial->name().toStdString(),pChangeCharacterDial->playerName().toStdString());
            pCharacters->add(character,index+1);
        }

        // updating the display
        insertRow(index+1);
        int column_nb;
        column_nb = columnCount();
        for (int i = 0; i < column_nb; i++)
        {
            QTableWidgetItem *row1 = new QTableWidgetItem("0");
            setItem(index+1,i,row1);
        }
        QTableWidgetItem *rowHeaderItem = verticalHeaderItem(index+1);
        if (rowHeaderItem != NULL)
        {
            rowHeaderItem->setText(pChangeCharacterDial->name()+"\n"+pChangeCharacterDial->playerName());
        }
        else
        {
            rowHeaderItem = new QTableWidgetItem(pChangeCharacterDial->name()+"\n"+pChangeCharacterDial->playerName());
            setVerticalHeaderItem(index+1, rowHeaderItem);
        }
        resizeRowsToContents();
    }
}
Beispiel #3
0
void toResultTableView::slotApplyColumnRules()
{
    // TODO: call after every model reset
    // connect(Model, SIGNAL(modelReset()), this, SLOT(slotApplyColumnRules()));
    if (!NumberColumn)
        hideColumn(0);

    if (ReadableColumns)
    {
        VisibleColumns = 0;
        // loop through columns and hide anything starting with a ' '
        for (int col = 1; col < model()->columnCount(); col++)
        {
            if (model()->headerData(
                        col,
                        Qt::Horizontal,
                        Qt::DisplayRole).toString().startsWith(" "))
            {
                hideColumn(col);
            }
            else
                VisibleColumns++;
        }
    }

    // hiding columns sends signal sectionResized
    ColumnsResized = false;

    slotResizeColumnsToContents();
    if (toConfigurationNewSingle::Instance().option(ToConfiguration::Global::MultiLineResultsBool).toBool())
        resizeRowsToContents();

    if (ReadableColumns && VisibleColumns == 1)
        setColumnWidth(1, viewport()->width());
}
Beispiel #4
0
void CTableView::adjustSizeToContents()
{
    resizeColumnsToContents();
    resizeRowsToContents();
    int32_t h = rowHeight(1) * model()->rowCount() + 2;
    int32_t w = columnWidth(1) * model()->columnCount() + 2;
    setFixedSize(w, h);
}
void MyTable::loadFile(const QString& fileName)
{
    qDebug() << "LoadFile" << fileName;
#ifdef EXCEL
    if (!excel->isNull()) {
        Excel::_Workbook pWb(0, excel->Workbooks()->querySubObject("Open(const QString&)", fileName) /*->Open(fileName)*/);
        if (excel->Workbooks()->Count()) {
            for (int devCh = 0; devCh < RowCount; ++devCh) {
                for (int adcCh = 0; adcCh < 2; ++adcCh) {
                    for (int resCh = 0; resCh < 3; ++resCh) {
                        data[devCh][adcCh * 3 + resCh].clear();
                        if (!adcCh)
                            data[devCh][adcCh * 3 + resCh].append(excel->Range(QString("D%1").arg(6 + devCh * 3 + resCh))->Value().toDouble());
                        else
                            data[devCh][adcCh * 3 + resCh].append(excel->Range(QString("G%1").arg(6 + devCh * 3 + resCh))->Value().toDouble());
                    }
                }
                Update(devCh);
            }
            pWb.Close();
            //excel->Workbooks()->Close();
            dataChanged = true;
            resizeEvent(0);
        }
    }
#else
    m_curFile = fileName;
    QAxObject* excel = new QAxObject("Excel.Application", 0);
    excel->dynamicCall("SetVisible(bool)", true);
    QAxObject* workbooks = excel->querySubObject("Workbooks");
    QAxObject* workbook = workbooks->querySubObject("Open(const QString&)", m_curFile);
    QAxObject* sheets = workbook->querySubObject("Worksheets");
    QVariant value;
    if (workbooks->dynamicCall("Count()").toInt()) {
        QAxObject* sheet = sheets->querySubObject("Item(int)", 1);
        for (int devCh = 0; devCh < RowCount; ++devCh) {
            m_model->clearData(devCh);
            for (int adcCh = 0; adcCh < 2; ++adcCh) {
                for (int resCh = 0; resCh < 3; ++resCh) {
                    if (!adcCh) {
                        QAxObject* cell = sheet->querySubObject("Cells(int,int)", 6 + devCh * 3 + resCh, 4);
                        value = cell->dynamicCall("Value()");
                    } else {
                        QAxObject* cell = sheet->querySubObject("Cells(int,int)", 6 + devCh * 3 + resCh, 7);
                        value = cell->dynamicCall("Value()");
                    }
                    m_model->addData(devCh, adcCh * 3 + resCh, value.toDouble());
                }
            }
        }
        workbook->dynamicCall("Close()");
        resizeEvent(0);
    }
    excel->dynamicCall("Quit()");
    excel->deleteLater();
    resizeRowsToContents();
#endif
}
Beispiel #6
0
DataOutputWidget::DataOutputWidget(QWidget *parent)
: QWidget(parent)
, m_model(new DataOutputModel(this))
, m_view(new DataOutputView(this))
, m_isEmpty(true)
{
  m_view->setModel(m_model);

  QHBoxLayout *layout = new QHBoxLayout(this);
  m_dataLayout = new QVBoxLayout();

  KToolBar *toolbar = new KToolBar(this);
  toolbar->setOrientation(Qt::Vertical);
  toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
  toolbar->setIconSize(QSize(16, 16));

  /// TODO: disable actions if no results are displayed or selected

  KAction *action;

  action = new KAction( KIcon("distribute-horizontal-x"), i18nc("@action:intoolbar", "Resize columns to contents"), this);
  toolbar->addAction(action);
  connect(action, SIGNAL(triggered()), this, SLOT(resizeColumnsToContents()));

  action = new KAction( KIcon("distribute-vertical-y"), i18nc("@action:intoolbar", "Resize rows to contents"), this);
  toolbar->addAction(action);
  connect(action, SIGNAL(triggered()), this, SLOT(resizeRowsToContents()));

  action = new KAction( KIcon("edit-copy"), i18nc("@action:intoolbar", "Copy"), this);
  toolbar->addAction(action);
  m_view->addAction(action);
  connect(action, SIGNAL(triggered()), this, SLOT(slotCopySelected()));

  action = new KAction( KIcon("document-export-table"), i18nc("@action:intoolbar", "Export..."), this);
  toolbar->addAction(action);
  m_view->addAction(action);
  connect(action, SIGNAL(triggered()), this, SLOT(slotExport()));

  action = new KAction( KIcon("edit-clear"), i18nc("@action:intoolbar", "Clear"), this);
  toolbar->addAction(action);
  connect(action, SIGNAL(triggered()), this, SLOT(clearResults()));

  toolbar->addSeparator();

  KToggleAction *toggleAction = new KToggleAction( KIcon("applications-education-language"), i18nc("@action:intoolbar", "Use system locale"), this);
  toolbar->addAction(toggleAction);
  connect(toggleAction, SIGNAL(triggered()), this, SLOT(slotToggleLocale()));

  m_dataLayout->addWidget(m_view);

  layout->addWidget(toolbar);
  layout->addLayout(m_dataLayout);
  layout->setContentsMargins(0, 0, 0, 0);

  setLayout(layout);
}
	bool SoundTableView::removeSelectedSound()
	{
		if(hasSceneSoundSelected())
		{
			soundsListModel->removeRow(this->currentIndex().row());
			resizeRowsToContents();

			return true;
		}

		return false;
	}
	bool ObjectTableView::removeSelectedObject()
	{
		if(hasSceneObjectSelected())
		{
			objectsListModel->removeRow(this->currentIndex().row());
			resizeRowsToContents();

			return true;
		}

		return false;
	}
Beispiel #9
0
void GrowingTableWidget::DataChanged(const QModelIndex& tl, const QModelIndex& br)
{
    Q_UNUSED(tl);
    Q_UNUSED(br);
    resizeRowsToContents();
    resizeColumnsToContents();
    int h = contentsMargins().top() + contentsMargins().bottom();
    h += horizontalHeader()->height();
    for(int i = 0; i < rowCount(); i++)
        h += rowHeight(i);
    setMinimumHeight(h);
}
	bool LocalizedShapeTableView::removeSelectedLocalizedShape()
	{
		if(hasLocalizedShapeSelected())
		{
			removeSelectedLocalizedShapeFromMap();
			localizedShapesTableModel->removeRow(this->currentIndex().row());

			resizeRowsToContents();

			return true;
		}

		return false;
	}
Beispiel #11
0
CSVWorld::RegionMap::RegionMap (const CSMWorld::UniversalId& universalId,
                                CSMDoc::Document& document, QWidget *parent)
    :  DragRecordTable(document, parent)
{
    verticalHeader()->hide();
    horizontalHeader()->hide();

    setSelectionMode (QAbstractItemView::ExtendedSelection);

    setModel (document.getData().getTableModel (universalId));

    resizeColumnsToContents();
    resizeRowsToContents();

    mSelectAllAction = new QAction (tr ("Select All"), this);
    connect (mSelectAllAction, SIGNAL (triggered()), this, SLOT (selectAll()));
    addAction (mSelectAllAction);

    mClearSelectionAction = new QAction (tr ("Clear Selection"), this);
    connect (mClearSelectionAction, SIGNAL (triggered()), this, SLOT (clearSelection()));
    addAction (mClearSelectionAction);

    mSelectRegionsAction = new QAction (tr ("Select Regions"), this);
    connect (mSelectRegionsAction, SIGNAL (triggered()), this, SLOT (selectRegions()));
    addAction (mSelectRegionsAction);

    mCreateCellsAction = new QAction (tr ("Create Cells Action"), this);
    connect (mCreateCellsAction, SIGNAL (triggered()), this, SLOT (createCells()));
    addAction (mCreateCellsAction);

    mSetRegionAction = new QAction (tr ("Set Region"), this);
    connect (mSetRegionAction, SIGNAL (triggered()), this, SLOT (setRegion()));
    addAction (mSetRegionAction);

    mUnsetRegionAction = new QAction (tr ("Unset Region"), this);
    connect (mUnsetRegionAction, SIGNAL (triggered()), this, SLOT (unsetRegion()));
    addAction (mUnsetRegionAction);

    mViewAction = new QAction (tr ("View Cells"), this);
    connect (mViewAction, SIGNAL (triggered()), this, SLOT (view()));
    addAction (mViewAction);

    mViewInTableAction = new QAction (tr ("View Cells in Table"), this);
    connect (mViewInTableAction, SIGNAL (triggered()), this, SLOT (viewInTable()));
    addAction (mViewInTableAction);

    setAcceptDrops(true);
}
	void ObjectTableView::addObject(const SceneObject *sceneObject)
	{
		QStandardItem *itemObjectName = new QStandardItem(QString::fromStdString(sceneObject->getName()));
		itemObjectName->setData(qVariantFromValue(sceneObject), Qt::UserRole + 1);
		itemObjectName->setEditable(false);

		QStandardItem *itemMeshFile = new QStandardItem(QString::fromStdString(sceneObject->getModel()->getMeshes()->getMeshFilename()));
		itemMeshFile->setData(qVariantFromValue(sceneObject), Qt::UserRole + 1);
		itemMeshFile->setEditable(false);

		int nextRow = objectsListModel->rowCount();
		objectsListModel->insertRow(nextRow);
		objectsListModel->setItem(nextRow, 0, itemObjectName);
		objectsListModel->setItem(nextRow, 1, itemMeshFile);

		resizeRowsToContents();
	}
	void SoundTableView::addSound(const SceneSound *sceneSound)
	{
		QStandardItem *itemSoundName = new QStandardItem(QString::fromStdString(sceneSound->getName()));
		itemSoundName->setData(qVariantFromValue(sceneSound), Qt::UserRole + 1);
		itemSoundName->setEditable(false);

		QStandardItem *itemSoundFile = new QStandardItem(QString::fromStdString(sceneSound->getSound()->getFilename()));
		itemSoundFile->setData(qVariantFromValue(sceneSound), Qt::UserRole + 1);
		itemSoundFile->setEditable(false);

		int nextRow = soundsListModel->rowCount();
		soundsListModel->insertRow(nextRow);
		soundsListModel->setItem(nextRow, 0, itemSoundName);
		soundsListModel->setItem(nextRow, 1, itemSoundFile);

		resizeRowsToContents();
	}
Beispiel #14
0
void SettingsDialog::on_pbPosition_clicked()
{
  QScopedPointer< Gui::Dialog > dialog(new Gui::Dialog(Gui::Dialog::CenterOfScreen,this));
  PositionModel *model = new PositionModel(dialog.data());
  QTableView *view = new QTableView(dialog.data());
  QItemSelectionModel *selectionModel = new QItemSelectionModel(model,dialog.data());

  dialog->setWindowTitle(tr("Set position"));

  QVBoxLayout *layout = new QVBoxLayout;
  QDialogButtonBox *dialogButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
                                                         Qt::Horizontal,dialog.data());
  connect(dialogButtons,SIGNAL(accepted()),dialog.data(),SLOT(accept()));
  connect(dialogButtons,SIGNAL(rejected()),dialog.data(),SLOT(reject()));

  view->setModel(model);
  view->setItemDelegateForColumn(0,new PositionLabelDelegate);
  view->setItemDelegateForColumn(1,new PositionDelegate(QApplication::palette()));
  view->setSelectionBehavior(QAbstractItemView::SelectRows);
  view->setSelectionMode(QAbstractItemView::SingleSelection);
  view->setSelectionModel(selectionModel);
  view->verticalHeader()->setVisible(false);
  view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
  view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
  view->setEditTriggers(QAbstractItemView::NoEditTriggers);

  layout->addWidget(view);
  layout->addWidget(dialogButtons);
  dialog->setLayout(layout);
  dialog->resize(700,500);
  connect(dialog.data(),SIGNAL(executed()),view,SLOT(resizeColumnsToContents()));
  connect(dialog.data(),SIGNAL(executed()),view,SLOT(resizeRowsToContents()));

  selectionModel->select(model->index(pbPosition->property("wallPosition").toInt(),0),
                         QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
  view->scrollTo(model->index(pbPosition->property("wallPosition").toInt(),0));
  if (dialog->exec() == QDialog::Accepted)
  {
    Wally::Application::Position p = static_cast<Wally::Application::Position> (selectionModel->currentIndex().row());
    pbPosition->setProperty("wallPosition",static_cast<int> (p));
    pbPosition->setText(positionToString(p).replace("&","&&"));
    settingsModified();
  }
}
	int LocalizedShapeTableView::addLocalizedShape(std::shared_ptr<const LocalizedCollisionShape> localizedShape)
	{
		BodyShapeWidget *bodyShapeWidget = BodyShapeWidgetRetriever(nullptr, nullptr).retrieveShapeWidget(localizedShape->shape->getShapeType());
		std::string shapeTypeString = bodyShapeWidget->getBodyShapeName();
		delete bodyShapeWidget;

		QStandardItem *itemShape = new QStandardItem(QString::fromStdString(shapeTypeString));
		addLocalizedShapeInMap(localizedShape);
		itemShape->setData(qVariantFromValue(localizedShape.get()), Qt::UserRole + 1);
		itemShape->setEditable(false);

		int nextRow = localizedShapesTableModel->rowCount();
		localizedShapesTableModel->insertRow(nextRow);
		localizedShapesTableModel->setItem(nextRow, 0, itemShape);

		resizeRowsToContents();

		return nextRow; //row id (start to 0)
	}
Beispiel #16
0
void TableWidget::populateTable(const openstudio::WorkspaceObject& obj)
{
  clear();
  setCurrentCell(0,0);
  setRowCount(1);

  openstudio::IddObject iddObj = obj.iddObject();
  for(unsigned i=0; i<obj.numFields(); ++i){
    bool defaultText = false;
    OptionalString val = obj.getString(i);
    if(!val){
      defaultText = true;
      val = obj.getString(i, true);
      // if still no value it is just blank
      if (!val){
        val = "";
      }
    }
    // setItem causes QTableWIdget to take ownership of newItem
    QTableWidgetItem * newItem = new QTableWidgetItem((*val).c_str());
    if(defaultText){
      newItem->setTextColor(Qt::gray);
    }
    setItem(rowCount()-1, 1, newItem);

    openstudio::OptionalIddField iddField = iddObj.getField(i);
    if(!iddField){
      // log error
    }
    else{
      *val = iddField->name();
    }
    // setItem causes QTableWIdget to take ownership of newItem
    newItem = new QTableWidgetItem((*val).c_str());
    setItem(rowCount()-1, 0, newItem);

    setRowCount(rowCount() + 1);
  }

  resizeColumnsToContents();
  resizeRowsToContents();
}
DatasetsTableView::DatasetsTableView(QWidget *parent)
    : QTableView(parent)
    , m_sortDatasetsProxyModel(nullptr)
{
    // the data model
    DatasetItemModel *data_model = new DatasetItemModel(this);

    // the sorting model
    m_sortDatasetsProxyModel.reset(new QSortFilterProxyModel(this));
    m_sortDatasetsProxyModel->setSourceModel(data_model);
    m_sortDatasetsProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
    m_sortDatasetsProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
    setModel(m_sortDatasetsProxyModel.data());

    // settings of the table
    setSortingEnabled(true);
    setShowGrid(true);
    setWordWrap(true);
    setAlternatingRowColors(true);
    sortByColumn(DatasetItemModel::Name, Qt::AscendingOrder);
    setSelectionBehavior(QAbstractItemView::SelectRows);
    setEditTriggers(QAbstractItemView::SelectedClicked);
    setSelectionMode(QAbstractItemView::MultiSelection);
    resizeColumnsToContents();
    resizeRowsToContents();

    horizontalHeader()->setSortIndicatorShown(true);
    horizontalHeader()->setSectionResizeMode(DatasetItemModel::Name, QHeaderView::Stretch);
    horizontalHeader()->setSectionResizeMode(DatasetItemModel::Tissue, QHeaderView::Stretch);
    horizontalHeader()->setSectionResizeMode(DatasetItemModel::Species, QHeaderView::Stretch);
    verticalHeader()->hide();

    model()->submit(); // support for caching (speed up)

    // allow to copy the dataset name
    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, &DatasetsTableView::customContextMenuRequested,
            this, &DatasetsTableView::customMenuRequested);

}
void QCustomTableWidget::setLists(SkillList *skills, CharacterList *chars)
{
    pSkills = skills;
    pCharacters = chars;
    clear();
    setColumnCount(0);
    setRowCount(0);
    int i=0;
    for (SkillList::iterator it = skills->begin(); it != skills->end(); it++)
    {
        insertColumn(i);
        setHorizontalHeaderItem(i,new QTableWidgetItem((*it).c_str()));
        i++;
    }
    int j=0,k;
    for (CharacterList::iterator it = chars->begin(); it != chars->end(); it++)
    {
        insertRow(j);
        setVerticalHeaderItem(j,new QTableWidgetItem(((*it).name()+"\n"+(*it).playerName()).c_str()));
        // creating items
        for (k=0;k<i;k++)
        {
        }
        // setting values
        k = 0;
        for (Character::SkillIterator itSkill = (*it).begin(); itSkill != (*it).end() && k<i; itSkill++)
        {
            setItem(j,k,new QTableWidgetItem((*itSkill).c_str()));
            k++;
        } 
        for (;k<i;k++)
        {
            setItem(j,k,new QTableWidgetItem("0"));
        }
        j++;
    }
    resizeRowsToContents();
    resizeColumnsToContents();
}
//! Overload of setModel()
void    GOCXMLPropertiesView::setModel(QAbstractItemModel *model){
    
    if(!model)
        return;

    //Propagate the model
	GOCPropertiesView::setModel(model);

    //Hide the inner attributes
    for(int row = 0; row<model->rowCount(); row++){
        //Get the ID of the attribute
        int attID = 0;
        QModelIndex attIDIndex;
        attIDIndex = model->index(row,OBJECT_ATT_ID);
        attID = model->data(attIDIndex).toInt();
        if(attID == 0){
            //Hide the row
            this->hideRow(row);
        }
    }

    resizeColumnsToContents();
    resizeRowsToContents();
}
	void SoundTableView::removeAllSounds()
	{
		soundsListModel->removeRows(0, soundsListModel->rowCount());
		resizeRowsToContents();
	}
	void ObjectTableView::removeAllObjects()
	{
		objectsListModel->removeRows(0, objectsListModel->rowCount());
		resizeRowsToContents();
	}
Beispiel #22
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    logfileIndicator (new QLabel ( this)),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    this->setWindowTitle( tr("QT Logger") );

    version = "1.1.2";


    this->setMouseTracking(true);
    this->setBackgroundRole(QPalette::Base);

    QCoreApplication::setOrganizationName("openhpsdr");
    QCoreApplication::setOrganizationDomain("openhpsdr.org");
    QCoreApplication::setApplicationName("QtLogger");

    //logfileIndicator->setStyleSheet (QString ("QLabel {color:red}"));
    logfileIndicator->setPixmap(QPixmap(":/icons/filefoldergrey16.svg"));
    logfileIndicator->setToolTip(QString("Logfile: No file")  );

    About *about = new About();
    about->setVersion( version );


    Help *help = new Help();

    data = new Data();
    data->setMinimumHeader();

    add = new addDialog( this );


    readDefinitions(":/xml/adif_codes_2.2.7.xml");


    add->loadmodeComboBox( modes );
    add->loadcountryComboBox( country );
    add->loadsubdivisionsComboBox( subdivisions );
    add->loadbandsData( bands );

    last = new lastContact( this );

    pref = new Preferences( this );
    pref->setPreferences( QString("radio"), settings.value("preference_radio").toString() );
    pref->setPreferences( QString("location"), settings.value("preference_location").toString() );
    pref->setPreferences( QString("event"), settings.value("preference_event").toString() );
    pref->setPreferences( QString("owner"), settings.value("preference_owner").toString() );
    pref->setPreferences( QString("qsl"), settings.value("preference_qsl").toString() );
    pref->setPreferences( QString("callfilter"), settings.value("callsign_filter").toString() );
    add->callsign_filter = pref->getPreferences("callfilter");


    udpSocket = new QUdpSocket(this);
    udpSocket->bind( 11500, QUdpSocket::ShareAddress );

    statusBar ()->addPermanentWidget (logfileIndicator);

    ui->tableView->verticalScrollBar()->setValue(ui->tableView->verticalScrollBar()->maximum());

    deleteFlag = false;

    connect(udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams()));
    connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(closeDown()));
    connect(ui->actionAbout,SIGNAL(triggered()),about,SLOT(aboutMessage()));
    connect(ui->actionHelp,SIGNAL(triggered()),help,SLOT(show()));
    connect(ui->actionPreferences,SIGNAL(triggered()),pref,SLOT(show()));
    connect(pref,SIGNAL(preferencesChanged()),this,SLOT(updateView()));
    connect(ui->actionOpen,SIGNAL(triggered()),data,SLOT(readData()));
    connect(ui->actionLast_Contact,SIGNAL(triggered()),last,SLOT(show()));
    connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(updateStatus()));
    connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(writeData()));
    connect(ui->actionSupport_Directory,SIGNAL(triggered()),this,SLOT(setSupportDirectory()));
    connect(ui->actionLog_Directory,SIGNAL(triggered()),this,SLOT(setLogDirectory()));
    connect(ui->tableView,SIGNAL(clicked(QModelIndex)),this,SLOT(removeTableRow(QModelIndex)));
    connect(ui->tableView,SIGNAL(activated(QModelIndex)),ui->tableView,SLOT(resizeRowsToContents()));
    connect(ui->actionAdd,SIGNAL(triggered()),add,SLOT(show()));
    connect(add,SIGNAL(newdata()),this,SLOT(update()));
    connect(data,SIGNAL(refresh()),this,SLOT(update()));
    connect(ui->actionDelete,SIGNAL(toggled(bool)),this,SLOT(setDeleteFlag(bool)));
    connect(add,SIGNAL(ownerChanged()),this,SLOT(updateOwner()));
    connect(add,SIGNAL(prefixChanged(QString)),last->proxyModel,SLOT(setFilterRegExp(QString)));
    connect(add,SIGNAL(prefixChanged(QString)),last,SLOT(setCallLabel(QString)));
    connect(add,SIGNAL(prefixChanged(QString)),add->proxyModel,SLOT(setFilterRegExp(QString)));
}
Beispiel #23
0
FreezeTableWidget::FreezeTableWidget(QAbstractItemModel *model, QWidget *parent)
	: DBView(parent),frozenTableView(0),
//for customSelectColumn - these mimic corresponding fields of QTableViewPrivate:
		columnSectionAnchor(-1),ctrlDragSelectionFlag(QItemSelectionModel::NoUpdate)
{
	frozenTableView = new DBView(this);
	frozenTableView->setObjectName("frozenRow");	//for styling

	setModel(model);	//calls reset() after connections
	frozenTableView->setModel(model);	//try DBView::reset()
	init();

	disconnect(horizontalHeader(), SIGNAL(sectionPressed(int)), this, SLOT(selectColumn(int)));
	disconnect(horizontalHeader(), SIGNAL(sectionEntered(int)), this, SLOT(_q_selectColumn(int)));
	connect(horizontalHeader(),&QHeaderView::sectionPressed,[this](int logicalIndex){
		customSelectColumn(logicalIndex,true);
	});
	connect(horizontalHeader(),&QHeaderView::sectionEntered,[this](int logicalIndex){
		customSelectColumn(logicalIndex,false);
	});

	connect(model,&QAbstractItemModel::dataChanged,
					this,&FreezeTableWidget::resizeRowsToContents);
	connect(model,&QAbstractItemModel::columnsInserted,
					this,&FreezeTableWidget::handleColumnsInserted);	//update on insertion

	connect(model,&QAbstractItemModel::modelReset,
					this,&FreezeTableWidget::resizeRowsToContents);	//resize when rows are removed, etc.
	connect(model,&QAbstractItemModel::modelReset,[this]{
		handleColumnsInserted(QModelIndex(),1,horizontalHeader()->count()-1);
	});	//fix for model reset unhiding frozenTableView columns

	//connect the headers and scrollbars of both tableviews together
	connect(horizontalHeader(),&QHeaderView::sectionResized,
					this,&FreezeTableWidget::updateSectionWidth);
	connect(verticalHeader(),&QHeaderView::sectionResized,
					this,&FreezeTableWidget::updateSectionHeight);
	connect(horizontalHeader(),&QHeaderView::sectionMoved,
					this,&FreezeTableWidget::handleColumnsMoved);
	connect(verticalHeader(),&QHeaderView::sectionMoved,
					this,&FreezeTableWidget::handleRowsMoved);

	connect(frozenTableView->verticalScrollBar(),&QScrollBar::valueChanged,
					verticalScrollBar(),&QScrollBar::setValue);
	connect(verticalScrollBar(),&QScrollBar::valueChanged,
					frozenTableView->verticalScrollBar(),&QScrollBar::setValue);

//after connections were established:
	setRowHidden(0,true);
	frozenTableView->setRowHidden(0,true);
	resizeRowsToContents();

	CheckboxHeader* tmp_header=qobject_cast<CheckboxHeader*>(verticalHeader());
	if(tmp_header) {
		connect(tmp_header,&CheckboxHeader::sectionsSetHidden,this,&FreezeTableWidget::slotSectionsSetHidden);
	}

	copyAction=new QAction(tr("Copy"), this);
	copyAction->setShortcuts(QKeySequence::Copy);
	copyAction->setStatusTip(tr("Copy cell data"));
	connect(copyAction, &QAction::triggered, [this]{
		QApplication::clipboard()->setText(getSelectedContents());
	});
	addAction(copyAction);	//to utilize shortcut

	deleteRowAction=new QAction(tr("Remove columns"), this);
	deleteRowAction->setStatusTip(tr("Remove selected columns from the table"));
	connect(deleteRowAction,&QAction::triggered,[this]{
		const QModelIndexList selectedColumns=customSelectedColumns(0);
		QSet<int> removedRowIds;
		for(const QModelIndex &idx: selectedColumns) {
			removedRowIds.insert(this->model()->data(this->model()->index(0,idx.column()),Qt::EditRole).toInt());
			this->model()->removeColumns(idx.column(),1);	//marks for removal, removes after submitAll() call
		}
		emit markRowsForRemoval(removedRowIds);
	});

	setContextMenuPolicy(Qt::CustomContextMenu);
	connect(this,&FreezeTableWidget::customContextMenuRequested,
					this,&FreezeTableWidget::customCellMenuRequested);

	verticalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(verticalHeader(),&QHeaderView::customContextMenuRequested,
					this,&FreezeTableWidget::customVHeaderMenuRequested);

	horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(horizontalHeader(),&QHeaderView::customContextMenuRequested,
					this,&FreezeTableWidget::customHHeaderMenuRequested);
}
Beispiel #24
0
void MyTable::showEvent(QShowEvent* /*event*/)
{
    resizeEvent(0);
    resizeRowsToContents();
}