Пример #1
0
/** Constructor */
NetworkDialog::NetworkDialog(QWidget *parent)
: MainPage(parent), connectdialog(NULL)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.connecttreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) );

  /* create a single connect dialog */
  connectdialog = new ConnectDialog();
  
  connect(ui.infoLog, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoLogMenu(const QPoint&)));
  
  /* hide the Tree +/- */
  ui.connecttreeWidget -> setRootIsDecorated( false );
  
  /* Set header resize modes and initial section sizes */
	QHeaderView * _header = ui.connecttreeWidget->header () ;   
	_header->setResizeMode (0, QHeaderView::Custom);
	_header->setResizeMode (1, QHeaderView::Interactive);
	_header->setResizeMode (2, QHeaderView::Interactive);
	_header->setResizeMode (3, QHeaderView::Interactive);
	_header->setResizeMode (4, QHeaderView::Interactive);
	_header->setResizeMode (5, QHeaderView::Interactive);
	_header->setResizeMode (6, QHeaderView::Interactive);
	_header->setResizeMode (7, QHeaderView::Interactive);
	_header->setResizeMode (8, QHeaderView::Interactive);
	_header->setResizeMode (9, QHeaderView::Interactive);
    
	_header->resizeSection ( 0, 25 );
	_header->resizeSection ( 1, 100 );
	_header->resizeSection ( 2, 100 );
	_header->resizeSection ( 3, 100 );
	_header->resizeSection ( 4, 100 );
	_header->resizeSection ( 5, 200);
	_header->resizeSection ( 6, 100 );
	_header->resizeSection ( 7, 100 );
	_header->resizeSection ( 8, 100 );
	_header->resizeSection ( 9, 100 );
	
	// set header text aligment
	QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem();
	headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
  headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(4, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(5, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(6, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(7, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(8, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(9, Qt::AlignHCenter | Qt::AlignVCenter);
	
	/*networkview = new NetworkView(ui.networkviewTab);
	QVBoxLayout *layout = new QVBoxLayout;
	layout->addWidget(networkview);
	ui.networkviewTab->setLayout(layout);
	layout->setSpacing( 0 );
	layout->setMargin( 0 );*/

  ui.networkTab->addTab(new NetworkView(),QString(tr("Network View")));
	ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix")));
     
    // Set Log infos
    setLogInfo(tr("RetroShare %1 started.", "e.g: RetroShare v0.x started.").arg(retroshareVersion()));
    
    setLogInfo(tr("Welcome to RetroShare."), QString::fromUtf8("blue"));
      
    QMenu *menu = new QMenu(tr("View"));
    menu->addAction(ui.actionTabsright); 
    menu->addAction(ui.actionTabswest);
    menu->addAction(ui.actionTabssouth); 
    menu->addAction(ui.actionTabsnorth);
    menu->addSeparator();
    menu->addAction(ui.actionTabsTriangular); 
    menu->addAction(ui.actionTabsRounded);
    ui.viewButton->setMenu(menu);
    
    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(getNetworkStatus()));
    timer->start(100000);
    
    QTimer *timer2 = new QTimer(this);
    timer2->connect(timer, SIGNAL(timeout()), this, SLOT(updateNetworkStatus()));
    timer2->start(1000);
    
    getNetworkStatus();
    updateNetworkStatus();
    //load();
    

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
Пример #2
0
void RoutePresenter::show()
{
    m_treeWidget->clear();

    QTreeWidgetItem* requestTop = new QTreeWidgetItem(m_treeWidget);
    requestTop->setText(0, "request");

    QTreeWidgetItem* modesItem = new QTreeWidgetItem(requestTop);
    modesItem->setText(0, "modes");
    showModes(modesItem, m_routeReply->request(), m_routeReply->request().travelModes());

    QTreeWidgetItem* waypointsItem = new QTreeWidgetItem(requestTop);
    waypointsItem->setText(0, "waypoints");
    waypointsItem->setText(1, QString().setNum(m_routeReply->request().waypoints().length()));
    showPoints(waypointsItem, m_routeReply->request().waypoints());

    QTreeWidgetItem* excludesItem = new QTreeWidgetItem(requestTop);
    excludesItem->setText(0, "exclude areas");
    excludesItem->setText(1, QString().setNum(m_routeReply->request().excludeAreas().length()));
    for (int i = 0; i < m_routeReply->request().excludeAreas().length(); ++i)
        showBoundingBox(excludesItem, m_routeReply->request().excludeAreas().at(i));

    QTreeWidgetItem* alternativesItem = new QTreeWidgetItem(requestTop);
    alternativesItem->setText(0, "alternatives");
    alternativesItem->setText(1, QString().setNum(m_routeReply->request().numberAlternativeRoutes()));

    showRoutes();
}
Пример #3
0
void ByteViewTab::protoTreeItemChanged(QTreeWidgetItem *current) {
    if (current && cap_file_) {
        field_info *fi;

        fi = current->data(0, Qt::UserRole).value<field_info *>();

        int i = 0;
        ByteViewText *byte_view_text = qobject_cast<ByteViewText*>(widget(i));
        while (byte_view_text) {
            if (byte_view_text->hasDataSource(fi->ds_tvb)) {
                QTreeWidgetItem *parent = current->parent();
                field_info *parent_fi = NULL;
                int f_start = -1, f_end = -1, f_len = -1;
                guint32 bmask = 0x00;
                int fa_start = -1, fa_end = -1, fa_len = -1;
                int p_start = -1, p_end = -1, p_len = -1;
                guint len = tvb_length(fi->ds_tvb);

                // Find and highlight the protocol bytes
                while (parent && parent->parent()) {
                    parent = parent->parent();
                }
                if (parent) {
                    parent_fi = parent->data(0, Qt::UserRole).value<field_info *>();
                }
                if (parent_fi && parent_fi->ds_tvb == fi->ds_tvb) {
                    p_start = parent_fi->start;
                    p_len = parent_fi->length;
                }

                if (cap_file_->search_in_progress && (cap_file_->hex || (cap_file_->string && cap_file_->packet_data))) {
                    /* In the hex view, only highlight the target bytes or string. The entire
                       field can then be displayed by clicking on any of the bytes in the field. */
                    if (cap_file_->hex) {
                        f_len = (int)strlen(cap_file_->sfilter)/2;
                    } else {
                        f_len = (int)strlen(cap_file_->sfilter);
                    }
                    f_start = cap_file_->search_pos - (f_len-1);
                } else {
                    f_start = fi->start;
                    f_len = fi->length;
                }

                /* bmask = finfo->hfinfo->bitmask << finfo->hfinfo->bitshift; */ /* (value & mask) >> shift */
                if (fi->hfinfo) bmask = fi->hfinfo->bitmask;
                fa_start = fi->appendix_start;
                fa_len = fi->appendix_length;

                if (!FI_GET_FLAG(fi, FI_LITTLE_ENDIAN) &&
                    !FI_GET_FLAG(fi, FI_BIG_ENDIAN)) {
                    /* unknown endianess - disable mask */
                    bmask = 0x00;
                }

                if (bmask == 0x00) {
                    int bito = FI_GET_BITS_OFFSET(fi);
                    int bitc = FI_GET_BITS_SIZE(fi);
                    int bitt = bito + bitc;

                    /* construct mask using bito & bitc */
                    /* XXX, mask has only 32 bit, later we can store bito&bitc, and use them (which should be faster) */
                    if (bitt > 0 && bitt < 32) {

                        bmask = ((1 << bitc) - 1) << ((8-bitt) & 7);
                    }
                }

                if (p_start >= 0 && p_len > 0 && (guint)p_start < len) {
                    p_end = p_start + p_len;
                }
                if (f_start >= 0 && f_len > 0 && (guint)f_start < len) {
                    f_end = f_start + f_len;
                }
                if (fa_start >= 0 && fa_len > 0 && (guint)fa_start < len) {
                    fa_end = fa_start + fa_len;
                }

                if (f_end == -1 && fa_end != -1) {
                    f_start = fa_start;
                    bmask = 0x00;
                    f_end = fa_end;
                    fa_start = fa_end = -1;
                }

                /* don't exceed the end of available data */
                if (p_end != -1 && (guint)p_end > len) p_end = len;
                if (f_end != -1 && (guint)f_end > len) f_end = len;
                if (fa_end != -1 && (guint)fa_end > len) fa_end = len;

                // Protocol
                byte_view_text->setProtocolHighlight(p_start, p_end);

                // Field bytes
                byte_view_text->setFieldHighlight(f_start, f_end);

                // Appendix (trailer) bytes
                byte_view_text->setFieldAppendixHighlight(fa_start, fa_end);

                byte_view_text->renderBytes();

                setCurrentIndex(i);
            }
            byte_view_text = qobject_cast<ByteViewText*>(widget(++i));
        }
    }
}
Пример #4
0
bool CopyReplaceDlg::perform()
{
    bool b_ret = false;
    for (;;) {

        QString s_source = ui->le_source->currentText ().trimmed ();
        if (s_source.isEmpty ()) {
            PilesGui::showError (tr("A source must be provided"));
            break;
        }

        QString s_dest = ui->le_destination->currentText ().trimmed ();
        if (s_dest.isEmpty ()) {
            PilesGui::showError (tr("A destination must be provided"));
            break;
        }

        int i_max;

        QStringList sl_find;
        QStringList sl_replace;
        i_max = ui->tv_replace->topLevelItemCount ();
        for (int i = 0; i < i_max; ++i) {
            QTreeWidgetItem * current =
                    ui->tv_replace->topLevelItem (i);
            if (isNewCommandEntry (current)) continue;

            sl_find.append (current->text (0));
            sl_replace.append (current->text (1));
        }

        bool b_indep =
                ui->ck_case_independent->checkState () ==
                Qt::Checked;

        bool b_recursive =
                ui->ck_recursive->checkState () ==
                Qt::Checked;

        QStringList sl_filter;
        i_max = ui->tv_filter->topLevelItemCount ();
        for (int i = 0; i < i_max; ++i) {
            QTreeWidgetItem * current =
                    ui->tv_filter->topLevelItem (i);
            if (isNewCommandEntry (current)) continue;

            sl_filter.append (current->text (0));
        }

        b_ret = Replacer::inFiles (
                    s_source,
                    s_dest,
                    b_recursive,
                    sl_find,
                    sl_replace,
                    b_indep ? Qt::CaseInsensitive : Qt::CaseSensitive,
                    sl_filter);

        break;
    }

    return b_ret;
}
Пример #5
0
void RoutePresenter::showRouteSegment(QTreeWidgetItem* routeItem, const QGeoRouteSegment &segment)
{
    QTreeWidgetItem* segmentItem = new QTreeWidgetItem(routeItem);
    segmentItem->setText(0, "segment");

    QTreeWidgetItem* durationItem = new QTreeWidgetItem(segmentItem);
    durationItem->setText(0, "duration");
    durationItem->setText(1, QString().setNum(segment.travelTime()));

    QTreeWidgetItem* distanceItem = new QTreeWidgetItem(segmentItem);
    distanceItem->setText(0, "distance");
    distanceItem->setText(1, QString().setNum(segment.distance()));

    // add back in when more qgeoinstruction classes are made available
    /*
        QString s = segment->turn();

        if (!s.isEmpty()) {
            propItem = new QTreeWidgetItem(maneuverItem);
            propItem->setText(0, "turn");
            propItem->setText(1, s);
        }

        s = segment->streetName();

        if (!s.isEmpty()) {
            propItem = new QTreeWidgetItem(maneuverItem);
            propItem->setText(0, "street name");
            propItem->setText(1, s);
        }

        s = segment->routeName();

        if (!s.isEmpty()) {
            propItem = new QTreeWidgetItem(maneuverItem);
            propItem->setText(0, "route name");
            propItem->setText(1, s);
        }

        s = segment->nextStreetName();

        if (!s.isEmpty()) {
            propItem = new QTreeWidgetItem(maneuverItem);
            propItem->setText(0, "next street name");
            propItem->setText(1, s);
        }

        s = segment->signPost();

        if (!s.isEmpty()) {
            propItem = new QTreeWidgetItem(maneuverItem);
            propItem->setText(0, "sign post");
            propItem->setText(1, s);
        }

        propItem = new QTreeWidgetItem(maneuverItem);
        propItem->setText(0, "traffic direction");
        propItem->setText(1, QString().setNum(segment->trafficDirection()));
    */
    QTreeWidgetItem* pathItem = new QTreeWidgetItem(segmentItem);
    pathItem->setText(0, "path");
    showPoints(pathItem, segment.path());

    if (!segment.maneuver().instructionText().isEmpty()) {
        QTreeWidgetItem* instructionItem = new QTreeWidgetItem(segmentItem);
        instructionItem->setText(0, "instruction");

        QTreeWidgetItem* positionItem = new QTreeWidgetItem(instructionItem);
        positionItem->setText(0, "position");
        QList<QGeoCoordinate> points;
        points.append(segment.maneuver().position());
        showPoints(positionItem, points);

        QTreeWidgetItem* instructionTextItem = new QTreeWidgetItem(instructionItem);
        instructionTextItem->setText(0, "text");
        instructionTextItem->setText(1, segment.maneuver().instructionText());
    }
}
 bool operator< (const QTreeWidgetItem &other) const
 {
     // We want rows with a UE to appear in the order they appear in the row_type enum.
     return type() < other.type();
 }
Пример #7
0
void KatePluginSymbolViewerView::parseBashSymbols(void)
{
       if (!mainWindow()->activeView())
               return;

       QString currline;
       QString funcStr("function ");

       int i;
       //bool mainprog;

       QTreeWidgetItem *node = NULL;
       QTreeWidgetItem *funcNode = NULL;
       QTreeWidgetItem *lastFuncNode = NULL;

       QPixmap func( ( const char** ) class_xpm );

       //It is necessary to change names
       m_func->setText(i18n("Show Functions"));

       if(m_plugin->treeOn)
       {
               funcNode = new QTreeWidgetItem(m_symbols, QStringList(i18n("Functions") ) );
               funcNode->setIcon(0, QIcon(func));

               if (m_plugin->expandedOn)
               {
                       m_symbols->expandItem(funcNode);
               }

               lastFuncNode = funcNode;

               m_symbols->setRootIsDecorated(1);
       }
       else
               m_symbols->setRootIsDecorated(0);

       KTextEditor::Document *kDoc = mainWindow()->activeView()->document();

       for (i = 0; i < kDoc->lines(); i++)
       {
               currline = kDoc->line(i);
               currline = currline.trimmed();
               currline = currline.simplified();

               bool comment = false;
               //kDebug(13000)<<currline<<endl;
               if(currline == "") continue;
               if(currline.at(0) == '#') comment = true;

               //mainprog=false;
               if(!comment && func_on)
               {
                       QString funcName;

                       // skip line if no function defined
                       // note: function name must match regex: [a-zA-Z0-9-_]+
                       if(!currline.contains(QRegExp("^(function )*[a-zA-Z0-9-_]+ *\\( *\\)"))
                               && !currline.contains(QRegExp("^function [a-zA-Z0-9-_]+")))
                               continue;

                       // strip everything unneeded and get the function's name
                       currline.remove(QRegExp("^(function )*"));
                       funcName = currline.split(QRegExp("((\\( *\\))|[^a-zA-Z0-9-_])"))[0].simplified();
                       if(!funcName.size())
                               continue;
                       funcName.append("()");

                       if (m_plugin->treeOn)
                       {
                               node = new QTreeWidgetItem(funcNode, lastFuncNode);
                               lastFuncNode = node;
                       }
                       else
                               node = new QTreeWidgetItem(m_symbols);

                       node->setText(0, funcName);
                       node->setIcon(0, QIcon(func));
                       node->setText(1, QString::number( i, 10));
               }
       } //for i loop
}
Пример #8
0
void KateBuildView::addError(const QString &filename, const QString &line,
                             const QString &column, const QString &message)
{
    bool isError=false;
    bool isWarning=false;
    QTreeWidgetItem* item = new QTreeWidgetItem(m_buildUi.errTreeWidget);
    item->setBackground(1, Qt::gray);
    // The strings are twice in case kate is translated but not make.
    if (message.contains(QStringLiteral("error")) ||
        message.contains(i18nc("The same word as 'make' uses to mark an error.","error")) ||
        message.contains(QStringLiteral("undefined reference")) ||
        message.contains(i18nc("The same word as 'ld' uses to mark an ...","undefined reference"))
       )
    {
        isError=true;
        item->setForeground(1, Qt::red);
        m_numErrors++;
        item->setHidden(false);
    }
    if (message.contains(QStringLiteral("warning")) ||
        message.contains(i18nc("The same word as 'make' uses to mark a warning.","warning"))
       )
    {
        isWarning=true;
        item->setForeground(1, Qt::yellow);
        m_numWarnings++;
        item->setHidden(m_buildUi.displayModeSlider->value() > 2);
    }
    item->setTextAlignment(1, Qt::AlignRight);

    // visible text
    //remove path from visible file name
    QFileInfo file(filename);
    item->setText(0, file.fileName());
    item->setText(1, line);
    item->setText(2, message.trimmed());

    // used to read from when activating an item
    item->setData(0, Qt::UserRole, filename);
    item->setData(1, Qt::UserRole, line);
    item->setData(2, Qt::UserRole, column);

    if ((isError==false) && (isWarning==false)) {
      item->setHidden(m_buildUi.displayModeSlider->value() > 1);
    }

    item->setData(0, IsErrorRole, isError);
    item->setData(0, IsWarningRole, isWarning);

    // add tooltips in all columns
    // The enclosing <qt>...</qt> enables word-wrap for long error messages
    item->setData(0, Qt::ToolTipRole, filename);
    item->setData(1, Qt::ToolTipRole, QStringLiteral("<qt>%1</qt>").arg(message));
    item->setData(2, Qt::ToolTipRole, QStringLiteral("<qt>%1</qt>").arg(message));
}
Пример #9
0
void ChangeProperties::updateProperties()
{
    bool hasControl = activex && !activex->isNull();
    tabWidget->setEnabled(hasControl);

    listProperties->clear();
    listEditRequests->clear();
    if (hasControl) {
	const QMetaObject *mo = activex->metaObject();
	const int numprops = mo->propertyCount();
	for (int i = mo->propertyOffset(); i < numprops; ++i) {
	    const QMetaProperty property = mo->property(i);
	    QTreeWidgetItem *item = new QTreeWidgetItem(listProperties);
	    item->setText(0, QString::fromLatin1(property.name()));
	    item->setText(1, QString::fromLatin1(property.typeName()));
            if (!property.isDesignable()) {
                item->setTextColor(0, Qt::gray);
                item->setTextColor(1, Qt::gray);
                item->setTextColor(2, Qt::gray);
            }
	    QVariant var = activex->property(property.name());
	    
	    switch (var.type()) {
	    case QVariant::Color:
		{
		    QColor col = qvariant_cast<QColor>(var);
		    item->setText(2, col.name());
		}
		break;
	    case QVariant::Font:
		{
		    QFont fnt = qvariant_cast<QFont>(var);
		    item->setText(2, fnt.toString());
		}
		break;
	    case QVariant::Bool:
		{
		    item->setText(2, var.toBool() ? QLatin1String("true") : QLatin1String("false"));
		}
		break;
	    case QVariant::Pixmap:
		{
		    QPixmap pm = qvariant_cast<QPixmap>(var);
		    item->setIcon(2, pm);
		}
		break;
	    case QVariant::List:
		{
		    QList<QVariant> varList = var.toList();
		    QStringList strList;
		    for (int i = 0; i < varList.count(); ++i) {
			QVariant var = varList.at(i);
			strList << var.toString();
		    }
		    item->setText(2, strList.join(QLatin1String(", ")));
		}
		break;
	    case QVariant::Int:
		if (property.isEnumType()) {
		    const QMetaEnum enumerator = mo->enumerator(mo->indexOfEnumerator(property.typeName()));
		    item->setText(2, QString::fromLatin1(enumerator.valueToKey(var.toInt())));
		    break;
		}
		//FALLTHROUGH
	    default:
		item->setText(2, var.toString());
		break;
	    }

            bool requesting = false;
#if 0
            {
                void *argv[] = { &requesting };
                activex->qt_metacall(QMetaObject::Call(0x10000000) /*RequestingEdit*/, i, argv);
            }
#endif
            if (requesting) {
		QTreeWidgetItem *check = new QTreeWidgetItem(listEditRequests);
                check->setText(0, QString::fromLatin1(property.name()));
                check->setCheckState(0, activex->propertyWritable(property.name()) ? Qt::Checked : Qt::Unchecked);
	    }
	}
        listProperties->setCurrentItem(listProperties->topLevelItem(0));
    } else {
        editValue->clear();
    }
}
Пример #10
0
InputSettingsWindow::InputSettingsWindow() {
  activeInput = 0;
  activeGroup = 0;
  groupIndex = 0;
  activeMouse = 0;

  layout = new QVBoxLayout;
  layout->setMargin(Style::WindowMargin);
  layout->setSpacing(Style::WidgetSpacing);
  setLayout(layout);

  list = new QTreeWidget;
  list->setColumnCount(2);
  list->setAllColumnsShowFocus(true);
  list->setSortingEnabled(false);
  list->header()->hide();
  list->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
  layout->addWidget(list);

  controlLayout = new QHBoxLayout;
  layout->addLayout(controlLayout);

  message = new QLabel;
  message->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
  controlLayout->addWidget(message);

  assignButton = new QPushButton("Assign");
  controlLayout->addWidget(assignButton);

  unassignButton = new QPushButton("Unassign");
  controlLayout->addWidget(unassignButton);

  buttonBox = new QLabel("Mouse Button");
  buttonBox->setFrameStyle(QFrame::Panel | QFrame::Raised);
  buttonBox->hide();
  controlLayout->addWidget(buttonBox);

  xAxisButton = new QPushButton("Mouse X-axis");
  xAxisButton->hide();
  controlLayout->addWidget(xAxisButton);

  yAxisButton = new QPushButton("Mouse Y-axis");
  yAxisButton->hide();
  controlLayout->addWidget(yAxisButton);

  stopButton = new QPushButton("Stop");
  stopButton->hide();
  controlLayout->addWidget(stopButton);

  connect(list, SIGNAL(itemSelectionChanged()), this, SLOT(synchronize()));
  connect(list, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(activateAssign()));
  connect(assignButton, SIGNAL(released()), this, SLOT(assign()));
  connect(unassignButton, SIGNAL(released()), this, SLOT(unassign()));
  connect(xAxisButton, SIGNAL(released()), this, SLOT(xAxisAssign()));
  connect(yAxisButton, SIGNAL(released()), this, SLOT(yAxisAssign()));
  connect(stopButton, SIGNAL(released()), this, SLOT(stop()));

  //initialize list

  port1 = new QTreeWidgetItem(list);
  port1->setData(0, Qt::UserRole, QVariant(-1));
  port1->setText(0, "Controller Port 1");

  port2 = new QTreeWidgetItem(list);
  port2->setData(0, Qt::UserRole, QVariant(-1));
  port2->setText(0, "Controller Port 2");

  userInterface = new QTreeWidgetItem(list);
  userInterface->setData(0, Qt::UserRole, QVariant(-1));
  userInterface->setText(0, "User Interface");

  for(unsigned i = 0; i < mapper().size(); i++) {
    InputGroup &group = *(mapper()[i]);

    QTreeWidgetItem *grandparent = 0;
    if(group.category == InputCategory::Port1) { grandparent = port1; }
    if(group.category == InputCategory::Port2) { grandparent = port2; }
    if(group.category == InputCategory::UserInterface) { grandparent = userInterface; }
    if(!grandparent) continue;

    QTreeWidgetItem *parent = new QTreeWidgetItem(grandparent);
    parent->setData(0, Qt::UserRole, QVariant(-1));
    parent->setText(0, group.label);

    for(unsigned i = 0; i < group.size(); i++) {
      QTreeWidgetItem *child = new QTreeWidgetItem(parent);
      child->setData(0, Qt::UserRole, QVariant(inputTable.size()));
      inputTable.append(group[i]);
    }
  }

  updateList();
  synchronize();
}
Пример #11
0
void RoomSelector::processListRoomsEvent(const Event_ListRooms &event)
{
    const int roomListSize = event.room_list_size();
    for (int i = 0; i < roomListSize; ++i) {
        const ServerInfo_Room &room = event.room_list(i);

        for (int j = 0; j < roomList->topLevelItemCount(); ++j) {
            QTreeWidgetItem *twi = roomList->topLevelItem(j);
            if (twi->data(0, Qt::UserRole).toInt() == room.room_id()) {
                if (room.has_name())
                    twi->setData(0, Qt::DisplayRole, QString::fromStdString(room.name()));
                if (room.has_description())
                    twi->setData(1, Qt::DisplayRole, QString::fromStdString(room.description()));
                if (room.has_player_count())
                    twi->setData(2, Qt::DisplayRole, room.player_count());
                if (room.has_game_count())
                    twi->setData(3, Qt::DisplayRole, room.game_count());
                return;
            }
        }
        QTreeWidgetItem *twi = new QTreeWidgetItem;
        twi->setData(0, Qt::UserRole, room.room_id());
        if (room.has_name())
            twi->setData(0, Qt::DisplayRole, QString::fromStdString(room.name()));
        if (room.has_description())
            twi->setData(1, Qt::DisplayRole, QString::fromStdString(room.description()));
        twi->setData(2, Qt::DisplayRole, room.player_count());
        twi->setData(3, Qt::DisplayRole, room.game_count());
        twi->setTextAlignment(2, Qt::AlignRight);
        twi->setTextAlignment(3, Qt::AlignRight);

        roomList->addTopLevelItem(twi);
        if (room.has_auto_join())
            if (room.auto_join())
                joinRoom(room.room_id(), false);
    }
}
Пример #12
0
//called when double-clicking any list item;
//double-clicking a group expands or collapses it,
//so avoid triggering assign() unless this is not a group
void InputSettingsWindow::activateAssign() {
  QTreeWidgetItem *item = list->currentItem();
  if(!item) return;
  signed index = item->data(0, Qt::UserRole).toInt();
  if(index >= 0) assign();
}
Пример #13
0
void InputSettingsWindow::updateList() {
  QList<QTreeWidgetItem*> all = list->findItems("", Qt::MatchContains);
  for(unsigned i = 0; i < all.size(); i++) {
    QTreeWidgetItem *grandparent = all[i];
    for(unsigned j = 0; j < grandparent->childCount(); j++) {
      QTreeWidgetItem *parent = grandparent->child(j);
      for(unsigned k = 0; k < parent->childCount(); k++) {
        QTreeWidgetItem *child = parent->child(k);
        signed index = child->data(0, Qt::UserRole).toInt();
        if(index == -1) continue;
        MappedInput *input = inputTable[index];
        child->setText(0, input->label);
        child->setText(1, string() << "= " << input->name);
        child->setForeground(1, QBrush(QColor(128, 128, 128)));
      }
    }
  }
}
Пример #14
0
void FunctionsTreeWidget::addFolder()
{
    blockSignals(true);
    if (selectedItems().isEmpty())
        return;

    QTreeWidgetItem *item = selectedItems().first();
    if (item->text(COL_PATH).isEmpty())
        item = item->parent();

    int type = item->data(COL_NAME, Qt::UserRole + 1).toInt();

    QString fullPath = item->text(COL_PATH);
    if (fullPath.endsWith('/') == false)
        fullPath.append("/");

    QString newName = "New folder";

    int folderCount = 1;

    while (m_foldersMap.contains(fullPath + newName))
    {
        newName = "New Folder " + QString::number(folderCount++);
    }

    fullPath += newName;

    QTreeWidgetItem *folder = new QTreeWidgetItem(item);
    folder->setText(COL_NAME, newName);
    folder->setIcon(COL_NAME, QIcon(":/folder.png"));
    folder->setData(COL_NAME, Qt::UserRole, Function::invalidId());
    folder->setData(COL_NAME, Qt::UserRole + 1, type);
    folder->setText(COL_PATH, fullPath);
    folder->setFlags(folder->flags() | Qt::ItemIsDropEnabled | Qt::ItemIsEditable);

    m_foldersMap[fullPath] = folder;
    item->setExpanded(true);

    blockSignals(false);

    scrollToItem(folder, QAbstractItemView::PositionAtCenter);
}
Пример #15
0
void GUIImport::updateViewConfig()
{
	for (StringMap::iterator it = m->viewConfig.begin(); it != m->viewConfig.end(); ++it)
	{
		if (strchr(it->first.c_str(), '.') == NULL)
		{
			// view
			QList<QTreeWidgetItem*> views = ui->viewTree->findItems(
				QString::fromStdString(it->first),
				Qt::MatchExactly, COL_ORGNAME);

			if (views.size() != 1)
			{
				DM::Logger(DM::Error) << "view tree corrupt";
				return;
			}

			QCheckBox* checkBox = (QCheckBox*)ui->viewTree->itemWidget(views.first(), COL_CHECKBOX);

			// note: if checked or partially checked -> take as if checked
			it->second = (checkBox->checkState() != Qt::Unchecked) ?
				views.first()->text(COL_NEWNAME).toStdString() : "";
		}
		else
		{
			// attribute
			QStringList parsedString = QString::fromStdString(it->first).split('.', QString::SkipEmptyParts);

			if (parsedString.size() != 2)
			{
				DM::Logger(DM::Error) << "view tree corrupt";
				return;
			}

			QList<QTreeWidgetItem*> attributes = ui->viewTree->findItems(
				parsedString.last(), Qt::MatchExactly | Qt::MatchRecursive, COL_ORGNAME);

			QTreeWidgetItem* attribute = NULL;
			foreach(QTreeWidgetItem* a, attributes)
			{
				if (a->parent() && a->parent()->text(COL_ORGNAME) == parsedString.first())
				{
					attribute = a;
					break;
				}
			}

			if (!attribute)
			{
				DM::Logger(DM::Error) << "view tree corrupt";
				return;
			}

			QCheckBox* checkBox = (QCheckBox*)ui->viewTree->itemWidget(attribute, COL_CHECKBOX);

			// note: if checked or partially checked -> take it
			it->second = (checkBox->checkState() != Qt::Unchecked) ?
				attribute->text(COL_NEWNAME).toStdString() : "";
		}
	}
	// epsg overwritings
	for (int i = 0; i < ui->viewTree->topLevelItemCount(); i++)
	{
		QTreeWidgetItem* it = ui->viewTree->topLevelItem(i);
		m->viewEPSGConfig[it->text(COL_ORGNAME).toStdString()] = it->text(COL_EPSG).toStdString();
	}
}
Пример #16
0
void ChangeProperties::on_buttonSet_clicked()
{
    QTreeWidgetItem *item = listProperties->currentItem();
    if (!item)
	return;
    
    QString prop = item->text(0);
    QVariant value = activex->property(prop.toLatin1());
    QVariant::Type type = value.type();
    if (!value.isValid()) {
	const QMetaObject *mo = activex->metaObject();
	const QMetaProperty property = mo->property(mo->indexOfProperty(prop.toLatin1()));
	type = QVariant::nameToType(property.typeName());
    }
    switch (type) {
    case QVariant::Color:
	{
	    QColor col;
	    col.setNamedColor(editValue->text());
	    if (col.isValid()) {
		value = qVariantFromValue(col);
	    } else {
		QMessageBox::warning(this, tr("Can't parse input"), 
		                           tr("Failed to create a color from %1\n"
					                "The string has to be a valid color name (e.g. 'red')\n"
							"or a RGB triple of format '#rrggbb'."
							).arg(editValue->text()));
	    }
	}
	break;
    case QVariant::Font:
	{
	    QFont fnt;
	    if (fnt.fromString(editValue->text())) {
		value = qVariantFromValue(fnt);
	    } else {
		QMessageBox::warning(this, tr("Can't parse input"), 
		                           tr("Failed to create a font from %1\n"
					        "The string has to have a format family,<point size> or\n"
						"family,pointsize,stylehint,weight,italic,underline,strikeout,fixedpitch,rawmode."
							).arg(editValue->text()));
	    }
	}
	break;
    case QVariant::Pixmap:
	{
	    QString fileName = editValue->text();
	    if (fileName.isEmpty())
		fileName = QFileDialog::getOpenFileName(this);
	    QPixmap pm(fileName);
	    if (pm.isNull())
		return;

	    value = qVariantFromValue(pm);
	}
	break;
    case QVariant::Bool:
	{
	    QString txt = editValue->text().toLower();
	    value = QVariant(txt != QLatin1String("0") && txt != QLatin1String("false"));
	}
	break;
    case QVariant::List:
	{
	    QStringList txtList = editValue->text().split(QRegExp(QLatin1String("[,;]")));
	    QList<QVariant> varList;
	    for (int i = 0; i < txtList.count(); ++i) {
		QVariant svar(txtList.at(i));
		QString str = svar.toString();
		str = str.trimmed();
		bool ok;
		int n = str.toInt(&ok);
		if (ok) {
		    varList << n;
		    continue;
		}
		double d = str.toDouble(&ok);
		if (ok) {
		    varList << d;
		    continue;
		}
		varList << str;
	    }
	    value = varList;
	}
	break;

    default:
	value = editValue->text();
	break;
    }
 
    Q_ASSERT(activex->setProperty(prop.toLatin1(), value));
    updateProperties();
    listProperties->setCurrentItem(listProperties->findItems(prop, Qt::MatchExactly).at(0));
}
Пример #17
0
void GUIImport::updateTree()
{
	if (treeCheckMapper)
	{
		delete treeCheckMapper;
		treeCheckMapper = NULL;
	}

	while (this->ui->viewTree->takeTopLevelItem(0))
		;

	treeCheckMapper = new QSignalMapper(this);

	for (StringMap::iterator viewIter = this->m->viewConfig.begin();
		viewIter != this->m->viewConfig.end(); ++viewIter)
	{
		if (strchr(viewIter->first.c_str(), '.') != NULL)
			continue;	// skip if it is not a view or empty

		Qt::CheckState state = viewIter->second.empty() ? Qt::Unchecked : Qt::Checked;

		// add view item
		QTreeWidgetItem* viewItem = new QTreeWidgetItem();

		viewItem->setText(COL_ORGNAME, QString::fromStdString(viewIter->first));
		viewItem->setText(COL_ARROW, "->");
		viewItem->setText(COL_NEWNAME, QString::fromStdString(state == Qt::Checked ? viewIter->second : viewIter->first));
		viewItem->setText(COL_TYPE, GetTypeString((DM::Components)this->m->viewConfigTypes[viewIter->first]));

		std::string epsgText;
		if (map_contains(&m->viewEPSGConfig, viewIter->first, epsgText) && atoi(epsgText.c_str()) == 0)
			viewItem->setText(COL_EPSG, QString::fromStdString(epsgText));
		else
			viewItem->setText(COL_EPSG, DEFAULT_TRAFO_STRING);

		// add attributes
		for (StringMap::iterator attrIter = this->m->viewConfig.begin();
			attrIter != this->m->viewConfig.end(); ++attrIter)
		{
			if (strchr(attrIter->first.c_str(), '.') == NULL)
				continue; // skip if it is a view or emtpy

			bool isAttributeActive = !attrIter->second.empty();

			if (!isAttributeActive && state == Qt::Checked)
				state = Qt::PartiallyChecked;

			QStringList parsedString = QString::fromStdString(attrIter->first).split('.', QString::SkipEmptyParts);

			if (parsedString.size() != 2)
			{
				DM::Logger(DM::Error) << "error parsing parameter: " << attrIter->first;
				continue;
			}

			if (parsedString.first() == QString::fromStdString(viewIter->first))
			{
				// this attribute is for this view
				QTreeWidgetItem* attrItem = new QTreeWidgetItem();

				attrItem->setText(COL_ORGNAME, parsedString.last());
				attrItem->setText(COL_ARROW, "->");
				attrItem->setText(COL_NEWNAME, isAttributeActive ?
					QString::fromStdString(attrIter->second) :
					parsedString.last());

				attrItem->setText(COL_TYPE,
					GetTypeString((DM::Attribute::AttributeType)this->m->viewConfigTypes[attrIter->first]));

				viewItem->addChild(attrItem);

				QCheckBox* check = new QCheckBox();
				check->setChecked(isAttributeActive);
				connect(check, SIGNAL(clicked()), treeCheckMapper, SLOT(map()));
				treeCheckMapper->setMapping(check, (QObject*)attrItem);
				this->ui->viewTree->setItemWidget(attrItem, COL_CHECKBOX, check);
			}
		}

		this->ui->viewTree->addTopLevelItem(viewItem);

		QCheckBox* check = new QCheckBox();
		check->setCheckState(state);
		connect(check, SIGNAL(clicked()), treeCheckMapper, SLOT(map()));
		treeCheckMapper->setMapping(check, (QObject*)viewItem);
		this->ui->viewTree->setItemWidget(viewItem, COL_CHECKBOX, check);
	}

	connect(treeCheckMapper, SIGNAL(mapped(QObject*)),
		this, SLOT(updateTreeChecks(QObject*)));

	this->ui->viewTree->setColumnWidth(COL_CHECKBOX, 70);
	this->ui->viewTree->resizeColumnToContents(COL_ORGNAME);
	this->ui->viewTree->resizeColumnToContents(COL_ARROW);
	this->ui->viewTree->resizeColumnToContents(COL_NEWNAME);
	this->ui->viewTree->resizeColumnToContents(COL_TYPE);
	this->ui->viewTree->resizeColumnToContents(COL_EPSG);
}
Пример #18
0
void CastTreeViewer::folderUp()
{
	QTreeWidgetItem *item = currentItem();
	if (item && item->parent() != (QTreeWidgetItem *)0)
		setCurrentItem(item->parent());
}
Пример #19
0
void QgsGrassTools::addModules( QTreeWidgetItem *parent, QDomElement &element, QTreeWidget *modulesTreeWidget, QStandardItemModel * modulesListModel, bool direct )
{
  QDomNode n = element.firstChild();

  QTreeWidgetItem *item;
  QTreeWidgetItem *lastItem = 0;
  while ( !n.isNull() )
  {
    QDomElement e = n.toElement();
    if ( !e.isNull() )
    {
// QgsDebugMsg(QString("tag = %1").arg(e.tagName()));

      if ( e.tagName() != "section" && e.tagName() != "grass" )
      {
        QgsDebugMsg( QString( "Unknown tag: %1" ).arg( e.tagName() ) );
        continue;
      }

      // Check GRASS version
      QString version_min = e.attribute( "version_min" );
      QString version_max = e.attribute( "version_max" );

      if ( !QgsGrassModuleOption::checkVersion( e.attribute( "version_min" ), e.attribute( "version_max" ) ) )
      {
        n = n.nextSibling();
        continue;
      }

      if ( parent )
      {
        item = new QTreeWidgetItem( parent, lastItem );
      }
      else
      {
        item = new QTreeWidgetItem( modulesTreeWidget, lastItem );
      }

      if ( e.tagName() == "section" )
      {
        QString label = QApplication::translate( "grasslabel", e.attribute( "label" ).toUtf8() );
        QgsDebugMsg( QString( "label = %1" ).arg( label ) );
        item->setText( 0, label );
        item->setExpanded( false );

        addModules( item, e, modulesTreeWidget, modulesListModel, direct );

        lastItem = item;
      }
      else if ( e.tagName() == "grass" )
      { // GRASS module
        QString name = e.attribute( "name" );
        QgsDebugMsg( QString( "name = %1" ).arg( name ) );

        QString path = QgsApplication::pkgDataPath() + "/grass/modules/" + name;
        QgsGrassModule::Description description = QgsGrassModule::description( path );

        if ( !direct || description.direct )
        {
          QString label = description.label;
          QPixmap pixmap = QgsGrassModule::pixmap( path, 32 );

          item->setText( 0, name + " - " + label );
          item->setIcon( 0, QIcon( pixmap ) );
          item->setText( 1, name );
          lastItem = item;

          // Add this item to our list model
          QStandardItem * mypDetailItem = new QStandardItem( name + "\n" + label );
          mypDetailItem->setData( name, Qt::UserRole + 1 ); //for calling runModule later
          QString mySearchText = name + " - " + label;
          mypDetailItem->setData( mySearchText, Qt::UserRole + 2 ); //for filtering later
          mypDetailItem->setData( pixmap, Qt::DecorationRole );
          mypDetailItem->setCheckable( false );
          mypDetailItem->setEditable( false );
          // setData in the delegate with a variantised QgsDetailedItemData
          QgsDetailedItemData myData;
          myData.setTitle( name );
          myData.setDetail( label );
          myData.setIcon( pixmap );
          myData.setCheckable( false );
          myData.setRenderAsWidget( false );
          QVariant myVariant = qVariantFromValue( myData );
          mypDetailItem->setData( myVariant, Qt::UserRole );
          modulesListModel->appendRow( mypDetailItem );
        }
        else
        {
          delete item;
        }
      }
    }
    n = n.nextSibling();
  }

}
Пример #20
0
void dlgPackageExporter::slot_export_package(){
    QString filePath = ui->filePath->text();
    QFile file_xml( filePath );
    if( file_xml.open( QIODevice::WriteOnly ) )
    {
        XMLexport writer( mpHost );
        //write trigs
        QList<QTreeWidgetItem *> items = treeWidget->findItems(QString("Triggers"), Qt::MatchExactly, 0);
        QTreeWidgetItem * top = items.first();
        QList<QTreeWidgetItem *> trigList;
        recurseTree(top,trigList);
        for (int i=0;i<trigList.size();i++){
            QTreeWidgetItem * item = trigList.at(i);
            if (item->checkState(0) == Qt::Unchecked && triggerMap.contains(item)){
                triggerMap[item]->exportItem = false;
            }
        }
        items = treeWidget->findItems(QString("Timers"), Qt::MatchExactly, 0);
        top = items.first();
        QList<QTreeWidgetItem *> timerList;
        recurseTree(top,timerList);
        for (int i=0;i<timerList.size();i++){
            QTreeWidgetItem * item = timerList.at(i);
            if (item->checkState(0) == Qt::Unchecked && timerMap.contains(item)){
                timerMap[item]->exportItem = false;
            }
        }
        items = treeWidget->findItems(QString("Aliases"), Qt::MatchExactly, 0);
        top = items.first();
        QList<QTreeWidgetItem *> aliasList;
        recurseTree(top,aliasList);
        for (int i=0;i<aliasList.size();i++){
            QTreeWidgetItem * item = aliasList.at(i);
            if (item->checkState(0) == Qt::Unchecked && aliasMap.contains(item)){
                aliasMap[item]->exportItem = false;
            }
        }
        items = treeWidget->findItems(QString("Buttons"), Qt::MatchExactly, 0);
        top = items.first();
        QList<QTreeWidgetItem *> actionList;
        recurseTree(top,actionList);
        for (int i=0;i<actionList.size();i++){
            QTreeWidgetItem * item = actionList.at(i);
            if (item->checkState(0) == Qt::Unchecked && actionMap.contains(item)){
                actionMap[item]->exportItem = false;
            }
        }
        items = treeWidget->findItems(QString("Scripts"), Qt::MatchExactly, 0);
        top = items.first();
        QList<QTreeWidgetItem *> scriptList;
        recurseTree(top,scriptList);
        for (int i=0;i<scriptList.size();i++){
            QTreeWidgetItem * item = scriptList.at(i);
            if (item->checkState(0) == Qt::Unchecked && scriptMap.contains(item)){
                qDebug()<<"not writing"<<scriptMap[item]->getName();
                scriptMap[item]->exportItem = false;
            }
        }
        items = treeWidget->findItems(QString("Keys"), Qt::MatchExactly, 0);
        top = items.first();
        QList<QTreeWidgetItem *> keyList;
        recurseTree(top,keyList);
        for (int i=0;i<keyList.size();i++){
            QTreeWidgetItem * item = keyList.at(i);
            if (item->checkState(0) == Qt::Unchecked && keyMap.contains(item)){
                keyMap[item]->exportItem = false;
            }
        }
        writer.exportGenericPackage(&file_xml);
        file_xml.close();
        //now fix all the stuff we weren't exporting
        //trigger, timer, alias,action,script, keys
        for (int i=0;i<trigList.size();i++){
            QTreeWidgetItem * item = trigList.at(i);
            if (triggerMap.contains(item)){
                triggerMap[item]->exportItem = true;
            }
        }
        for (int i=0;i<timerList.size();i++){
            QTreeWidgetItem * item = timerList.at(i);
            if (timerMap.contains(item)){
                timerMap[item]->exportItem = true;
            }
        }
        for (int i=0;i<actionList.size();i++){
            QTreeWidgetItem * item = actionList.at(i);
            if (actionMap.contains(item)){
                actionMap[item]->exportItem = true;
            }
        }
        for (int i=0;i<scriptList.size();i++){
            QTreeWidgetItem * item = scriptList.at(i);
            if (scriptMap.contains(item)){
                scriptMap[item]->exportItem = true;
            }
        }
        for (int i=0;i<keyList.size();i++){
            QTreeWidgetItem * item = keyList.at(i);
            if (keyMap.contains(item)){
                keyMap[item]->exportItem = true;
            }
        }
        for (int i=0;i<aliasList.size();i++){
            QTreeWidgetItem * item = aliasList.at(i);
            if (aliasMap.contains(item)){
                aliasMap[item]->exportItem = true;
            }
        }

        ui->infoLabel->setText("Exported package to "+filePath);
    } else {
        ui->infoLabel->setText("Failed to export - couldn't open "+filePath+" for writing in. Do you have the necessary permissions to write to that folder?");
    }
}
Пример #21
0
void StatisticWindow::rebuild(QDate from, QDate to)
{
    QDateTime statStart(from);
    QDateTime statEnd(to.addDays(1));

    //prepare containers
    m_Uncategorized.TotalTime = 0;
    m_Uncategorized.NormalValue = 0;
    m_Uncategorized.Name = tr("Uncategorized");
    m_Uncategorized.Color = Qt::gray;
    m_Categories.resize(m_DataManager->categoriesCount());
    for (int i = 0; i<m_Categories.size(); i++){
        m_Categories[i].TotalTime = 0;
        m_Categories[i].NormalValue = 0;
        m_Categories[i].Name = m_DataManager->categories(i)->name;
        m_Categories[i].Color = m_DataManager->categories(i)->color;
    }

    m_Applications.resize(m_DataManager->applicationsCount());
    for (int i = 0; i<m_Applications.size(); i++){
        sAppInfo* app = m_DataManager->applications(i);
        m_Applications[i].TotalTime = 0;
        m_Applications[i].NormalValue = 0;
        m_Applications[i].Name = app->activities[0].name;
        m_Applications[i].Color = Qt::white;
        m_Applications[i].childs.resize(app->activities.size());
        for (int j = 0; j<m_Applications[i].childs.size(); j++){
            m_Applications[i].childs[j].TotalTime = 0;
            m_Applications[i].childs[j].NormalValue = 0;
            m_Applications[i].childs[j].Name = app->activities[j].name;
            m_Applications[i].childs[j].Color = Qt::white;
        }
    }

    //calculation
    int TotalTime = 0;
    for (int i = 0; i<m_Applications.size(); i++){
        const sAppInfo* app = m_DataManager->applications(i);
        for (int activity = 0; activity<app->activities.size(); activity++){
            const sActivityInfo* ainfo = &app->activities[activity];
            for (int j = 0; j<ainfo->periods.size(); j++){
                QDateTime start = ainfo->periods[j].start;
                QDateTime end = ainfo->periods[j].start.addSecs(ainfo->periods[j].length);
                if (end>statStart && start<statEnd){
                    if (start<statStart)
                        start = statStart;
                    if (end>statEnd)
                        end = statEnd;
                    int duration = start.secsTo(end);
                    TotalTime+=duration;
                    m_Applications[i].TotalTime+=duration;
                    m_Applications[i].childs[activity].TotalTime+=duration;
                    int cat = ainfo->categories[ainfo->periods[j].profileIndex];
                    if (cat==-1)
                        m_Uncategorized.TotalTime+=duration;
                    else
                        m_Categories[cat].TotalTime+=duration;
                }
                if (start>statEnd || end>statEnd)
                    break;
            }
        }
    }

    //calculate normalized values
    if (TotalTime>0){
        m_Uncategorized.NormalValue = (float)m_Uncategorized.TotalTime/TotalTime;
        for (int i = 0; i<m_Categories.size(); i++)
            m_Categories[i].NormalValue = (float)m_Categories[i].TotalTime/TotalTime;

        for (int i = 0; i<m_Applications.size(); i++){
            m_Applications[i].NormalValue = (float)m_Applications[i].TotalTime/TotalTime;
            for (int j = 0; j<m_Applications[i].childs.size(); j++)
                m_Applications[i].childs[j].NormalValue = (float)m_Applications[i].childs[j].TotalTime/TotalTime;
        }
    }

    qSort( m_Categories.begin(), m_Categories.end(), lessThan );

    ui->widgetDiagram->setTotalTime(TotalTime);
    ui->widgetDiagram->update();


    //fill applications widget
    ui->treeWidgetApplications->setSortingEnabled(false);
    ui->treeWidgetApplications->clear();
    for (int i = 0; i<m_Applications.size(); i++){
        if (m_Applications[i].TotalTime>0){
            QTreeWidgetItem* item = new QTreeWidgetItem();
            item->setText(0,m_Applications[i].Name);
            item->setData(0,Qt::UserRole,i);
            item->setText(1,DurationToString(m_Applications[i].TotalTime));
            item->setText(2,fixSize(QString::number(m_Applications[i].NormalValue*100,'f',2),5)+"%");
            ui->treeWidgetApplications->addTopLevelItem(item);
            for (int j = 0; j<m_Applications[i].childs.size(); j++){
                if (m_Applications[i].childs[j].TotalTime>0){
                    QTreeWidgetItem* aitem = new QTreeWidgetItem();
                    QString childName = m_Applications[i].childs[j].Name;
                    if (j==0)
                        childName+=tr("(default)");
                    aitem->setText(0,childName);
                    aitem->setData(0,Qt::UserRole,i);
                    aitem->setData(0,Qt::UserRole+1,j);
                    aitem->setText(1,DurationToString(m_Applications[i].childs[j].TotalTime));
                    aitem->setText(2,fixSize(QString::number(m_Applications[i].childs[j].NormalValue*100,'f',2),5)+"%");
                    item->addChild(aitem);
                }
            }

        }
    }
    ui->treeWidgetApplications->setSortingEnabled(true);
}
Пример #22
0
void StaffTextProperties::channelItemChanged(QTreeWidgetItem* item, QTreeWidgetItem* pitem)
      {
      if (pitem)
            saveChannel(pitem->data(0, Qt::UserRole).toInt());
      if (item == 0)
            return;

      actionList->clear();
      Part* part = _staffText->staff()->part();

      int channelIdx      = item->data(0, Qt::UserRole).toInt();
      int tick = static_cast<Segment*>(_staffText->parent())->tick();
      Channel* channel    = part->instrument(tick)->channel(channelIdx);
      QString channelName = channel->name;

      for (const NamedEventList& e : part->instrument(tick)->midiActions()) {
            QTreeWidgetItem* item = new QTreeWidgetItem(actionList);
            if (e.name.isEmpty() || e.name == "normal") {
                  item->setText(0, tr("normal"));
                  item->setData(0, Qt::UserRole, "normal");
                  }
            else {
                  item->setText(0, qApp->translate("InstrumentsXML", e.name.toUtf8().data()));
                  item->setData(0, Qt::UserRole, e.name);
                  }
            item->setText(1, qApp->translate("InstrumentsXML", e.descr.toUtf8().data()));
            }
      for (const NamedEventList& e : channel->midiActions) {
            QTreeWidgetItem* item = new QTreeWidgetItem(actionList);
            if (e.name.isEmpty() || e.name == "normal") {
                  item->setText(0, tr("normal"));
                  item->setData(0, Qt::UserRole, "normal");
                  }
            else {
                  item->setText(0, qApp->translate("InstrumentsXML", e.name.toUtf8().data()));
                  item->setData(0, Qt::UserRole, e.name);
                  }
            item->setText(1, qApp->translate("InstrumentsXML", e.descr.toUtf8().data()));
            }
      for (const ChannelActions& ca : *_staffText->channelActions()) {
            if (ca.channel == channelIdx) {
                  for (QString s : ca.midiActionNames) {
                        QList<QTreeWidgetItem*> items;
                        for (int i = 0; i < actionList->topLevelItemCount(); i++) {
                              QTreeWidgetItem* item = actionList->topLevelItem(i);
                              if (item->data(0, Qt::UserRole) == s) {
                                    item->setSelected(true);
                                    }
                              }
                        }
                  }
            }
      }
Пример #23
0
void ProfileDialog::updateWidgets()
{
    QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem();
    bool enable_new = false;
    bool enable_del = false;
    bool enable_copy = false;
    bool enable_ok = true;
    profile_def *current_profile = NULL;

    if (item) {
        current_profile = (profile_def *) VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole))->data;
        enable_new = true;
        enable_copy = true;
        if (!current_profile->is_global && !(item->font(0).strikeOut())) {
            enable_del = true;
        }
    }

    if (current_profile) {
        QString profile_path;
        QString profile_info;
        switch (current_profile->status) {
        case PROF_STAT_DEFAULT:
            if (item->font(0).strikeOut()) {
                profile_info = tr("Will be reset to default values");
            } else {
                profile_path = get_persconffile_path("", FALSE);
            }
            break;
        case PROF_STAT_EXISTS:
            {
            char* profile_dir = current_profile->is_global ? get_global_profiles_dir() : get_profiles_dir();
            profile_path = profile_dir;
            g_free(profile_dir);

            profile_path.append(QDir::separator()).append(current_profile->name);
            }
            break;
        case PROF_STAT_COPY:
            if (current_profile->reference) {
                profile_info = tr("Created from %1").arg(current_profile->reference);
                if (current_profile->from_global) {
                    profile_info.append(QString(" %1").arg(tr("(system provided)")));
                }
                break;
            }
            /* Fall Through */
        case PROF_STAT_NEW:
            profile_info = tr("Created from default settings");
            break;
        case PROF_STAT_CHANGED:
            profile_info = tr("Renamed from %1").arg(current_profile->reference);
            break;
        }
        if (!profile_path.isEmpty()) {
            pd_ui_->infoLabel->setUrl(QUrl::fromLocalFile(profile_path).toString());
            pd_ui_->infoLabel->setText(profile_path);
            pd_ui_->infoLabel->setToolTip(tr("Go to %1").arg(profile_path));
        } else {
            pd_ui_->infoLabel->clear();
            pd_ui_->infoLabel->setText(profile_info);
        }
    } else {
        pd_ui_->infoLabel->clear();
    }

    if (pd_ui_->profileTreeWidget->topLevelItemCount() > 0) {
        profile_def *profile;
        for (int i = 0; i < pd_ui_->profileTreeWidget->topLevelItemCount(); i++) {
            item = pd_ui_->profileTreeWidget->topLevelItem(i);
            profile = (profile_def *) VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole))->data;
            if (gchar *err_msg = profile_name_is_valid(profile->name)) {
                item->setToolTip(0, err_msg);
                item->setBackground(0, ColorUtils::fromColorT(&prefs.gui_text_invalid));
                if (profile == current_profile) {
                    pd_ui_->infoLabel->setText(err_msg);
                }
                g_free(err_msg);
                enable_ok = false;
                continue;
            }
            if (profile->is_global) {
                item->setToolTip(0, tr("This is a system provided profile."));
                continue;
            }
            if (current_profile && !current_profile->is_global && profile != current_profile && strcmp(profile->name, current_profile->name) == 0) {
                item->setToolTip(0, tr("A profile already exists with this name."));
                item->setBackground(0, ColorUtils::fromColorT(&prefs.gui_text_invalid));
                if (current_profile->status != PROF_STAT_DEFAULT &&
                    current_profile->status != PROF_STAT_EXISTS)
                {
                    pd_ui_->infoLabel->setText(tr("A profile already exists with this name"));
                }
                enable_ok = false;
            } else if (item->font(0).strikeOut()) {
                item->setToolTip(0, tr("The profile will be reset to default values."));
                item->setBackground(0, ColorUtils::fromColorT(&prefs.gui_text_deprecated));
            } else {
                item->setBackground(0, QBrush());
            }
        }
    }

    pd_ui_->profileTreeWidget->resizeColumnToContents(0);
    pd_ui_->newToolButton->setEnabled(enable_new);
    pd_ui_->deleteToolButton->setEnabled(enable_del);
    pd_ui_->copyToolButton->setEnabled(enable_copy);
    ok_button_->setEnabled(enable_ok);
}
Пример #24
0
StaffTextProperties::StaffTextProperties(const StaffText* st, QWidget* parent)
   : QDialog(parent)
      {
      setObjectName("StaffTextProperties");
      setupUi(this);
      if (st->systemFlag()) {
            setWindowTitle(tr("System Text Properties"));
            tabWidget->removeTab(tabWidget->indexOf(tabAeolusStops)); // Aeolus settings  for staff text only
            //if (!enableExperimental) tabWidget->removeTab(tabWidget->indexOf(tabMIDIAction));
            tabWidget->removeTab(tabWidget->indexOf(tabChangeChannel)); // Channel switching  for staff text only
            }
      else {
            setWindowTitle(tr("Staff Text Properties"));
            //tabWidget->removeTab(tabWidget->indexOf(tabSwingSettings)); // Swing settings for system text only, could be disabled here, if desired
#ifndef AEOLUS
            tabWidget->removeTab(tabWidget->indexOf(tabAeolusStops));
#endif
            //if (!enableExperimental) tabWidget->removeTab(tabWidget->indexOf(tabMIDIAction));
            }
      setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
      _staffText = static_cast<StaffText*>(st->clone());

      vb[0][0] = voice1_1;
      vb[0][1] = voice1_2;
      vb[0][2] = voice1_3;
      vb[0][3] = voice1_4;

      vb[1][0] = voice2_1;
      vb[1][1] = voice2_2;
      vb[1][2] = voice2_3;
      vb[1][3] = voice2_4;

      vb[2][0] = voice3_1;
      vb[2][1] = voice3_2;
      vb[2][2] = voice3_3;
      vb[2][3] = voice3_4;

      vb[3][0] = voice4_1;
      vb[3][1] = voice4_2;
      vb[3][2] = voice4_3;
      vb[3][3] = voice4_4;

      channelCombo[0] = channelCombo1;
      channelCombo[1] = channelCombo2;
      channelCombo[2] = channelCombo3;
      channelCombo[3] = channelCombo4;

      //---------------------------------------------------
      // setup "switch channel"
      //---------------------------------------------------

      for (int i = 0; i < 4; ++i)
            initChannelCombo(channelCombo[i], _staffText);

      Part* part = _staffText->staff()->part();
      int tick = static_cast<Segment*>(st->parent())->tick();
      int n = part->instrument(tick)->channel().size();
      int rows = 0;
      for (int voice = 0; voice < VOICES; ++voice) {
            if (_staffText->channelName(voice).isEmpty())
                  continue;
            for (int i = 0; i < n; ++i) {
                  const Channel* a = part->instrument(tick)->channel(i);
                  if (a->name != _staffText->channelName(voice))
                        continue;
                  int row = 0;
                  for (row = 0; row < rows; ++row) {
                        if (channelCombo[row]->currentIndex() == i) {
                              vb[voice][row]->setChecked(true);
                              break;
                              }
                        }
                  if (row == rows) {
                        vb[voice][rows]->setChecked(true);
                        channelCombo[row]->setCurrentIndex(i);
                        ++rows;
                        }
                  break;
                  }
            }
      QSignalMapper* mapper = new QSignalMapper(this);
      for (int row = 0; row < 4; ++row) {
            for (int col = 0; col < 4; ++col) {
                  connect(vb[col][row], SIGNAL(clicked()), mapper, SLOT(map()));
                  mapper->setMapping(vb[col][row], (col << 8) + row);
                  }
            }

      if (_staffText->swing()) {
            setSwingBox->setChecked(true);
            if (_staffText->swingParameters()->swingUnit == MScore::division/2) {
                  swingBox->setEnabled(true);
                  swingEighth->setChecked(true);
                  swingBox->setValue(_staffText->swingParameters()->swingRatio);
                  }
            else if (_staffText->swingParameters()->swingUnit == MScore::division/4) {
                  swingBox->setEnabled(true);
                  swingSixteenth->setChecked(true);
                  swingBox->setValue(_staffText->swingParameters()->swingRatio);
                  }
            else if (_staffText->swingParameters()->swingUnit == 0) {
                 swingBox->setEnabled(false);
                 SwingOff->setChecked(true);
                 swingBox->setValue(_staffText->swingParameters()->swingRatio);
                 }
            }

      connect(mapper, SIGNAL(mapped(int)), SLOT(voiceButtonClicked(int)));
      connect(SwingOff, SIGNAL(toggled(bool)), SLOT(setSwingControls(bool)));
      connect(swingEighth, SIGNAL(toggled(bool)), SLOT(setSwingControls(bool)));
      connect(swingSixteenth, SIGNAL(toggled(bool)), SLOT(setSwingControls(bool)));

      //---------------------------------------------------
      //    setup midi actions
      //---------------------------------------------------

      QTreeWidgetItem* selectedItem = 0;
      for (int i = 0; i < n; ++i) {
            const Channel* a = part->instrument(tick)->channel(i);
            QTreeWidgetItem* item = new QTreeWidgetItem(channelList);
            item->setData(0, Qt::UserRole, i);
            if (a->name.isEmpty() || a->name == "normal")
                  item->setText(0, tr("normal"));
            else
                  item->setText(0, qApp->translate("InstrumentsXML", a->name.toUtf8().data()));
            item->setText(1, qApp->translate("InstrumentsXML", a->descr.toUtf8().data()));
            if (i == 0)
                  selectedItem = item;
            }
      connect(channelList, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
         SLOT(channelItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
      connect(this, SIGNAL(accepted()), SLOT(saveValues()));
      channelList->setCurrentItem(selectedItem);

      //---------------------------------------------------
      //    setup aeolus stops
      //---------------------------------------------------

      changeStops->setChecked(_staffText->setAeolusStops());

      for (int i = 0; i < 4; ++i) {
            for (int k = 0; k < 16; ++k)
                  stops[i][k] = 0;
            }
      stops[0][0]  = stop_3_0;
      stops[0][1]  = stop_3_1;
      stops[0][2]  = stop_3_2;
      stops[0][3]  = stop_3_3;
      stops[0][4]  = stop_3_4;
      stops[0][5]  = stop_3_5;
      stops[0][6]  = stop_3_6;
      stops[0][7]  = stop_3_7;
      stops[0][8]  = stop_3_8;
      stops[0][9]  = stop_3_9;
      stops[0][10] = stop_3_10;
      stops[0][11] = stop_3_11;

      stops[1][0]  = stop_2_0;
      stops[1][1]  = stop_2_1;
      stops[1][2]  = stop_2_2;
      stops[1][3]  = stop_2_3;
      stops[1][4]  = stop_2_4;
      stops[1][5]  = stop_2_5;
      stops[1][6]  = stop_2_6;
      stops[1][7]  = stop_2_7;
      stops[1][8]  = stop_2_8;
      stops[1][9]  = stop_2_9;
      stops[1][10] = stop_2_10;
      stops[1][11] = stop_2_11;
      stops[1][12] = stop_2_12;

      stops[2][0]  = stop_1_0;
      stops[2][1]  = stop_1_1;
      stops[2][2]  = stop_1_2;
      stops[2][3]  = stop_1_3;
      stops[2][4]  = stop_1_4;
      stops[2][5]  = stop_1_5;
      stops[2][6]  = stop_1_6;
      stops[2][7]  = stop_1_7;
      stops[2][8]  = stop_1_8;
      stops[2][9]  = stop_1_9;
      stops[2][10] = stop_1_10;
      stops[2][11] = stop_1_11;
      stops[2][12] = stop_1_12;
      stops[2][13] = stop_1_13;
      stops[2][14] = stop_1_14;
      stops[2][15] = stop_1_15;

      stops[3][0]  = stop_p_0;
      stops[3][1]  = stop_p_1;
      stops[3][2]  = stop_p_2;
      stops[3][3]  = stop_p_3;
      stops[3][4]  = stop_p_4;
      stops[3][5]  = stop_p_5;
      stops[3][6]  = stop_p_6;
      stops[3][7]  = stop_p_7;
      stops[3][8]  = stop_p_8;
      stops[3][9]  = stop_p_9;
      stops[3][10] = stop_p_10;
      stops[3][11] = stop_p_11;
      stops[3][12] = stop_p_12;
      stops[3][13] = stop_p_13;
      stops[3][14] = stop_p_14;
      stops[3][15] = stop_p_15;

      curTabIndex = tabWidget->currentIndex();
      connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(tabChanged(int)));

      MuseScore::restoreGeometry(this);
      }
Пример #25
0
void RoutePresenter::showModes(QTreeWidgetItem* top,
                               const QGeoRouteRequest &request,
                               QGeoRouteRequest::TravelModes travelModes)
{
    QTreeWidgetItem* optimizationItem = new QTreeWidgetItem(top);
    optimizationItem->setText(0, "optimization");

    QGeoRouteRequest::RouteOptimizations optimization = request.routeOptimization();

    if (optimization.testFlag(QGeoRouteRequest::ShortestRoute)) {
        QTreeWidgetItem* shortestRouteItem = new QTreeWidgetItem(optimizationItem);
        shortestRouteItem->setText(1, "ShortestRoute");
    }
    if (optimization.testFlag(QGeoRouteRequest::FastestRoute)) {
        QTreeWidgetItem* fastestRouteItem = new QTreeWidgetItem(optimizationItem);
        fastestRouteItem->setText(1, "FastestRoute");
    }
    if (optimization.testFlag(QGeoRouteRequest::MostEconomicRoute)) {
        QTreeWidgetItem* economicRouteItem = new QTreeWidgetItem(optimizationItem);
        economicRouteItem->setText(1, "MostEconomicRoute");
    }
    if (optimization.testFlag(QGeoRouteRequest::MostScenicRoute)) {
        QTreeWidgetItem* scenicRouteItem = new QTreeWidgetItem(optimizationItem);
        scenicRouteItem->setText(1, "MostScenicRoute");
    }

    QTreeWidgetItem* travelModeItem = new QTreeWidgetItem(top);
    travelModeItem->setText(0, "travel mode");

    if (travelModes.testFlag(QGeoRouteRequest::CarTravel)) {
        QTreeWidgetItem* carTravelItem = new QTreeWidgetItem(travelModeItem);
        carTravelItem->setText(1, "CarTravel");
    }
    if (travelModes.testFlag(QGeoRouteRequest::PedestrianTravel)) {
        QTreeWidgetItem* pedestrianTravelItem = new QTreeWidgetItem(travelModeItem);
        pedestrianTravelItem->setText(1, "PedestrianTravel");
    }
    if (travelModes.testFlag(QGeoRouteRequest::PublicTransitTravel)) {
        QTreeWidgetItem* transitTravelItem = new QTreeWidgetItem(travelModeItem);
        transitTravelItem->setText(1, "PublicTransitTravel");
    }
    if (travelModes.testFlag(QGeoRouteRequest::BicycleTravel)) {
        QTreeWidgetItem* bicycleTravelItem = new QTreeWidgetItem(travelModeItem);
        bicycleTravelItem->setText(1, "BicycleTravel");
    }
    if (travelModes.testFlag(QGeoRouteRequest::TruckTravel)) {
        QTreeWidgetItem* truckTravelItem = new QTreeWidgetItem(travelModeItem);
        truckTravelItem->setText(1, "TruckTravel");
    }

    QTreeWidgetItem* featuresItem = new QTreeWidgetItem(top);
    featuresItem->setText(0, "features");

    QList<QGeoRouteRequest::FeatureType> featureTypeList
        = request.featureTypes();

    for (int i = 0; i < featureTypeList.size(); ++i) {
        QGeoRouteRequest::FeatureWeight weight
            = request.featureWeight(featureTypeList.at(i));

        if (weight == QGeoRouteRequest::NeutralFeatureWeight)
            continue;

        QString labelString = "";
        switch (weight) {
        case QGeoRouteRequest::PreferFeatureWeight:
            labelString = "Prefer";
            break;
        case QGeoRouteRequest::AvoidFeatureWeight:
            labelString = "Avoid";
            break;
        case QGeoRouteRequest::DisallowFeatureWeight:
            labelString = "Disallow";
            break;
        }

        if (labelString.isEmpty())
            continue;

        labelString += " ";

        switch (featureTypeList.at(i)) {
        case QGeoRouteRequest::TollFeature:
            labelString += "tolls";
            break;
        case QGeoRouteRequest::HighwayFeature:
            labelString += "highways";
            break;
        case QGeoRouteRequest::PublicTransitFeature:
            labelString += "public transit";
            break;
        case QGeoRouteRequest::FerryFeature:
            labelString += "ferries";
            break;
        case QGeoRouteRequest::TunnelFeature:
            labelString += "tunnels";
            break;
        case QGeoRouteRequest::DirtRoadFeature:
            labelString += "dirt roads";
            break;
        case QGeoRouteRequest::ParksFeature:
            labelString += "parks";
            break;
        case QGeoRouteRequest::MotorPoolLaneFeature:
            labelString += "motor pool lanes";
            break;
        default:
            labelString = "";
            break;
        }

        if (labelString.isEmpty())
            continue;

        QTreeWidgetItem* item = new QTreeWidgetItem(featuresItem);
        item->setText(1, labelString);
    }
}
Пример #26
0
void SettingsSharing::slotContextMenu(const QPoint &){
    QList<QTreeWidgetItem*> selected = treeWidget_SIMPLE_MODE->selectedItems();
    QMenu *menu = new QMenu();
    QAction *add_new = nullptr, *rem = nullptr, *rename = nullptr;
    WulforUtil *WU = WulforUtil::getInstance();

    add_new = new QAction(WU->getPixmap(WulforUtil::eiEDITADD), tr("Add"), menu);
    menu->addAction(add_new);

    if (selected.size() == 1){
        rename = new QAction(WU->getPixmap(WulforUtil::eiEDIT), tr("Rename"), menu);
        menu->addAction(rename);
    }

    if (!selected.isEmpty()){
        rem = new QAction(WU->getPixmap(WulforUtil::eiEDITDELETE), tr("Remove"), menu);
        menu->addAction(rem);
    }

    QAction *res = menu->exec(QCursor::pos());

    delete menu;

    if (!res)
        return;

    if (res == add_new){
        QString dir = QFileDialog::getExistingDirectory(this, tr("Select directory"), QDir::homePath());

        if (dir.isEmpty())
            return;

        dir = QDir::toNativeSeparators(dir);

        if (!dir.endsWith(PATH_SEPARATOR))
            dir += PATH_SEPARATOR_STR;

        bool ok = false;
        QString dir_alias = QInputDialog::getText(this, tr("Select directory"), tr("Name"),
                                                  QLineEdit::Normal, QDir(dir).dirName(), &ok);

        dir_alias = dir_alias.trimmed();

        if (!ok || dir_alias.isEmpty())
            return;

        try
        {
            ShareManager::getInstance()->addDirectory(dir.toStdString(), dir_alias.toStdString());
        }
        catch (const ShareException &e)
        {
            QMessageBox msg_box(QMessageBox::Critical,
                                tr("Error"),
                                QString::fromStdString(e.getError()),
                                QMessageBox::Ok);

            msg_box.exec();

            return;
        }

        QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_SIMPLE_MODE);

        item->setText(0, dir);
        item->setText(1, dir_alias);
        item->setText(2, "");
        item->setText(3, "");
    }
    else if (res == rem){
        for (const auto &i : selected)
            ShareManager::getInstance()->removeDirectory(i->text(0).toStdString());
    }
    else if (res == rename){
        QTreeWidgetItem *item = selected.at(0);
        QString realname = item->text(0);
        QString virtname = item->text(1);
        bool ok = false;
        QString new_virtname = QInputDialog::getText(this, tr("Enter new name"),
                                                     tr("Name"), QLineEdit::Normal, virtname, &ok);

        if (!ok || new_virtname.isEmpty() || new_virtname == virtname)
            return;

        try {
            ShareManager::getInstance()->renameDirectory(realname.toStdString(), new_virtname.toStdString());
        }
        catch (const ShareException &e){
            QMessageBox msg_box(QMessageBox::Critical,
                                tr("Error"),
                                QString::fromStdString(e.getError()),
                                QMessageBox::Ok);

            msg_box.exec();

            return;
        }
    }

    updateShareView();
}
Пример #27
0
void RoutePresenter::showRoute(QTreeWidgetItem* top, const QGeoRoute& route)
{
    QTreeWidgetItem* routeItem = new QTreeWidgetItem(top);
    routeItem->setText(0, "route");

    QTreeWidgetItem* idItem = 0;
    if (!route.routeId().isEmpty()) {
        idItem = new QTreeWidgetItem(routeItem);
        idItem->setText(0, "id");
        idItem->setText(1, route.routeId());
    }

    QTreeWidgetItem* modeItem = new QTreeWidgetItem(routeItem);
    modeItem->setText(0, "mode");
    showModes(modeItem, route.request(), route.travelMode());

    QTreeWidgetItem* distanceItem = new QTreeWidgetItem(routeItem);
    distanceItem->setText(0, "distance");
    distanceItem->setText(1, QString().setNum(route.distance()));

    showBoundingBox(routeItem, route.bounds());

    QTreeWidgetItem* wayPointsItem = new QTreeWidgetItem(routeItem);
    QString overviewLabel = "overview";
    if (route.path().count() > 100)
        overviewLabel += "(100)";
    wayPointsItem->setText(0, overviewLabel);
    showPoints(wayPointsItem, route.path());

    QList<QGeoRouteSegment> segments;
    QGeoRouteSegment segment = route.firstRouteSegment();
    while (segment.isValid()) {
        segments << segment;
        segment = segment.nextRouteSegment();
    }

    QTreeWidgetItem* segmentsItem = new QTreeWidgetItem(routeItem);
    QString segmentsLabel = "segments";
    if (segments.length() > 100)
        segmentsLabel += "(100)";

    segmentsItem->setText(0, segmentsLabel);

    segmentsItem->setText(1, QString().setNum(segments.length()));
    for (int i = 0; i < segments.length() && i < 100; ++i) {
        showRouteSegment(segmentsItem, segments[i]);
    }
}
Пример #28
0
bool CQRDFTreeView::enterProtected()
{
  clear();

  mpAnnotation = CAnnotation::castObject(mpObject);

  if (mpAnnotation == NULL) return false;

  if (!mpAnnotation->getMiriamAnnotation().empty())
    {
      mpGraph = CRDFParser::graphFromXml(mpAnnotation->getMiriamAnnotation());
    }

  CCopasiMessage::clearDeque();

  if (CCopasiMessage::size() != 0)
    {
      QString Message = FROM_UTF8(CCopasiMessage::getAllMessageText());
      CQMessageBox::warning(this, QString("RDF Warning"), Message,
                            QMessageBox::Ok, QMessageBox::Ok);
    }

  if (mpGraph == NULL)
    mpGraph = new CRDFGraph;

  // We make sure that we always have an about node.
  mpGraph->createAboutNode(mpObject->getKey());

  // We iterate of all triplets
  std::set< CRDFTriplet >::const_iterator it = mpGraph->getTriplets().begin();
  std::set< CRDFTriplet >::const_iterator end = mpGraph->getTriplets().end();

  for (; it != end; ++it)
    {
      CQRDFTreeViewItem * pSubjectItem = find(it->pSubject);

      if (pSubjectItem == NULL)
        {
          pSubjectItem = new CQRDFTreeViewItem(mpTreeWidget, NULL);
          insert(it->pSubject, pSubjectItem);
          // Display the subject information

          const CRDFSubject & Subject = it->pSubject->getSubject();

          switch (Subject.getType())
            {
              case CRDFSubject::RESOURCE:
                pSubjectItem->setText(COL_SUBJECT, FROM_UTF8(Subject.getResource()));
                break;

              case CRDFSubject::BLANK_NODE:
                pSubjectItem->setText(COL_SUBJECT, FROM_UTF8(Subject.getBlankNodeID()));
                break;
            }
        }

      CQRDFTreeViewItem * pObjectItem = NULL;

      if (it->Predicate.getURI() == "http://www.w3.org/1999/02/22-rdf-syntax-ns#subject")
        {
          pObjectItem = new CQRDFTreeViewItem(pSubjectItem, NULL);
          insert(it->pObject, pObjectItem);
        }
      else
        pObjectItem = find(it->pObject);

      if (pObjectItem == NULL)
        {
          pObjectItem = new CQRDFTreeViewItem(pSubjectItem, NULL);
          insert(it->pObject, pObjectItem);
        }
      else
        {
          QTreeWidgetItem * pParent = pObjectItem->parent();

          if (pParent == NULL)
            {
              mpTreeWidget->invisibleRootItem()->removeChild(pObjectItem);
              pSubjectItem->addChild(pObjectItem);
            }
          else
            {
              pParent->removeChild(pObjectItem);
              pSubjectItem->addChild(pObjectItem);
            }
        }

      pObjectItem->setTriplet(*it);
    }

  //mpTreeWidget->setFocus();

  return true;
}
Пример #29
0
HolidayRegionSelector::HolidayRegionSelector( QWidget *parent ) :
  QWidget( parent ), d( new Private( this ) )
{
  d->m_ui.setupUi( this );

  // Setup the columns
  d->m_ui.regionTreeWidget->setColumnCount( 5 );
  QTreeWidgetItem *headerItem = d->m_ui.regionTreeWidget->headerItem();
  QString header = i18nc( "Header for Select column", "Select" );
  QString text = i18n( "<p>This column selects to use the Holiday Region</p>" );
  headerItem->setText( Private::SelectColumn, header );
  headerItem->setToolTip( Private::SelectColumn, text );
  headerItem->setWhatsThis( Private::SelectColumn, text );
  headerItem->setText( Private::ComboColumn, header );
  headerItem->setToolTip( Private::ComboColumn, text );
  headerItem->setWhatsThis( Private::ComboColumn, text );
  header = i18nc( "Header for Holiday Region column", "Region" );
  text = i18n( "<p>This column displays the name of the Holiday Region</p>" );
  headerItem->setText( Private::RegionColumn, header );
  headerItem->setToolTip( Private::RegionColumn, text );
  headerItem->setWhatsThis( Private::RegionColumn, text );
  header = i18nc( "Header for Language column", "Language" );
  text = i18n( "<p>This column displays the language of the Holiday Region</p>" );
  headerItem->setText( Private::LanguageColumn, header );
  headerItem->setToolTip( Private::LanguageColumn, text );
  headerItem->setWhatsThis( Private::LanguageColumn, text );
  header = i18nc( "Header for Description column", "Description" );
  text = i18n( "<p>This column displays the description of the Holiday Region</p>" );
  headerItem->setText( Private::DescriptionColumn, header );
  headerItem->setToolTip( Private::DescriptionColumn, text );
  headerItem->setWhatsThis( Private::DescriptionColumn, text );

  d->m_ui.regionTreeWidget->setSelectionMode( QAbstractItemView::NoSelection );
  d->m_ui.regionTreeWidget->setItemsExpandable( true ); //per bug 271628
  d->m_ui.regionTreeWidget->setUniformRowHeights( true );
  d->m_ui.regionTreeWidget->setAllColumnsShowFocus( true );
  connect( d->m_ui.regionTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
           this, SLOT(itemChanged(QTreeWidgetItem*,int)) );

  QMap<QString, QStringList> regionCodeMap;
  QMap<QString, HolidayRegion*> regionMap;
  foreach ( const QString &regionCode, HolidayRegion::regionCodes() ) {
    regionMap[regionCode] = new HolidayRegion( regionCode );
    QString country = regionMap[regionCode]->countryCode().split( '-' ).at( 0 );
    regionCodeMap[country].append( regionCode );
  }
Пример #30
0
QString GTUtilsAnnotationsTreeView::getQualifierValue(HI::GUITestOpStatus &os, const QString &qualifierName, QTreeWidgetItem *parentItem) {
    GTTreeWidget::getItemCenter(os, parentItem);
    QTreeWidgetItem *qualifierItem = findItem(os, qualifierName, parentItem);
    GT_CHECK_RESULT(NULL != qualifierItem, "Qualifier item not found", "");
    return qualifierItem->text(AnnotationsTreeView::COLUMN_VALUE);
}