Example #1
0
void DeckViewScene::rebuildTree()
{
    clearContents();
    
    if (!deck)
        return;
    
    InnerDecklistNode *listRoot = deck->getRoot();
    for (int i = 0; i < listRoot->size(); i++) {
        InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
        
        DeckViewCardContainer *container = cardContainers.value(currentZone->getName(), 0);
        if (!container) {
            container = new DeckViewCardContainer(currentZone->getName());
            cardContainers.insert(currentZone->getName(), container);
            addItem(container);
        }
        
        for (int j = 0; j < currentZone->size(); j++) {
            DecklistCardNode *currentCard = dynamic_cast<DecklistCardNode *>(currentZone->at(j));
            if (!currentCard)
                continue;

            for (int k = 0; k < currentCard->getNumber(); ++k) {
                DeckViewCard *newCard = new DeckViewCard(currentCard->getName(), currentZone->getName(), container);
                container->addCard(newCard);
                emit newCardAdded(newCard);
            }
        }
    }
}
Example #2
0
void add_widget::on_pushButton_add_connection_clicked()
{
    bool AllOk = connectionErrorCheck();

    if(AllOk) {
     vector<person> p = ComputerScientist.getPersons();
     vector<computer> c = ComputerScientist.getComputers();

     string connectFirstName = ui->input_connect_firstname->text().toStdString();
     string connectLastName = ui->input_connect_lastname->text().toStdString();
     string connectCompName = ui->Input_connect_computer_name->text().toStdString();


    bool check = ComputerScientist.addConnection(connectFirstName, connectLastName, connectCompName);
        if(check) {
        cout << "Successfully added a new connection" << endl;
        clearContents(3);
        }
            else {
        cout << "Failed to add" << endl;
            }
    }
    else {
        ui->label_connection_error->setText(QString::fromStdString(currentError));
    }
}
Example #3
0
UndoRedoHandler::~UndoRedoHandler() {
	XOJ_CHECK_TYPE(UndoRedoHandler);

	clearContents();

	XOJ_RELEASE_TYPE(UndoRedoHandler);
}
Example #4
0
void ItemImage::setImage( const QImage& img )
{
    QMutexLocker locker( &mutex );

    clearContents();
    m_image = new QImage( img );
    if( m_image->width() < 32 && m_image->height() < 32 ) {
        setMinimumSize( QSize( 32, 32 ) );
        setMaximumSize( QSize( 32, 32 ) );
    } else if( m_image->width() < 32 && m_image->height() >= 32 ) {
        setMinimumSize( QSize( 32, m_image->size().height() ) );
        setMaximumSize( QSize( 32, m_image->size().height() ) );
    } else if( m_image->width() >= 32 && m_image->height() < 32 ) {
        setMinimumSize( QSize( m_image->size().width(), 32 ) );
        setMaximumSize( QSize( m_image->size().width(), 32 ) );
    } else {
        setMinimumSize( m_image->size() );
        setMaximumSize( m_image->size() );
    }

    emit imageChanged( img );

    updatePieces();
    update();
}
void SymbolListWidget::SetFavoritePage(QList<int> flist)
{
clearContents();
int rows=(flist.count()-1)/4+1;
setRowCount(rows);
for ( uint j = 0; j < rows; ++j ) setRowHeight(j,36);
QString icon_name;
for( int i = 0; i < flist.count(); i++ )
	{
	if ((flist.at(i)>-1) && (flist.at(i)<412))
		{
		QTableWidgetItem* item= new QTableWidgetItem();
		if (flist.at(i)>=372)
			{
			icon_name=":/symbols/img"+QString::number(flist.at(i)-371)+"greek.png";
			}
		else
			{
			icon_name=":/symbols/img"+QString::number(flist.at(i)+1)+".png";
			}
		item->setText(code[flist.at(i)]+";"+QString::number(flist.at(i)));
		item->setIcon(QIcon(icon_name));
		item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		setItem(i/4,i%4,item);
		}
	}
}
Example #6
0
void pTableWidget::removeAll()
{
    clearContents();

    while(rowCount() > 0)
        removeRow(0);
}
Example #7
0
void add_widget::on_pushButton_add_computer_clicked()
{
    bool AllOk = computerErrorCheck();

    if(AllOk) {

    string computerName = ui->input_computer_name->text().toStdString();
    string computerType = ui->input_type->text().toStdString();
    int yearInvented = ui->input_yearBuilt->text().toInt();
    bool wasMade = ui->input_ifMade->text().toInt();

    computer c;
    c.setName(computerName);
    c.setType(computerType);
    c.setYearMade(yearInvented);
    c.setWasMade(wasMade);

    bool check = ComputerScientist.addComp(c);
        if(check) {
        cout << "Successfully added" << endl;
        clearContents(2);
        }
            else {
        cout << "Failed to add" << endl;
            }
    }

    else{

        ui->label_computer_error_2->setText(QString::fromStdString(currentError));
    }

}
Example #8
0
void MorphismListWidget::updateList(const VariableList &variableList)
{

  // updates morphism list

  int row = 0;
  int rowSpan = 0;
  QTableWidgetItem *nameItem;
  QTableWidgetItem *varItem;

  clearContents();

  VariableListIterator i(variableList);
  while (i.hasNext()) {
    i.next();
    if (i.value().type() == Morphism)
      row += i.value().mapData().domainRank();
  }
  setRowCount(row);

  i.toFront();
  row = 0;
  while (i.hasNext()) {
    i.next();

    if (i.value().type() == Morphism) {
      nameItem = item(row,0);
      if (!nameItem) {
        nameItem = new QTableWidgetItem;
        setItem(row,0,nameItem);
      }
      nameItem->setText(i.key());
      nameItem->setTextAlignment(Qt::AlignLeft);
      nameItem->setTextAlignment(Qt::AlignVCenter);
      nameItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
      rowSpan = i.value().mapData().domainRank();
      setSpan(row,0,rowSpan,1);

      MapIterator x(i.value().mapData());
      while (x.hasNext()) {
        x.next();
        if (x.key().isLower()) {
          varItem = item(row,1);
          if (!varItem) {
            varItem = new QTableWidgetItem;
            setItem(row,1,varItem);
          }
          varItem->setText(QString(x.key()) + " -> " + x.value());
          varItem->setTextAlignment(Qt::AlignLeft);
          varItem->setTextAlignment(Qt::AlignVCenter);
          varItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

          row++;
        }
      }
    }
  }

}
void QMessageContentContainerPrivate::setContentType(const QByteArray &type, const QByteArray &subType, const QByteArray &charset)
{
    clearContents();

    _type = type;
    _subType = subType;
    _charset = charset;
}
Example #10
0
void Uri::Private::newAndDetach(Uri *uri)
{
    if (m_refs > 1) {
        uri->d = new Private;
        deref();
    } else if (this == m_privateEmpty) {
        m_privateEmpty = 0;
    } else {
        clearContents();
    }
}
Example #11
0
void tableView::colum_Sort(int col_id)
{
	if (col_id - 1 != pDoc->m_meta_graph->getDisplayedAttribute())
	{
		pDoc->m_meta_graph->setDisplayedAttribute(col_id - 1);
		clearContents();
		PrepareCache(0, m_curr_row);
		return;

		RedoTable();
	}
}
Example #12
0
void Table::setMaskType(PolyEdit::Shape type)
{
    isReady = false;

    clear();
    mMask->clear();

    switch (type)
    {
        case PolyEdit::Polygon:
        {
            setColumnCount(2);
            setRowCount(1);
            setHorizontalHeaderItem(0, new Cell("X"));
            setHorizontalHeaderItem(1, new Cell("Y"));
            break;
        }
        case PolyEdit::Circle:
        {
            setColumnCount(1);
            setRowCount(3);
            setHorizontalHeaderItem(0, new Cell("Circle"));
            setVerticalHeaderItem(0,new Cell("X"));
            setVerticalHeaderItem(1,new Cell("Y"));
            setVerticalHeaderItem(2,new Cell("Radius"));
            break;
        }
        case PolyEdit::Box:
        {
            setColumnCount(1);
            setRowCount(4);
            setHorizontalHeaderItem(0, new Cell("Box"));
            setVerticalHeaderItem(0,new Cell("Left"));
            setVerticalHeaderItem(1,new Cell("Top"));
            setVerticalHeaderItem(2,new Cell("Width"));
            setVerticalHeaderItem(3,new Cell("Height"));
            break;
        }
        case PolyEdit::Invalid:
        {
            break;
        }
    }

    clearContents();

    mType = type;
    horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

    mMask->setType(type);

    isReady = true;
}
Example #13
0
void VariableListWidget::updateList(const VariableList & variableList)
{

  // updates variable dialog

  int row = 0;
  QTableWidgetItem *nameItem;
  QTableWidgetItem *varItem;

  clearContents();

  VariableListIterator i(variableList);
  while (i.hasNext()) {
    i.next();
    if (i.value().type() == Element || i.value().type() == Integer)
      row++;
  }
  setRowCount(row);

  i.toFront();
  row = 0;
  while (i.hasNext()) {
    i.next();

    if (i.value().type() == Element || i.value().type() == Integer) {
      nameItem = item(row,0);
      if (!nameItem) {
        nameItem = new QTableWidgetItem;
        setItem(row,0,nameItem);
      }
      nameItem->setText(i.key());
      nameItem->setTextAlignment(Qt::AlignLeft);
      nameItem->setTextAlignment(Qt::AlignVCenter);
      nameItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

      varItem = item(row,1);
      if (!varItem) {
        varItem = new QTableWidgetItem;
        setItem(row,1,varItem);
      }
      varItem->setText(i.value().toOutput());
      varItem->setTextAlignment(Qt::AlignLeft);
      varItem->setTextAlignment(Qt::AlignVCenter);
      varItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

      row++;
    }

  }

}
Example #14
0
void SymbolViewer::setContext( GpsimProcessor * gpsim )
{
	RegisterSet * registerSet = gpsim ? gpsim->registerMemory() : 0l;
	
	if ( registerSet == m_pCurrentContext )
		return;
	
	m_pSymbolList->clear();
    m_pSymbolList->setColumnCount(2);
    m_pSymbolList->setRowCount(0);

    m_pSymbolList->setHorizontalHeaderItem(0, new QTableWidgetItem(i18n("Name")));
    m_pSymbolList->setHorizontalHeaderItem(1, new QTableWidgetItem(i18n("Value")));
    m_pSymbolList->horizontalHeaderItem(0)->setText(i18n("Name"));
    m_pSymbolList->horizontalHeaderItem(1)->setText(i18n("Value"));

    m_pGpsim = gpsim;
	m_pCurrentContext = registerSet;
	
	if (!m_pCurrentContext)
		return;
		
	connect( gpsim, SIGNAL(destroyed()), m_pSymbolList, SLOT(clearContents()) );
	
	unsigned count = m_pCurrentContext->size();
	for ( unsigned i = 0; i < count; ++i )
	{
		RegisterInfo * reg = m_pCurrentContext->fromAddress(i);

        if (!reg) {
            qDebug() << " skip null register at " << i;
            continue;
        }
		
		if ( (reg->type() == RegisterInfo::Generic) ||
					(reg->type() == RegisterInfo::Invalid) ) {
            continue;
        }
		
        qDebug() << Q_FUNC_INFO << " add reg at " << i << " info " << reg;

        m_pSymbolList->insertRow(i);

		SymbolViewerItem *itemName = new SymbolViewerItem( this, reg, 0 );
        m_pSymbolList->setItem(i, 0, itemName);
        SymbolViewerItem *itemVal = new SymbolViewerItem( this, reg, 1 );
        m_pSymbolList->setItem(i, 1, itemVal);
	}
}
Example #15
0
		void        loadFromFile                    ()
		{
			// Clears the contents of the file, then loads the contents of the file 'fileName'
			std::fstream file(fileName, std::ios::in);
			clearContents();
			contents.push_back(NumericLine());
			if (file.is_open())
			{
				double buffer;
				while (file >> buffer)
				{
					contents.at(size() - 1).push_back(buffer);
					if (file.peek() == '\n')
					{
						contents.push_back(NumericLine());
					}
				}
			}
Example #16
0
void pTableWidget::removeRow(int row)
{
    if(rowCount() == 1)
        clearContents();

    for(int column = 0; column < columnCount(); column++)
    {
        QWidget *w = cellWidget(row, column);
        if(w != 0)
        {
            removeCellWidget(row, column);
            delete w;
        }
    }

    QTableWidget::removeRow(row);

    updateToolButtonNumber();
}
Example #17
0
Doc::~Doc()
{
    delete m_masterTimer;
    m_masterTimer = NULL;

    clearContents();

    if (isKiosk() == false)
        m_outputMap->saveDefaults();
    delete m_outputMap;
    m_outputMap = NULL;

    if (isKiosk() == false)
        m_inputMap->saveDefaults();
    delete m_inputMap;
    m_inputMap = NULL;

    delete m_fixtureDefCache;
    m_fixtureDefCache = NULL;
}
void SelectProcess::updateProcessList()
{
    QList<ProcessInfo> list;
    auto table = ui->processList;

    table->clearContents();
    table->setRowCount(0);

    if (getProcessList(list)) {
        for (const ProcessInfo &info : list) {
            QTableWidgetItem *name = new QTableWidgetItem(info.name);
            QTableWidgetItem *pid = new QTableWidgetItem(QString::number(info.pid));

            const int row = table->rowCount();
            table->setRowCount(row + 1);
            table->setItem(row, 0, name);
            table->setItem(row, 1, pid);
        }
    } else {
        addLogErr(trUtf8("Не удалось получить список процессов."));
    }
}
Example #19
0
void cInfoWidget::Update()
{
    clearContents();

    std::deque<HpiInfo> info;
    m_provider.GetInfo( info );

    setRowCount( info.size() );

    for ( unsigned int i = 0, n = info.size(); i < n; ++i ) {
        QTableWidgetItem * item;

        item = new QTableWidgetItem( QString::fromStdWString( info[i].name ) );
        item->setFlags( Qt::ItemIsEnabled );
        setItem( i, 0, item );

        item = new QTableWidgetItem( QString::fromStdWString( info[i].value ) );
        item->setFlags( Qt::ItemIsEnabled );
        setItem( i, 1, item );
    }

    resizeColumnToContents( 0 );
}
Example #20
0
void QQuestionsTableWidget::setQuestions(const QList<QQuestion> & questions)
{
    QStringList answers;
    clearContents();
    while(rowCount())
        removeRow(0);
    setSortingEnabled(false);
    blockSignals(true);
    model() -> blockSignals(true);
    foreach(QQuestion quest,questions)
    {
        answers = quest.answers();
        if (answers.count() != (int)CHOICE_COUNT)
            continue;
        addQuestionRow();
        //setting columns: question, answers, true answer and rating
        item(rowCount() - 1,0) -> setText(quest.question());
        for (unsigned int i = 0; i < CHOICE_COUNT; i++)
            item(rowCount() - 1,1 + i) -> setText(answers.at(i));
        dynamic_cast<QComboBox *>(cellWidget(rowCount() - 1,1 + CHOICE_COUNT)) -> setCurrentText(QString::number(quest.goodAnswerIndex()));
        if (RATING)
            dynamic_cast<QComboBox *>(cellWidget(rowCount() - 1,1 + CHOICE_COUNT + 1)) -> setCurrentText(QString::number(quest.rating()));
    }
Example #21
0
Omnibar::Omnibar(MainWindow *main, QWidget *parent) :
    QLineEdit(parent)
{
    // Radare core found in:
    this->main = main;

    // QLineEdit basic features
    this->setMinimumHeight(16);
    this->setMaximumHeight(16);
    this->setFrame(false);
    //this->setPlaceholderText("Go to address...");
    this->setStyleSheet("border-radius: 5px;");
    this->setTextMargins(10, 0, 0, 0);
    this->setClearButtonEnabled(true);

    this->commands << ": Comments toggle"
                   << ": Dashboard toggle"
                   << ": Flags toggle"
                   << ": Functions toggle"
                   << ": Imports toggle"
                   << ": Notepad toggle"
                   << ": Relocs toggle"
                   << ": Run Script"
                   << ": Sections toggle"
                   << ": Strings toggle"
                   << ": Symbols toggle"
                   << ": Tabs up/down"
                   << ": Theme switch"
                   << ": Lock/Unlock interface"
                   << ": Web server start/stop";

    connect(this, SIGNAL(returnPressed()), this, SLOT(on_gotoEntry_returnPressed()));

    // Esc clears omnibar
    QShortcut* clear_shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
    connect(clear_shortcut, SIGNAL(activated()), this, SLOT(clearContents()));
}
Example #22
0
void add_widget::on_pushButton_add_pioneer_clicked()
{

    bool allOk = pioneerErrorCheck();

    if(allOk){

        string firstName = ui->input_firstname->text().toStdString();
        string lastName = ui->input_lastname->text().toStdString();
        string sex = ui->input_gender->text().toStdString();
        int yearBorn = ui->input__yearOfBirth->text().toInt();
        int yearDied = ui->input_yearOfDeath->text().toInt();

        person p;
        p.setFirstName(firstName);
        p.setLastName(lastName);
        p.setSex(sex);
        p.setBorn(yearBorn);
        p.setDied(yearDied);

        bool check = ComputerScientist.addPerson(p);
        if(check) {
            cout << "Successfully added" << endl;
            clearContents(1);
        }
            else{
            cout << "Failed to add" << endl;
        }

    }
    else{

        ui->label_pioneer_error->setText(QString::fromStdString(currentError));
    }


}
Example #23
0
Doc::~Doc()
{
    delete m_masterTimer;
    m_masterTimer = NULL;

    clearContents();

    if (isKiosk() == false)
    {
        // TODO: is this still needed ??
        //m_ioMap->saveDefaults();
    }
    delete m_ioMap;
    m_ioMap = NULL;

    delete m_ioPluginCache;
    m_ioPluginCache = NULL;

    delete m_modifiersCache;
    m_modifiersCache = NULL;

    delete m_fixtureDefCache;
    m_fixtureDefCache = NULL;
}
Example #24
0
void DetailsTable::createAsteroidCometTable(SkyObject *obj)
{
    clearContents();

    QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();

    QString perihelionVal, orbitIdVal, neoVal, diamVal, rotPeriodVal, moidVal;
    QString orbitClassVal, albedoVal, dimVal, periodVal;

    // Add specifics data
    switch(obj->type())
    {
    case SkyObject::ASTEROID:
        {
            KSAsteroid* ast = (KSAsteroid *)obj;

            // Perihelion
            perihelionVal = QString::number(ast->getPerihelion()) + " AU";

            // Earth MOID
            moidVal = ast->getEarthMOID() == 0 ? QString("--") : QString::number(ast->getEarthMOID()) + QString(" AU");

            // Orbit ID
            orbitIdVal = ast->getOrbitID();

            // Orbit Class
            orbitClassVal = ast->getOrbitClass();

            // NEO
            neoVal = ast->isNEO() ? i18n("Yes") : i18n("No");

            // Albedo
            albedoVal = ast->getAlbedo() == 0 ? QString("--") : QString::number(ast->getAlbedo());

            // Diameter
            diamVal = ast->getDiameter() == 0 ? QString("--") : QString::number(ast->getDiameter()) + QString(" km");

            // Dimensions
            dimVal = ast->getDimensions().isEmpty() ? QString("--") : ast->getDimensions() + QString(" km");

            // Rotation period
            rotPeriodVal = ast->getRotationPeriod() == 0 ? QString("--") : QString::number(ast->getRotationPeriod()) + QString(" h");

            // Period
            periodVal = ast->getPeriod() == 0 ? QString("--") : QString::number(ast->getPeriod()) + QString(" y");

            break;
        }

    case SkyObject::COMET:
        {
            KSComet* com = (KSComet *)obj;

            // Perihelion
            perihelionVal = QString::number(com->getPerihelion()) + " AU";

            // Earth MOID
            moidVal = com->getEarthMOID() == 0 ? QString("--") : QString::number(com->getEarthMOID()) + QString(" AU");

            // Orbit ID
            orbitIdVal = com->getOrbitID();

            // Orbit Class
            orbitClassVal = com->getOrbitClass();

            // NEO
            neoVal = com->isNEO() ? i18n("Yes") : i18n("No");

            // Albedo
            albedoVal = com->getAlbedo() == 0 ? QString("--") : QString::number(com->getAlbedo());

            // Diameter
            diamVal = com->getDiameter() == 0 ? QString("--") : QString::number(com->getDiameter()) + QString(" km");

            // Dimensions
            dimVal = com->getDimensions().isEmpty() ? QString("--") : com->getDimensions() + QString(" km");

            // Rotation period
            rotPeriodVal = com->getRotationPeriod() == 0 ? QString("--") : QString::number(com->getRotationPeriod()) + QString(" h");

            // Period
            periodVal = com->getPeriod() == 0 ? QString("--") : QString::number(com->getPeriod()) + QString(" y");

            break;
        }

    default:
        {
            return;
        }
    }

    // Set column width constraints
    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25);
    m_TableFormat.setColumnWidthConstraints(constraints);

    QTextTable *table = cursor.insertTable(6, 4, m_TableFormat);
    table->mergeCells(0, 0, 1, 4);
    QTextBlockFormat centered;
    centered.setAlignment(Qt::AlignCenter);
    table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Asteroid/Comet details"), m_TableTitleCharFormat);

    table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Perihelion:"), m_ItemNameCharFormat);
    table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(1, 1).firstCursorPosition().insertText(perihelionVal, m_ItemValueCharFormat);

    table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Orbit ID:"), m_ItemNameCharFormat);
    table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(2, 1).firstCursorPosition().insertText(orbitIdVal, m_ItemValueCharFormat);

    table->cellAt(3, 0).firstCursorPosition().insertText(i18n("NEO:"), m_ItemNameCharFormat);
    table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(3, 1).firstCursorPosition().insertText(neoVal, m_ItemValueCharFormat);

    table->cellAt(4, 0).firstCursorPosition().insertText(i18n("Diameter:"), m_ItemNameCharFormat);
    table->cellAt(4, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(4, 1).firstCursorPosition().insertText(diamVal, m_ItemValueCharFormat);

    table->cellAt(5, 0).firstCursorPosition().insertText(i18n("Rotation period:"), m_ItemNameCharFormat);
    table->cellAt(5, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(5, 1).firstCursorPosition().insertText(rotPeriodVal, m_ItemValueCharFormat);

    table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Earth MOID:"), m_ItemNameCharFormat);
    table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(1, 3).firstCursorPosition().insertText(moidVal, m_ItemValueCharFormat);

    table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Orbit class:"), m_ItemNameCharFormat);
    table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(2, 3).firstCursorPosition().insertText(orbitClassVal, m_ItemValueCharFormat);

    table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Albedo:"), m_ItemNameCharFormat);
    table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(3, 3).firstCursorPosition().insertText(albedoVal, m_ItemValueCharFormat);

    table->cellAt(4, 2).firstCursorPosition().insertText(i18n("Dimensions:"), m_ItemNameCharFormat);
    table->cellAt(4, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(4, 3).firstCursorPosition().insertText(dimVal, m_ItemValueCharFormat);

    table->cellAt(5, 2).firstCursorPosition().insertText(i18n("Period:"), m_ItemNameCharFormat);
    table->cellAt(5, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(5, 3).firstCursorPosition().insertText(periodVal, m_ItemValueCharFormat);
}
Example #25
0
void DetailsTable::createGeneralTable(SkyObject *obj)
{
    clearContents();

    QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();

    //Fill in the data fields
    //Contents depend on type of object
    StarObject *s = 0;
    DeepSkyObject *dso = 0;
    KSPlanetBase *ps = 0;
    QString pname, oname;

    QString objNamesVal, objTypeVal, objDistVal, objSizeVal, objMagVal, objBvVal, objIllumVal;
    QString objSizeLabel, objMagLabel;

    switch(obj->type())
    {
    case SkyObject::STAR:
        {
            s = (StarObject *)obj;

            objNamesVal = s->longname();

            if(s->getHDIndex() != 0)
            {
                if(!s->longname().isEmpty())
                {
                    objNamesVal = s->longname() + QString(", HD%1").arg(QString::number(s->getHDIndex())) ;
                }

                else
                {
                    objNamesVal = QString(", HD%1").arg(QString::number(s->getHDIndex()));
                }
            }

            objTypeVal = s->sptype() + ' ' + i18n("star");
            objMagVal = i18nc("number in magnitudes", "%1 mag", KGlobal::locale()->formatNumber(s->mag(), 1)); //show to tenths place

            if(s->getBVIndex() < 30.0)
            {
                objBvVal = QString::number(s->getBVIndex(), 'g', 2);
            }

            //distance
            if(s->distance() > 2000. || s->distance() < 0.)  // parallax < 0.5 mas
            {
                objDistVal = i18nc("larger than 2000 parsecs", "> 2000 pc");
            }

            else if(s->distance() > 50.0) //show to nearest integer
            {
                objDistVal = i18nc("number in parsecs", "%1 pc", KGlobal::locale()->formatNumber(s->distance(), 0));
            }

            else if(s->distance() > 10.0) //show to tenths place
            {
                objDistVal = i18nc("number in parsecs", "%1 pc", KGlobal::locale()->formatNumber(s->distance(), 1));
            }

            else //show to hundredths place
            {
                objDistVal = i18nc("number in parsecs", "%1 pc", KGlobal::locale()->formatNumber(s->distance(), 2));
            }

            //Note multiplicity/variablility in angular size label
            if(s->isMultiple() && s->isVariable())
            {
                objSizeLabel = i18nc("the star is a multiple star", "multiple") + ',';
                objSizeVal = i18nc("the star is a variable star", "variable");
            }

            else if(s->isMultiple())
            {
                objSizeLabel = i18nc("the star is a multiple star", "multiple");
            }

            else if(s->isVariable())
            {
                objSizeLabel = i18nc("the star is a variable star", "variable");
            }

            objIllumVal = "--";

            break; //End of stars case
        }

    case SkyObject::ASTEROID:  //[fall through to planets]

    case SkyObject::COMET:     //[fall through to planets]

    case SkyObject::MOON:      //[fall through to planets]

    case SkyObject::PLANET:
        {
            ps = (KSPlanetBase *)obj;

            objNamesVal = ps->longname();
            //Type is "G5 star" for Sun
            if(ps->name() == "Sun")
            {
                objTypeVal = i18n("G5 star");
            }

            else if(ps->name() == "Moon")
            {
                objTypeVal = ps->translatedName();
            }

            else if(ps->name() == i18n("Pluto") || ps->name() == "Ceres" || ps->name() == "Eris") // TODO: Check if Ceres / Eris have translations and i18n() them
            {
                objTypeVal = i18n("Dwarf planet");
            }

            else
            {
                objTypeVal = ps->typeName();
            }

            //Magnitude: The moon displays illumination fraction instead
            if(obj->name() == "Moon")
            {
                objIllumVal = QString("%1 %").arg(KGlobal::locale()->formatNumber(((KSMoon *)obj)->illum()*100., 0));
            }

            objMagVal = i18nc("number in magnitudes", "%1 mag", KGlobal::locale()->formatNumber(ps->mag(), 1)); //show to tenths place

            //Distance from Earth.  The moon requires a unit conversion
            if(ps->name() == "Moon")
            {
                objDistVal = i18nc("distance in kilometers", "%1 km", KGlobal::locale()->formatNumber(ps->rearth() * AU_KM ));
            }

            else
            {
                objDistVal = i18nc("distance in Astronomical Units", "%1 AU", KGlobal::locale()->formatNumber(ps->rearth()));
            }

            //Angular size; moon and sun in arcmin, others in arcsec
            if(ps->angSize())
            {
                if(ps->name() == "Sun" || ps->name() == "Moon")
                {
                    // Needn't be a plural form because sun / moon will never contract to 1 arcminute
                    objSizeVal = i18nc("angular size in arcminutes", "%1 arcmin", KGlobal::locale()->formatNumber(ps->angSize()));
                }

                else
                {
                    objSizeVal = i18nc("angular size in arcseconds","%1 arcsec", KGlobal::locale()->formatNumber(ps->angSize() * 60.0));
                }
            }

            else
            {
                objSizeVal = "--";
            }

            break; //End of planets/comets/asteroids case
        }

    default: //Deep-sky objects
        {
            dso = (DeepSkyObject *)obj;

            //Show all names recorded for the object
            if(!dso->longname().isEmpty() && dso->longname() != dso->name())
            {
                pname = dso->translatedLongName();
                oname = dso->translatedName();
            }

            else
            {
                pname = dso->translatedName();
            }

            if(!dso->translatedName2().isEmpty())
            {
                if(oname.isEmpty())
                {
                    oname = dso->translatedName2();
                }

                else
                {
                    oname += ", " + dso->translatedName2();
                }
            }

            if(dso->ugc() != 0)
            {
                if(!oname.isEmpty())
                {
                    oname += ", ";
                }

                oname += "UGC " + QString::number(dso->ugc());
            }
            if(dso->pgc() != 0)
            {
                if(!oname.isEmpty())
                {
                    oname += ", ";
                }

                oname += "PGC " + QString::number(dso->pgc());
            }

            if(!oname.isEmpty())
            {
                pname += ", " + oname;
            }

            objNamesVal = pname;

            objTypeVal = dso->typeName();

            if(dso->type() == SkyObject::RADIO_SOURCE)
            {
                objMagLabel = i18nc("integrated flux at a frequency", "Flux(%1):", dso->customCatalog()->fluxFrequency());
                objMagVal = i18nc("integrated flux value", "%1 %2", KGlobal::locale()->formatNumber(dso->flux(), 1),
                                  dso->customCatalog()->fluxUnit()); //show to tenths place
            }

            else if(dso->mag() > 90.0)
            {
                objMagVal = "--";
            }

            else
            {
                objMagVal = i18nc("number in magnitudes", "%1 mag", KGlobal::locale()->formatNumber(dso->mag(), 1)); //show to tenths place
            }

            //No distances at this point...
            objDistVal = "--";

            //Only show decimal place for small angular sizes
            if(dso->a() > 10.0)
            {
                objSizeVal = i18nc("angular size in arcminutes", "%1 arcmin", KGlobal::locale()->formatNumber(dso->a(), 0));
            }

            else if(dso->a())
            {
                objSizeVal = i18nc("angular size in arcminutes", "%1 arcmin", KGlobal::locale()->formatNumber(dso->a(), 1));
            }

            else
            {
                objSizeVal = "--";
            }

            break; //End of deep-space objects case
        }
    }

    //Common to all types:
    if(obj->type() == SkyObject::CONSTELLATION )
    {
        objTypeVal = KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName(obj);
    }

    else
    {
        objTypeVal = i18nc("%1 type of sky object (planet, asteroid etc), %2 name of a constellation", "%1 in %2", objTypeVal,
                           KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName(obj));
    }

    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25);
    m_TableFormat.setColumnWidthConstraints(constraints);

    QTextTable *table = cursor.insertTable(5, 4, m_TableFormat);
    table->mergeCells(0, 0, 1, 4);
    QTextBlockFormat centered;
    centered.setAlignment(Qt::AlignCenter);
    table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(0, 0).firstCursorPosition().insertText(i18n("General"), m_TableTitleCharFormat);

    table->mergeCells(1, 1, 1, 3);
    table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Names:"), m_ItemNameCharFormat);
    table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(1, 1).firstCursorPosition().insertText(objNamesVal, m_ItemValueCharFormat);

    table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Type:"), m_ItemNameCharFormat);
    table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(2, 1).firstCursorPosition().insertText(objTypeVal, m_ItemValueCharFormat);

    table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Distance:"), m_ItemNameCharFormat);
    table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(3, 1).firstCursorPosition().insertText(objDistVal, m_ItemValueCharFormat);

    table->cellAt(4, 0).firstCursorPosition().insertText(i18n("Size:"), m_ItemNameCharFormat);
    table->cellAt(4, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(4, 1).firstCursorPosition().insertText(objSizeVal, m_ItemValueCharFormat);

    table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Magnitude:"), m_ItemNameCharFormat);
    table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(2, 3).firstCursorPosition().insertText(objMagVal, m_ItemValueCharFormat);

    table->cellAt(3, 2).firstCursorPosition().insertText(i18n("B-V index:"), m_ItemNameCharFormat);
    table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(3, 3).firstCursorPosition().insertText(objBvVal, m_ItemValueCharFormat);

    table->cellAt(4, 2).firstCursorPosition().insertText(i18n("Illumination:"), m_ItemNameCharFormat);
    table->cellAt(4, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(4, 3).firstCursorPosition().insertText(objIllumVal, m_ItemValueCharFormat);
}
void DownloadAbstractTableWidget::clear()
{
    clearContents();
    setRowCount(0);
}
Example #27
0
MaskFrame::MaskFrame():
_bIsCleared(true),
ofFbo()
{
    clearContents();
}
Example #28
0
void DetailsTable::createCoordinatesTable(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
{
    clearContents();

    QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();

    // Set column width constraints
    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25);
    m_TableFormat.setColumnWidthConstraints(constraints);

    // Insert table & row containing table name
    QTextTable *table = cursor.insertTable(4, 4, m_TableFormat);
    table->mergeCells(0, 0, 1, 4);
    QTextBlockFormat centered;
    centered.setAlignment(Qt::AlignCenter);
    table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Coordinates"), m_TableTitleCharFormat);

    //Coordinates Section:
    //Don't use KLocale::formatNumber() for the epoch string,
    //because we don't want a thousands-place separator!
    QString sEpoch = QString::number(ut.epoch(), 'f', 1);
    //Replace the decimal point with localized decimal symbol
    sEpoch.replace('.', KGlobal::locale()->decimalSymbol());

    table->cellAt(1, 0).firstCursorPosition().insertText(i18n("RA (%1):", sEpoch), m_ItemNameCharFormat);
    table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(1, 1).firstCursorPosition().insertText(obj->ra().toHMSString(), m_ItemValueCharFormat);

    table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Dec (%1):", sEpoch), m_ItemNameCharFormat);
    table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(2, 1).firstCursorPosition().insertText(obj->dec().toDMSString(), m_ItemValueCharFormat);

    table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Hour angle:"), m_ItemNameCharFormat);
    table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
    //Hour Angle can be negative, but dms HMS expressions cannot.
    //Here's a kludgy workaround:
    dms lst = geo->GSTtoLST(ut.gst());
    dms ha(lst.Degrees() - obj->ra().Degrees());
    QChar sgn('+');
    if(ha.Hours() > 12.0)
    {
        ha.setH(24.0 - ha.Hours());
        sgn = '-';
    }
    table->cellAt(3, 1).firstCursorPosition().insertText(QString("%1%2").arg(sgn).arg(ha.toHMSString()), m_ItemValueCharFormat);

    table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Azimuth:"), m_ItemNameCharFormat);
    table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(1, 3).firstCursorPosition().insertText(obj->az().toDMSString(), m_ItemValueCharFormat);

    table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Altitude:"), m_ItemNameCharFormat);
    table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
    dms a;
    if(Options::useAltAz())
    {
        a = obj->alt();
    }

    else
    {
        a = obj->altRefracted();
    }
    table->cellAt(2, 3).firstCursorPosition().insertText(a.toDMSString(), m_ItemValueCharFormat);

    table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Airmass:"), m_ItemNameCharFormat);
    table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
    //Airmass is approximated as the secant of the zenith distance,
    //equivalent to 1./sin(Alt).  Beware of Inf at Alt=0!
    QString aMassStr;
    if(obj->alt().Degrees() > 0.0)
    {
        aMassStr = KGlobal::locale()->formatNumber(1./sin(obj->alt().radians() ), 2);
    }

    else
    {
        aMassStr = "--";
    }
    table->cellAt(3, 3).firstCursorPosition().insertText(aMassStr, m_ItemValueCharFormat);

    // Restore the position and other time-dependent parameters
    obj->recomputeCoords(ut, geo);
}
Example #29
0
DeckViewScene::~DeckViewScene()
{
    clearContents();
    delete deck;
}
Example #30
0
void DetailsTable::createRSTTAble(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
{
    clearContents();

    QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();

    QString rtValue, stValue; // Rise/Set time values
    QString azRValue, azSValue; // Rise/Set azimuth values

    //Prepare time/position variables
    QTime rt = obj->riseSetTime(ut, geo, true); //true = use rise time
    dms raz = obj->riseSetTimeAz(ut, geo, true); //true = use rise time

    //If transit time is before rise time, use transit time for tomorrow
    QTime tt = obj->transitTime(ut, geo);
    dms talt = obj->transitAltitude(ut, geo);
    if(tt < rt)
    {
        tt = obj->transitTime(ut.addDays(1), geo);
        talt = obj->transitAltitude(ut.addDays(1), geo);
    }

    //If set time is before rise time, use set time for tomorrow
    QTime st = obj->riseSetTime(ut, geo, false); //false = use set time
    dms saz = obj->riseSetTimeAz(ut, geo, false); //false = use set time
    if(st < rt)
    {
        st = obj->riseSetTime(ut.addDays(1), geo, false); //false = use set time
        saz = obj->riseSetTimeAz(ut.addDays( 1 ), geo, false); //false = use set time
    }

    if(rt.isValid())
    {
        rtValue = QString().sprintf("%02d:%02d", rt.hour(), rt.minute());
        stValue = QString().sprintf("%02d:%02d", st.hour(), st.minute());
        azRValue = raz.toDMSString();
        azSValue = saz.toDMSString();
    }

    else
    {
        if(obj->alt().Degrees() > 0.0)
        {
            rtValue = i18n("Circumpolar");
            stValue = i18n("Circumpolar");
        }

        else
        {
            rtValue = i18n("Never rises");
            stValue = i18n("Never rises");
        }

        azRValue = i18nc("Not Applicable", "N/A");
        azSValue = i18nc("Not Applicable", "N/A");
    }

    // Set column width constraints
    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25)
                << QTextLength(QTextLength::PercentageLength, 25);
    m_TableFormat.setColumnWidthConstraints(constraints);

    // Insert table & row containing table name
    QTextTable *table = cursor.insertTable(4, 4, m_TableFormat);
    table->mergeCells(0, 0, 1, 4);
    QTextBlockFormat centered;
    centered.setAlignment(Qt::AlignCenter);
    table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Rise/Set/Transit"), m_TableTitleCharFormat);

    // Insert cell names & values
    table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Rise time:"), m_ItemNameCharFormat);
    table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(1, 1).firstCursorPosition().insertText(rtValue, m_ItemValueCharFormat);

    table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Transit time:"), m_ItemNameCharFormat);
    table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(2, 1).firstCursorPosition().insertText(QString().sprintf("%02d:%02d", tt.hour(), tt.minute()), m_ItemValueCharFormat);

    table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Set time:"), m_ItemNameCharFormat);
    table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(3, 1).firstCursorPosition().insertText(stValue, m_ItemValueCharFormat);

    table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Azimuth at rise:"), m_ItemNameCharFormat);
    table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(1, 3).firstCursorPosition().insertText(azRValue, m_ItemValueCharFormat);

    table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Altitude at transit:"), m_ItemNameCharFormat);
    table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(2, 3).firstCursorPosition().insertText(talt.toDMSString(), m_ItemValueCharFormat);

    table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Azimuth at set:"), m_ItemNameCharFormat);
    table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
    table->cellAt(3, 3).firstCursorPosition().insertText(azSValue, m_ItemValueCharFormat);

    // Restore the position and other time-dependent parameters
    obj->recomputeCoords( ut, geo );
}