Пример #1
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 CategoryFilterWidget::removeUnusedCategories()
{
    auto session = BitTorrent::Session::instance();
    foreach (const QString &category, session->categories())
        if (model()->data(static_cast<CategoryFilterProxyModel *>(model())->index(category), Qt::UserRole) == 0)
            session->removeCategory(category);
    updateGeometry();
}
Пример #3
0
void ItemBoxTreeWidget::removeCategory(const QString &cat_id)
{

    int cat_idx = indexOfCategory(cat_id);
    if (cat_idx >= topLevelItemCount() || cat_idx < 0) {
        return;
    }

    removeCategory(cat_idx);

}
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());
}
Пример #5
0
void Settings::accept()
{
    QMap<QString, QString> hermes;

    hermes["language"] = language();
    hermes["seeMedia"] = seeMedia();
    hermes["addMedia"] = addMedia();
    hermes["removeMedia"] = removeMedia();
    hermes["seeCategory"] = seeCategory();
    hermes["addCategory"] = addCategory();
    hermes["removeCategory"] = removeCategory();
    hermes["newData"] = newData();
    hermes["loadData"] = loadData();
    hermes["saveData"] = saveData();
    hermes["saveAsData"] = saveAsData();
    hermes["quit"] = quit();
    hermes["search"] = search();
    hermes["users"] = users();
    hermes["settings"] = settings();

    emit s_setting(hermes);
    close();
}
Пример #6
0
MainController::MainController(): m_mw(new MainWindow), m_search(m_mw)
{


    connect(m_mw, SIGNAL(s_save(QString)), this, SLOT(save(QString)));
    connect(m_mw, SIGNAL(s_load(QString)), this, SLOT(load(QString)));
    connect(m_mw, SIGNAL(s_newBase()), this, SLOT(newBase()));

    connect(m_mw, SIGNAL(s_addCategory(QString)), this, SLOT(newCategory(QString)));
    connect(m_mw, SIGNAL(s_removeCategory(QString)), this, SLOT(removeCategory(QString)));
    connect(m_mw, SIGNAL(s_seeCategory()), this, SLOT(editCategory()));
    connect(m_mw, SIGNAL(s_showCategory()), this, SLOT(showCategory()));

    connect(m_mw, SIGNAL(s_addMedia(QString)), this, SLOT(newMedia(QString)));
    connect(m_mw, SIGNAL(s_removeMedia(QString,QString)), this, SLOT(removeMedia(QString,QString)));
    connect(m_mw, SIGNAL(s_seeMedia()), this, SLOT(editMedia()));

    connect(m_mw, SIGNAL(s_showUser()), this, SLOT(setUser()));

    connect(m_mw, SIGNAL(s_search()), this, SLOT(search()));

    connect(&m_search, SIGNAL(s_find(QList<MediaSPointer>)), this, SLOT(showSearch(QList<MediaSPointer>)));

    connect(m_mw, SIGNAL(s_settings()), this, SLOT(settings()));

    m_mw->setShortcut(SettingsController::settings());

    SettingsController artemis;
    artemis.newSettings(SettingsController::settings());

    if(UserController::userCount() == 0)
        UserController().exec();
    else
        UserController::connectUser();

}
Пример #7
0
void LLInventoryCategoriesObserver::changed(U32 mask)
{
	if (!mCategoryMap.size())
		return;

	std::vector<LLUUID> deleted_categories_ids;

	for (category_map_t::iterator iter = mCategoryMap.begin();
		 iter != mCategoryMap.end();
		 ++iter)
	{
		const LLUUID& cat_id = (*iter).first;
		LLCategoryData& cat_data = (*iter).second;
        
		LLViewerInventoryCategory* category = gInventory.getCategory(cat_id);
		if (!category)
        {
            LL_WARNS() << "Category : Category id = " << cat_id << " disappeared" << LL_ENDL;
			cat_data.mCallback();
            // Keep track of those deleted categories so we can remove them
            deleted_categories_ids.push_back(cat_id);
			continue;
        }

		const S32 version = category->getVersion();
		const S32 expected_num_descendents = category->getDescendentCount();
		if ((version == LLViewerInventoryCategory::VERSION_UNKNOWN) ||
			(expected_num_descendents == LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN))
		{
			continue;
		}

		// Check number of known descendents to find out whether it has changed.
		LLInventoryModel::cat_array_t* cats;
		LLInventoryModel::item_array_t* items;
		gInventory.getDirectDescendentsOf(cat_id, cats, items);
		if (!cats || !items)
		{
			LL_WARNS() << "Category '" << category->getName() << "' descendents corrupted, fetch failed." << LL_ENDL;
			// NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean
			// that the cat just doesn't have any items or subfolders).
			// Unrecoverable, so just skip this category.

			llassert(cats != NULL && items != NULL);

			continue;
		}
		
		const S32 current_num_known_descendents = cats->size() + items->size();

		bool cat_changed = false;

		// If category version or descendents count has changed
		// update category data in mCategoryMap
		if (version != cat_data.mVersion || current_num_known_descendents != cat_data.mDescendentsCount)
		{
			cat_data.mVersion = version;
			cat_data.mDescendentsCount = current_num_known_descendents;
			cat_changed = true;
		}

		// If any item names have changed, update the name hash 
		// Only need to check if (a) name hash has not previously been
		// computed, or (b) a name has changed.
		if (!cat_data.mIsNameHashInitialized || (mask & LLInventoryObserver::LABEL))
		{
			LLMD5 item_name_hash = gInventory.hashDirectDescendentNames(cat_id);
			if (cat_data.mItemNameHash != item_name_hash)
			{
				cat_data.mIsNameHashInitialized = true;
				cat_data.mItemNameHash = item_name_hash;
				cat_changed = true;
			}
		}

		// If anything has changed above, fire the callback.
		if (cat_changed)
			cat_data.mCallback();
	}
    
    // Remove deleted categories from the list
 	for (std::vector<LLUUID>::iterator deleted_id = deleted_categories_ids.begin(); deleted_id != deleted_categories_ids.end(); ++deleted_id)
	{
		removeCategory(*deleted_id);
    }
}
Пример #8
0
SimilarCategoriesDialog::SimilarCategoriesDialog( ElementList &list, QWidget* parent )
   : QDialog( parent ),
     m_elementList(list)
{
   setObjectName( "SimilarCategoriesDialog" );
   setModal( true );

	SimilarCategoriesDialogLayout = new QVBoxLayout( this );
   SimilarCategoriesDialogLayout->setMargin( 11 );
   SimilarCategoriesDialogLayout->setSpacing( 6 );
   SimilarCategoriesDialogLayout->setObjectName( "SimilarCategoriesDialogLayout" );

	layout6 = new QHBoxLayout();
   layout6->setMargin( 0 );
   layout6->setSpacing( 6 );
   layout6->setObjectName( "layout6" );

	layout4 = new QGridLayout();
   layout4->cellRect( 1, 1 );
   layout4->setMargin( 0 );
   layout4->setSpacing( 6 );
   layout4->setObjectName( "layout4" );

	categoriesBox = new KLineEdit( this );

	layout4->addWidget( categoriesBox, 0, 1 );

	thresholdSlider = new QSlider( this );
   thresholdSlider->setObjectName( "thresholdSlider" );
	thresholdSlider->setValue( 40 );
	thresholdSlider->setOrientation( Qt::Horizontal );

	layout4->addWidget( thresholdSlider, 1, 1 );

	thresholdLabel = new QLabel( this );
   thresholdLabel->setObjectName( "thresholdLabel" );

	layout4->addWidget( thresholdLabel, 1, 0 );

	categoryLabel = new QLabel( this );
   categoryLabel->setObjectName( "categoryLabel" );

	layout4->addWidget( categoryLabel, 0, 0 );
	layout6->addLayout( layout4 );

	layout5 = new QVBoxLayout();
   layout5->setMargin( 0 );
   layout5->setSpacing( 6 );
   layout5->setObjectName( "layout5" );

	searchButton = new QPushButton( this );
   searchButton->setObjectName( "searchButton" );
	layout5->addWidget( searchButton );
	spacer4 = new QSpacerItem( 20, 51, QSizePolicy::Minimum, QSizePolicy::Expanding );
	layout5->addItem( spacer4 );
	layout6->addLayout( layout5 );
	SimilarCategoriesDialogLayout->addLayout( layout6 );

	layout9 = new QHBoxLayout();
   layout9->setMargin( 0 );
   layout9->setSpacing( 6 );
   layout9->setObjectName( "layout9" );

	layout8 = new QVBoxLayout();
   layout8->setMargin( 0 );
   layout8->setSpacing( 6 );
   layout8->setObjectName( "layout8" );

	allLabel = new QLabel( this );
   allLabel->setObjectName( "allLabel" );
	layout8->addWidget( allLabel );

	allListView = new K3ListView( this );
	allListView->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 1, allListView->sizePolicy().hasHeightForWidth() ) );
	layout8->addWidget( allListView );
	layout9->addLayout( layout8 );

	layout1 = new QVBoxLayout();
   layout1->setMargin( 0 );
   layout1->setSpacing( 6 );
   layout1->setObjectName( "layout1" );

	removeButton = new QPushButton( this );
   removeButton->setObjectName( "removeButton" );
	layout1->addWidget( removeButton );

	addButton = new QPushButton( this );
   addButton->setObjectName( "addButton" );
	layout1->addWidget( addButton );
	spacer1 = new QSpacerItem( 20, 61, QSizePolicy::Minimum, QSizePolicy::Expanding );
	layout1->addItem( spacer1 );
	layout9->addLayout( layout1 );

	layout7 = new QVBoxLayout();
   layout7->setMargin( 0 );
   layout7->setSpacing( 6 );
   layout7->setObjectName( "layout7" );

	toMergeLabel = new QLabel( this );
   toMergeLabel->setObjectName( "toMergeLabel" );
	layout7->addWidget( toMergeLabel );

	toMergeListView = new K3ListView( this );
	toMergeListView->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 1, toMergeListView->sizePolicy().hasHeightForWidth() ) );
	layout7->addWidget( toMergeListView );
	layout9->addLayout( layout7 );
	SimilarCategoriesDialogLayout->addLayout( layout9 );

	layout10 = new QHBoxLayout();
   layout10->setMargin( 0 );
   layout10->setSpacing( 6 );
   layout10->setObjectName( "layout10" );

	spacer2 = new QSpacerItem( 310, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
	layout10->addItem( spacer2 );

	mergeButton = new QPushButton( this );
   mergeButton->setObjectName( "mergeButton" );
	layout10->addWidget( mergeButton );

	cancelButton = new QPushButton( this );
   cancelButton->setObjectName( "cancelButton" );
	layout10->addWidget( cancelButton );
	SimilarCategoriesDialogLayout->addLayout( layout10 );
	languageChange();
	resize( QSize(573, 429).expandedTo(minimumSizeHint()) );
	//clearWState( WState_Polished );

	connect( searchButton, SIGNAL(clicked()), this, SLOT(findMatches()) );
	connect( mergeButton, SIGNAL(clicked()), this, SLOT(mergeMatches()) );
	connect( cancelButton, SIGNAL(clicked()), this, SLOT(reject()) );
	connect( addButton, SIGNAL(clicked()), this, SLOT(addCategory()) );
	connect( removeButton, SIGNAL(clicked()), this, SLOT(removeCategory()) );
}
Пример #9
0
//        return;
//    }
//    ui->listWidget_2->setCurrentRow(originalRowIndex);
        ui->listWidget_2->setCurrentRow(0);
}

