예제 #1
0
void MaterialCategoryModel::addCategory(const QString& name,
                                        const QString& displayName,
                                        const QColor& bgColor,
                                        bool readonly)
{
    addCategory(QUuid::createUuid().toString(), name, displayName, bgColor, readonly);
}
예제 #2
0
void EditParams::setModule(const char* module)
{
	//Set up the tab widget before rendering into it
	if(catTab!=NULL)
		delete catTab;
	catTab = new QTabWidget(this);
	m_ui->mainLayout->insertWidget(1, catTab);

	//Change the module name
	this->module = module;
	m_ui->lbl_modulename->setText(QString::fromUtf8(ppk_module_display_name(module)));
	m_ui->lbl_textintro->setText(tr("Edit settings of the \nmodule %0").arg(QString::fromUtf8(ppk_module_display_name(module))));

	//Show the available parameters
	const ppk_proto_param** list=ppk_module_available_parameters(module);
	if(list)
	{
		int i=0;
		while(list[i]!=NULL && list[i]->group!=NULL)
		{
			if(!categories.contains(QString::fromUtf8(list[i]->group->display_name)))
				addCategory(catTab, list[i]->group);

			addParam(catTab, categories[QString::fromUtf8(list[i]->group->display_name)], list[i]);

			i++;
		}
	}
}
예제 #3
0
///-------------------------------------------------------------
void CXMLAnalyser::fillResultList( const QVector< int > &categories )
///-------------------------------------------------------------
{
    QDomNodeList nodeList;

    if ( true == getCategoriesList( nodeList ) )
    {
        int         amount = nodeList.size( );
        int         value;
        QString     text;
        QDomElement node;

        for ( int i = 0; i < amount; ++i )
        {
            node = nodeList.item( i ).toElement( );
            value = node.attribute( "CatID" ).toInt( );

            if ( categories.end( ) != std::find( categories.begin( ), categories.end( ), value ) )
            {
                text = node.text( );
                addCategory( value, text );
            }
        }
    }
}
예제 #4
0
void EntityIdentifier::parseCategoryDefinition(JSONObject *data, int packID) {
  QString category;
  if (data->has("category"))
    category = data->at("category")->asString();
  else
    category = "Unknown";

  QColor catcolor;
  if (data->has("catcolor")) {
    QString colorname = data->at("catcolor")->asString();
    catcolor.setNamedColor(colorname);
    assert(catcolor.isValid());
  } else {  // use hashed by name instead
    quint32 hue = qHash(category);
    catcolor.setHsv(hue % 360, 255, 255);
  }
  addCategory(qMakePair(category, catcolor));

  if (data->has("entity")) {
    JSONArray *entities = dynamic_cast<JSONArray *>(data->at("entity"));
    int len = entities->length();

    for (int e = 0; e < len; e++)
      parseEntityDefinition(dynamic_cast<JSONObject *>(entities->at(e)),
                            category, catcolor, packID);
  }
}
예제 #5
0
NewCategoryDialog::NewCategoryDialog(QWidget *parent) :
    QDialog(parent),
    m_nameEdit(new QLineEdit(this)),
    m_pathEdit(new QLineEdit(this)),
    m_browseButton(new QPushButton(tr("Browse"), this)),
    m_doneButton(new QPushButton(tr("Done"), this))
{
    this->setWindowTitle(tr("New category"));
    this->setAttribute(Qt::WA_DeleteOnClose, true);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
    buttonBox->addButton(m_browseButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(QDialogButtonBox::Cancel);
    buttonBox->addButton(m_doneButton, QDialogButtonBox::AcceptRole);

    QGridLayout *grid = new QGridLayout(this);
    grid->addWidget(new QLabel(tr("Name") + ":", this), 0, 0);
    grid->addWidget(m_nameEdit, 0, 1);
    grid->addWidget(new QLabel(tr("Download path") + ":", this), 1, 0);
    grid->addWidget(m_pathEdit, 1, 1);
    grid->addWidget(buttonBox, 2, 0, 1, 2);

    m_doneButton->setEnabled(false);

    this->connect(m_nameEdit, SIGNAL(textChanged(QString)), this, SLOT(onNameTextChanged(QString)));
    this->connect(m_browseButton, SIGNAL(clicked()), this, SLOT(showFileDialog()));
    this->connect(buttonBox, SIGNAL(accepted()), this, SLOT(addCategory()));
    this->connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
예제 #6
0
void Spreadsheet::setUp(const FactControl & x) {
  const GBList<int> & V = x.indicesOfPermanentFacts();
  GBList<int>::const_iterator w = V.begin();
  const int n = V.size();
//GBStream << "#:rules:" << n << '\n';
  d_rules.reserve(n);
  for(int i=0;i<n;++i,++w) {
    int j = *w;
    const GroebnerRule & r = x.fact(j);
    VariableSet variables;
    d_rules.push_back(r);
    int nfac = r.LHS().numberOfFactors();
    if(nfac==1) {
      d_singleRules.push_back(r);
      d_singleVariables.insert(*(r.LHS().begin()));
      d_digested.push_back(i);
    } else {
      GrabVariables(r,variables);
      VariableSet knownvariables,unknownvariables;
      ((AdmWithLevels *)d_order)->sortIntoKnownsAndUnknowns(
             variables,knownvariables,unknownvariables);
      Categories * ptr = findCategory(unknownvariables);
      if(!ptr) {
        RECORDHERE(ptr = new Categories(); )
        ptr->addUnknowns(unknownvariables);
        addCategory(*ptr); 
        RECORDHERE(delete ptr;)
        ptr = findCategory(unknownvariables);
        if(!ptr) DBG();
      };
예제 #7
0
category_t *sortCategory(category_t *head, int size)
{
  if(size < 1)
    return head;
  int i;
  category_t *current = head, *temp = current;
  for(i = 0; i < size; i++)
  {
    if(strcmp(current->title, temp->title) > 0)
      temp = current;
    if(current->next != NULL)
      current = current->next;
  }
  if(strcmp(current->title, temp->title) > 0)
    temp = current;
  if(strcmp(temp->title, current->title) != 0)
  {
    if(strcmp(temp->title, head->title) == 0)
      head = temp->next;
    else 
      temp = removeCategory(head, temp->title); 
    addCategory(current, temp);
  }
  return sortCategory(head, size-1);
}
void QgsCategorizedSymbolRendererV2Widget::addCategory()
{
  QgsSymbolV2 *symbol = QgsSymbolV2::defaultSymbol( mLayer->geometryType() );
  QgsRendererCategoryV2 cat( QString(), symbol, QString() );
  addCategory( cat );
  mRenderer->addCategory( cat );
}
예제 #9
0
ConsoleRoboCupCtrl::ConsoleRoboCupCtrl(SimRobot::Application& application) :
  RoboCupCtrl(application), calculateImageFps(FRAMES_PER_SECOND),
  mode(SystemCall::simulatedRobot), currentCompletionIndex(completion.end()),
  toolBar(*this)
{
  application.getLayoutSettings().setValue("Run", true);

  consoleView = new ConsoleView("Console", *this);
  addView(consoleView, nullptr, SimRobot::Flag::verticalTitleBar);
  addView(new ConsoleView("Console.Pad", *this, true), consoleView, SimRobot::Flag::verticalTitleBar);

  SimRobot::Object* documentationCategory = addCategory("Docs", nullptr, ":/Icons/page_white_h.png");
  addView(new CABSLGraphViewObject("Docs.BehaviorControl", "BehaviorControl", "Options.h"), documentationCategory);

  // file names for representations
  representationToFile["representation:BallSpecification"] = "ballSpecification.cfg";
  representationToFile["representation:BehaviorParameters"] = "behaviorParameters.cfg";
  representationToFile["representation:CameraCalibration"] = "cameraCalibration.cfg";
  representationToFile["representation:CameraIntrinsics"] = "cameraIntrinsics.cfg";
  representationToFile["representation:HeadLimits"] = "headLimits.cfg";
  representationToFile["representation:IMUCalibration"] = "imuCalibration.cfg";
  representationToFile["representation:JointCalibration"] = "jointCalibration.cfg";
  representationToFile["representation:JointLimits"] = "jointLimits.cfg";
  representationToFile["representation:MassCalibration"] = "massCalibration.cfg";
  representationToFile["representation:RobotDimensions"] = "robotDimensions.cfg";
}
예제 #10
0
Dataset::Dataset(string str): root(str){
  path full_path =  system_complete(root);
  directory_iterator end_itr;
  size_t label = 0;
  if(is_directory(full_path)){
    try{
      for (directory_iterator itr( full_path ); itr != end_itr;++itr ){
	if(is_directory(itr->path())){
	  string root, descriptor, catname;
	  root = (string) itr->path().string().c_str();
	  catname = (string) itr->path().filename().c_str();
	  vector<DataPoint> dps = getDataPoints(itr->path(), label, catname);
	  Category newcat(catname, root, label, dps);
	  category_names[label] = catname;
	  if(newcat.size() > 10){
	    addCategory(newcat);
	    label++;
	  }
	}
      }
    }
    catch(...){
    }
  } 
}
예제 #11
0
void addCategoryToObject( int inObjectID, int inParentID ) {

    if( getCategory( inParentID ) == NULL ) {
        addCategory( inParentID );
        }

    if( inObjectID >= reverseMapSize ) {
        // expand map

        int newMapSize = inObjectID + 1;
        
        ReverseCategoryRecord **newMap = new ReverseCategoryRecord*[newMapSize];
        
        for( int i=0; i<newMapSize; i++ ) {
            newMap[i] = NULL;
            }

        memcpy( newMap, reverseMap, 
                sizeof(ReverseCategoryRecord*) * reverseMapSize );

        delete [] reverseMap;
        reverseMap = newMap;
        reverseMapSize = newMapSize;
        }
    
    
    CategoryRecord *r = getCategory( inParentID );
    
    if( r != NULL ) {

        for( int i=0; i< r->objectIDSet.size(); i++ ) {
            if( r->objectIDSet.getElementDirect( i ) == inObjectID ) {
                // already there
                return;
                }
            }

        r->objectIDSet.push_back( inObjectID );
        r->objectWeights.push_back( 0.0f );
        autoAdjustWeights( inParentID );
        
        ReverseCategoryRecord *rr = getReverseCategory( inObjectID );

        
        if( rr == NULL ) {
            rr = new ReverseCategoryRecord;

            rr->childID = inObjectID;
            
            reverseMap[ inObjectID ] = rr;        
            }
        
        rr->categoryIDSet.push_back( inParentID );

        saveCategoryToDisk( inParentID );
        }
    
    }
예제 #12
0
파일: settings.c 프로젝트: An00bIS47/gbMon2
// ---------------------------------------------------------------------------
int Settings_Load(char* file) {
	if(settings != NULL) Settings_Unload();
	settings = (SettingsFile*)malloc(sizeof(SettingsFile));
	settings->category = NULL;
	settings->cats = 0;
	FILE* f = fopen(file, "r");
	if(f == NULL) return 0;
	char buffer[256];
	char* line;
	int current_cat = -1;
	while(fgets(buffer, 256, f) != NULL) {
		line = trim(&buffer[0]);
		if(strlen(line) == 0) continue; // blank line
		if(line[0] == '#') continue; // just a comment
		// new category
		if(line[0] == '[') {
			line++;
			line[strlen(line) - 1] = 0;
			char* cat_name = (char*)malloc(sizeof(char) * (1 + strlen(line)));
            strcpy(cat_name, line);
			addCategory(cat_name);
            current_cat = settings->cats - 1;
            //printf("Cat: %s\r\n", line);
		}
		// new value
		else {
			// value without category -> error
			if(current_cat == -1) {
				fclose(f);
				return 0;
			}
			// get key and value
			char* ptr = strtok(line, "=");
			if(ptr == NULL) {
				fclose(f);
				return 0;
			}
			ptr = skipWhitespace(ptr);
			char* key = (char*)malloc(sizeof(char) * (1 + strlen(ptr)));
			strcpy(key, ptr);
			key = trim(key);
			ptr = strtok(NULL, "\1");
			//ptr += strlen(ptr) + 1;
			if(ptr == NULL) {
				fclose(f);
				return 0;
			}
			ptr = skipWhitespace(ptr);
			char* value = (char*)malloc(sizeof(char) * (1 + strlen(ptr)));
			strcpy(value, ptr);
			value = trim(value);
            addValue(current_cat, key, value);
            printf(" -> %s: %s\r\n", key, value);
		}
	}
	fclose(f);
	return 1;
}
예제 #13
0
void MainController::newCategory(QString name)
{
    if(!categories().contains(name))
    {
        CategorySPointer zeus(new Category);
        zeus->setName(name);
        addCategory(zeus);
        m_mw->setCategoryList(categories().keys());
        m_mw->setCurrentCategory(name);
    }

}
예제 #14
0
/*!
    \internal
*/
int QDesignerWidgetBoxInterface::findOrInsertCategory(const QString &categoryName)
{
    int count = categoryCount();
    for (int index=0; index<count; ++index) {
        Category c = category(index);
        if (c.name() == categoryName)
            return index;
    }

    addCategory(Category(categoryName));
    return count;
}
예제 #15
0
// MANIPULATORS
Category *CategoryManager::addCategory(const char *categoryName,
                                       int         recordLevel,
                                       int         passLevel,
                                       int         triggerLevel,
                                       int         triggerAllLevel)
{
    return addCategory(0,
                       categoryName,
                       recordLevel,
                       passLevel,
                       triggerLevel,
                       triggerAllLevel);
}
예제 #16
0
void CategoryModel::refresh()
{
    catData.clear();
    addCategory(" All packages"," "+tr("All packages"),"applications-system",QString(),QString());
    addCategory(" Updates"," "+tr("Updates"),"update",QString(),QString::number(ICONSTATE_UPDATE));
    addCategory(" Installed"," "+tr("Installed"),"installed",QString(),QString::number(ICONSTATE_INSTALLED)+","+QString::number(ICONSTATE_INSTALLED_DEPRECATED));
    addCategory(" Not installed"," "+tr("Not installed"),"available",QString(),QString::number(ICONSTATE_AVAILABLE)+","+QString::number(ICONSTATE_AVAILABLE_DEPRECATED));
    QDir dir("/etc/apackager/categories.d");
    QMap <QString, QString> map;
    QStringList filters;
    filters << "*.conf";
    QStringList files = dir.entryList(filters);
    for (int k=0; k<files.size(); ++k){
        map.clear();
        QFile file(dir.path()+"/"+files.at(k));
        file.open(QIODevice::ReadOnly | QIODevice::Text);
        QTextStream in(&file);
        in.setCodec(QTextCodec::codecForName("UTF8"));
        while(!in.atEnd()){
            QString str=in.readLine();
            QRegExp reg("^[ ]*([^= ]*)[ ]*=([^=]*)$");
            if (reg.indexIn(str)!=-1){
                QString param=reg.cap(1);
                QString val=reg.cap(2);
                param=param.toLower();
                val.remove(QRegExp("^[ ]*|[ ]$"));
                if (param=="tags") val.replace(" ","");
                map[param]=val;
                //qDebug()<<"param: "<<param<<" value: "<<val;
            }
        }
        file.close();
        catData.push_back(map);
    }
    reset();
}
예제 #17
0
void WidgetBoxTreeWidget::addCustomCategories(bool replace)
{
    if (replace) {
        // clear out all existing custom widgets
        if (const int numTopLevels =  topLevelItemCount()) {
            for (int t = 0; t < numTopLevels ; ++t)
                categoryViewAt(t)->removeCustomWidgets();
        }
    }
    // re-add
    const CategoryList customList = loadCustomCategoryList();
    const CategoryList::const_iterator cend = customList.constEnd();
    for (CategoryList::const_iterator it = customList.constBegin(); it != cend; ++it)
        addCategory(*it);
}
예제 #18
0
void CategoryFilterWidget::showMenu(QPoint)
{
    QMenu menu(this);

    QAction *addAct = menu.addAction(
                          GuiIconProvider::instance()->getIcon("list-add")
                          , tr("Add category..."));
    connect(addAct, SIGNAL(triggered()), SLOT(addCategory()));

    auto selectedRows = selectionModel()->selectedRows();
    if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first())) {
        if (BitTorrent::Session::instance()->isSubcategoriesEnabled()) {
            QAction *addSubAct = menu.addAction(
                        GuiIconProvider::instance()->getIcon("list-add")
                        , tr("Add subcategory..."));
            connect(addSubAct, SIGNAL(triggered()), SLOT(addSubcategory()));
        }

        QAction *removeAct = menu.addAction(
                        GuiIconProvider::instance()->getIcon("list-remove")
                        , tr("Remove category"));
        connect(removeAct, SIGNAL(triggered()), SLOT(removeCategory()));
    }

    QAction *removeUnusedAct = menu.addAction(
                                   GuiIconProvider::instance()->getIcon("list-remove")
                                   , tr("Remove unused categories"));
    connect(removeUnusedAct, SIGNAL(triggered()), SLOT(removeUnusedCategories()));

    menu.addSeparator();

    QAction *startAct = menu.addAction(
                            GuiIconProvider::instance()->getIcon("media-playback-start")
                            , tr("Resume torrents"));
    connect(startAct, SIGNAL(triggered()), SIGNAL(actionResumeTorrentsTriggered()));

    QAction *pauseAct = menu.addAction(
                            GuiIconProvider::instance()->getIcon("media-playback-pause")
                            , tr("Pause torrents"));
    connect(pauseAct, SIGNAL(triggered()), SIGNAL(actionPauseTorrentsTriggered()));

    QAction *deleteTorrentsAct = menu.addAction(
                                     GuiIconProvider::instance()->getIcon("edit-delete")
                                     , tr("Delete torrents"));
    connect(deleteTorrentsAct, SIGNAL(triggered()), SIGNAL(actionDeleteTorrentsTriggered()));

    menu.exec(QCursor::pos());
}
예제 #19
0
void CategoryMgr::editCategories(const Category* cat, QWidget* parent)
{
  // Create the filter dialog
  CategoryDlg* dlg = new CategoryDlg(parent, "CategoryDlg");

  // editing an existing category?
  if (cat != NULL)
  {
    // yes, use it's info for the defaults
    dlg->m_Name->setText(cat->name());
    dlg->m_Filter->setText(cat->filter());
    dlg->m_FilterOut->setText(cat->filterout());
    dlg->m_Color->setPalette(QPalette(QColor(cat->color())));
  }
  else
  {
    dlg->m_Name->setText("");
    dlg->m_Filter->setText(".");
    dlg->m_FilterOut->setText("");
    dlg->m_Color->setPalette(QPalette(QColor("black")));
  }

  // execute the dialog
  int res = dlg->exec();

  // if the dialog wasn't accepted, don't add/change a category
  if (res != QDialog::Accepted)
    return;

  // remove the old category
  if (cat != NULL)
    remCategory(cat);

  // Add Category
  QString name = dlg->m_Name->text();
  QString filter = dlg->m_Filter->text();

  //seqDebug("Got name: '%s', filter '%s', filterout '%s', color '%s'",
  //  name?name:"", color?color:"", filter?filter:"", filterout?filterout:""); 

  if (!name.isEmpty() && !filter.isEmpty())
    addCategory(name, 
		filter, 
		dlg->m_FilterOut->text(), 
		dlg->m_Color->backgroundColor());
  
  delete dlg;
}
예제 #20
0
int main() {
	SetColorAndBackground(0xFFF,0);
	Postagens posts[100];
	Autor autores[100];
	char categorias[100][100];
	Numeros numeros;
	int opcao;
	addPrePosts(autores,categorias,&numeros);
	while(true) {
		opcao=0;
		system("cls");
		printf("Blog dojão\n");
		printf("1 - Adicionar Postagem\n");
		printf("2 - Visualizar Postagens\n");
		printf("3 - Adicionar Categoria\n");
		printf("4 - Adicionar Autor\n");
		printf("5 - Deletar Categoria\n");
		printf("6 - Deletar Autor\n");
		printf("7 - Deletar Postagem\n");
		
		printf("\n\n\nEscolha um menu:");
		scanf("%d",&opcao);
		switch (opcao) {
			case 1:
				addPost(posts,autores,categorias,&numeros);
				break;
			case 2:
				showPosts(posts,autores,categorias,&numeros);
				break;
			case 3:
				addCategory(categorias,&numeros);
				break;
			case 4:
				addAuthor(autores,&numeros);
				break;
			case 5:
				deleteCategory(categorias,&numeros);
				break;
			case 6:
				deleteAuthor(autores,&numeros);
				break;
			case 7:
				deletePost(posts,&numeros);
				break;
		}
	}
}
예제 #21
0
MaterialCategoryModel::MaterialCategoryModel(QObject *parent) :
    QAbstractTableModel(parent),
    modified_(false)
{
    addCategory("No Category", tr("No Category"), QColor(255, 255, 255, 0), true);
    addCategory("Structural", tr("Structural"), QColor(100, 0, 0, 255), true);
    addCategory("Structural Core", tr("Structural Core"), QColor(0, 100, 0, 255), true);
    addCategory("Thermal Management", tr("Thermal Management"), QColor(0, 100, 0, 255), true);
    addCategory("Glue", tr("Glue"), QColor(0, 100, 0, 255), true);
    addCategory("Elementary", tr("Elementary"), QColor(0, 100, 0, 255), true);
}
예제 #22
0
void CategoryModel::insertRow()
{
    int n(0);
    int i(0);
    bool findName(false);
    do {
        n++;
        i=0;
        findName=false;
        while (i<catData.size()&& !findName){
            findName=(catData.at(i).value("name[en]")=="New category-"+QString::number(n));
            ++i;
        }
    } while(findName);
    addCategory("New category-"+QString::number(n),tr("New category")+"-"+QString::number(n),"applications-system",QString(),QString());
    reset();
}
예제 #23
0
bool WidgetBoxTreeWidget::loadContents(const QString &contents)
{
    QString errorMessage;
    CategoryList cat_list;
    if (!readCategories(m_file_name, contents, &cat_list, &errorMessage)) {
        qdesigner_internal::designerWarning(errorMessage);
        return false;
    }

    foreach(const Category &cat, cat_list)
        addCategory(cat);

    addCustomCategories(false);
    // Restore which items are expanded
    restoreExpandedState();
    return true;
}
예제 #24
0
// Are we allowed to print this category??
bool Debug::isCategoryAllowed(const vpr::DebugCategory& catId)
{
   bool allow_category(false);

   // Make sure category is in the vector
   category_map_t::iterator cat = mCategories.find(catId.mGuid);

   if ( cat == mCategories.end() )
   {
      // Autoregister
      addCategory(catId);
      cat = mCategories.find(catId.mGuid);
   }

   vprASSERT(cat != mCategories.end() && "Auto-register failed");    // ASSERT: We have a valid category

   category_map_t::iterator cat_all = mCategories.find(vprDBG_ALL.mGuid);
   vprASSERT(cat_all != mCategories.end());    // ASSERT: We have a valid category

   // If I specified to listen to all OR
   // If it has category of ALL
   const bool cat_is_all(catId.mGuid == vprDBG_ALL.mGuid);
   const bool allow_all((*cat_all).second.mAllowed == true);

   if ( cat_is_all || allow_all )
   {
      allow_category = true;
   }
   else
   {
      allow_category = (*cat).second.mAllowed;
   }

   // Check dis-allowing
   // - If a category is disallowed, then set it false
   if ( allow_category )   // Only worry about it if it is already enabled
   {
      if ( (*cat).second.mDisallowed )      // If disallowed
      {
         allow_category = false;          // Dis-allow it
      }
   }

   return allow_category;
}
예제 #25
0
CategoriesDialog::CategoriesDialog(QWidget *parent) :
    QDialog(parent),
    m_model(new CategoryModel(this)),
    m_view(new QTreeView(this)),
    m_nameEdit(new QLineEdit(this)),
    m_pathButton(new QMaemo5ValueButton(tr("Download path"), this)),
    m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Vertical, this)),
    m_layout(new QGridLayout(this))
{
    setWindowTitle(tr("Categories"));
    setMinimumHeight(360);

    m_view->setModel(m_model);
    m_view->setSelectionBehavior(QTreeView::SelectRows);
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    m_view->setEditTriggers(QTreeView::NoEditTriggers);
    m_view->setItemsExpandable(false);
    m_view->setUniformRowHeights(true);
    m_view->setAllColumnsShowFocus(true);
    m_view->setRootIsDecorated(false);
    m_view->header()->setStretchLastSection(true);

    m_nameEdit->setPlaceholderText(tr("Name"));

    m_pathButton->setValueText(tr("None chosen"));

    m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);

    m_layout->addWidget(m_view, 0, 0);
    m_layout->addWidget(m_nameEdit, 1, 0);
    m_layout->addWidget(m_pathButton, 2, 0);
    m_layout->addWidget(m_buttonBox, 2, 1);
    m_layout->setRowStretch(0, 1);

    connect(m_view, SIGNAL(clicked(QModelIndex)), this, SLOT(setCurrentCategory(QModelIndex)));
    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_nameEdit, SIGNAL(textChanged(QString)), this, SLOT(onNameChanged(QString)));
    connect(m_nameEdit, SIGNAL(returnPressed()), m_buttonBox->button(QDialogButtonBox::Ok), SLOT(animateClick()));
    connect(m_pathButton, SIGNAL(clicked()), this, SLOT(showFileDialog()));
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(addCategory()));
}
예제 #26
0
CategorySettingsPage::CategorySettingsPage(QWidget *parent) :
    SettingsPage(parent),
    m_model(new CategoryModel(this)),
    m_view(new QTreeView(this)),
    m_nameEdit(new QLineEdit(this)),
    m_pathEdit(new QLineEdit(this)),
    m_pathButton(new QPushButton(QIcon::fromTheme("document-open"), tr("&Browse"), this)),
    m_saveButton(new QPushButton(QIcon::fromTheme("document-save"), tr("&Save"), this)),
    m_layout(new QFormLayout(this))
{
    setWindowTitle(tr("Categories"));

    m_view->setModel(m_model);
    m_view->setAlternatingRowColors(true);
    m_view->setSelectionBehavior(QTreeView::SelectRows);
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    m_view->setEditTriggers(QTreeView::NoEditTriggers);
    m_view->setItemsExpandable(false);
    m_view->setUniformRowHeights(true);
    m_view->setAllColumnsShowFocus(true);
    m_view->setRootIsDecorated(false);
    m_view->header()->setStretchLastSection(true);

    m_saveButton->setEnabled(false);

    m_layout->addRow(m_view);
    m_layout->addRow(tr("&Name:"), m_nameEdit);
    m_layout->addRow(tr("&Path:"), m_pathEdit);
    m_layout->addWidget(m_pathButton);
    m_layout->addWidget(m_saveButton);

    connect(m_view, SIGNAL(clicked(QModelIndex)), this, SLOT(setCurrentCategory(QModelIndex)));
    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_nameEdit, SIGNAL(textChanged(QString)), this, SLOT(onNameChanged(QString)));
    connect(m_nameEdit, SIGNAL(returnPressed()), m_saveButton, SLOT(animateClick()));
    connect(m_pathEdit, SIGNAL(textChanged(QString)), this, SLOT(onPathChanged(QString)));
    connect(m_pathEdit, SIGNAL(returnPressed()), m_saveButton, SLOT(animateClick()));
    connect(m_pathButton, SIGNAL(clicked()), this, SLOT(showFileDialog()));
    connect(m_saveButton, SIGNAL(clicked()), this, SLOT(addCategory()));
}
예제 #27
0
void MaterialCategoryModel::read(QIODevice *source)
{
    QDomDocument document;
    if (!document.setContent(source)) return;

    QDomElement docElem = document.documentElement();
    QDomNodeList categoryElemList = docElem.elementsByTagName("Category");

    if (categoryElemList.count()==0) return;

    for (int i=0;i<categoryElemList.count();++i) {
        QDomElement catElem = categoryElemList.at(i).toElement();

        QDomElement uuid = catElem.elementsByTagName("UUID").at(0).toElement();
        QDomElement name = catElem.elementsByTagName("Name").at(0).toElement();

        MaterialCategory* category = getCategory(name.text());
        if (category!=NULL && category->isReadOnly()) {
            QString suuid = uuid.text();
            if (suuid.length()==0) suuid = QUuid::createUuid().toString();
            changedCategoryUUID(category, suuid);

            NQLog("MaterialCategoryModel", NQLog::Spam) << "Cat: " << category;
            NQLog("MaterialCategoryModel", NQLog::Spam) << "     " << category->getUUID();

            continue;
        }

        QDomElement colorElem = catElem.elementsByTagName("Color").at(0).toElement();
        int red = colorElem.attribute("Red", "255").toInt();
        int green = colorElem.attribute("Green", "255").toInt();
        int blue = colorElem.attribute("Blue", "255").toInt();
        QColor color(red, green, blue);

        addCategory(uuid.text(), name.text(), name.text(), color, false);
    }

    modified_ = false;
}
예제 #28
0
파일: settings.c 프로젝트: An00bIS47/gbMon2
// ---------------------------------------------------------------------------
int Settings_Add(char* category, char* key, char* value) {
    int cat, cat_found = -1;
    char *s_cat, *s_key, *s_val;
    s_cat = (char*)malloc((1 + strlen(category)) * sizeof(char));
    s_key = (char*)malloc((1 + strlen(key)) * sizeof(char));
    s_val = (char*)malloc((1 + strlen(value)) * sizeof(char));
    strcpy(s_cat, category);
    strcpy(s_key, key);
    strcpy(s_val, value);
    for(cat = 0; cat < settings->cats; cat++) {
        if(strcmp(category, settings->category[cat].name) == 0) {
            cat_found = cat;
            break;
        }
    }
    int found = 0;
    // need to add this category
    if(cat_found == -1) {
        addCategory(s_cat);
        cat_found = settings->cats - 1;
        //printf("add %s\r\n", s_cat);
    } else {
        // check if this key already exists
        int val;
        for(val = 0; val < settings->category[cat_found].vals; val++) {
            if(strcmp(settings->category[cat_found].values[val].key, s_key) == 0) {
                found = 1;
                free(settings->category[cat_found].values[val].value);
                free(s_key);
                free(s_cat);
                settings->category[cat_found].values[val].value = s_val;
                break;
            }
        }
    }
    // add key-value pair
    if(!found) addValue(cat_found, s_key, s_val);
    return 1;
}
예제 #29
0
const Category* CategoryMgr::addCategory(const QString& name, 
					 const QString& filter, 
					 const QString& filterout, 
					 QColor color)
{
  //seqDebug("addCategory() '%s' - '%s':'%s'", name, filter, filterout?filterout:"null");
  
  // ZBTEMP: TODO, need to add check for duplicate category name
  m_changed = true;
  if (!name.isEmpty() && !filter.isEmpty()) 
  {
    Category* newcat = new Category(name, filter, filterout, color);
    
    m_categories.append(newcat);
    
    emit addCategory(newcat);
    
    //seqDebug("Added '%s'-'%s' '%s' %d", newcat->name, newcat->filter, newcat->listitem->text(0).ascii(), newcat->listitem);
     return newcat;
  }

  return NULL;
}
void QgsCategorizedSymbolRendererV2Widget::populateCategories()
{
  QStandardItemModel* m = qobject_cast<QStandardItemModel*>( viewCategories->model() );
  m->clear();

  QStringList labels;
  labels << tr( "Symbol" ) << tr( "Value" ) << tr( "Label" );
  m->setHorizontalHeaderLabels( labels );

  int i, count = mRenderer->categories().count();

  // TODO: sort?? utils.sortVariantList(keys);

  for ( i = 0; i < count; i++ )
  {
    const QgsRendererCategoryV2 &cat = mRenderer->categories()[i];
    addCategory( cat );
  }

  viewCategories->resizeColumnToContents( 0 );
  viewCategories->resizeColumnToContents( 1 );
  viewCategories->resizeColumnToContents( 2 );
}