Example #1
0
QList<QStandardItem *> MainWindow::createrowinputtable(QFileInfo fileinfo)
{
    QList<QStandardItem *>listitems;
    qint64 fs;
    QString strfs;
    for(int col=0 ; col < inputmodel->columnCount() ; col++)
    {
        QStandardItem *item = new QStandardItem();
        switch(col)
        {
           case 0:item->setText(fileinfo.fileName());
                   // add logs,constellations,signals,prns
                  item->setFlags(item->flags() ^ Qt::ItemIsEditable);
                   addChildrentofile(item);
                   break;

          case 1:  fs = fileinfo.size();
                  strfs = convertintokbmbgb(fs);
                  item->setText(strfs);
                  item->setFlags(item->flags() ^ Qt::ItemIsEditable);
                  break;

          case 2: item->setFlags(item->flags() ^ Qt::ItemIsEditable); //initialize nof ascii logs
                  break;

          case 3:  item->setFlags(item->flags() ^ Qt::ItemIsEditable);// initialize no of binary logs
                    break;

          case 4: item->setFlags(item->flags() ^ Qt::ItemIsEditable);//initialize no of unkonwn logs
                  break;
        }
        listitems.append(item);
    }
    return listitems;
}
Example #2
0
void AnalysisThread::addHttpNode(const ApplicationData* pad)
{
    QStandardItem* httpitem = new QStandardItem();
    QStringList contentList = pad->strContent.split("\r\n");

    this->len = pad->strContent.size();
    setUserRoleData(httpitem);
    httpitem->setText("Hypertext Transfer Protocol");

    QStandardItem* item;

    foreach (QString contentitem, contentList)
    {
        if (contentitem == "")
        {
            continue;
        }
        item = new QStandardItem();
        contentitem += "\\r\\n";
        this->len = contentitem.size() - 2; // As \\r \\n each is two char
        item->setText(contentitem);
        setUserRoleData(item);
        httpitem->appendRow(item);
        this->offset += this->len;
    }
 
    this->model->setItem(this->irow++, 0, httpitem);   
}
void list_handling::compare_one_download(const download &new_download, const download &old_download, QStandardItem *pkg, int dl_line){
	QStandardItem *dl;

	if(old_download.id != new_download.id){
		dl = pkg->child(dl_line, 0);
		dl->setText(QString("%1").arg(new_download.id));
	}

	if(old_download.title != new_download.title){
		dl = pkg->child(dl_line, 1);
		dl->setText(QString(new_download.title.c_str()));
	}

	if(old_download.url != new_download.url){
		dl = pkg->child(dl_line, 2);
		dl->setText(QString(new_download.url.c_str()));
	}

	if((new_download.status != old_download.status) || (new_download.downloaded != old_download.downloaded) || (new_download.size != old_download.size) ||
	   (new_download.wait != old_download.wait) || (new_download.error != old_download.error) || (new_download.speed != old_download.speed)){

		string color, status_text, time_left;
		color = build_status(status_text, time_left, new_download);

		dl = pkg->child(dl_line, 3);
		dl->setText(QString(time_left.c_str()));

		string colorstring = "img/bullet_" + color + ".png";

		dl = pkg->child(dl_line, 4);
		dl->setText(QString(my_main_window->CreateQString(status_text.c_str())));
		dl->setIcon(QIcon(colorstring.c_str()));
	}
}
    foreach (QChar c, characters) {
        // Write the table entries
        QList<QStandardItem *> rowItems;
        // Character
        QStandardItem *item = new QStandardItem();
        item->setText(QString(c));
        rowItems << item;
        // Decimal number
        item = new QStandardItem();
        ushort char_number = c.unicode();
        item->setText(QString::number(char_number));
        rowItems << item;
        // Hex number
        item = new QStandardItem();
        QString hexadecimal;
        hexadecimal.setNum(char_number,16);
        item->setText(hexadecimal.toUpper());
        rowItems << item;
        // Name
        item = new QStandardItem();
        item->setText(XMLEntities::instance()->GetEntityName(char_number));
        rowItems << item;
        // Description
        item = new QStandardItem();
        item->setText(XMLEntities::instance()->GetEntityDescription(char_number));
        rowItems << item;

        for (int i = 0; i < rowItems.count(); i++) {
            rowItems[i]->setEditable(false);
        }

        m_ItemModel->appendRow(rowItems);
    }