void MainWindow::initSignalsAndSlots()
{
    //双击表格某单元格,根据该行id,从数据库里读取信息
    connect(ui->tableWidget,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(showText(int,int)));
    connect(ui->tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(updateTheRightSideBar(int,int)));
    connect(ui->menu_action_add_file,SIGNAL(triggered()),this,SLOT(addFile()));

    connect(ui->menu_action_remove_file,SIGNAL(triggered()),this,SLOT(removeDocument()));
    connect(ui->menu_action_add_category,SIGNAL(triggered()),this,SLOT(addCategory()));
    connect(ui->menu_action_remove_category,SIGNAL(triggered()),this,SLOT(removeCategory()));
    connect(ui->menu_action_change_category,SIGNAL(triggered()),this,SLOT(changeCategory()));
    connect(ui->menu_action_manual_input,SIGNAL(triggered()),this,SLOT(manual_input()));
    connect(ui->menu_action_addto_favorite,SIGNAL(triggered()),this,SLOT(add_to_favorite()));
    connect(ui->menu_action_remove_favorite,SIGNAL(triggered()),this,SLOT(remove_outof_favorite()));
    connect(searchSquare,SIGNAL(returnPressed()),this,SLOT(search()));
    connect(ui->menu_action_about,SIGNAL(triggered()),this,SLOT(about()));

    connect(ui->menu_action_open_file,SIGNAL(triggered()),this,SLOT(openFile()));
}

void MainWindow::showText(int a, int b)
{
    QMessageBox::about(this,"Tsignal",ui->tableWidget->item(a,b)->text());
}