예제 #1
0
/***********************************************************************
 *
 * FUNCTION:    ThumbnailViewSelectCategory
 *
 * DESCRIPTION: This routine handles selection, creation and deletion of
 *              categories form the Details Dialog.
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    The index of the new category.
 *
 *              The following global variables are modified:
 *          p.category
 *          d.show_all_categories
 *          d.categoryName
 *
 ***********************************************************************/
static UInt16 ThumbnailViewSelectCategory(void) {
  FormPtr frm;
  UInt16 category;
  Boolean categoryEdited;

  /* Process the category popup list. */
  category = p.category;

  frm = FrmGetActiveForm();
  categoryEdited = CategorySelect(d.dbR, frm, CategoryPop,
                  CategoryList, true, &category, d.categoryName, 1,
                  categoryDefaultEditCategoryString);

  if (categoryEdited || (category != p.category)) {
    ChangeCategory(category);

    /* Disable 5-way navigation */
    d.fiveWayNavigation = false;
    p.dbI = noRecordSelected;

    /* Display the new category. */
    ThumbnailViewLoadRecords(frm);
  }

  return (category);
}
예제 #2
0
// ========================
//        PRIVATE SLOTS
// ========================
void StartMenu::LaunchItem(QString path, bool fix){
  if(path.startsWith("chcat::::")){ 
    ChangeCategory(path.section("::::",1,50));
    return;
  }
  qDebug() << "Launching Item:" << path << fix;
  if(!path.isEmpty()){
    qDebug() << "Launch Application:" << path;
    if( fix && !path.startsWith("lumina-open") ){ LSession::LaunchApplication("lumina-open \""+path+"\""); }
    else{ LSession::LaunchApplication(path); }
    emit CloseMenu(); //so the menu container will close
  }
}
예제 #3
0
/***********************************************************************
 *
 * FUNCTION:    ThumbnailViewNextCategory
 *
 * DESCRIPTION: This routine display the next category,  if the last
 *              catagory isn't being displayed
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    nothing
 *
 *              The following global variables are modified:
 *          p.category
 *          d.categoryName
 *
 ***********************************************************************/
void ThumbnailViewNextCategory(void) {
  UInt16 category = CategoryGetNext(d.dbR, p.category);

  if (category != p.category) {
    FormPtr frm = FrmGetActiveForm();
    ControlPtr ctl = GetObjectPointer(frm, CategoryPop);

    ChangeCategory(category);

    /* Set the label of the category trigger. */
    CategoryGetName(d.dbR, p.category, d.categoryName);
    CategorySetTriggerLabel(ctl, d.categoryName);

    /* Display the new category. */
    SetTopVisibleRecord(0);
    ThumbnailViewLoadGadgets(frm);
  }
}
예제 #4
0
void CatBrowser::MessageReceived(BMessage *msg)
{
	switch(msg->what)
	{
		case M_QUIT_APP:
		{
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;
		}
		case M_SET_CATEGORY:
		{
			BMenuItem *marked = fCategories->FindMarked();
			if(!marked)
				break;
			else
				fCategory = marked->Label();
			fBack->SetEnabled(false);
			SetupQuery();
			RunQuery();
			
			if(fPageCount < 2)
				fNext->SetEnabled(false);
			else
				fNext->SetEnabled(true);
			break;
		}
		case M_RESULTS_BACK:
		{
			if(fCurrentPage > 0)
			{
				fCurrentPage--;
				RunQuery();
			}
			if(fCurrentPage < fPageCount - 1)
				fNext->SetEnabled(true);
			
			if(fCurrentPage == 0)
				fBack->SetEnabled(false);
			break;
		}
		case M_RESULTS_NEXT:
		{
			if(fCurrentPage < fPageCount - 1)
			{
				fCurrentPage++;
				if(fCurrentPage >= fPageCount - 1)
					fNext->SetEnabled(false);
				
				RunQuery();
			}
			
			if(!fBack->IsEnabled())
				fBack->SetEnabled(true);
			break;
		}
		case M_RECATEGORIZE_RECIPE:
		{
			int32 number;
			BString oldcat, newcat;
			msg->FindInt32("number",&number);
			msg->FindString("oldcategory",&oldcat);
			msg->FindString("newcategory",&newcat);
			
			int32 index = 0, selection;
			DBCommand("BEGIN","CatBrowser:begin mass recat");
			BeginViewTransaction();
			do
			{
				selection = fList->CurrentSelection(index);
				index++;
				if(selection >=0)
				{
					RecipeItem *item = (RecipeItem*)fList->ItemAt(selection);
					if(item)
					{
						ChangeCategory(item->fNumber, item->fCategory.String(),
										newcat.String());
					}
				}
				
			} while(selection >= 0);
			EndViewTransaction();
			DBCommand("COMMIT","ChefView:end mass recat");
			SetupQuery();
			RunQuery();
			break;
		}
		case M_SHOW_RECAT:
		{
			int32 selection, firstselection, count=0;
			firstselection = selection = fList->CurrentSelection();
			if(selection < 0)
				break;
			count++;
			
			do
			{
				selection = fList->CurrentSelection(count);
				if(selection >= 0)
					count++;
			} while (selection >= 0);
			
			RecipeItem *item = (RecipeItem*)fList->ItemAt(firstselection);
			if(item)
			{
				BRect r(Frame().OffsetByCopy(20,20));
				r.right = r.left + 300;
				r.bottom = r.top + 200;
				RecatWindow *win = new RecatWindow(r,BMessenger(this), 
												(count>1) ? -1 : item->fNumber,
												item->fCategory.String());
				win->AddToSubset(this);
				win->Show();
			}
			break;
		}
		case M_DELETE_RECIPE:
		{
			int32 index = 0, selection;
			DBCommand("BEGIN","CatBrowser:begin mass delete");
			BeginViewTransaction();
			do
			{
				selection = fList->CurrentSelection(index);
				index++;
				if(selection >=0)
				{
					RecipeItem *item = (RecipeItem*)fList->ItemAt(selection);
					if(item)
						DeleteRecipe(item->fNumber, item->fCategory.String());
				}
				
			} while(selection >= 0);
			EndViewTransaction();
			DBCommand("COMMIT","ChefView:end mass recat");
			SetupQuery();
			RunQuery();
			
			// refresh the display in the main window in case we deleted something
			// that would be in the results
			BMessage msg(M_FIND_RECIPE);
			fMessenger.SendMessage(&msg);
			break;
		}
		case M_SET_RECIPE:
		{
			if(fEditMode)
			{
				if(fList->CurrentSelection(1)>=0)
					break;
			}
			
			RecipeItem *item = (RecipeItem*)fList->ItemAt(fList->CurrentSelection());
			if(item)
			{
				BMessage msg(M_LOOKUP_RECIPE);
				msg.AddInt32("number",item->fNumber);
				msg.AddString("category",item->fCategory);
				msg.AddString("name",item->fName);
				fMessenger.SendMessage(&msg);
			}
			break;
		}
		default:
			BWindow::MessageReceived(msg);
	}
}