void CommonEventsDatas::setDefaultEvent(QStandardItemModel* model,
                                        QStringList& namesEvents,
                                        QList<QVector<SystemCreateParameter*>>&
                                        parameters)
{
    QStandardItemModel* modelParameters;
    QList<QStandardItem*> row;
    SystemEvent* ev;
    QStandardItem* item;

    for (int i = 0; i < namesEvents.size(); i++){
        modelParameters = new QStandardItemModel;
        for (int j = 0; j < parameters[i].size(); j++){
            row = parameters[i][j]->getModelRow();
            modelParameters->appendRow(row);
        }
        item = new QStandardItem();
        item->setText(SuperListItem::beginningText);
        modelParameters->appendRow(item);
        ev = new SystemEvent(i+1, namesEvents[i], modelParameters);
        item = new QStandardItem;
        item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(ev)));
        item->setText(ev->toString());
        model->appendRow(item);
    }
}
Example #6
0
//==================================================
// == Set An Option
void XSettingsModel::set_option(QString option, bool enabled, QString value)
{
	//qDebug() << "set " << option << _loading;
	if(_loading){
		return;
	}
	//= Find item matching the "option"
	QList<QStandardItem *>items = findItems(option, Qt::MatchExactly,C_OPTION);
	//qDebug() << "opts" << items;

	//TODO handle error if not found
    if (items.size() == 0) {
        outLog("set_option:setx called with INVALID option ["+option+"]");
        return;
    }

	//= Get/update the "enabled" item in the same row
	QStandardItem *eItem = item(items[0]->row(),C_ENABLED);
	eItem->setText(enabled ? "1" : "0");


	//= Get/update the "value" item in the same row
	QStandardItem *vItem = item(items[0]->row(),C_VALUE);
	vItem->setText(value);

	set_row_bg(items[0]->row(), enabled ? QColor(200,255,200) : QColor(240,240,240));

	//= Announce the change
	//emit upx(option, enabled,  value);
	emit updated(get_fgfs_list());
}
Example #7
0
QStandardItemModel* Importer::ImportData()
{
    QString current_path = QDir::currentPath() +  "//" + datafilename();
    QFile file(QDir::toNativeSeparators(current_path));
    if(!file.open(QIODevice::ReadOnly)) {
        QMessageBox::information(0, tr("Ошибка"), file.errorString());
        qDebug() << "Error in open file: " + file.errorString();
    }

    QTextStream in(&file);
    in.setCodec(QTextCodec::codecForName("IBM 866"));

    QString line = in.readLine();
    QStringList fields = line.split(separator());

    QStandardItemModel *model = new QStandardItemModel(0, fields.count()+1);
    model->setHorizontalHeaderLabels(fields);

    // Заменяем заголовки столбцов
    for (int i = 0; i < model->columnCount() - 1; i++)
    {
        QStandardItem *item = model->horizontalHeaderItem(i);
        QString item_text = item->text();

        if (item_text.compare(tr("ФИОТБН")) == 0) {
            item->setText(tr("Отправитель"));
        } else if (item_text.compare(tr("Кому")) == 0) {
            item->setText(tr("Получатель"));
        }
    }
    int last_col_idx = model->columnCount() - 1;
    model->setHorizontalHeaderItem(last_col_idx, new QStandardItem(tr("Состояние")));

    model->horizontalHeaderItem(last_col_idx)->setText(tr("Состояние"));

//    model->setHorizontalHeaderItem(0, new QStandardItem(tr("ТБН")));
//    model->setHorizontalHeaderItem(1, new QStandardItem(tr("Отправитель")));
//    model->setHorizontalHeaderItem(4, new QStandardItem(tr("Получатель")));
//    model->setHorizontalHeaderItem(12, new QStandardItem(tr("Состояние")));

    while(!in.atEnd())
    {
        QString line = in.readLine();
        QStringList fields = line.split(separator());

        QStringListIterator it(fields);
        QList<QStandardItem *> data;
        while (it.hasNext())
        {
            data << new QStandardItem(it.next());
        }

        model->appendRow(data);
    }

    file.close();

    return model;
}
void CommonEventsDatas::setDefault(){
    SystemCommonReaction* react;
    SystemCommonObject* object;
    SuperListItem* super;
    QStandardItem* item;

    // Events system
    QStringList namesEventsSystem;
    namesEventsSystem << "Time" << "Chronometer" << "KeyPress" << "KeyRelease";
    QList<QVector<SystemCreateParameter*>> parametersSystem;
    parametersSystem << QVector<SystemCreateParameter*>({
            new SystemCreateParameter(1,"Interval",new PrimitiveValue(0)),
            new SystemCreateParameter(2,"Repeat",new PrimitiveValue(true))});
    parametersSystem << QVector<SystemCreateParameter*>({
            new SystemCreateParameter(1,"Left",new PrimitiveValue(0))});
    parametersSystem << QVector<SystemCreateParameter*>({
            new SystemCreateParameter(1,"ID",new PrimitiveValue),
            new SystemCreateParameter(2,"Repeat",new PrimitiveValue(false)),
            new SystemCreateParameter(3,"Immediate Repeat",
                                      new PrimitiveValue(false))});
    parametersSystem << QVector<SystemCreateParameter*>({
            new SystemCreateParameter(1,"ID",new PrimitiveValue)});
    setDefaultEvent(m_modelEventsSystem, namesEventsSystem, parametersSystem);

    // Events user
    QStringList namesEventsUser;
    namesEventsUser << "Hero action";
    QList<QVector<SystemCreateParameter*>> parametersUser;
    parametersUser << QVector<SystemCreateParameter*>({});
    setDefaultEvent(m_modelEventsUser, namesEventsUser, parametersUser);

    // States
    super = new SuperListItem(1, "Normal");
    item = new QStandardItem;
    item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(super)));
    item->setText(super->toString());
    m_modelStates->appendRow(item);

    // Common reactors
    react = new SystemCommonReaction;
    item = new QStandardItem;
    item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(react)));
    item->setText(react->toString());
    m_modelCommonReactors->appendRow(item);

    // Common objects
    object = new SystemCommonObject;
    object->setDefaultFirst();
    item = new QStandardItem;
    item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(object)));
    item->setText(object->toString());
    m_modelCommonObjects->appendRow(item);
    object = new SystemCommonObject;
    object->setDefaultHero(m_modelEventsSystem, m_modelEventsUser);
    item = new QStandardItem;
    item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(object)));
    item->setText(object->toString());
    m_modelCommonObjects->appendRow(item);
}
Example #9
0
void  ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
                            const QIcon &defaultIcon,
                            QStandardItemList &sl)
{

    // Tooltip, mostly for icon view mode
    QString firstTooltip = action->objectName();
    const QString text = action->text();
    if (!text.isEmpty()) {
        firstTooltip += QLatin1Char('\n');
        firstTooltip += text;
    }

    Q_ASSERT(sl.size() == NumColumns);

    QStandardItem *item =  sl[NameColumn];
    item->setText(action->objectName());
    QIcon icon = action->icon();
    if (icon.isNull())
        icon = defaultIcon;
    item->setIcon(icon);
    item->setToolTip(firstTooltip);
    item->setWhatsThis(firstTooltip);
    // Used
    const QWidgetList associatedDesignerWidgets = associatedWidgets(action);
    const bool used = !associatedDesignerWidgets.empty();
    item = sl[UsedColumn];
    item->setCheckState(used ? Qt::Checked : Qt::Unchecked);
    if (used) {
        QString usedToolTip;
        const QString separator = QLatin1String(", ");
        const int count = associatedDesignerWidgets.size();
        for (int i = 0; i < count; i++) {
            if (i)
                usedToolTip += separator;
            usedToolTip += associatedDesignerWidgets.at(i)->objectName();
        }
        item->setToolTip(usedToolTip);
    } else {
        item->setToolTip(QString());
    }
    // text
    item = sl[TextColumn];
    item->setText(action->text());
    item->setToolTip(action->text());
    // shortcut
    const QString shortcut = actionShortCut(core, action).value().toString(QKeySequence::NativeText);
    item = sl[ShortCutColumn];
    item->setText(shortcut);
    item->setToolTip(shortcut);
    // checkable
    sl[CheckedColumn]->setCheckState(action->isCheckable() ?  Qt::Checked : Qt::Unchecked);
    // ToolTip. This might be multi-line, rich text
    QString toolTip = action->toolTip();
    item = sl[ToolTipColumn];
    item->setToolTip(toolTip);
    item->setText(toolTip.replace(QLatin1Char('\n'), QLatin1Char(' ')));
}
	AcceptRIEXDialog::AcceptRIEXDialog (const QList<RIEXItem>& items,
			QObject *entryObj, QString message, QWidget *parent)
	: QDialog (parent)
	, Model_ (new QStandardItemModel (this))
	{
		Ui_.setupUi (this);

		Model_->setHorizontalHeaderLabels ({ tr ("Action"), tr ("ID"), tr ("Name"), tr ("Groups") });

		for (const RIEXItem& item : items)
		{
			QList<QStandardItem*> row;

			QStandardItem *action = new QStandardItem;
			action->setCheckState (Qt::Checked);
			action->setCheckable (true);
			switch (item.Action_)
			{
			case RIEXItem::AAdd:
				action->setText (tr ("add"));
				break;
			case RIEXItem::ADelete:
				action->setText (tr ("delete"));
				break;
			case RIEXItem::AModify:
				action->setText (tr ("modify"));
				break;
			default:
				action->setText (tr ("(unknown)"));
				break;
			}

			action->setData (QVariant::fromValue<RIEXItem> (item));

			row << action;
			row << new QStandardItem (item.ID_);
			row << new QStandardItem (item.Nick_);
			row << new QStandardItem (item.Groups_.join ("; "));

			Model_->appendRow (row);
		}

		Ui_.ItemsTree_->setModel (Model_);

		ICLEntry *entry = qobject_cast<ICLEntry*> (entryObj);
		const QString& id = entry->GetEntryName ().isEmpty () ?
				entry->GetHumanReadableID () :
				entry->GetEntryName () + " (" + entry->GetHumanReadableID () + ")";

		const QString& text = message.isEmpty () ?
				tr ("%1 has suggested to modify your contact list:")
					.arg (id) :
				tr ("%1 has suggested to modify your contact list:\n%2")
					.arg (id)
					.arg (message);
		Ui_.MessageLabel_->setText (text);
	}
Example #11
0
void MainWindow::on_setGPLogDir(QString dirname)
{
    if ( dirname.isEmpty() )
    {
        qDebug() << "No dir is selected \n Using Current Directory";
        _strLogDir = QDir::currentPath();
    }
    else
    {
        _strLogDir = dirname;
    }

    qDebug() << "Directory " << _strLogDir << " selected";

    // clear old model
    _modelGenerations->clear();

    // initialize view header
    QStringList generationList;
    generationList.append("generation milestone");
    _modelGenerations->setHorizontalHeaderLabels(generationList);

    QDir qDir(_strLogDir);
    QStringList filters;

    // set generations' files
    // get the largest generation
    filters << "beagle_g?.obm";
    QStringList entries = qDir.entryList(filters);
    for( int i = 0; i < entries.size(); i++ ) {
        QStandardItem * item = new QStandardItem;
        item->setText(entries.at(i));
        _modelGenerations->appendRow(item);
    }

    filters.clear();
    filters << "beagle_g??.obm";
    entries = qDir.entryList(filters);
    for( int i = 0; i < entries.size(); i++ ) {
        QStandardItem * item = new QStandardItem;
        item->setText(entries.at(i));
        _modelGenerations->appendRow(item);
    }

    filters.clear();
    filters << "beagle_g???.obm";
    entries = qDir.entryList(filters);
    for( int i = 0; i < entries.size(); i++ ) {
        QStandardItem * item = new QStandardItem;
        item->setText(entries.at(i));
        _modelGenerations->appendRow(item);
    }

    // set log file
    //setLogFile(_strLogDir + "/beagle.log");
}
Example #12
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    CameraAbilities a;
    int size,r;
    ui->setupUi(this);

    QStandardItemModel *model = new QStandardItemModel(this);

    model->setHorizontalHeaderItem(0, new QStandardItem(QString("Camera")));
    model->setHorizontalHeaderItem(1, new QStandardItem(QString("Comment")));
    ui->tableView->setModel(model);

    GPContext* context = gp_context_new();
    CameraAbilitiesList* list;

    gp_abilities_list_new(&list);
    gp_abilities_list_load(list, context);

    size = gp_abilities_list_count(list);
    for(int i= 0; i < size; i++)
    {
        r = gp_abilities_list_get_abilities(list, i, &a);
        if( r < 0 ) break;
        QStandardItem* cam = new QStandardItem(QString(a.model));
        model->setItem(i,0, cam);

        QStandardItem* com = new QStandardItem();
        switch (a.status)
        {
        case GP_DRIVER_STATUS_TESTING:
            com->setText(QString("TESTING"));
            break;
        case GP_DRIVER_STATUS_EXPERIMENTAL:
             com->setText(QString("EXPERIMENTAL"));
            break;
        case GP_DRIVER_STATUS_DEPRECATED:
            com->setText(QString("DEPRECATED"));
            break;
        case GP_DRIVER_STATUS_PRODUCTION:
            break;
        default:
            com->setText(QString("UNKOWN"));
            break;
        }
        model->setItem(i,1, com);
    }

    gp_abilities_list_free(list);
    list = NULL;
    gp_context_unref(context);
    context = NULL;


}
void CntImageEditorView::populateModel(QStandardItemModel *model)
{
    QStandardItem *newPhoto = new QStandardItem();
    newPhoto->setText(hbTrId("txt_phob_list_take_a_new_photo"));
    newPhoto->setData(HbIcon("qtg_large_camera"), Qt::DecorationRole);
    model->appendRow(newPhoto);
    
    QStandardItem *fromGallery = new QStandardItem();
    fromGallery->setText(hbTrId("txt_phob_list_chooce_from_gallery"));
    fromGallery->setData(HbIcon("qtg_large_photos"), Qt::DecorationRole);
    model->appendRow(fromGallery);
}
Example #14
0
void updateModel(QStandardItem* parentItem, ReflectableClass& object, Node* node, const std::string& propertyPrefix = "") {
  vector<IClassProperty*> properties = object.getProperties();

  for (unsigned i = 0, gridPos = 0; i < properties.size(); ++i) {
    if (properties[i]->getAttribute<HideAttribute>())
      continue;

    QStandardItem* value = parentItem->child(gridPos, 1);
    if (!value) {

      string keyName = properties[i]->getName();
      ShortNameAttribute* shortName = properties[i]->getAttribute<ShortNameAttribute>();
      if (shortName)
        keyName = keyName + " (" + shortName->getName() + ")";
      QStandardItem* key = new QStandardItem(keyName.c_str());
      value = new QStandardItem();
      parentItem->setChild(gridPos, 0, key);
      parentItem->setChild(gridPos, 1, value);
    }

    IReflectableAttribute* reflectable = properties[i]->getAttribute<IReflectableAttribute>();
    if (reflectable) {
      ReflectableClass* subObject = reflectable->getValuePtr(object, properties[i]);

      // If the type of the reflectable object has changed, the subtree needs to be rebuild.
      // You need to know the previous type in order to detect a change. ScalarAttributes are
      // no longer supported in order to guarantee, that the string value is always set to the
      // previous type name.
      if (subObject) {
        std::string oldClassName(value->text().toStdString());
        if (oldClassName.compare(subObject->getClassName())) {
          value->setText(subObject->getClassName().c_str());
          buildModel(parentItem->child(gridPos, 0), subObject, node, propertyPrefix + properties[i]->getName() + ".");
        } else {
          updateModel(parentItem->child(gridPos, 0), *subObject, node, propertyPrefix + properties[i]->getName() + ".");
        }
      } else {
        value->setText(properties[i]->getStringValue(object).c_str());
      }
    } else if (properties[i]->getAttribute<FlagAttribute>()) {
      ClassProperty<bool>* boolProperty = dynamic_cast<ClassProperty<bool>* >(properties[i]);
      // properties tagged as Flag() must be of type bool
      assert(boolProperty);
      if (boolProperty->getValue(object))
        value->setCheckState(Qt::Checked);
      else
        value->setCheckState(Qt::Unchecked);
    } else{
      value->setText(properties[i]->getStringValue(object).c_str());
    }
    ++gridPos;
  }
}
QList<QStandardItem *> SystemMonsterTroop::getModelRow() const{
    QList<QStandardItem*> row = QList<QStandardItem*>();
    QStandardItem* itemID = new QStandardItem;
    QStandardItem* itemLevel = new QStandardItem;
    itemID->setData(QVariant::fromValue(reinterpret_cast<quintptr>(this)));
    itemID->setText(toString());
    itemLevel->setText(QString::number(m_level));
    row.append(itemID);
    row.append(itemLevel);

    return row;
}
Example #16
0
/* 
  Update the contents for the message pointed to by 'msg', if it's in the
  model, otherwise ignore the request.  Currently the contents are the
  status (icon) and the priority. Other changes such as in the subject
  or the date could be visually reflected by this function if the UI
  permitted those changes.
*/
void
mail_item_model::update_msg(const mail_msg* msg)
{
  DBG_PRINTF(4, "update_msg of " MAIL_ID_FMT_STRING, msg->get_id());
  QStandardItem* item=item_from_id(msg->get_id());
  if (!item)
    return;
  QModelIndex index=item->index();
  QStandardItem* isubject = itemFromIndex(index);
  bool bold=isubject->font().bold();
  DBG_PRINTF(5, "mail_id=" MAIL_ID_FMT_STRING ", status=%d, bold=%d",
	     msg->get_id(), msg->status(), bold);
  if ((msg->status()!=0 && bold) || (msg->status()==0 && !bold)) {
    // reverse bold attribute
    QFont f=isubject->font();
    f.setBold(!bold);
    isubject->setFont(f);
    itemFromIndex(index.sibling(index.row(), column_sender))->setFont(f);
    itemFromIndex(index.sibling(index.row(), column_date))->setFont(f);
    itemFromIndex(index.sibling(index.row(), column_pri))->setFont(f);
    itemFromIndex(index.sibling(index.row(), column_recipient))->setFont(f);
  }

  // status icon
  QIcon* icon = icon_status(msg->status());
  QStandardItem* istatus = itemFromIndex(index.sibling(index.row(), column_status));
  if (istatus) {
    if (icon)
      istatus->setIcon(*icon);
    else
      istatus->setIcon(QIcon());
  }

  // priority
  QStandardItem* ipri = itemFromIndex(index.sibling(index.row(), column_pri));
  if (ipri) {
    if (msg->priority()!=0)
      ipri->setText(QString("%1").arg(msg->priority()));
    else
      ipri->setText("");
  }

  // note
  QStandardItem* inote = itemFromIndex(index.sibling(index.row(), column_note));
  if (inote) {
    inote->setData(msg->has_note());
    if (msg->has_note())
      inote->setIcon(STATUS_ICON(FT_ICON16_EDIT_NOTE));
    else
      inote->setIcon(QIcon());
  }

}
Example #17
0
void AllFilesWidget::SetupTable(int sort_column, Qt::SortOrder sort_order)
{
    m_ItemModel->clear();
    QStringList header;
    header.append(tr("Directory"));
    header.append(tr("Name"));
    header.append(tr("File Size (KB)"));
    header.append(tr("Type"));
    header.append(tr("Semantics"));
    m_ItemModel->setHorizontalHeaderLabels(header);
    ui.fileTree->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui.fileTree->setModel(m_ItemModel);
    ui.fileTree->header()->setSortIndicatorShown(true);
    double total_size = 0;
    QString main_folder = m_Book->GetFolderKeeper()->GetFullPathToMainFolder();
    foreach(Resource *resource, m_AllResources) {
        QString fullpath = resource->GetFullPath();
        QString filepath = resource->GetRelativePath();
        QString directory = resource->GetFolder();
        QString filename = resource->Filename();
        QList<QStandardItem *> rowItems;
        QStandardItem *item;
        // Directory
        item = new QStandardItem();
        item->setText(directory);
        rowItems << item;
        // Filename
        item = new QStandardItem();
        item->setText(filename);
        item->setToolTip(filepath);
        rowItems << item;
        // File Size
        double ffsize = QFile(fullpath).size() / 1024.0;
        total_size += ffsize;
        QString fsize = QString::number(ffsize, 'f', 2);
        NumericItem *size_item = new NumericItem();
        size_item->setText(fsize);
        rowItems << size_item;
        // Type
        item = new QStandardItem();
        item ->setText(GetType(resource));
        rowItems << item;
        // Semantics
        item = new QStandardItem();
        item->setText(m_Book->GetOPF()->GetGuideSemanticNameForResource(resource));
        rowItems << item;

        // Add item to table
        m_ItemModel->appendRow(rowItems);
        for (int i = 0; i < rowItems.count(); i++) {
            rowItems[i]->setEditable(false);
        }
    }
Example #18
0
QStandardItem *TextDocumentModel::formatItem(const QTextFormat &format)
{
  QStandardItem *item = new QStandardItem;
  if (!format.isValid()) {
    item->setText(tr("no format"));
  } else if (format.isImageFormat()) {
    const QTextImageFormat imgformat = format.toImageFormat();
    item->setText(tr("Image: %1").arg(imgformat.name()));
  } else {
    item->setText(tr("Format type: %1").arg(format.type()));
  }
  return item;
}
Example #19
0
SystemClass::SystemClass(int i, LangsTranslation *names, int initialLevel, int
    maxLevel, int expBase, int expInflation) :
    SystemClass(i, names, initialLevel, maxLevel, expBase, expInflation, new
        QStandardItemModel, new QStandardItemModel)
{
    QStandardItem* item;
    item = new QStandardItem();
    item->setText(SuperListItem::beginningText);
    m_statisticsProgression->appendRow(item);
    item = new QStandardItem();
    item->setText(SuperListItem::beginningText);
    m_skills->appendRow(item);
}
Example #20
0
CTrackList::CTrackList(QWidget *parent, double tz) :
  QDialog(parent),
  ui(new Ui::CTrackList)
{
  ui->setupUi(this);
  setWindowFlags(((windowFlags() | Qt::CustomizeWindowHint)
                    & ~Qt::WindowCloseButtonHint));

  QStandardItemModel *model = new QStandardItemModel(0, 4);

  model->setHeaderData(0, Qt::Horizontal, tr("Name"));
  model->setHeaderData(1, Qt::Horizontal, tr("From"));
  model->setHeaderData(2, Qt::Horizontal, tr("To"));
  model->setHeaderData(3, Qt::Horizontal, tr("Steps"));

  for (int i = 0; i < tTracking.count(); i++)
  {
    QStandardItem *item = new QStandardItem;
    item->setText(tTracking[i].objName);
    item->setCheckable(true);
    if (tTracking[i].show)
    {
      item->setCheckState(Qt::Checked);
    }
    model->setItem(i, 0, item);

    item = new QStandardItem;
    item->setText(getStrDate(tTracking[i].jdFrom, tz) + " " + getStrTime(tTracking[i].jdFrom, tz, true));
    model->setItem(i, 1, item);

    item = new QStandardItem;
    item->setText(getStrDate(tTracking[i].jdTo, tz) + " " + getStrTime(tTracking[i].jdTo, tz, true));
    model->setItem(i, 2, item);

    item = new QStandardItem;
    item->setText(QString::number(tTracking[i].tPos.count()));
    model->setItem(i, 3, item);
  }

  ui->treeView->setModel(model);
  ui->treeView->setRootIsDecorated(false);
  ui->treeView->header()->resizeSection(0, 100);
  ui->treeView->header()->resizeSection(1, 120);
  ui->treeView->header()->resizeSection(2, 120);
  ui->treeView->header()->resizeSection(3, 60);

  QShortcut *sh1 = new QShortcut(QKeySequence(Qt::Key_Delete), ui->treeView, 0, 0,  Qt::WidgetShortcut);
  connect(sh1, SIGNAL(activated()), this, SLOT(slotDeleteItem()));
}
Example #21
0
void tst_QStandardItem::clone()
{
    QStandardItem item;
    item.setText(QLatin1String("text"));
    item.setToolTip(QLatin1String("toolTip"));
    item.setStatusTip(QLatin1String("statusTip"));
    item.setWhatsThis(QLatin1String("whatsThis"));
    item.setSizeHint(QSize(64, 48));
    item.setFont(QFont());
    item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    item.setBackground(QColor(Qt::blue));
    item.setForeground(QColor(Qt::green));
    item.setCheckState(Qt::PartiallyChecked);
    item.setAccessibleText(QLatin1String("accessibleText"));
    item.setAccessibleDescription(QLatin1String("accessibleDescription"));
    item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);

    QStandardItem *clone = item.clone();
    QCOMPARE(clone->text(), item.text());
    QCOMPARE(clone->toolTip(), item.toolTip());
    QCOMPARE(clone->statusTip(), item.statusTip());
    QCOMPARE(clone->whatsThis(), item.whatsThis());
    QCOMPARE(clone->sizeHint(), item.sizeHint());
    QCOMPARE(clone->font(), item.font());
    QCOMPARE(clone->textAlignment(), item.textAlignment());
    QCOMPARE(clone->background(), item.background());
    QCOMPARE(clone->foreground(), item.foreground());
    QCOMPARE(clone->checkState(), item.checkState());
    QCOMPARE(clone->accessibleText(), item.accessibleText());
    QCOMPARE(clone->accessibleDescription(), item.accessibleDescription());
    QCOMPARE(clone->flags(), item.flags());
    QVERIFY(!(*clone < item));
    delete clone;
}
void QgsSymbolV2SelectorDialog::populateSymbolView()
{
  QSize previewSize = viewSymbols->iconSize();
  QPixmap p( previewSize );
  QPainter painter;

  QStandardItemModel* model = qobject_cast<QStandardItemModel*>( viewSymbols->model() );
  if ( !model )
  {
    return;
  }
  model->clear();

  QStringList names = mStyle->symbolNames();
  for ( int i = 0; i < names.count(); i++ )
  {
    QgsSymbolV2* s = mStyle->symbol( names[i] );
    if ( s->type() != mSymbol->type() )
    {
      delete s;
      continue;
    }
    QStandardItem* item = new QStandardItem( names[i] );
    item->setData( names[i], Qt::UserRole ); //so we can show a label when it is clicked
    item->setText( "" ); //set the text to nothing and show in label when clicked rather
    item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
    // create preview icon
    QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( s, previewSize );
    item->setIcon( icon );
    // add to model
    model->appendRow( item );
    delete s;
  }
}
Example #23
0
void BookmarkList::dropEvent(QDropEvent *event)
{
	const QMimeData* data = event->mimeData();
	if(data->hasUrls())
	{
		//TODO: Add insert to the dropped row, except row 0
		QStandardItemModel* mod = (QStandardItemModel*)model();
		QString path = data->urls()[0].path(); 
		QFileInfo f(path);
		if(mod)
		{
			QList<QStandardItem*> items = mod->findItems(f.fileName());
			if(f.isDir() && items.isEmpty())
			{
				QStandardItem *it = new QStandardItem();
				it->setText(f.fileName());
				it->setData(path);
#if QT_VERSION >= 0x040600
				// Todo: Use a "favorites folder" icon instead
				it->setIcon(*globalIcon);
#else
				it->setIcon(QIcon(":/images/icons/clip-folder-bookmark.png"));
#endif	
				it->setDropEnabled(true);
				mod->appendRow(it);
				emit bookmarkAdded();
			}
		}
	}
	event->acceptProposedAction();
}
Example #24
0
void AlbumCoverSearcher::SearchFinished(quint64 id,
                                        const CoverSearchResults& results) {
  if (id != id_) return;

  ui_->search->setEnabled(true);
  ui_->artist->setEnabled(true);
  ui_->album->setEnabled(true);
  ui_->covers->setEnabled(true);
  ui_->search->setText(tr("Search"));
  id_ = 0;

  for (const CoverSearchResult& result : results) {
    if (result.image_url.isEmpty()) continue;

    quint64 id = app_->album_cover_loader()->LoadImageAsync(
        options_, result.image_url.toString(), QString());

    QStandardItem* item = new QStandardItem;
    item->setIcon(no_cover_icon_);
    item->setText(result.description);
    item->setData(result.image_url, Role_ImageURL);
    item->setData(id, Role_ImageRequestId);
    item->setData(false, Role_ImageFetchFinished);
    item->setData(QVariant(Qt::AlignTop | Qt::AlignHCenter),
                  Qt::TextAlignmentRole);
    item->setData(result.provider, GroupedIconView::Role_Group);

    model_->appendRow(item);

    cover_loading_tasks_[id] = item;
  }

  if (cover_loading_tasks_.isEmpty()) ui_->busy->hide();
}
Example #25
0
CEphTable::CEphTable(QWidget *parent, QString name, QStringList header, QList<tableRow_t> row) :
  QDialog(parent),
  ui(new Ui::CEphTable)
{
  ui->setupUi(this);

  m_name = name;
  setWindowTitle(tr("Ephemerides of ") + name);

  QStandardItemModel *m = new QStandardItemModel(0, header.count());

  for (int i = 0; i < header.count(); i++)
  {
    m->setHeaderData(i, Qt::Horizontal, header[i]);
  }

  for (int i = 0; i < row.count(); i++)
  {
    QList <QStandardItem *> items;

    for (int j = 0; j < row[i].row.count(); j++)
    {
      QStandardItem *itm = new QStandardItem;

      itm->setText(row[i].row[j]);

      items.append(itm);
    }

    m->appendRow(items);
  }

  ui->tableView->setModel(m);
}
Example #26
0
void MessagesModel::addMessage(const QString &id, const QString &parentId, const QString &subject, const QString &from, const QDateTime &received, bool read)
{
    QStandardItem *stdItem = findItem(id);
    if (stdItem) {
        return;
    }

    QList<QStandardItem*> items;
    stdItem = new QStandardItem;
    QFont font = stdItem->font();
    font.setBold(true);
    if (!read) {
        stdItem->setFont(font);
    }
    stdItem->setText(from);
    stdItem->setData(id, RoleMessageId);
    stdItem->setData(parentId, RoleParentFolderId);
    items << stdItem;

    stdItem = new QStandardItem(subject);
    if (!read) {
        stdItem->setFont(font);
    }
    items << stdItem;

    stdItem = new QStandardItem;
    if (!read) {
        stdItem->setFont(font);
    }
    stdItem->setData(received, Qt::DisplayRole);
    items << stdItem;

    appendRow(items);
}
Example #27
0
void LocationCompleter::addSuggestions(const QStringList &suggestions)
{
    const auto suggestionItems = s_model->suggestionItems();

    // Delete existing suggestions
    for (QStandardItem *item : suggestionItems) {
        s_model->takeRow(item->row());
        delete item;
    }

    // Add new suggestions
    QList<QStandardItem*> items;
    for (const QString &suggestion : suggestions) {
        QStandardItem* item = new QStandardItem();
        item->setText(suggestion);
        item->setData(suggestion, LocationCompleterModel::TitleRole);
        item->setData(suggestion, LocationCompleterModel::UrlRole);
        item->setData(m_suggestionsTerm, LocationCompleterModel::SearchStringRole);
        item->setData(true, LocationCompleterModel::SearchSuggestionRole);
        items.append(item);
    }

    s_model->addCompletions(items);
    m_oldSuggestions = suggestions;

    if (!m_popupClosed) {
        showPopup();
    }
}
Example #28
0
CompletionMenu * AutoCompleter::menuForClassMethodCompletion(CompletionDescription const & completion,
                                                             ScCodeEditor * editor)
{
    using namespace ScLanguage;
    const Introspection & introspection = Main::scProcess()->introspection();

    const Class *klass = NULL;

    switch (completion.tokenType) {
    case Token::Float:
    case Token::RadixFloat:
    case Token::HexInt:
        // Only show completion if at least 1 character after dot
        if(!completion.base.contains(".") && completion.text.isEmpty())
            return NULL;
    default:;
    }

    klass = classForToken(completion.tokenType, completion.base);

    if (klass == NULL) {
        qDebug() << "Autocompletion not implemented for" << completion.base;
        return NULL;
    }

    QMap<QString, const Method*> methodMap; // for quick lookup
    QList<const Method*> methodList; // to keep order by class hierarchy
    do {
        foreach (const Method * method, klass->methods)
        {
            QString methodName = method->name.get();

            // Operators are also methods, but are not valid in
            // a method call syntax, so filter them out.
            Q_ASSERT(!methodName.isEmpty());
            if (!methodName[0].isLetter())
                continue;

            if (methodMap.value(methodName) != 0)
                continue;

            methodMap.insert(methodName, method);
            methodList.append(method);
        }
        klass = klass->superClass;
    } while (klass);

    CompletionMenu * menu = new CompletionMenu(editor);
    menu->setCompletionRole(CompletionMenu::CompletionRole);

    foreach(const Method *method, methodList) {
        QString methodName = method->name.get();
        QString detail(" [ %1 ]");

        QStandardItem *item = new QStandardItem();
        item->setText( methodName + detail.arg(method->ownerClass->name) );
        item->setData( QVariant::fromValue(method), CompletionMenu::MethodRole );
        item->setData( methodName, CompletionMenu::CompletionRole );
        menu->addItem(item);
    }
Example #29
0
// -------- QTestFunction
void QTestFunction::addIncident(IncidentType type,
                                const QString &file,
                                const QString &line,
                                const QString &details)
{
    QStandardItem *status = new QStandardItem(incidentString(type));
    status->setData(QVariant::fromValue(type));

    switch (type) {
        case QTestFunction::Pass: status->setForeground(Qt::green); break;
        case QTestFunction::Fail: status->setForeground(Qt::red); break;
        case QTestFunction::XFail: status->setForeground(Qt::darkMagenta); break;
        case QTestFunction::XPass: status->setForeground(Qt::darkGreen); break;
    }

    QStandardItem *location = new QStandardItem;
    if (!file.isEmpty()) {
        location->setText(file + QLatin1Char(':') + line);
        location->setForeground(Qt::red);

        QTestLocation loc;
        loc.file = file;
        loc.line = line;
        location->setData(QVariant::fromValue(loc));
    }

    appendRow(QList<QStandardItem *>() << status << location);

    if (!details.isEmpty()) {
        status->setColumnCount(2);
        status->appendRow(QList<QStandardItem *>() << new QStandardItem() << new QStandardItem(details));
    }
}
Example #30
0
void TreeView::showExample2(void)
{
    this->setColumn(4, 100, QStringLiteral("Abnormal sensor"), QStringLiteral("state"));

    for(int i = 0; i < 10; ++i)
    {
        QList<QStandardItem *>  leve2;
        QStandardItem * item = new QStandardItem(QString("GRPS_%0").arg(i));
        item->setCheckable(1);//使能复选框
        item->setIcon(QIcon(":/image/Aqua Ball Red.ico"));
        item->setText(QString("%0").arg(i));
        leve2.append(item);
        for(int i = 1; i < 4; ++i)
       {
           QStandardItem * item = new QStandardItem(QString("state_%0").arg(i));
           leve2.append(item);
       }

        mode->appendRow(leve2);

    }

   // ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);//设置多选
    this->setEditTriggers(0);//取消双击修改
   this->setContextMenuPolicy(Qt::CustomContextMenu);//设置treeView右键单击产生相应信号,并设置连接
}